Enemies upgrades on Life & Damages over game time

This commit is contained in:
2023-10-22 17:39:01 +02:00
parent e929533e7d
commit 537eaf000b
+11 -1
View File
@@ -11,7 +11,8 @@ public class Ennemy : MonoBehaviour
private SpriteRenderer _sr;
private Transform _player;
public float Life = 100;
public static float StartLife = 100;
public float Life;
public float Speed = .1f;
public int Damages = 1;
@@ -19,6 +20,7 @@ public class Ennemy : MonoBehaviour
private void Awake()
{
Life = StartLife;
if (transform.parent != null)
{
transform.parent = null;
@@ -30,6 +32,8 @@ public class Ennemy : MonoBehaviour
_sr = GetComponent<SpriteRenderer>();
_player = GameObject.FindGameObjectWithTag("Player").transform;
InvokeRepeating(nameof(UpgradeSelf), 2f, 10f);
}
private void Update()
@@ -125,4 +129,10 @@ public class Ennemy : MonoBehaviour
yield return new WaitForSeconds(.1f);
}
}
private void UpgradeSelf()
{
Damages += 15;
StartLife += 5;
}
}