Sfoglia il codice sorgente

棒子只对空中飞行单位造成眩晕,不会对地面单位造成眩晕

LAPTOP-OM1V99U2\永远de小亡灵 9 mesi fa
parent
commit
021b279f3c

+ 3 - 1
ActionTowerDefense/Assets/Resources/Prefab/Demonic_Sword.prefab

@@ -205,6 +205,7 @@ MonoBehaviour:
   invincibleTime: 0
   injuryNumText: {fileID: 6467251191553420251, guid: 9b37289f93ea76745ab2cefb79a93e3c, type: 3}
   showInjuryNum: 0
+  canFly: 0
   ls: {fileID: 0}
   isInSoulTower: 0
   totalDieKeepTime: 0
@@ -268,6 +269,7 @@ MonoBehaviour:
   beRepelValue: 0
   weakTime: 0
   totalWeakTime: 3
+  newTotalWeakTime: 0
   weakHitRate: 2
   weakForce: {x: 0, y: 0, z: 0}
   easyToGetHit: 0.2
@@ -318,7 +320,6 @@ MonoBehaviour:
   id: 0
   costMp: 50
   totalSummonTime: 0.5
-  canFly: 0
   isBack: 0
   flyHeight: 0
   flyUpSpeed: 10
@@ -720,6 +721,7 @@ MonoBehaviour:
   repelValue: 0
   offsetY: 1
   hitRate: 1
+  onlyFlyCanWeak: 1
 --- !u!1 &7669620205589286043
 GameObject:
   m_ObjectHideFlags: 0

+ 6 - 0
ActionTowerDefense/Assets/Scripts/AttackTrigger.cs

@@ -14,6 +14,8 @@ public class AttackTrigger : MonoBehaviour
     public int offsetY = 1;
     public float hitRate = 1;
     private bool isInVain;   //击中光球,攻击无效
+    [Header("只有空中单位会被造成眩晕")]
+    public bool onlyFlyCanWeak;
 
     private void Awake()
     {
@@ -68,6 +70,10 @@ public class AttackTrigger : MonoBehaviour
             {
                 if (trigedObjs[i] && Util.CheckCanHit(owner.tag, trigedObjs[i].owner.tag) && !trigedObjs[i].owner.isDie)
                 {
+                    if (onlyFlyCanWeak && !trigedObjs[i].owner.canFly)
+                    {
+                        trigedObjs[i].owner.GetComponent<MoveCharacter>().newTotalWeakTime = 0;
+                    }
                     trigedObjs[i].BeHit(damage, force, changeHurt, repelValue);
                     if (trigedObjs[i].owner.debugAttackFrom)
                     {

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

@@ -87,6 +87,7 @@ public class Character : MonoBehaviour
     public float invincibleTime;    //无敌时间
     public GameObject injuryNumText;//伤害跳字
     public bool showInjuryNum;      //伤害跳字开关
+    public bool canFly = false;
 
     [Header("锁魂塔")]
     public LockSoul ls;

+ 2 - 2
ActionTowerDefense/Assets/Scripts/Demonic.cs

@@ -12,7 +12,6 @@ public class Demonic : MoveCharacter
     public int id;
     public float costMp = 10;
     public float totalSummonTime = 0.5f;
-    public bool canFly = false;
     public bool isBack = false;         //Íù·´·½Ïò×ß
     public float flyHeight;
     public float flyUpSpeed = 10;
@@ -732,6 +731,7 @@ public class Demonic : MoveCharacter
                 break;
             case CharacterState.Weak:
                 beRepelValue = totalBeRepelValue;
+                newTotalWeakTime = totalWeakTime;
                 if (canFly)
                 {
                     rb.constraints = RigidbodyConstraints.FreezeRotation | RigidbodyConstraints.FreezePositionZ | RigidbodyConstraints.FreezePositionY;
@@ -797,7 +797,7 @@ public class Demonic : MoveCharacter
                 dieKeepTime = totalDieKeepTime;
                 break;
             case CharacterState.Weak:
-                weakTime = totalWeakTime;
+                weakTime = newTotalWeakTime;
                 rb.AddForce(weakForce);
                 if (canFly)
                 {

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

@@ -31,7 +31,6 @@ public class Enemy : MoveCharacter
     public int id;
     public int baseSortingOrder;
     int sortingOrder = 0;
-    public bool canFly = false;
     public bool isBack = false; //Íù·´·½Ïò×ß
     public float flyHeight;
     public float flyUpSpeed = 10;
@@ -735,7 +734,7 @@ public class Enemy : MoveCharacter
                 break;
             case CharacterState.Weak:
                 beRepelValue = totalBeRepelValue;
-
+                newTotalWeakTime = totalWeakTime;
                 if (isBeBlownUp)
                 {
                     isBeBlownUp = false;
@@ -881,7 +880,7 @@ public class Enemy : MoveCharacter
                         beRepelValue = totalBeRepelValue;
                         break;
                     default:
-                        weakTime = totalWeakTime;
+                        weakTime = newTotalWeakTime;
                         rb.AddForce(weakForce);
                         if (canFly)
                         {

+ 4 - 0
ActionTowerDefense/Assets/Scripts/MoveCharacter.cs

@@ -29,10 +29,13 @@ public class MoveCharacter : Character
 
     [Header("虚弱状态")]
     public float totalBeRepelValue;
+    
     [HideInInspector]
     public float beRepelValue;
     public float weakTime;
     public float totalWeakTime;
+    [HideInInspector]
+    public float newTotalWeakTime;
     public float weakHitRate = 2;
     [HideInInspector]
     public Vector3 weakForce;
@@ -144,6 +147,7 @@ public class MoveCharacter : Character
         playerMesh = mesh;
         playerMats = mats;
         playerOut = outlineMats;
+        newTotalWeakTime = totalWeakTime;
     }
 
     //0:漂浮 1:正常 2:无敌

+ 9 - 9
ActionTowerDefense/Assets/Scripts/PlayerController.cs

@@ -36,7 +36,6 @@ public class PlayerController : MoveCharacter
     [Header("玩家属性")]
     public int playerId;
     public bool canJump;
-    public bool canfly;
     public bool endTranSummon;  //是否在结束变身后召唤英灵
 
     [Header("变身英灵")]
@@ -1093,7 +1092,7 @@ public class PlayerController : MoveCharacter
                     foot.trigGroundList.Remove(platform.gameObject);
                 }
             }
-            if (canfly)
+            if (canFly)
             {
                 if (leftDir.x > 0.3f || leftDir.x < -0.3f || leftDir.y > 0.3f || leftDir.y < -0.3f)
                 {
@@ -1232,7 +1231,7 @@ public class PlayerController : MoveCharacter
                     break;
                 }
                 CheckTurn();
-                if (canfly)
+                if (canFly)
                 {
                     rb.linearVelocity = leftDir.normalized * moveSpeed;
                 }
@@ -1626,7 +1625,7 @@ public class PlayerController : MoveCharacter
                         aniCollider.Play("Hurt", 0, 0);
                     }
                     Vector3 vel = rb.linearVelocity;
-                    if (!canfly)
+                    if (!canFly)
                     {
                         if (foot.TrigGround && vel.y < 0)
                         {
@@ -1674,7 +1673,7 @@ public class PlayerController : MoveCharacter
             default:
                 break;
         }
-        if (!foot.TrigGround && !canfly)
+        if (!foot.TrigGround && !canFly)
         {
             if (rb.linearVelocity.y > 0)
             {
@@ -1764,7 +1763,7 @@ public class PlayerController : MoveCharacter
             default:
                 break;
         }
-
+        
         foot.trigGroundList.Clear();
         bodyTrans.gameObject.SetActive(false);
         uiHp.transform.parent.gameObject.SetActive(false);
@@ -1881,6 +1880,7 @@ public class PlayerController : MoveCharacter
                 break;
             case CharacterState.Weak:
                 beRepelValue = totalBeRepelValue;
+                newTotalWeakTime = totalWeakTime;
                 break;
             case CharacterState.Conduct:
                 rb.isKinematic = false;
@@ -1997,7 +1997,7 @@ public class PlayerController : MoveCharacter
                 dieKeepTime = totalDieKeepTime;
                 break;
             case CharacterState.Weak:
-                weakTime = totalWeakTime;
+                weakTime = newTotalWeakTime;
                 //hurtKeepTime = minHurtKeepTime;
                 break;
             case CharacterState.Conduct:
@@ -2027,7 +2027,7 @@ public class PlayerController : MoveCharacter
     public Vector3 AirMove(Vector3 velocity)
     {
         CheckTurn();
-        if (canfly)
+        if (canFly)
         {
             velocity = leftDir.normalized * flySpeed;
             if (transform.position.y > maxFlyHeight && velocity.y > 0)
@@ -2105,7 +2105,7 @@ public class PlayerController : MoveCharacter
         outlineMats = dem.outlineMats;
         if (dem.canFly)
         {
-            canfly = true;
+            canFly = true;
             canJump = false;
             rb.useGravity = false;
         }

+ 4 - 4
ActionTowerDefense/Assets/Scripts/Spirits/Trans_Assassin.cs

@@ -51,7 +51,7 @@ public class Trans_Assassin : MonoBehaviour
                     player.canMove = false;
                     player.ChangeState(CharacterState.None);
                     player.ani.Play("charge", 0, 0);
-                    player.canfly = true;
+                    player.canFly = true;
                     if (!player.foot.TrigGround)
                     {
 
@@ -83,7 +83,7 @@ public class Trans_Assassin : MonoBehaviour
                 if (time >= rushTime)
                 {
                     player.canMove = true;
-                    player.canfly = false;
+                    player.canFly = false;
                     dashEffect.canHit = false;
                     player.bodyTrans.rotation = Quaternion.Euler(Vector3.zero);
                     player.ChangeState(CharacterState.Fall);
@@ -105,7 +105,7 @@ public class Trans_Assassin : MonoBehaviour
                     player.canMove = false;
                     player.ChangeState(CharacterState.None);
                     player.ani.Play("charge", 0, 0);
-                    player.canfly = true;
+                    player.canFly = true;
                     if (!player.foot.TrigGround)
                     {
 
@@ -136,7 +136,7 @@ public class Trans_Assassin : MonoBehaviour
                 if (time >= rushTime)
                 {
                     player.canMove = true;
-                    player.canfly = false;
+                    player.canFly = false;
                     dashEffect.canHit = false;
                     player.bodyTrans.rotation = Quaternion.Euler(Vector3.zero);
                     player.ChangeState(CharacterState.Fall);

+ 2 - 2
ActionTowerDefense/Assets/Scripts/Spirits/Trans_Invisible.cs

@@ -41,7 +41,7 @@ public class Trans_Invisible : MonoBehaviour
     {
         
         player = transform.GetComponentInParent<PlayerController>();
-        player.canfly = true;
+        player.canFly = true;
         player.maxFlyHeight = maxFlyHeight;
         player.isInvisible = true;
 
@@ -76,7 +76,7 @@ public class Trans_Invisible : MonoBehaviour
     }
     private void OnDisable()
     {
-        player.canfly = false;
+        player.canFly = false;
     }
     /*
     private void Update()