Kaynağa Gözat

调整动作速度 跳跃高度

zhengchen 1 yıl önce
ebeveyn
işleme
af3620018c

+ 13 - 7
Assets/Resources/Cock/Cock Animator Controller.controller

@@ -197,7 +197,7 @@ AnimatorState:
   m_PrefabInstance: {fileID: 0}
   m_PrefabAsset: {fileID: 0}
   m_Name: attack random 2
-  m_Speed: 1
+  m_Speed: 3
   m_CycleOffset: 0
   m_Transitions:
   - {fileID: -2653612831575421775}
@@ -489,7 +489,7 @@ AnimatorState:
   m_Motion: {fileID: 1827226128182048838, guid: 9c33970e193e6e342bebb347b6565178,
     type: 3}
   m_Tag: 
-  m_SpeedParameter: 
+  m_SpeedParameter: random4speed
   m_MirrorParameter: 
   m_CycleOffsetParameter: 
   m_TimeParameter: 
@@ -637,6 +637,12 @@ AnimatorController:
     m_DefaultInt: 0
     m_DefaultBool: 0
     m_Controller: {fileID: 0}
+  - m_Name: random4speed
+    m_Type: 1
+    m_DefaultFloat: 10
+    m_DefaultInt: 0
+    m_DefaultBool: 0
+    m_Controller: {fileID: 0}
   m_AnimatorLayers:
   - serializedVersion: 5
     m_Name: Base Layer
@@ -786,7 +792,7 @@ AnimatorState:
   m_PrefabInstance: {fileID: 0}
   m_PrefabAsset: {fileID: 0}
   m_Name: attack random 4
-  m_Speed: 4
+  m_Speed: 1
   m_CycleOffset: 0
   m_Transitions:
   - {fileID: 120510955580992770}
@@ -802,7 +808,7 @@ AnimatorState:
   m_Motion: {fileID: 1827226128182048838, guid: 88c01d4eb6475d544879cdf61423f720,
     type: 3}
   m_Tag: 
-  m_SpeedParameter: 
+  m_SpeedParameter: random4speed
   m_MirrorParameter: 
   m_CycleOffsetParameter: 
   m_TimeParameter: 
@@ -823,9 +829,9 @@ AnimatorStateTransition:
   m_Mute: 0
   m_IsExit: 0
   serializedVersion: 3
-  m_TransitionDuration: 0.25
-  m_TransitionOffset: 0
-  m_ExitTime: 0.95454544
+  m_TransitionDuration: 0.25000048
+  m_TransitionOffset: 0.35656035
+  m_ExitTime: 0.9545454
   m_HasExitTime: 0
   m_HasFixedDuration: 1
   m_InterruptionSource: 0

+ 6 - 1
Assets/Scripts/Comp/CockActionComp.cs

@@ -3,7 +3,6 @@ using System.Collections;
 using Game;
 using Sound;
 using UnityEngine;
-using UnityEngine.UI;
 
 namespace Comp
 {
@@ -101,6 +100,11 @@ namespace Comp
                     }
                     else
                     {
+                        if (randomAttack == 4)
+                        {
+                            Debug.Log("random attack=====" + randomAttack);
+                        }
+
                         CockController.RandomAttack(randomAttack);
                         randomAttack = 0;
                     }
@@ -109,6 +113,7 @@ namespace Comp
                 {
                     curAction?.Invoke();
                 }
+
                 curAction = null;
                 yield return _waitEverySecond;
             }

+ 4 - 6
Assets/Scripts/Comp/CockMoveComp.cs

@@ -1,4 +1,5 @@
 using System;
+using Game;
 using UnityEngine;
 
 namespace Comp
@@ -17,10 +18,7 @@ namespace Comp
 
         private const float MovingTime = 0.4f; // 移动时间
 
-        // 跳跃相关
-        private const float HighJumpSpeed = 2.4f; // 高跳速度
-
-        private const float LowJumpSpeed = 2f; // 低跳速度
+        public int cockId;
 
         private Vector3 CreateMovingVector(float speed)
         {
@@ -52,8 +50,8 @@ namespace Comp
         }
 
         public void Jump(bool highJump)
-        {
-            var jumpSpeed = highJump ? HighJumpSpeed : LowJumpSpeed;
+        {   
+            var jumpSpeed = highJump ? AttackRandomUtil.GetHighJumpSpeed(cockId) : AttackRandomUtil.GetLowJumpSpeed(cockId);
             var jumpingVector = CreateJumpingVector(jumpSpeed);
             _rigidbody.AddForce(jumpingVector, ForceMode.Impulse); // 添加力
         }

+ 34 - 2
Assets/Scripts/Game/AttackRandomUtil.cs

@@ -17,9 +17,19 @@ namespace Game
             { 7, new int[] { 1, 3, 4, -1 } },
         };
 
+        private static readonly Dictionary<int, float[]> CockJumpDict = new Dictionary<int, float[]>()
+        {
+            { 1, new float[] { 2.4f, 2f } }, // 高跳速度,低跳速度
+            { 2, new float[] { 2.7f, 2.3f } },
+            { 3, new float[] { 2.3f, 2.1f } },
+            { 4, new float[] { 2.6f, 2.2f } },
+            { 5, new float[] { 2.8f, 2.4f } },
+            { 6, new float[] { 2.2f, 1.8f } },
+            { 7, new float[] { 2.9f, 2.5f } },
+        };
+
         public static int GetRandomNumberFromDict(int cockId)
-        {   
-            Debug.Log("cock id is " + cockId);
+        {
             if (CockAttackDict.ContainsKey(cockId))
             {
                 var numbers = CockAttackDict[cockId];
@@ -31,5 +41,27 @@ namespace Game
             // 如果 key 不存在,可以返回一个默认值或抛出异常等处理方式
             return -1;
         }
+
+        public static float GetHighJumpSpeed(int cockId)
+        {
+            if (CockAttackDict.ContainsKey(cockId))
+            {
+                var numbers = CockJumpDict[cockId];
+                return numbers[0] * 1.5f;
+            }
+            // 如果 key 不存在,可以返回一个默认值或抛出异常等处理方式
+            return 2.4f;
+        }
+        
+        public static float GetLowJumpSpeed(int cockId)
+        {
+            if (CockAttackDict.ContainsKey(cockId))
+            {
+                var numbers = CockJumpDict[cockId];
+                return numbers[1] * 1.5f;
+            }
+            // 如果 key 不存在,可以返回一个默认值或抛出异常等处理方式
+            return 2f;
+        }
     }
 }

+ 0 - 1
Assets/Scripts/Game/GameBattleState.cs

@@ -123,7 +123,6 @@ namespace Game
                 {
                     case 1:
                         var randomAttack = AttackRandomUtil.GetRandomNumberFromDict(attackCockActionComp.cockId);
-                        Debug.Log("random attack " + randomAttack);
                         attackCockActionComp.randomAttack = randomAttack;
                         attackCockActionComp.curAction = attackCockActionComp.CockController.JumpAndAttack;
                         break;

+ 3 - 0
Assets/Scripts/Game/GamePendingState.cs

@@ -63,6 +63,9 @@ namespace Game
             localCockActionComp.cockId = _gameCore.localPlayer.cockId;
             antiCockActionComp.cockId = _gameCore.antiPlayer.cockId;
 
+            localCockActionComp.gameObject.GetComponent<CockMoveComp>().cockId = _gameCore.localPlayer.cockId;
+            antiCockActionComp.gameObject.GetComponent<CockMoveComp>().cockId = _gameCore.antiPlayer.cockId;
+
             localCockActionComp.playerId = _gameCore.localPlayer.playerId;
             antiCockActionComp.playerId = _gameCore.antiPlayer.playerId;