Bläddra i källkod

白鹭1014,进一步协调动画

GrainFull 4 månader sedan
förälder
incheckning
6294b14bf3

+ 51 - 82
ActionTowerDefense/Assets/Resources/Prefab/Enemy/Enemy_1014.prefab

@@ -75,8 +75,8 @@ BoxCollider:
   m_IsTrigger: 1
   m_Enabled: 1
   serializedVersion: 2
-  m_Size: {x: 3.0108309, y: 6.0193615, z: 2}
-  m_Center: {x: 1.0168002, y: 1.2417183, z: 0}
+  m_Size: {x: 3.4691882, y: 6.0193615, z: 2}
+  m_Center: {x: 0.06276035, y: 1.2417183, z: 0}
 --- !u!114 &8924180071245218248
 MonoBehaviour:
   m_ObjectHideFlags: 0
@@ -189,8 +189,8 @@ BoxCollider:
   m_IsTrigger: 1
   m_Enabled: 1
   serializedVersion: 2
-  m_Size: {x: 3.1932826, y: 4.14734, z: 2}
-  m_Center: {x: 1.5477865, y: 3.160111, z: 0}
+  m_Size: {x: 3.1932826, y: 4.916024, z: 2}
+  m_Center: {x: 1.5477865, y: 1.2948952, z: 0}
 --- !u!114 &9020361017135710302
 MonoBehaviour:
   m_ObjectHideFlags: 0
@@ -431,7 +431,7 @@ Transform:
   m_PrefabAsset: {fileID: 0}
   m_GameObject: {fileID: 2234394376273647362}
   m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
-  m_LocalPosition: {x: -0.19, y: 0, z: 0}
+  m_LocalPosition: {x: 0, y: 0, z: 0}
   m_LocalScale: {x: 1, y: 1, z: 1}
   m_ConstrainProportionsScale: 0
   m_Children: []
@@ -767,8 +767,8 @@ Transform:
   m_LocalScale: {x: 1, y: 1, z: 1}
   m_ConstrainProportionsScale: 0
   m_Children: []
-  m_Father: {fileID: 8639832132491289354}
-  m_RootOrder: 1
+  m_Father: {fileID: 6561999689701501378}
+  m_RootOrder: 8
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
 --- !u!114 &3566347593191160092
 MonoBehaviour:
@@ -790,8 +790,8 @@ MonoBehaviour:
   trigEnemyTowerList: []
   trigBossList: []
   needToChange: 1
-  maxLen: 1
-  minLen: 2
+  maxLen: 2.1
+  minLen: 2.1
 --- !u!65 &4334931071865358337
 BoxCollider:
   m_ObjectHideFlags: 0
@@ -803,8 +803,8 @@ BoxCollider:
   m_IsTrigger: 1
   m_Enabled: 1
   serializedVersion: 2
-  m_Size: {x: 2, y: 20.215729, z: 20}
-  m_Center: {x: -1, y: -7.49, z: 0}
+  m_Size: {x: 2.1766057, y: 29.720766, z: 20}
+  m_Center: {x: 0.39999998, y: -12.158563, z: 0}
 --- !u!1 &5388987656270167698
 GameObject:
   m_ObjectHideFlags: 0
@@ -902,6 +902,7 @@ Transform:
   - {fileID: 8482269351142858204}
   - {fileID: 776105162125788029}
   - {fileID: 6220414675483084992}
+  - {fileID: 5016048881761595890}
   m_Father: {fileID: 5769591908339262981}
   m_RootOrder: 1
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
@@ -973,7 +974,7 @@ RectTransform:
   m_Children:
   - {fileID: 4847391198550739967}
   m_Father: {fileID: 8639832132491289354}
-  m_RootOrder: 2
+  m_RootOrder: 1
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
   m_AnchorMin: {x: 0, y: 0}
   m_AnchorMax: {x: 0, y: 0}
@@ -1098,7 +1099,7 @@ Transform:
   m_PrefabAsset: {fileID: 0}
   m_GameObject: {fileID: 8639832132450015563}
   m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
-  m_LocalPosition: {x: 0.59, y: 1.32, z: 0}
+  m_LocalPosition: {x: 0.59, y: 0.4, z: 0}
   m_LocalScale: {x: 1, y: 1, z: 1}
   m_ConstrainProportionsScale: 0
   m_Children: []
@@ -1116,7 +1117,7 @@ BoxCollider:
   m_IsTrigger: 1
   m_Enabled: 1
   serializedVersion: 2
-  m_Size: {x: 1.2707447, y: 0.1896857, z: 2}
+  m_Size: {x: 1.2707447, y: 0.5, z: 2}
   m_Center: {x: 0.64777595, y: -1.0383594, z: 0}
 --- !u!114 &8639832132450015562
 MonoBehaviour:
@@ -1132,6 +1133,7 @@ MonoBehaviour:
   m_EditorClassIdentifier: 
   rb: {fileID: 0}
   moveCharacter: {fileID: 0}
+  canOnGiant: 0
   haveGravity: 1
   trigGroundList: []
   platform: {fileID: 0}
@@ -1168,7 +1170,6 @@ Transform:
   m_ConstrainProportionsScale: 0
   m_Children:
   - {fileID: 5769591908339262981}
-  - {fileID: 5016048881761595890}
   - {fileID: 152626645726552729}
   m_Father: {fileID: 0}
   m_RootOrder: 0
@@ -1199,7 +1200,7 @@ MonoBehaviour:
   ani: {fileID: 5978259926173120695}
   totalDieKeepTime: 0.33333334
   totalAttack_summonTime: 0.6666667
-  totalAttack_marchTime: 6.666
+  totalAttack_marchTime: 5.999
   showInjuryNum: 1
   injuryNumText: {fileID: 6467251191553420251, guid: 9b37289f93ea76745ab2cefb79a93e3c, type: 3}
   injuryNumTextSummon: {fileID: 6467251191553420251, guid: 71b4c570c9e403d429846b71878a20c4, type: 3}
@@ -1275,6 +1276,7 @@ MonoBehaviour:
   sustainedInjury_damage: 0
   heavyDamage: 0
   killer: {fileID: 0}
+  tag: 0
   exp: 30
   name: 
   baseSortingOrder: 2001
@@ -1295,6 +1297,13 @@ MonoBehaviour:
   dropSoulMax: 5
   dropSoulMin: 5
   dropSoulAngle: 90
+  canEscape: 0
+  stopEscapeCD: 0
+  escapeSpeed: 0
+  distanceToTowerDeviation: 0
+  distanceToTowerBase: 0
+  distanceToEnemyDeviation: 0
+  distanceToEnemyBase: 0
 --- !u!54 &8639832132491289349
 Rigidbody:
   m_ObjectHideFlags: 0
@@ -1329,10 +1338,19 @@ MonoBehaviour:
     - attackMethod: 0
       attackType: 0
       startKeyName: attack_on
-      startKeyTime: 0.8
+      startKeyTime: 1
       endType: 1
-      endKeyName: attack_on
-      endKeyTime: 2.8
+      endKeyName: attack_off
+      endKeyTime: 1.8333334
+  - aniName: attack_summon
+    keys:
+    - attackMethod: 0
+      attackType: 0
+      startKeyName: attack_on
+      startKeyTime: 0
+      endType: 1
+      endKeyName: attack_off
+      endKeyTime: 0.13333334
   keyTimes: []
   attackTime: 0
   attackKeyCount: 0
@@ -1386,8 +1404,6 @@ MonoBehaviour:
     isDemSummon: 0
   addAttackEffect: {fileID: 0}
   skill: {fileID: 0}
-  attackEffect: {fileID: 0}
-  effect: {fileID: 0}
   attackDistance: 0
   attackTrigger: {fileID: 8924180071245218248}
   isAttackTriggerOn: 0
@@ -1446,7 +1462,7 @@ MonoBehaviour:
         damage: 0
       isDemSummon: 0
     attackTrigger: {fileID: 8924180071245218248}
-    attackDistance: 3
+    attackDistance: 6
     maxAttackDis: 0
     minAttackDis: 0
     needToChange: 0
@@ -1462,7 +1478,6 @@ MonoBehaviour:
     maxDownAngle: 0
     shootTrack: 1
     shootAlwaysTrack: 0
-    skillPrefab: {fileID: 3174868161031788453, guid: 9eb41f096fe437e47b16a65344bd9922, type: 3}
     skill: {fileID: 0}
   curAttackMethod:
     id: 0
@@ -1523,7 +1538,6 @@ MonoBehaviour:
     maxDownAngle: 0
     shootTrack: 0
     shootAlwaysTrack: 0
-    skillPrefab: {fileID: 0}
     skill: {fileID: 0}
 --- !u!114 &5660842489896163536
 MonoBehaviour:
@@ -1538,67 +1552,22 @@ MonoBehaviour:
   m_Name: 
   m_EditorClassIdentifier: 
   owner: {fileID: 1986582536140952583}
-  dashHeight: 1
-  riseHeight: 14
-  dashForce: 100
-  riseForce: 100
-  dashDuration: 0.5
-  breakDuration: 0.5
-  riseDuration: 0.5
+  targetRiseHeight: 9
+  maxRiseHeight: 15
+  upHeight: 3
+  dashSpeed: 70
+  riseSpeed: 20
+  breakDuration: 3.333
   dashDirection: {x: 0, y: -1, z: 0}
   riseDirection: {x: 0, y: 1, z: 0}
   canDash: 1
   useLocalSpace: 1
-  downSpeedCurve:
-    serializedVersion: 2
-    m_Curve:
-    - serializedVersion: 3
-      time: 0
-      value: 0
-      inSlope: 0
-      outSlope: 0
-      tangentMode: 0
-      weightedMode: 0
-      inWeight: 0
-      outWeight: 0
-    - serializedVersion: 3
-      time: 1
-      value: 1
-      inSlope: 0
-      outSlope: 0
-      tangentMode: 0
-      weightedMode: 0
-      inWeight: 0
-      outWeight: 0
-    m_PreInfinity: 2
-    m_PostInfinity: 2
-    m_RotationOrder: 4
-  upSpeedCurve:
-    serializedVersion: 2
-    m_Curve:
-    - serializedVersion: 3
-      time: 0
-      value: 0
-      inSlope: 0
-      outSlope: 0
-      tangentMode: 0
-      weightedMode: 0
-      inWeight: 0
-      outWeight: 0
-    - serializedVersion: 3
-      time: 1
-      value: 1
-      inSlope: 0
-      outSlope: 0
-      tangentMode: 0
-      weightedMode: 0
-      inWeight: 0
-      outWeight: 0
-    m_PreInfinity: 2
-    m_PostInfinity: 2
-    m_RotationOrder: 4
-  isDashing: 0
-  isRising: 0
-  isBreaking: 0
   drag: 0
   maxSpeed: 2000
+  foot: {fileID: 8639832132450015563}
+  waterRing: {fileID: 6136447150923814641, guid: d59899074cb99914981efdc30df0c632, type: 3}
+  groundLayer:
+    serializedVersion: 2
+    m_Bits: 8200
+  groundCheckRadius: 2
+  groundCheckPoint: {fileID: 8639832132450015556}

+ 1 - 1
ActionTowerDefense/Assets/Resources/Prefab/FX/Water_Ring_fall.prefab

@@ -34179,7 +34179,7 @@ MonoBehaviour:
   m_PrefabInstance: {fileID: 0}
   m_PrefabAsset: {fileID: 0}
   m_GameObject: {fileID: 6136447150923814641}
-  m_Enabled: 1
+  m_Enabled: 0
   m_EditorHideFlags: 0
   m_Script: {fileID: 11500000, guid: d9805ed1e1eb4034ba09501123850708, type: 3}
   m_Name: 

+ 98 - 140
ActionTowerDefense/Assets/Scripts/Skills/chargeDownward.cs

@@ -7,23 +7,22 @@ public class chargeDownward : MonoBehaviour
     private enum MovementState { Idle, Dashing, Breaking, Rising }
     private MovementState currentState = MovementState.Idle;
 
-    public Character owner;
+    public Enemy owner;
     private AttackController attackController;
     private Rigidbody rb;
 
     [Header("移动参数")]
-    [LabelText("冲刺目标高度")]
-    public float dashHeight = 1f;
-    public float riseHeight = 14f;
+    [LabelText("目标上升高度")] 
+    public float targetRiseHeight = 8f;
+    public float maxRiseHeight = 16f;
+    public float upHeight = 4f;
 
-    [LabelText("冲刺力大小")]
-    public float dashForce = 500f;     // 增大默认力值
-    public float riseForce = 500f;      // 增大默认力值
+    [LabelText("冲刺速度")]
+    public float dashSpeed = 1f; 
+    public float riseSpeed = 1f;
 
-    [LabelText("冲刺时间")]
-    public float dashDuration = 0.5f;
+    [LabelText("冷却时间")]
     public float breakDuration = 0.5f;
-    public float riseDuration = 0.5f;
 
     [LabelText("冲刺方向")]
     public Vector3 dashDirection = Vector3.down;
@@ -35,50 +34,48 @@ public class chargeDownward : MonoBehaviour
     [LabelText("是否使用本地坐标")]
     public bool useLocalSpace = true;
 
-    [Header("冲刺曲线")]
-    [LabelText("速度曲线")]
-    public AnimationCurve downSpeedCurve = AnimationCurve.EaseInOut(0f, 0f, 1f, 1f);
-    public AnimationCurve upSpeedCurve = AnimationCurve.EaseInOut(0f, 0f, 1f, 1f);
-
-    [Header("状态")]
-    [DisplayOnly]
-    public bool isDashing = false;
-    public bool isRising = false;
-    [DisplayOnly]
-    public bool isBreaking = false;
-
     [Header("力控制")]
     [LabelText("阻尼系数")]
-    public float drag = 0.5f;          // 减小默认阻尼值
+    public float drag = 0.5f;
     [LabelText("最大速度")]
-    public float maxSpeed = 30f;       // 增大最大速度
+    public float maxSpeed = 30f;
 
-    private Vector3 startPosition;          // 冲刺起始位置
-    private Vector3 riseStartPosition;      // 上升起始位置
-    private float dashStartTime;            // 冲刺开始时间
-    private float riseStartTime;            // 上升开始时间
-    private float breakStartTime;           // 冷却开始时间
+    public GameObject foot;
+    public GameObject waterRing;
 
-    // 记录当前进度(替代协程)
-    private float currentDashProgress = 0f;
-    private float currentRiseProgress = 0f;
+    [Header("碰撞检测")]
+    [LabelText("地面层")]
+    public LayerMask groundLayer;
+    [LabelText("检测半径")]
+    public float groundCheckRadius = 0.2f;
+    [LabelText("地面检测点")]
+    public Transform groundCheckPoint;
+
+    private Vector3 riseStartPosition; // 记录上升起始位置,用于计算相对高度
+    private float breakStartTime;      // 冷却开始时间
 
-    // 目标速度
     private Vector3 targetVelocity = Vector3.zero;
 
     void Awake()
     {
         attackController = GetComponent<AttackController>();
         rb = GetComponent<Rigidbody>();
-        GetLastTimes();
-
     }
+
     public void Update()
     {
         if (owner.state != CharacterState.Attack)
         {
-            // 非攻击状态时重置
             StopAllMovements();
+            if (owner.state == CharacterState.Rise)
+            {
+                foot.GetComponent<Foot>().trigGroundList.Clear();
+                foot.SetActive(false);
+            }
+            else
+            {
+                foot.SetActive(true);
+            }
             return;
         }
 
@@ -113,16 +110,12 @@ public class chargeDownward : MonoBehaviour
 
     private void FixedUpdate()
     {
-
         if (currentState == MovementState.Dashing || currentState == MovementState.Rising)
         {
             Vector3 desiredVelocity = targetVelocity - rb.velocity;
-
-
-            float forceMagnitude = (currentState == MovementState.Dashing) ? dashForce : riseForce;
+            float forceMagnitude = (currentState == MovementState.Dashing) ? dashSpeed : riseSpeed;
             Vector3 force = desiredVelocity * forceMagnitude;
 
-
             if (rb.velocity.magnitude < maxSpeed || Vector3.Dot(rb.velocity, targetVelocity) < 0)
             {
                 rb.AddForce(force, ForceMode.Force);
@@ -130,134 +123,85 @@ public class chargeDownward : MonoBehaviour
         }
     }
 
-    private void GetLastTimes()
-    {
-        foreach (AttackController.SpineAniKey spineAniKey in attackController.attackKeys)
-        {
-            if (spineAniKey.aniName == "attack_march")
-            {
-                foreach (AttackController.AttackKeyType attackKeyType in spineAniKey.keys)
-                {
-                    float startKeyTime = attackKeyType.startKeyTime;
-                    float endKeyTime = attackKeyType.endKeyTime;
-                    float attackTime = owner.totalAttack_marchTime;
-                    dashDuration = (endKeyTime - startKeyTime)*0.8f;
-                    breakDuration = ((endKeyTime - startKeyTime) * 0.2f+attackTime - endKeyTime) / 2;
-                    riseDuration = ((endKeyTime - startKeyTime) * 0.2f+attackTime - endKeyTime) / 2;
-                }
-            }
-        }
-    }
     public void StartDash()
     {
-        if (isDashing) return;
+        foot.SetActive(false);
+        if (IsDashing) return;
 
-        startPosition = transform.position;
-        dashStartTime = Time.time;
-        isDashing = true;
+        IsDashing = true;
         canDash = false;
-        //owner.ani.Play("attack_march",0,0);
-
-        float dashDistance = Mathf.Abs(startPosition.y - dashHeight); 
-
 
-        Vector3 direction = useLocalSpace
-            ? transform.TransformDirection(dashDirection)
-            : dashDirection;
-
-
-        if (direction.y > 0) direction.y = -direction.y;
-
-        targetVelocity = 10*direction * (dashDistance / dashDuration);
-        currentDashProgress = 0f;
+        Vector3 direction = useLocalSpace ? transform.TransformDirection(dashDirection) : dashDirection;
+        if (direction.y > 0) direction.y = -direction.y; // 确保向下
 
+        targetVelocity = direction * dashSpeed;
     }
 
     private void UpdateDashing()
     {
-        if (!isDashing) return;
-
-        float elapsedTime = Time.time - dashStartTime;
-        float progress = Mathf.Clamp01(elapsedTime / dashDuration);
-        currentDashProgress = progress;
-
-
-        float curvedProgress = downSpeedCurve.Evaluate(progress);
-
+        if (!IsDashing) return;
 
-        float dashDistance = Mathf.Abs(startPosition.y - dashHeight);
-
-
-        Vector3 direction = useLocalSpace
-            ? transform.TransformDirection(dashDirection)
-            : dashDirection;
-
-        if (direction.y > 0) direction.y = -direction.y;
-
-
-        targetVelocity = 10*direction * (dashDistance / dashDuration) * (1 - curvedProgress);
-
-        if (progress >= 1f || Mathf.Abs(transform.position.y - dashHeight) < 0.1f)
+        if (IsGrounded())
         {
-            isDashing = false;
+            if (targetRiseHeight < maxRiseHeight)
+            {
+                owner.flyHeight = targetRiseHeight;
+                targetRiseHeight += upHeight;
+            }
+            owner.ani.speed = 3.33f / breakDuration;
+            owner.ani.Play("attack_fall", 0, 0);
+            IsDashing = false;
             isBreaking = true;
             breakStartTime = Time.time;
             currentState = MovementState.Breaking;
-
             rb.velocity = Vector3.zero;
-            Debug.Log("冲刺结束");
+            return;
+
         }
+
+        //Vector3 direction = useLocalSpace ? transform.TransformDirection(dashDirection) : dashDirection;
+        //if (direction.y > 0) direction.y = -direction.y;
+
+        //targetVelocity = direction * dashSpeed;
     }
 
     public void StartRise()
     {
-        if (isRising || isBreaking) return;
-
-        riseStartPosition = transform.position;
-        riseStartTime = Time.time;
-        isRising = true;
-        owner.ani.Play("walk",0,0);
-        float riseDistance = Mathf.Abs(riseHeight - riseStartPosition.y);
+        if (IsRising || isBreaking) return;
 
-        Vector3 direction = useLocalSpace
-            ? transform.TransformDirection(riseDirection)
-            : riseDirection;
+        riseStartPosition = transform.position; // 记录上升起点
+        IsRising = true;
+        owner.ani.speed = 1f;
+        owner.ani.Play("walk", 0, 0);
 
-        if (direction.y < 0) direction.y = -direction.y;
+        Vector3 direction = useLocalSpace ? transform.TransformDirection(riseDirection) : riseDirection;
+        if (direction.y < 0) direction.y = -direction.y; // 确保向上
 
-        targetVelocity = direction * (riseDistance / riseDuration);
-        currentRiseProgress = 0f;
+        targetVelocity = direction * riseSpeed;
     }
 
     private void UpdateRising()
     {
-        if (!isRising) return;
-
-        float elapsedTime = Time.time - riseStartTime;
-        float progress = Mathf.Clamp01(elapsedTime / riseDuration);
-        currentRiseProgress = progress;
+        if (!IsRising) return;
 
-        float curvedProgress = upSpeedCurve.Evaluate(progress);
+        float heightDifference = Mathf.Abs(transform.position.y - targetRiseHeight);
 
-        float riseDistance = Mathf.Abs(riseHeight - riseStartPosition.y);
-
-        Vector3 direction = useLocalSpace
-            ? transform.TransformDirection(riseDirection)
-            : riseDirection;
-
-        if (direction.y < 0) direction.y = -direction.y;
-
-        targetVelocity = 2*direction * (riseDistance / riseDuration) * (1 - curvedProgress);
-
-        if (progress >= 1f || Mathf.Abs(transform.position.y - riseHeight) < 0.1f)
+        if (heightDifference < 0.3f)
         {
-            isRising = false;
+            IsRising = false;
             canDash = true;
             currentState = MovementState.Idle;
-            owner.ChangeState(CharacterState.Idle);
-            rb.velocity = Vector3.zero;
-            Debug.Log("上升结束");
+            owner.ChangeState(CharacterState.Rise);
+            foot.GetComponent<Foot>().trigGroundList.Clear();
+            foot.SetActive(true);
+            return;
         }
+
+        //// 持续更新上升方向和速度
+        //Vector3 direction = useLocalSpace ? transform.TransformDirection(riseDirection) : riseDirection;
+        //if (direction.y < 0) direction.y = -direction.y;
+
+        //targetVelocity = direction * riseSpeed;
     }
 
     private void UpdateBreaking()
@@ -268,17 +212,31 @@ public class chargeDownward : MonoBehaviour
         {
             isBreaking = false;
             currentState = MovementState.Idle;
-            Debug.Log("冷却完成");
         }
     }
 
     public void StopAllMovements()
     {
-        isDashing = false;
-        isRising = false;
+        IsDashing = false;
+        IsRising = false;
         isBreaking = false;
-        currentDashProgress = 0f;
-        currentRiseProgress = 0f;
         currentState = MovementState.Idle;
     }
+
+    private bool IsGrounded()
+    {
+        if (Physics.CheckSphere(groundCheckPoint.position, groundCheckRadius, LayerMask.GetMask("Ground")))
+        {
+            GameObject Fx =PoolManager.Instantiate(waterRing);
+            Fx.transform.position = new Vector3(this.transform.position.x, 0, transform.position.z);
+            ParticleSystem water = Fx.GetComponent<ParticleSystem>();
+            water.Play();
+        }
+        return Physics.CheckSphere(groundCheckPoint.position, groundCheckRadius, groundLayer);
+    }
+
+    public bool IsDashing { get; private set; }
+    public bool IsRising { get; private set; }
+    [ShowInInspector, ReadOnly]
+    private bool isBreaking;
 }