Parcourir la source

moved hurting player to its own place

DasGewehr il y a 9 ans
Parent
commit
045db2320e

+ 2 - 2
game/Assets/Prefabs/Enemy.prefab

@@ -486,7 +486,7 @@ Transform:
   m_PrefabInternal: {fileID: 100100000}
   m_GameObject: {fileID: 1196849215294664}
   m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
-  m_LocalPosition: {x: 18.913963, y: 1, z: -9.469598}
+  m_LocalPosition: {x: 0, y: 1, z: 0}
   m_LocalScale: {x: 1, y: 1, z: 1}
   m_Children:
   - {fileID: 4517153640541662}
@@ -1302,7 +1302,6 @@ MonoBehaviour:
   m_Script: {fileID: 11500000, guid: fd8e0aeb284c1814b899164958dfa9c2, type: 3}
   m_Name: 
   m_EditorClassIdentifier: 
-  powerSuckDelay: 1
   powerDrop: {fileID: 1236734196835136, guid: 74eceab4a010bc340b3953e37f3e3678, type: 2}
   powerLevel: 0
 --- !u!114 &114593885084691842
@@ -1316,6 +1315,7 @@ MonoBehaviour:
   m_Script: {fileID: 11500000, guid: 3256c467d6d1a154783493eccb700526, type: 3}
   m_Name: 
   m_EditorClassIdentifier: 
+  powerSuckDelay: 1
 --- !u!136 &136848187219270198
 CapsuleCollider:
   m_ObjectHideFlags: 1

+ 0 - 31
game/Assets/Scripts/Enemy/Enemy.cs

@@ -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;
-
-            
-        }
-    }
 }

+ 32 - 10
game/Assets/Scripts/Enemy/WeaponEnemy.cs

@@ -2,15 +2,37 @@
 using System.Collections.Generic;
 using UnityEngine;
 
-public class WeaponEnemy : MonoBehaviour {
+public class WeaponEnemy : MonoBehaviour
+{
+    public float powerSuckDelay = 1;
+    private IEnumerator drainCoroutine;
+
+    void OnCollisionEnter(Collision collision)
+    {
+            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);
+        }
+    }
+
+    private IEnumerator DrainPower(Player player)
+    {
+        while (true)
+        {
+            yield return new WaitForSeconds(powerSuckDelay);
+
+            player.PowerLevel -= 2.5f;
+        }
+    }
 
-	// Use this for initialization
-	void Start () {
-		
-	}
-	
-	// Update is called once per frame
-	void Update () {
-		
-	}
 }