diff --git a/Assets/Scripts C#/Ratbots/Creeper.cs b/Assets/Scripts C#/Ratbots/Creeper.cs new file mode 100644 index 0000000..1ffa67e --- /dev/null +++ b/Assets/Scripts C#/Ratbots/Creeper.cs @@ -0,0 +1,21 @@ +using UnityEngine; +using System.Collections; + +public class Creeper : Ratbot +{ + float countdown; + + void Update() { + if (Vector3.Distance(player.transform.position, transform.position) > 5) { + MoveTowardsPlayer(moveSpeed); + float newTime = countdown + Time.deltaTime; + countdown = (newTime < 1) ? newTime : 1; + } else { + countdown -= Time.deltaTime; + if (countdown < 0) Explode(); + } + } + void Explode() { + Destroy(gameObject); + } +} diff --git a/Assets/Scripts C#/Ratbots/Creeper.cs.meta b/Assets/Scripts C#/Ratbots/Creeper.cs.meta new file mode 100644 index 0000000..b19f844 --- /dev/null +++ b/Assets/Scripts C#/Ratbots/Creeper.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: d23c0105448702c45b209f27f497780f \ No newline at end of file