Pārlūkot izejas kodu

变身刺客三段跳

LAPTOP-OM1V99U2\永远de小亡灵 1 gadu atpakaļ
vecāks
revīzija
38aedd1ecc

+ 48 - 19
ActionTowerDefense/Assets/Scripts/PlayerController.cs

@@ -70,6 +70,9 @@ public class PlayerController : MoveCharacter
     public float cacheJumpTime; //即将落地时按下跳跃键不会跳跃,手感不好,缓存几帧,在这几帧内落地会立即跳跃;
     public float totalCacheJumpTime = 0.1f;
     [HideInInspector]
+    public float tandemJumpTime; //即将落地时按下跳跃键不会跳跃,手感不好,缓存几帧,在这几帧内落地会立即跳跃;
+    public float totalTandemJumpTime = 0.1f;
+    [HideInInspector]
     public float summonTime;
     [HideInInspector]
     public float cacheAttackTime; //无法攻击时按下攻击键不会攻击,手感不好,缓存几帧,在这几帧内落地会立即攻击;
@@ -88,8 +91,9 @@ public class PlayerController : MoveCharacter
     [HideInInspector]
     public float cacheRushTime; //无法Rush时按下Rush键不会Rush,手感不好,缓存几帧,在这几帧内落地会立即Rush;
     public float totalCacheRushTime = 0.1f;
-    [HideInInspector]
-    public bool airJumped;
+
+    public int airJumped;
+    public int jumpNumber = 2;  //最大跳跃次数
     public PlayerAttackState attackState;
     public float attackMoveSpeed = 5f;
     public Vector3 rushDir;
@@ -290,7 +294,7 @@ public class PlayerController : MoveCharacter
         }
         PlayersInput.instance[playerId] = this;
         skeletonMecanim.skeletonDataAsset = playerSpine[playerId];
-        
+
 
 
         //else
@@ -397,18 +401,17 @@ public class PlayerController : MoveCharacter
             moveVec = value.Get<Vector2>();
         }
     }
-    
+
     void OnJump()
     {
         if (canJump && canMove)
         {
             isClickBtnJump = true;
         }
-        
     }
     void OnSummon0()
     {
-        if(!isFloat && canMove)
+        if (!isFloat && canMove)
         {
             isClickBtnWest = true;
             if (isTransfiguration)
@@ -464,7 +467,7 @@ public class PlayerController : MoveCharacter
     {
         if (!isTransfiguration && !isFloat && canMove)
             isSpiritSummon = true;
-        if(isTransfiguration && currentSpirit == 0)
+        if (isTransfiguration && currentSpirit == 0)
         {
             isTryingToRelieve = true;
         }
@@ -631,7 +634,7 @@ public class PlayerController : MoveCharacter
         }
         else
         {
-            airJumped = false;
+            airJumped = 0;
             //if (btnNorthPress || cacheAttackTime > 0)
             //{
             //    if (excludeState != CharacterState.Attack)
@@ -681,7 +684,7 @@ public class PlayerController : MoveCharacter
             }
             if (canfly)
             {
-                if (leftDir.x > 0.3f || leftDir.x < -0.3f || leftDir.y>0.3f||leftDir.y<-0.3f)
+                if (leftDir.x > 0.3f || leftDir.x < -0.3f || leftDir.y > 0.3f || leftDir.y < -0.3f)
                 {
                     if (excludeState != CharacterState.Run)
                     {
@@ -739,6 +742,7 @@ public class PlayerController : MoveCharacter
         {
             cacheJumpTime = totalCacheJumpTime;
         }
+
         if (btnNorthPress)
         {
             cacheAttackTime = totalCacheAttackTime;
@@ -846,9 +850,17 @@ public class PlayerController : MoveCharacter
                 }
                 if (btnJumpPress || cacheJumpTime > 0)
                 {
-                    if (!airJumped && rb.velocity.y < airJumpSpeed)
+                    if (airJumped == 0 && jumpNumber >= 2 && rb.velocity.y < airJumpSpeed)
+                    {
+                        print(1);
+                        airJumped = 1;
+                        AirJump();
+                        break;
+                    }
+                    if (airJumped == 1 && jumpNumber >= 3 && rb.velocity.y < airJumpSpeed)
                     {
-                        airJumped = true;
+                        print(2);
+                        airJumped = 2;
                         AirJump();
                         break;
                     }
@@ -892,11 +904,29 @@ public class PlayerController : MoveCharacter
                         Jump();
                         break;
                     }
-                    else if (!airJumped)
+                    else
                     {
-                        airJumped = true;
-                        AirJump();
-                        break;
+                        switch (airJumped)
+                        {
+                            case 0:
+                                if(jumpNumber >= 2)
+                                {
+                                    print(3);
+                                    airJumped = 1;
+                                    AirJump();
+                                    
+                                }
+                                break;
+                            case 1:
+                                if(jumpNumber >= 3)
+                                {
+                                    print(4);
+                                    airJumped = 2;
+                                    AirJump();
+                                }
+
+                                break;
+                        }
                     }
                 }
                 CachedPlayerInput();
@@ -1197,7 +1227,6 @@ public class PlayerController : MoveCharacter
                 rb.velocity += Vector3.up * extraFallGravity * Time.deltaTime;
             }
         }
-
         isClickBtnRush = false;
         isKeepBtnRush = false;
         isClickBtnJump = false;
@@ -1233,7 +1262,7 @@ public class PlayerController : MoveCharacter
             if (mp > 0)
             {
                 lostMp += mpReplySpeed * Time.deltaTime;
-                mp -= mpReplySpeed * Time.deltaTime;   
+                mp -= mpReplySpeed * Time.deltaTime;
             }
             if (mp < 0)
             {
@@ -1462,7 +1491,7 @@ public class PlayerController : MoveCharacter
     }
 
     private Collider playerSoulCollector;
-    
+
     public void Transfiguration(int id) //变身
     {
         playerSoulCollector = soulCollector;
@@ -1507,7 +1536,7 @@ public class PlayerController : MoveCharacter
         }
         else
         {
-            spiritObj.transform.position = transform.position ;
+            spiritObj.transform.position = transform.position;
             if (dem.bodyTrans.localScale.x > 0)
             {
                 dem.Turn();

+ 3 - 0
ActionTowerDefense/Assets/Scripts/Spirits/Trans_Assassin.cs

@@ -4,9 +4,12 @@ using UnityEngine;
 
 public class Trans_Assassin : MonoBehaviour
 {
+    public PlayerController player;
     // Start is called before the first frame update
     void Start()
     {
+        player = GetComponentInParent<PlayerController>();
+        player.jumpNumber = 3;
         
     }