fix upgrades
This commit is contained in:
parent
d8c49317a3
commit
5dcbd3c313
17 changed files with 477 additions and 83 deletions
|
|
@ -12,6 +12,7 @@ public class Enemy : Entity
|
|||
public EnemyAbility ability;
|
||||
public float currentCooldown;
|
||||
}
|
||||
public static event Action OnDamaged;
|
||||
[Header("Targetting")]
|
||||
public Entity closestTarget;
|
||||
public float engagementRange;
|
||||
|
|
@ -112,6 +113,12 @@ public class Enemy : Entity
|
|||
}
|
||||
}
|
||||
|
||||
public override void TakeDamage(float damage)
|
||||
{
|
||||
base.TakeDamage(damage);
|
||||
OnDamaged?.Invoke();
|
||||
}
|
||||
|
||||
protected virtual void DropUpgrade(UpgradeDrop drop)
|
||||
{
|
||||
float random = Random.Range(0, 100);
|
||||
|
|
|
|||
|
|
@ -29,10 +29,14 @@ public class EnemySpawner : MonoBehaviour
|
|||
[SerializeField] private float currentSpawnTime;
|
||||
[Header("Boss")]
|
||||
public Enemy bossEnemy;
|
||||
private Enemy bossEnemyInstance;
|
||||
public Transform bossSpawnPoint;
|
||||
[SerializeField] private GameObject bossUI;
|
||||
[SerializeField] private Transform bossHealthBar;
|
||||
[Header("Cache")]
|
||||
[SerializeField] private Transform enemyFolder;
|
||||
[SerializeField] private Marisa player;
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (canSpawn)
|
||||
|
|
@ -46,16 +50,24 @@ public class EnemySpawner : MonoBehaviour
|
|||
}
|
||||
}
|
||||
|
||||
public void SpawnEnemy(Enemy enemy, Vector3 location)
|
||||
public Enemy SpawnEnemy(Enemy enemy, Vector3 location)
|
||||
{
|
||||
Enemy newEnemy = Instantiate(enemy, location, Quaternion.identity);
|
||||
newEnemy.transform.SetParent(enemyFolder);
|
||||
newEnemy.closestTarget = player; //idk if there's actually gonna be any other target lol
|
||||
return newEnemy;
|
||||
}
|
||||
|
||||
public void StartBoss()
|
||||
{
|
||||
SpawnEnemy(bossEnemy, bossSpawnPoint.position);
|
||||
bossEnemyInstance = SpawnEnemy(bossEnemy, bossSpawnPoint.position);
|
||||
bossUI.SetActive(true);
|
||||
canSpawn = false;
|
||||
Enemy.OnDamaged += UpdateBossHealthBar; //this kinda sucks but it technically works??
|
||||
}
|
||||
|
||||
private void UpdateBossHealthBar()
|
||||
{
|
||||
bossHealthBar.localScale = new Vector3(Math.Clamp(bossEnemyInstance.health / bossEnemyInstance.maxHealth, 0, bossEnemyInstance.maxHealth), 1, 1);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue