2026-06-18 16:37:02 +01:00
|
|
|
using Synty.AnimationBaseLocomotion.Samples;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
public class Pickup : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
public enum PickupType { Health, Strength, StunBomb }
|
|
|
|
|
|
|
|
|
|
[Header("Pickup Settings")]
|
|
|
|
|
public PickupType type;
|
|
|
|
|
public float rotationSpeed = 90f; // Gives it that classic video game spin
|
|
|
|
|
|
|
|
|
|
[Header("Health Settings")]
|
|
|
|
|
public int healAmount = 50;
|
2026-06-19 16:20:36 +01:00
|
|
|
public GameObject healthVFX;
|
2026-06-18 16:37:02 +01:00
|
|
|
|
|
|
|
|
[Header("Strength Settings")]
|
|
|
|
|
public float strengthMultiplier = 2.0f; // Doubles damage and knockback
|
|
|
|
|
public float strengthDuration = 10f;
|
2026-06-19 16:20:36 +01:00
|
|
|
public GameObject strengthVFX;
|
2026-06-18 16:37:02 +01:00
|
|
|
|
|
|
|
|
[Header("Stun Settings")]
|
|
|
|
|
public float stunRadius = 8f;
|
|
|
|
|
public float stunDuration = 5f;
|
|
|
|
|
public LayerMask enemyLayer;
|
2026-06-19 16:20:36 +01:00
|
|
|
public GameObject stunVFX;
|
2026-06-18 16:37:02 +01:00
|
|
|
|
|
|
|
|
void Update()
|
|
|
|
|
{
|
|
|
|
|
// Slowly rotate the pickup to make it visually obvious
|
|
|
|
|
transform.Rotate(Vector3.up, rotationSpeed * Time.deltaTime);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void OnTriggerEnter(Collider other)
|
|
|
|
|
{
|
|
|
|
|
// Make sure your Player Prefab has the "Player" Tag assigned at the very top of its Inspector!
|
|
|
|
|
if (other.CompareTag("Player"))
|
|
|
|
|
{
|
|
|
|
|
ApplyPickupEffect(other.gameObject);
|
|
|
|
|
|
|
|
|
|
// Optional: Play a sound or spawn a particle effect here before destroying
|
|
|
|
|
|
|
|
|
|
Destroy(gameObject); // Remove the pickup from the world
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ApplyPickupEffect(GameObject player)
|
|
|
|
|
{
|
|
|
|
|
switch (type)
|
|
|
|
|
{
|
|
|
|
|
case PickupType.Health:
|
|
|
|
|
PlayerHealth health = player.GetComponent<PlayerHealth>();
|
|
|
|
|
if (health != null) health.Heal(healAmount);
|
2026-06-19 16:20:36 +01:00
|
|
|
Instantiate(healthVFX, player.transform.position + Vector3.up * 0.1f, player.transform.rotation, player.transform);
|
2026-06-18 16:37:02 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case PickupType.Strength:
|
2026-06-19 16:20:36 +01:00
|
|
|
SyntyPlayerCombat combat = player.GetComponent<SyntyPlayerCombat>();
|
2026-06-18 16:37:02 +01:00
|
|
|
if (combat != null) combat.ApplyStrengthBuff(strengthMultiplier, strengthDuration);
|
2026-06-19 16:20:36 +01:00
|
|
|
Instantiate(strengthVFX, transform.position, transform.rotation);
|
2026-06-18 16:37:02 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case PickupType.StunBomb:
|
|
|
|
|
ExecuteStunBomb(transform.position);
|
2026-06-19 16:20:36 +01:00
|
|
|
Instantiate(stunVFX, transform.position, transform.rotation);
|
2026-06-18 16:37:02 +01:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ExecuteStunBomb(Vector3 center)
|
|
|
|
|
{
|
|
|
|
|
Collider[] hitEnemies = Physics.OverlapSphere(center, stunRadius, enemyLayer);
|
|
|
|
|
foreach (Collider enemyCollider in hitEnemies)
|
|
|
|
|
{
|
|
|
|
|
EnemyAI enemy = enemyCollider.GetComponentInParent<EnemyAI>();
|
|
|
|
|
if (enemy != null)
|
|
|
|
|
{
|
|
|
|
|
enemy.ApplyStun(stunDuration);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void OnDrawGizmosSelected()
|
|
|
|
|
{
|
|
|
|
|
if (type == PickupType.StunBomb)
|
|
|
|
|
{
|
|
|
|
|
Gizmos.color = Color.cyan;
|
|
|
|
|
Gizmos.DrawWireSphere(transform.position, stunRadius);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|