SZAND\msx_2 před 1 rokem
rodič
revize
7a10b4bf8a

+ 5 - 4
ActionTowerDefense/Assets/Resources/Prefab/MySpirit/Spirits_Cook.prefab

@@ -905,7 +905,7 @@ MonoBehaviour:
   soulPrefab: {fileID: 0}
   soulStartSpeed: 1
   easyToGetHit: 0.2
-  canNotBeHit: 0
+  isInvincible: 0
   player: {fileID: 0}
   id: 0
   costMp: 1
@@ -923,6 +923,7 @@ MonoBehaviour:
   hasEffect: 0
   soulCollector: {fileID: 0}
   isBack: 0
+  runSpeed: 4
   attributeUpEffect: {fileID: 0}
   hasUp: 0
   isFirst: 1
@@ -1059,7 +1060,7 @@ MonoBehaviour:
   m_PrefabInstance: {fileID: 0}
   m_PrefabAsset: {fileID: 0}
   m_GameObject: {fileID: 6139679835290116115}
-  m_Enabled: 0
+  m_Enabled: 1
   m_EditorHideFlags: 0
   m_Script: {fileID: 11500000, guid: 21f006d2c845e2e43bce70ea7a2d8dcc, type: 3}
   m_Name: 
@@ -1084,8 +1085,8 @@ BoxCollider:
   m_IsTrigger: 1
   m_Enabled: 1
   serializedVersion: 2
-  m_Size: {x: 0, y: 0, z: 20}
-  m_Center: {x: 0, y: 0, z: 0}
+  m_Size: {x: 5, y: 10, z: 20}
+  m_Center: {x: 0, y: 5, z: 0}
 --- !u!1 &6824693000491653481
 GameObject:
   m_ObjectHideFlags: 0

+ 61 - 0
ActionTowerDefense/Assets/Scripts/Demonic.cs

@@ -25,6 +25,8 @@ public class Demonic : MoveCharacter
     public Collider soulCollector;
     public bool isBack = false;         //Íù·´·½Ïò×ß
 
+    public float runSpeed;
+
     private void Awake()
     {
     }
@@ -330,6 +332,58 @@ public class Demonic : MoveCharacter
                 }
                 AdjustHeight();
                 break;
+            case CharacterState.Rush:
+                if (isAttack)
+                {
+                    Attack2();
+                    break;
+                }
+                if (!foot.TrigGround && !canFly)
+                {
+                    if (rb.velocity.y > 0)
+                    {
+                        ChangeState(CharacterState.Rise);
+                        break;
+                    }
+                    else
+                    {
+                        ChangeState(CharacterState.Fall);
+                        break;
+                    }
+                }
+                if (leftDir.x < 0.3f && leftDir.x > -0.3f)
+                {
+                    ChangeState(CharacterState.Idle);
+                    break;
+                }
+                if (leftDir.x > 0.3f)
+                {
+                    //rb.velocity += Vector3.right * moveAcc * Time.deltaTime;
+                    rb.velocity = Vector3.right * runSpeed;
+                    //if (rb.velocity.x > maxMoveSpeed)
+                    //{
+                    //    rb.velocity = new Vector3(maxMoveSpeed, rb.velocity.y, rb.velocity.z);
+                    //}
+                    if (bodyTrans.localScale.x > 0)
+                    {
+                        Turn();
+                    }
+                }
+                else if (leftDir.x < -0.3f)
+                {
+                    //rb.velocity -= Vector3.right * moveAcc * Time.deltaTime;
+                    rb.velocity = Vector3.left * runSpeed;
+                    //if (rb.velocity.x < -maxMoveSpeed)
+                    //{
+                    //    rb.velocity = new Vector3(-maxMoveSpeed, rb.velocity.y, rb.velocity.z);
+                    //}
+                    if (bodyTrans.localScale.x < 0)
+                    {
+                        Turn();
+                    }
+                }
+                AdjustHeight();
+                break;
             case CharacterState.Rise:
                 if (rb.velocity.y <= 0)
                 {
@@ -454,6 +508,9 @@ public class Demonic : MoveCharacter
             case CharacterState.Run:
                 rb.velocity = Vector3.zero;
                 break;
+            case CharacterState.Rush:
+                rb.velocity = Vector3.zero;
+                break;
             case CharacterState.Rise:
                 break;
             case CharacterState.Fall:
@@ -501,6 +558,10 @@ public class Demonic : MoveCharacter
                 aniCollider.Play("Walk", 0, 0);
                 //animalAni.SetInteger("state", (int)PlayerState.Walk);
                 break;
+            case CharacterState.Rush:
+                ani.Play("rush", 0, 0);
+                aniCollider.Play("Rush", 0, 0);
+                break;
             case CharacterState.Rise:
                 aniCollider.Play("Rise", 0, 0);
                 break;

+ 12 - 0
ActionTowerDefense/Assets/Scripts/Spirits/ESpirits_Cook.cs

@@ -319,6 +319,18 @@ public class ESpirits_Cook : MonoBehaviour
         }
     }
 
+    private void OnDisable()
+    {
+        if (food.layer == 7 && !target.isDie)
+        {
+            food.GetComponent<Demonic>().ChangeState(CharacterState.Weak);
+        }
+        else if (food.layer == 6 && !target.isDie)
+        {
+            food.GetComponent<PlayerController>().ChangeState(CharacterState.Weak);
+        }
+    }
+
     private void FixedUpdate()
     {
         if (isAct)

+ 14 - 3
ActionTowerDefense/Assets/Scripts/Spirits/Spirits_Cook.cs

@@ -133,7 +133,7 @@ public class Spirits_Cook : MonoBehaviour
                     food = target.gameObject;
                     if (!target.isDie)
                     {
-                        Enemy fEne = food.GetComponent<Enemy>();
+                        fEne = food.GetComponent<Enemy>();
                         fEne.isCaughtByCook = true;
                         fEne.ChangeState(CharacterState.Coma);
                         //food.GetComponent<Demonic>().ChangeState(CharacterState.Die);
@@ -147,7 +147,7 @@ public class Spirits_Cook : MonoBehaviour
             }
             //»Ø¼ÒÂô´®
             /*
-            else if (state == cookState.back && target.gameObject.layer == 8)
+            else if (state == cookState.back && target.gameObject.layer == 7)
             {
                 ChangeState(cookState.cook);
                 if (food.layer == 8 && !target.isDie)
@@ -158,6 +158,8 @@ public class Spirits_Cook : MonoBehaviour
         }
     }
 
+    Enemy fEne;
+
     private void ChangeState(cookState cs)
     {
         switch (cs)
@@ -196,6 +198,7 @@ public class Spirits_Cook : MonoBehaviour
             case cookState.back:
                 dem.canMove = true;
                 dem.isBack = true;
+                destX = Random.Range(minX, maxX);
                 break;
             default:
                 break;
@@ -208,7 +211,7 @@ public class Spirits_Cook : MonoBehaviour
         switch (cs)
         {
             case cookState.back:
-                if (cook.transform.position.x <= destX)
+                if (cook.transform.position.x >= destX)
                 {
                     ChangeState(cookState.cook);
                     if (food.layer == 8 && !target.isDie)
@@ -273,6 +276,14 @@ public class Spirits_Cook : MonoBehaviour
         }
     }
 
+    private void OnDisable()
+    {
+        if (!fEne.isDie)
+        {
+            fEne.ChangeState(CharacterState.Weak);
+        }
+    }
+
     private void FixedUpdate()
     {
         if (isAct)