Просмотр исходного кода

弓兵起手式结束且上升后进行下一操作

SZAND\msx_2 6 месяцев назад
Родитель
Сommit
7c4fa5b382

Разница между файлами не показана из-за своего большого размера
+ 0 - 0
ActionTowerDefense/Assets/GameLevelEditor/maps.asset


+ 4 - 2
ActionTowerDefense/Assets/Resources/Prefab/MySoldier/Demonic_Arrow.prefab

@@ -1127,10 +1127,12 @@ MonoBehaviour:
   extraRiseGravity: -28.8
   extraFallGravity: -14.4
   moveSpeed: 5
+  needToAdjustFlyHeight: 1
   flyHeight: 0
-  maxFlyHeight: 7
+  maxFlyHeight: 9
   minFlyHeight: 5
-  flyUpSpeed: 10
+  flyUpTime: 0.258
+  isAdjustHeight: 0
   totalBeRepelValue: 100
   beRepelValue: 0
   weakTime: 0

+ 23 - 16
ActionTowerDefense/Assets/Scripts/Characters/Demonic.cs

@@ -264,6 +264,11 @@ public class Demonic : MoveCharacter
         switch (state)
         {
             case CharacterState.Idle:
+                if (isAdjustHeight == 1)
+                {
+                    ChangeState(CharacterState.Rise);
+                    break;
+                }
                 if (isAttack)
                 {
                     Attack_march();
@@ -287,7 +292,6 @@ public class Demonic : MoveCharacter
                     ChangeState(CharacterState.Run);
                     break;
                 }
-                AdjustHeight();
                 rb.velocity = Vector3.right * velocityAddition;
                 break;
             case CharacterState.Run:
@@ -394,22 +398,24 @@ public class Demonic : MoveCharacter
                 }
                 break;
             case CharacterState.Rise:
-                if (rb.velocity.y <= 0)
+                if (isAdjustHeight == 1)
                 {
-                    ChangeState(CharacterState.Fall);
-                    break;
+                    AdjustHeight();
+                }
+                else if(isAdjustHeight == 2)
+                {
+                    ChangeState(CharacterState.Idle);
+                    isAdjustHeight = 0;
+                }
+                else
+                {
+                    if (rb.velocity.y <= 0)
+                    {
+                        ChangeState(CharacterState.Fall);
+                        break;
+                    }
+                    rb.velocity += Vector3.up * extraRiseGravity * Time.deltaTime;
                 }
-                //if (btnJumpPress || cacheJumpTime > 0)
-                //{
-                //    if (!airJumped && rb.velocity.y < airJumpSpeed)
-                //    {
-                //        airJumped = true;
-                //        AirJump();
-                //        break;
-                //    }
-                //}
-
-                rb.velocity += Vector3.up * extraRiseGravity * Time.deltaTime;
                 break;
             case CharacterState.Fall:
                 if (foot.TrigGround || canFly)
@@ -637,9 +643,10 @@ public class Demonic : MoveCharacter
 
     public void Attack_summon()
     {
-        if (canFly)
+        if (needToAdjustFlyHeight && canFly)
         {
             flyHeight = Random.Range(minFlyHeight, maxFlyHeight);
+            isAdjustHeight = 1;
         }
         attackController.Attack_summon();
         Vector3 moveDir;

+ 15 - 6
ActionTowerDefense/Assets/Scripts/Characters/MoveCharacter.cs

@@ -4,7 +4,6 @@ using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using TMPro;
-using System.Linq;
 
 public class MoveCharacter : Character
 {
@@ -26,15 +25,18 @@ public class MoveCharacter : Character
 
     [Header("ÊôÐÔ")]
     public float moveSpeed = 5;
+    public bool needToAdjustFlyHeight;
     [DisplayOnly]
     public float flyHeight;
     public float maxFlyHeight;
     public float minFlyHeight;
-    public float flyUpSpeed = 10;
+    float refspeed = 1;
+    public float flyUpTime;
+    [HideInInspector]
+    public int isAdjustHeight;
 
     [Header("ÐéÈõ״̬")]
-    public float totalBeRepelValue;
-    
+    public float totalBeRepelValue;   
     [HideInInspector]
     public float beRepelValue;
     public float weakTime;
@@ -316,17 +318,24 @@ public class MoveCharacter : Character
             if (transform.position.y - flyHeight > 0.1f)
             {
                 Vector3 pos = transform.position;
-                pos.y -= flyUpSpeed * Time.deltaTime;
+                pos.y = Mathf.SmoothDamp(pos.y, flyHeight, ref refspeed, flyUpTime);
                 transform.position = pos;
                 return false;
             }
             else if (transform.position.y - flyHeight < -0.1f)
             {
                 Vector3 pos = transform.position;
-                pos.y += flyUpSpeed * Time.deltaTime;
+                pos.y = Mathf.SmoothDamp(pos.y, flyHeight, ref refspeed, flyUpTime);
                 transform.position = pos;
                 return false;
             }
+            else
+            {
+                Vector3 pos = transform.position;
+                pos.y = flyHeight;
+                transform.position = pos;
+                isAdjustHeight = 2;
+            }
         }
         return true;
     }

Некоторые файлы не были показаны из-за большого количества измененных файлов