|
|
@@ -4,8 +4,6 @@ using UnityEngine;
|
|
|
|
|
|
public class Enemy : MonoBehaviour
|
|
|
{
|
|
|
- public float powerSuckDelay = 1;
|
|
|
-
|
|
|
[SerializeField]
|
|
|
private GameObject powerDrop;
|
|
|
[SerializeField]
|
|
|
@@ -18,8 +16,6 @@ public class Enemy : MonoBehaviour
|
|
|
|
|
|
private DayTimeLabel lastCharging;
|
|
|
|
|
|
- private IEnumerator drainCoroutine;
|
|
|
-
|
|
|
void OnCollisionEnter(Collision collision)
|
|
|
{
|
|
|
if(!dead)
|
|
|
@@ -28,20 +24,6 @@ public class Enemy : MonoBehaviour
|
|
|
{
|
|
|
Death();
|
|
|
}
|
|
|
- else if (collision.collider.tag == "Player")
|
|
|
- {
|
|
|
- drainCoroutine = DrainPower(collision.collider.GetComponent<Player>());
|
|
|
- StartCoroutine(drainCoroutine);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- void OnCollisionExit(Collision collision)
|
|
|
- {
|
|
|
- if (collision.collider.tag == "Player")
|
|
|
- {
|
|
|
- if (drainCoroutine != null)
|
|
|
- StopCoroutine(drainCoroutine);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -116,17 +98,4 @@ public class Enemy : MonoBehaviour
|
|
|
|
|
|
GameObject.Destroy(gameObject);
|
|
|
}
|
|
|
-
|
|
|
- private IEnumerator DrainPower(Player player)
|
|
|
- {
|
|
|
- while (true)
|
|
|
- {
|
|
|
- yield return new WaitForSeconds(powerSuckDelay);
|
|
|
-
|
|
|
-
|
|
|
- player.PowerLevel -= 0.5f;
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
}
|