Procházet zdrojové kódy

厨师动画加入

SZAND\msx_2 před 1 rokem
rodič
revize
a6586e8717

+ 5 - 4
ActionTowerDefense/Assets/Resources/Prefab/ESpirits_Cook.prefab

@@ -329,8 +329,6 @@ MonoBehaviour:
   colliders:
   - {fileID: 4480734502875862885}
   - {fileID: 2460330936527559963}
-  walkSpeed: 3
-  runSpeed: 5
   intervalTimeSell: 1
   minX: 8.5
   maxX: 20
@@ -340,6 +338,8 @@ MonoBehaviour:
   larger: 1.2
   lockEffect: {fileID: 2123904437201259524, guid: 24cf2b33715a9e04b9aabcb789c31067, type: 3}
   cookTime: 2
+  seizeTime: 2
+  chargeTime: 1
 --- !u!1 &3483054690158852324
 GameObject:
   m_ObjectHideFlags: 0
@@ -862,8 +862,8 @@ MonoBehaviour:
   foot: {fileID: 5440846222604650418}
   extraRiseGravity: -28.8
   extraFallGravity: -14.4
-  moveSpeed: 0
-  beRepelValue: 0
+  moveSpeed: 2
+  beRepelValue: 5
   totalBeRepelValue: 30
   weakTime: 0
   totalWeakTime: 0
@@ -912,6 +912,7 @@ MonoBehaviour:
   dashEffect: {fileID: 2254593709981819441, guid: 3839706ae501f6f4494a5b38dd4e936e, type: 3}
   targetDir: {x: 0, y: 0, z: 0}
   haveDownRush: 0
+  rushHaveAttack: 0
   downRushTime: 0.8
   finishRushTime: 0.8
   isBack: 0

+ 59 - 0
ActionTowerDefense/Assets/Scripts/Enemy.cs

@@ -278,6 +278,58 @@ public class Enemy : 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 * rushSpeed;
+                    //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 * rushSpeed;
+                    //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)
                 {
@@ -495,6 +547,9 @@ public class Enemy : MoveCharacter
             case CharacterState.Run:
                 rb.velocity = Vector3.zero;
                 break;
+            case CharacterState.Rush:
+                rb.velocity = Vector3.zero;
+                break;
             case CharacterState.Rise:
                 break;
             case CharacterState.Fall:
@@ -563,6 +618,10 @@ public class Enemy : 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;

+ 39 - 41
ActionTowerDefense/Assets/Scripts/Spirits/ESpirits_Cook.cs

@@ -7,42 +7,33 @@ using Random = UnityEngine.Random;
 
 public class ESpirits_Cook : MonoBehaviour
 {
-    public TextMeshProUGUI text;    //剩余串的数量文本
-    private GameObject dia;         //文本框
+    public TextMeshProUGUI text;        //剩余串的数量文本
+    private GameObject dia;             //文本框
 
-    private Transform cook;         //厨子
-    private Animator ani;           //厨子动画
-    private Collider col;           //厨子的碰撞体
-    public int chuan;               //厨子拥有多少串
-    public bool isGood;             //厨子是否是好厨子
-    public GameObject[] colliders;  //一些要开要关的collider
-    public float walkSpeed;         //走路速度
-    public float runSpeed;          //冲刺速度
+    private Transform cook;             //厨子
+    private Animator ani;               //厨子动画
+    private Collider col;               //厨子的碰撞体
+    public int chuan;                   //厨子拥有多少串
+    public bool isGood;                 //厨子是否是好厨子
+    public GameObject[] colliders;      //一些要开要关的collider
 
     private float intervalTimePast;
-    public float intervalTimeSell;  //卖串的间隔时间
-    private bool isInterval = false;        //开始计算间隔时间
+    public float intervalTimeSell;      //卖串的间隔时间
+    private bool isInterval = false;    //开始计算间隔时间
 
-    public float minX;              //厨子卖串的最小地址站
-    public float maxX;              //厨子卖串的最大地址站
+    public float minX;                  //厨子卖串的最小地址站
+    public float maxX;                  //厨子卖串的最大地址站
 
-    public float value;             //加血程度百分比
-    public GameObject effect;       //加血效果
+    public float value;                 //加血程度百分比
+    public GameObject effect;           //加血效果
 
-    private Enemy ene;              //厨子的enemy脚本
+    private Enemy ene;                  //厨子的enemy脚本
 
-    //private bool once = false;      //死一次
-    //private bool die = false;       //厨子命尽
-    //private bool toCatch = false;   //没串了去抓人
-    private bool isRunning = false; //开跑
+    private float activeTime;           //厨子已出现的时长
+    public float activeAniTime;         //厨子出现动画的时长
+    private bool isAct = false;         //厨子已经完整出现
 
-    private float activeTime;       //厨子已出现的时长
-    public float activeAniTime;     //厨子出现动画的时长
-    private bool isAct = false;     //厨子已经完整出现
-
-    //private List<GameObject> customers; //厨子的所有顾客
-
-    public float larger;            //顾客变大的程度
+    public float larger;                //顾客变大的程度
 
     private GameObject player1;
     private GameObject player2;
@@ -54,6 +45,8 @@ public class ESpirits_Cook : MonoBehaviour
 
     private float pastTime;
     public float cookTime;
+    public float seizeTime;
+    public float chargeTime;
 
     private float destX;
 
@@ -91,6 +84,11 @@ public class ESpirits_Cook : MonoBehaviour
         return x;
     }
 
+    private void ToRush()
+    {
+        ChangeState(cookState.run);
+    }
+
     private void OnTriggerEnter(Collider other)
     {
         //路过发串
@@ -113,8 +111,7 @@ public class ESpirits_Cook : MonoBehaviour
                     if (chuan == 0)
                     {
                         ani.Play("charge", 0, 0);
-                        //toCatch = true;
-                        ChangeState(cookState.run);
+                        Invoke("ToRush", chargeTime);
                     }
                 }
             }
@@ -171,7 +168,7 @@ public class ESpirits_Cook : MonoBehaviour
                     g.SetActive(true);
                 }
                 ene.canMove = true;
-                ene.ChangeState(CharacterState.Run);
+                ene.ChangeState(CharacterState.Rush);
                 break;
             //抓住你啦
             case cookState.seize:
@@ -188,6 +185,7 @@ public class ESpirits_Cook : MonoBehaviour
                 ene.canMove = true;
                 ene.isBack = true;
                 break;
+            //首次登场
             case cookState.first:
                 dia.SetActive(false);
                 ene.canMove = true;
@@ -227,14 +225,6 @@ public class ESpirits_Cook : MonoBehaviour
     {
         switch (cs)
         {
-            case cookState.walk:
-                break;
-            case cookState.find:
-                if (ene.isFindPlayer)
-                {
-                    ene.ChangeState(CharacterState.ReadyToRush);
-                }
-                break;
             case cookState.back:
                 if (cook.transform.position.x <= destX)
                 {
@@ -246,11 +236,11 @@ public class ESpirits_Cook : MonoBehaviour
                 if (pastTime >= cookTime)
                 {
                     pastTime = 0;
-                    ChangeState(cookState.back);
+                    ChangeState(cookState.sell);
                 }
                 break;
             case cookState.run:
-                ene.targetCharacter = target.GetComponent<Character>();
+                //ene.targetCharacter = target.GetComponent<Character>();
                 break;
             case cookState.sell:
                 break;
@@ -260,6 +250,14 @@ public class ESpirits_Cook : MonoBehaviour
                     ChangeState(cookState.sell);
                 }
                 break;
+            case cookState.seize:
+                pastTime += Time.deltaTime;
+                if (pastTime >= seizeTime)
+                {
+                    pastTime = 0;
+                    ChangeState(cookState.back);
+                }
+                break;
             default:
                 break;
         }