Преглед на файлове

Enemy和Demonic增加受伤无敌时间

wulifu преди 1 година
родител
ревизия
c5cd3edee3

+ 4 - 2
ActionTowerDefense/Assets/Resources/Prefab/EnemyTower.prefab

@@ -269,7 +269,7 @@ Transform:
   m_GameObject: {fileID: 3581793008941702770}
   m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
   m_LocalPosition: {x: 5, y: -1, z: 0}
-  m_LocalScale: {x: 1, y: 1, z: 1}
+  m_LocalScale: {x: 2, y: 2, z: 1}
   m_ConstrainProportionsScale: 0
   m_Children:
   - {fileID: 3581793009506298626}
@@ -301,7 +301,7 @@ MonoBehaviour:
   totalAttack1Time: 1
   totalAttack2Time: 1
   isDie: 0
-  totalHp: 100
+  totalHp: 10000
   hp: 0
   attack1Infos:
   - damage: 10
@@ -317,6 +317,8 @@ MonoBehaviour:
   totalDieKeepTime: 2
   attackTarget: {fileID: 0}
   shootTrack: 1
+  invincibleTime: 0
+  totalInvincibleTime: 0
   searchTrigger: {fileID: 3581793009074591734}
   targetTypes: 0100000003000000
   searchTarget: {fileID: 0}

+ 4 - 2
ActionTowerDefense/Assets/Resources/Prefab/Tower.prefab

@@ -714,7 +714,7 @@ Transform:
   m_GameObject: {fileID: 6126647545658003341}
   m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
   m_LocalPosition: {x: 53.2, y: -1, z: 0}
-  m_LocalScale: {x: 1, y: 1, z: 1}
+  m_LocalScale: {x: 2, y: 2, z: 1}
   m_ConstrainProportionsScale: 0
   m_Children:
   - {fileID: 6126647544008014589}
@@ -746,7 +746,7 @@ MonoBehaviour:
   totalAttack1Time: 1
   totalAttack2Time: 1
   isDie: 0
-  totalHp: 100
+  totalHp: 10000
   hp: 0
   attack1Infos:
   - damage: 10
@@ -762,6 +762,8 @@ MonoBehaviour:
   totalDieKeepTime: 2
   attackTarget: {fileID: 0}
   shootTrack: 1
+  invincibleTime: 0
+  totalInvincibleTime: 0
   searchTrigger: {fileID: 6126647545521899017}
   targetTypes: 04000000
   searchTarget: {fileID: 0}

+ 0 - 28
ActionTowerDefense/Assets/Scenes/SampleScene.unity

@@ -1108,22 +1108,10 @@ PrefabInstance:
   m_Modification:
     m_TransformParent: {fileID: 0}
     m_Modifications:
-    - target: {fileID: 3581793008941702768, guid: 9b26b01efd8ba674a98444c19a0af89e, type: 3}
-      propertyPath: totalHp
-      value: 10000
-      objectReference: {fileID: 0}
     - target: {fileID: 3581793008941702769, guid: 9b26b01efd8ba674a98444c19a0af89e, type: 3}
       propertyPath: m_RootOrder
       value: 6
       objectReference: {fileID: 0}
-    - target: {fileID: 3581793008941702769, guid: 9b26b01efd8ba674a98444c19a0af89e, type: 3}
-      propertyPath: m_LocalScale.x
-      value: 2
-      objectReference: {fileID: 0}
-    - target: {fileID: 3581793008941702769, guid: 9b26b01efd8ba674a98444c19a0af89e, type: 3}
-      propertyPath: m_LocalScale.y
-      value: 2
-      objectReference: {fileID: 0}
     - target: {fileID: 3581793008941702769, guid: 9b26b01efd8ba674a98444c19a0af89e, type: 3}
       propertyPath: m_LocalPosition.x
       value: 5
@@ -1168,10 +1156,6 @@ PrefabInstance:
       propertyPath: m_Name
       value: EnemyTower
       objectReference: {fileID: 0}
-    - target: {fileID: 3581793008941702770, guid: 9b26b01efd8ba674a98444c19a0af89e, type: 3}
-      propertyPath: m_IsActive
-      value: 1
-      objectReference: {fileID: 0}
     m_RemovedComponents: []
   m_SourcePrefab: {fileID: 100100000, guid: 9b26b01efd8ba674a98444c19a0af89e, type: 3}
 --- !u!1001 &6745549283345970834
@@ -1189,14 +1173,6 @@ PrefabInstance:
       propertyPath: m_RootOrder
       value: 7
       objectReference: {fileID: 0}
-    - target: {fileID: 6126647545658003342, guid: 27fc9f9c5a91ca44395c454662e9576a, type: 3}
-      propertyPath: m_LocalScale.x
-      value: 2
-      objectReference: {fileID: 0}
-    - target: {fileID: 6126647545658003342, guid: 27fc9f9c5a91ca44395c454662e9576a, type: 3}
-      propertyPath: m_LocalScale.y
-      value: 2
-      objectReference: {fileID: 0}
     - target: {fileID: 6126647545658003342, guid: 27fc9f9c5a91ca44395c454662e9576a, type: 3}
       propertyPath: m_LocalPosition.x
       value: 139
@@ -1237,9 +1213,5 @@ PrefabInstance:
       propertyPath: m_LocalEulerAnglesHint.z
       value: 0
       objectReference: {fileID: 0}
-    - target: {fileID: 6126647545658003378, guid: 27fc9f9c5a91ca44395c454662e9576a, type: 3}
-      propertyPath: totalHp
-      value: 10000
-      objectReference: {fileID: 0}
     m_RemovedComponents: []
   m_SourcePrefab: {fileID: 100100000, guid: 27fc9f9c5a91ca44395c454662e9576a, type: 3}

+ 7 - 0
ActionTowerDefense/Assets/Scripts/Character.cs

@@ -57,6 +57,9 @@ public class Character : MonoBehaviour
     public float totalDieKeepTime = 2f;
     public Character attackTarget;
     public bool shootTrack = false;
+    [HideInInspector]
+    public float invincibleTime;
+    public float totalInvincibleTime = 2f;
 
     public virtual void Init()
     {
@@ -104,6 +107,10 @@ public class Character : MonoBehaviour
 
     public virtual void BeHit(int damage, Vector3 force)
     {
+        if (invincibleTime > 0)
+        {
+            return;
+        }
         hp -= damage;
         uiHp.Show(hp, totalHp);
         rb.AddForce(force);

+ 3 - 0
ActionTowerDefense/Assets/Scripts/Demonic.cs

@@ -188,6 +188,7 @@ public class Demonic : MoveCharacter
         hurtKeepTime -= Time.deltaTime;
         attackTime -= Time.deltaTime;
         dieKeepTime -= Time.deltaTime;
+        invincibleTime -= Time.deltaTime;
         Vector3 leftDir = GetMoveDir();
         bool isAttack = GetAttack();
         switch (state)
@@ -404,6 +405,7 @@ public class Demonic : MoveCharacter
                 ani.Play("hitted", 0, 0);
                 aniCollider.Play("Hurt", 0, 0);
                 hurtKeepTime = totalHurtKeepTime;
+                invincibleTime = totalInvincibleTime;
                 //ani.Play("Invincible", 2, 0);
                 break;
             case CharacterState.Attack:
@@ -430,4 +432,5 @@ public class Demonic : MoveCharacter
         base.Attack2();
         attackTarget = targetCharacter;
     }
+
 }

+ 2 - 0
ActionTowerDefense/Assets/Scripts/Enemy.cs

@@ -128,6 +128,7 @@ public class Enemy : MoveCharacter
         hurtKeepTime -= Time.deltaTime;
         attackTime -= Time.deltaTime;
         dieKeepTime -= Time.deltaTime;
+        invincibleTime -= Time.deltaTime;
         Vector3 leftDir = GetMoveDir();
         bool isAttack = GetAttack();
         switch (state)
@@ -343,6 +344,7 @@ public class Enemy : MoveCharacter
                 ani.Play("hitted", 0, 0);
                 aniCollider.Play("Hurt", 0, 0);
                 hurtKeepTime = totalHurtKeepTime;
+                invincibleTime = totalInvincibleTime;
                 //ani.Play("Invincible", 2, 0);
                 break;
             case CharacterState.Attack:

+ 0 - 12
ActionTowerDefense/Assets/Scripts/PlayerController.cs

@@ -40,9 +40,6 @@ public class PlayerController : MoveCharacter
     public float rushCostMp = 5;
     public float sprintCostMp = 5;
 
-    [HideInInspector]
-    public float invincibleTime;
-    public float totalInvincibleTime = 2f;
     public float rushInvincibleTime = 0.2f;
     [HideInInspector]
     public float canJumpTime; //离开平台后仍然可以跳跃的时间,用于提升手感
@@ -825,15 +822,6 @@ public class PlayerController : MoveCharacter
         }
     }
 
-    public override void BeHit(int damage, Vector3 force)
-    {
-        if (invincibleTime > 0)
-        {
-            return;
-        }
-        base.BeHit(damage, force);
-    }
-
     public bool CheckCanSummon(int id)
     {
         GameObject prefab = demonicPrefabs[id];