Initial Commit
This commit is contained in:
@@ -52,7 +52,7 @@ public class EnemyAI : MonoBehaviour
|
||||
|
||||
// Add a random offset to the initial attack timer so the mob doesn't attack in perfectly unified sync
|
||||
lastAttackTime = Time.time + Random.Range(0f, attackCooldown);
|
||||
//AssignTarget();
|
||||
AssignTarget();
|
||||
}
|
||||
|
||||
void Update()
|
||||
|
||||
@@ -6,23 +6,28 @@ 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
|
||||
[SerializeField] private PickupType type;
|
||||
[SerializeField] private float rotationSpeed = 90f; // Gives it that classic video game spin
|
||||
|
||||
[Header("Health Settings")]
|
||||
public int healAmount = 50;
|
||||
public GameObject healthVFX;
|
||||
[SerializeField] private int healAmount = 50;
|
||||
[SerializeField] private GameObject healthVFX;
|
||||
|
||||
[Header("Strength Settings")]
|
||||
public float strengthMultiplier = 2.0f; // Doubles damage and knockback
|
||||
public float strengthDuration = 10f;
|
||||
public GameObject strengthVFX;
|
||||
[SerializeField] private float strengthMultiplier = 2.0f; // Doubles damage and knockback
|
||||
[SerializeField] private float strengthDuration = 10f;
|
||||
[SerializeField] private GameObject strengthVFX;
|
||||
|
||||
[Header("Stun Settings")]
|
||||
public float stunRadius = 8f;
|
||||
public float stunDuration = 5f;
|
||||
public LayerMask enemyLayer;
|
||||
public GameObject stunVFX;
|
||||
[SerializeField] private float stunRadius = 8f;
|
||||
[SerializeField] private float stunDuration = 5f;
|
||||
[SerializeField] private LayerMask enemyLayer;
|
||||
[SerializeField] private GameObject stunVFX;
|
||||
|
||||
// Cached components for performance
|
||||
private PlayerHealth playerHealth;
|
||||
private SyntyPlayerCombat syntyPlayerCombat;
|
||||
private EnemyAI enemyAI;
|
||||
|
||||
void Update()
|
||||
{
|
||||
@@ -48,34 +53,97 @@ public class Pickup : MonoBehaviour
|
||||
switch (type)
|
||||
{
|
||||
case PickupType.Health:
|
||||
PlayerHealth health = player.GetComponent<PlayerHealth>();
|
||||
if (health != null) health.Heal(healAmount);
|
||||
Instantiate(healthVFX, player.transform.position + Vector3.up * 0.1f, player.transform.rotation, player.transform);
|
||||
ApplyHealthPickup(player);
|
||||
break;
|
||||
|
||||
case PickupType.Strength:
|
||||
SyntyPlayerCombat combat = player.GetComponent<SyntyPlayerCombat>();
|
||||
if (combat != null) combat.ApplyStrengthBuff(strengthMultiplier, strengthDuration);
|
||||
Instantiate(strengthVFX, transform.position, transform.rotation);
|
||||
ApplyStrengthPickup(player);
|
||||
break;
|
||||
|
||||
case PickupType.StunBomb:
|
||||
ExecuteStunBomb(transform.position);
|
||||
Instantiate(stunVFX, transform.position, transform.rotation);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void ApplyHealthPickup(GameObject player)
|
||||
{
|
||||
// Cache the component for performance
|
||||
if (playerHealth == null)
|
||||
{
|
||||
playerHealth = player.GetComponent<PlayerHealth>();
|
||||
if (playerHealth == null)
|
||||
playerHealth = player.GetComponentInParent<PlayerHealth>();
|
||||
}
|
||||
|
||||
if (playerHealth != null)
|
||||
{
|
||||
playerHealth.Heal(healAmount);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning("PlayerHealth component not found on player or its parent");
|
||||
}
|
||||
|
||||
// Spawn VFX at pickup location
|
||||
if (healthVFX != null)
|
||||
{
|
||||
Instantiate(healthVFX, transform.position, Quaternion.identity);
|
||||
}
|
||||
|
||||
// Spawn VFX at player location
|
||||
if (healthVFX != null && player != null)
|
||||
{
|
||||
Instantiate(healthVFX, player.transform.position + Vector3.up * 0.1f,
|
||||
player.transform.rotation, player.transform);
|
||||
}
|
||||
}
|
||||
|
||||
private void ApplyStrengthPickup(GameObject player)
|
||||
{
|
||||
// Cache the component for performance
|
||||
if (syntyPlayerCombat == null)
|
||||
{
|
||||
syntyPlayerCombat = player.GetComponent<SyntyPlayerCombat>();
|
||||
}
|
||||
|
||||
if (syntyPlayerCombat != null)
|
||||
{
|
||||
syntyPlayerCombat.ApplyStrengthBuff(strengthMultiplier, strengthDuration);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning("SyntyPlayerCombat component not found on player");
|
||||
}
|
||||
|
||||
// Spawn VFX at pickup location
|
||||
if (strengthVFX != null)
|
||||
{
|
||||
Instantiate(strengthVFX, transform.position, transform.rotation);
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
// Cache the component for performance
|
||||
if (enemyAI == null)
|
||||
{
|
||||
enemy.ApplyStun(stunDuration);
|
||||
enemyAI = enemyCollider.GetComponentInParent<EnemyAI>();
|
||||
}
|
||||
|
||||
if (enemyAI != null)
|
||||
{
|
||||
enemyAI.ApplyStun(stunDuration);
|
||||
}
|
||||
}
|
||||
|
||||
// Spawn VFX at pickup location
|
||||
if (stunVFX != null)
|
||||
{
|
||||
Instantiate(stunVFX, transform.position, transform.rotation);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,4 +155,4 @@ public class Pickup : MonoBehaviour
|
||||
Gizmos.DrawWireSphere(transform.position, stunRadius);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user