فهرست منبع

调整胖子平台击飞的关系

WGL 4 ماه پیش
والد
کامیت
4827f982fe

+ 1 - 1
ActionTowerDefense/Assets/Resources/Prefab/Player.prefab

@@ -5109,7 +5109,7 @@ GameObject:
   m_Component:
   - component: {fileID: 9080369701262820802}
   - component: {fileID: 669663247824325687}
-  m_Layer: 21
+  m_Layer: 15
   m_Name: BodyCollider (1)
   m_TagString: Untagged
   m_Icon: {fileID: 0}

+ 3 - 1
ActionTowerDefense/Assets/Resources/Prefab/ScenceInteraction/Platform.prefab

@@ -73,7 +73,7 @@ GameObject:
   m_Component:
   - component: {fileID: 4214188590365893651}
   - component: {fileID: 5706277928133819894}
-  m_Layer: 23
+  m_Layer: 21
   m_Name: Collider
   m_TagString: Untagged
   m_Icon: {fileID: 0}
@@ -225,8 +225,10 @@ MonoBehaviour:
   feet: []
   left: {fileID: 1110442559149676122}
   right: {fileID: 1931566334561107229}
+  collider: {fileID: 7684122083059334898}
   canDown: 1
   haveMagnetic: 0
+  canPenetrateBullets: 0
 --- !u!1 &9070787072253727074
 GameObject:
   m_ObjectHideFlags: 0

+ 5 - 1
ActionTowerDefense/Assets/Scripts/Characters/AttributeStatus.cs

@@ -172,6 +172,7 @@ public class AttributeStatus : MonoBehaviour
                     //»÷·É
                     case AttackEffect.BlowUp:
                         AddBlowUp(attackInfo.blowUp, attackFrom.bodyTrans);
+                        character.bodyCollider.layer = LayerMask.NameToLayer("BodyToPlatformCollider");
                         if (attackInfo.blowUp.haveLandingDamage)
                         {
                             landingDamageFrom = attackFrom;
@@ -180,6 +181,7 @@ public class AttributeStatus : MonoBehaviour
                     //»÷Âä
                     case AttackEffect.ShotDown:
                         AddShotDown(attackInfo.shotDown, attackFrom.bodyTrans);
+                        character.bodyCollider.layer = LayerMask.NameToLayer("BodyToPlatformCollider");
                         if (attackInfo.shotDown.haveLandingDamage)
                         {
                             landingDamageFrom = attackFrom;
@@ -233,6 +235,7 @@ public class AttributeStatus : MonoBehaviour
                         else if (foot.TrigGround || curHeight <= origPos.y + 0.05f)
                         {
                             floatingState = 0;
+                            character.bodyCollider.layer = character.gameObject.layer;
                             character.isAdjustHeight = 1;
                             OutSpecialState();
                             return;
@@ -271,7 +274,7 @@ public class AttributeStatus : MonoBehaviour
                         break;
                     case 0:
                         Vector3 vel = rb.velocity;
-                        if (isFly && foot.TrigGround)
+                        if (isFly && foot.TrigGround && vel.y <= 0)
                         {
                             vel = Vector3.zero;
                             if (!foot.haveGravity)
@@ -279,6 +282,7 @@ public class AttributeStatus : MonoBehaviour
                                 transform.position = new Vector3(transform.position.x, character.platformPosY, transform.position.z);
                             }
                             character.ani.Play("weak", 0, 0);
+
                             hitState = 1;
                             if (haveLandingDamage)
                             {

+ 28 - 6
ActionTowerDefense/Assets/Scripts/Characters/Foot.cs

@@ -8,6 +8,8 @@ public class Foot : MonoBehaviour
     [FoldoutGroup("组件")] public Rigidbody rb;
     [FoldoutGroup("组件")] public MoveCharacter moveCharacter;
 
+    [FoldoutGroup("条件")] [LabelText("是否能站在胖子上")] public bool canOnGiant;
+
     public bool haveGravity = true;
     public bool TrigGround
     {
@@ -116,17 +118,37 @@ public class Foot : MonoBehaviour
 
     private void OnTriggerEnter(Collider other)
     {
-        bool flag1 = other.CompareTag("Ground");
-        bool flag2 = other.CompareTag("Platform");
-        if (flag1|| flag2)
+        if (other.CompareTag("Ground"))
         {
             if (!trigGroundList.Exists(t => t == other.gameObject))
             {
                 trigGroundList.Add(other.gameObject);
-                Platform platform = other.GetComponent<Platform>();
-                if (platform!=null)
+            }
+        }
+        if (other.CompareTag("Platform"))
+        {
+            Platform platform = other.GetComponent<Platform>();
+            if (platform != null)
+            {
+                //是否为胖子头上的平台(==null不是胖子的平台)
+                if (platform.rb == null)
+                {
+                    if (!trigGroundList.Exists(t => t == other.gameObject))
+                    {
+                        trigGroundList.Add(other.gameObject);
+                        platform.feet.Add(this);
+                    }
+                }
+                else
                 {
-                    platform.feet.Add(this);
+                    if (canOnGiant)
+                    {
+                        if (!trigGroundList.Exists(t => t == other.gameObject))
+                        {
+                            trigGroundList.Add(other.gameObject);
+                            platform.feet.Add(this);
+                        }
+                    }
                 }
             }
         }

+ 1 - 34
ActionTowerDefense/Assets/Scripts/Platform.cs

@@ -13,7 +13,7 @@ public class Platform : MonoBehaviour
     [FoldoutGroup("条件")] [LabelText("是否可以下平台")] public bool canDown = true;
     [FoldoutGroup("条件")] [LabelText("是否优先行走")] public bool haveMagnetic;
     [FoldoutGroup("条件")] [LabelText("是否可以穿透子弹")] public bool canPenetrateBullets;
-
+    
     public bool TrigFeet
     {
         get
@@ -21,40 +21,7 @@ public class Platform : MonoBehaviour
             return feet.Count > 0;
         }
     }
-    
 
-    private void OnTriggerEnter(Collider other)
-    {
-        
-        //Foot foot = other.GetComponent<Foot>();
-        //if (foot != null && foot.transform.parent.gameObject.layer != 8)
-        //{
-        //    //if (Mathf.Abs(foot.transform.position.x - transform.position.x) > edgeDistance)
-        //    //{
-        //    //    return;
-        //    //}
-        //    if(!foot.trigGroundList.Exists(t=>t == gameObject))
-        //    {
-        //        foot.trigGroundList.Add(gameObject);
-        //    }
-        //    feet.Add(foot);
-        //}
-    }
-    private void OnTriggerExit(Collider other)
-    {
-        //Foot foot = other.GetComponent<Foot>();
-        //if(foot != null && foot.transform.parent.gameObject.layer != 8)
-        //{
-        //    if(foot.trigGroundList.Exists(i =>i == gameObject))
-        //    {
-        //        foot.trigGroundList.Remove(gameObject);
-        //    }
-        //    if(feet.Exists(i => i == foot))
-        //    {
-        //        feet.Remove(foot);
-        //    }
-        //}
-    }
     private void OnDisable()
     {
         foreach(Foot i in feet)

+ 1 - 1
ActionTowerDefense/ProjectSettings/DynamicsManager.asset

@@ -18,7 +18,7 @@ PhysicsManager:
   m_ClothInterCollisionDistance: 0.1
   m_ClothInterCollisionStiffness: 0.2
   m_ContactsGeneration: 1
-  m_LayerCollisionMatrix: ffe731ffffe721ffffe721fffff761ffffe721ffffe721ff3fc000ff3fc000ff3fc000ff3fe000ff3fe000ff009000ff08a800ff3ff640ffff2728ffffbf20ff3f0002ff000005ff000002ff004010ff010008ff3fc080ff082000ff000020ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
+  m_LayerCollisionMatrix: ffe711ffffe701ffffe701fffff741ffffe701ffffe701ff3f4000ff3f4000ff3f4000ff3f6000ff3f6000ff001000ff082800ff3f7640ffffa728ff3f4020ff3f0002ff000005ff000002ff004010ff010008ff00c080ff082000ff000020ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
   m_AutoSimulation: 1
   m_AutoSyncTransforms: 0
   m_ReuseCollisionCallbacks: 1

+ 4 - 3
ActionTowerDefense/ProjectSettings/TagManager.asset

@@ -14,6 +14,7 @@ TagManager:
   - Ground
   - Platform
   - Plane
+  - FxTemporaire
   layers:
   - Default
   - TransparentFX
@@ -30,15 +31,15 @@ TagManager:
   - Attackless
   - Platform
   - Bullet
-  - Portal
+  - BodyToPlatformCollider
   - Boss
   - SearchTrigger
   - BeSearchTrigger
   - BeHitTrigger
   - AttackTrigger
-  - PlayerRushBody
+  - PlatformCollider
   - Foot
-  - CantRush
+  - 
   - 
   - 
   -