Parcourir la source

举鸡代码恢复

zhengchen il y a 1 an
Parent
commit
6f0f3fecb6

+ 3 - 3
Assets/Scripts/Comp/BattleMainComp.cs

@@ -28,9 +28,9 @@ namespace Comp
             SoundCore.Instance.PlaySound(SoundType.BattleBgmMain, SoundCtrl.BattleBgmPlayer, true, true);
             MessageComp.Instance.OnBattleClientMsg += OnClientMsg;
             MessageComp.Instance.OnBattlePlayerQuit += OnPlayerQuit;
-#if UNITY_EDITOR
-            _debug = true;
-#endif
+// #if UNITY_EDITOR
+//             _debug = true;
+// #endif
             if (_debug)
             {
                 var logs =

+ 33 - 14
Assets/Scripts/Comp/CockActionComp.cs

@@ -31,6 +31,12 @@ namespace Comp
 
         private Rigidbody _rigidbody;
 
+        public bool OpenGravity = false;
+
+        public bool CloseGravity = false;
+
+        public Vector3 stayPos = Vector3.zero;
+
         // 水平与垂直方向运动相关
 
         public int playerId;
@@ -44,9 +50,7 @@ namespace Comp
         private GameObject _missPrefab;
 
         private bool _createMiss = false;
-
-        public bool willBeLift = false;
-
+        
         public ICockController CockController
         {
             get
@@ -95,9 +99,32 @@ namespace Comp
 
         private void Update()
         {
-            if (!_createMiss) return;
-            _createMiss = false;
-            CreateMissText();
+            if (_createMiss)
+            {
+                CreateMissText();
+                _createMiss = false;
+            }
+        }
+
+        private void FixedUpdate()
+        {
+            if (CloseGravity)
+            {
+                _rigidbody.useGravity = false;
+                Debug.Log("关闭重力" + _rigidbody.useGravity + "===" + playerId);
+                if (stayPos != Vector3.zero)
+                    transform.localPosition = stayPos;
+            }
+
+            if (OpenGravity)
+            {
+                CloseGravity = false;
+                stayPos = Vector3.zero;
+                OpenGravity = false;
+                _rigidbody.useGravity = true;
+                _rigidbody.velocity = Vector3.zero;
+                Debug.Log("开启重力" + _rigidbody.useGravity + "===" + playerId);
+            }
         }
 
         private void OnRun()
@@ -125,18 +152,10 @@ namespace Comp
 
         public void OnAttackEnd()
         {
-            if (willBeLift)
-            {
-                _rigidbody.useGravity = false;
-            }
         }
 
         public void OnJumpEnd()
         {
-            if (willBeLift)
-            {
-                _rigidbody.useGravity = false;
-            }
         }
 
         public void SetHighJump(bool high)

+ 11 - 9
Assets/Scripts/Comp/MasterActionComp.cs

@@ -60,17 +60,16 @@ namespace Comp
         private IEnumerator CockRayCast() // 判断碰撞点,现在不用射线了
         {
             yield return new WaitForSeconds(1f);
+            Debug.Log("lift cock");
             var actionComp = GameCore.Instance.GetCockActionCompByPlayerId(playerId);
             var cockObj = actionComp.gameObject;
             _cock = cockObj;
             if (playerId == GameCore.Instance.localPlayer.playerId)
-                _collisionX = _cock.transform.position.x - 1f;
+                _collisionX = _cock.transform.position.x - 1.5f;
             else
             {
-                _collisionX = _cock.transform.position.x + 1f;
+                _collisionX = _cock.transform.position.x + 1.5f;
             }
-
-            actionComp.willBeLift = true;
         }
 
         private void FixedUpdate()
@@ -123,17 +122,18 @@ namespace Comp
             {
                 _liftPos = _cock.transform.position;
                 _cock.transform.parent = transform;
-                var comp = _cock.GetComponent<CockActionComp>();
+                var comp = GameCore.Instance.GetCockActionCompByPlayerId(playerId);
+                comp.CloseGravity = true;
                 switch (comp.cockId)
                 {
                     case 1:
-                        _cock.transform.localPosition = new Vector3(0, 0.9f, 0.3f);
+                        comp.stayPos = new Vector3(0, 0.9f, 0.3f);
                         break;
                     case 2:
-                        _cock.transform.localPosition = new Vector3(0, 0.9f, 0.4f);
+                        comp.stayPos = new Vector3(0, 0.9f, 0.4f);
                         break;
                     default:
-                        _cock.transform.localPosition = new Vector3(0, 0.9f, 0.3f);
+                        comp.stayPos = new Vector3(0, 0.9f, 0.3f);
                         break;
                 }
 
@@ -141,9 +141,11 @@ namespace Comp
             }
             else
             {
+                var comp = GameCore.Instance.GetCockActionCompByPlayerId(playerId);
+                comp.stayPos = Vector3.zero;
                 _cock.transform.parent = GameCore.Instance.parent.transform;
                 _cock.transform.position = _liftPos;
-                _cock.GetComponent<Rigidbody>().useGravity = true;
+                comp.OpenGravity = true;
                 _isPutDown = false;
             }
         }

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

@@ -35,6 +35,7 @@ namespace Game
 
         public override void EnterState()
         {
+            _gameCore.liftTimes--;
             _gameCore.masterBack.Item1 = false;
             _gameCore.masterBack.Item2 = false;
             foreach (var masterActionComp in _gameCore.masterDict)