Ver código fonte

保存一下,明天再来

SZAND\msx_2 1 ano atrás
pai
commit
0d58e8a763

+ 2 - 2
ActionTowerDefense/Assets/Resources/Prefab/FX/CookAimEffect.prefab

@@ -25,7 +25,7 @@ Transform:
   m_GameObject: {fileID: 2123904437201259524}
   m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
   m_LocalPosition: {x: 0, y: 0, z: 0}
-  m_LocalScale: {x: 1, y: 1, z: 1}
+  m_LocalScale: {x: 12, y: 1, z: 1}
   m_ConstrainProportionsScale: 0
   m_Children:
   - {fileID: 6299539607906624902}
@@ -10019,7 +10019,7 @@ Transform:
   m_PrefabAsset: {fileID: 0}
   m_GameObject: {fileID: 8703134072210761286}
   m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
-  m_LocalPosition: {x: 0, y: 0, z: 0}
+  m_LocalPosition: {x: 0, y: 1.3, z: 0}
   m_LocalScale: {x: 1, y: 3, z: 1}
   m_ConstrainProportionsScale: 0
   m_Children:

+ 49 - 42
ActionTowerDefense/Assets/Scripts/Spirits/Spirits_Cook.cs

@@ -16,6 +16,8 @@ public class Spirits_Cook : MonoBehaviour
     public bool isEnemy;            //厨子是否是敌方
     public bool isGood;             //厨子是否是好厨子
     public GameObject[] colliders;  //一些要开要关的collider
+    public float walkSpeed;         //走路速度
+    public float runSpeed;          //冲刺速度
 
     public float value;             //加血程度百分比
     public GameObject effect;       //加血效果
@@ -24,7 +26,7 @@ public class Spirits_Cook : MonoBehaviour
     private Enemy ene;              //厨子的enemy脚本
 
     private bool once = false;      //死一次
-    private bool goAway = false;    //厨子命尽
+    private bool die = false;       //厨子命尽
     private bool toCatch = false;   //没串了去抓人
     private bool isRunning = false; //开跑
 
@@ -49,11 +51,15 @@ public class Spirits_Cook : MonoBehaviour
     public enum cookState
     {
         sell = 0,
-        run = 1,
-        cook = 2,
+        walk = 1,
+        find = 2,
+        run = 3,
+        cook = 4,
+        back = 5,
     }
 
     private cookState state;
+    private GameObject food;    //被抓的食材
 
     private void Start()
     {
@@ -78,7 +84,8 @@ public class Spirits_Cook : MonoBehaviour
 
     private void OnTriggerEnter(Collider other)
     {
-        if (!once && other.gameObject.layer == 7 || other.gameObject.layer == 8 || other.gameObject.layer == 6)
+        //路过发串
+        if (state == cookState.sell && !die && other.gameObject.layer == 7 || other.gameObject.layer == 8 || other.gameObject.layer == 6)
         {
             if (chuan > 0)
             {
@@ -100,21 +107,15 @@ public class Spirits_Cook : MonoBehaviour
                     }
                 }
             }
-            /*总共拿一串
-            if (!ca.hasHpUp)
+        }
+        //抓人
+        else if (state == cookState.run || state == cookState.find || state == cookState.walk && !once)
+        {
+            if (!isEnemy && other.gameObject.layer == 8 || isEnemy && (other.gameObject.layer == 7 || other.gameObject.layer == 6))
             {
-                chuan -= 1;
-                text.text = chuan.ToString();
-                ani.Play("attack_march", 0, 0);
-                ca.HpUp(value);
-                ca.hasHpUp = true;
-                Instantiate(effect, ga.transform.position, new Quaternion(0, 0, 0, 0), ga.transform);
-                if (chuan == 0)
-                {
-                    goAway = true;
-                }
+                food = other.gameObject;
+                ChangeState(cookState.cook);
             }
-            */
         }
     }
 
@@ -122,44 +123,46 @@ public class Spirits_Cook : MonoBehaviour
     {
         switch (cs)
         {
-            case cookState.cook:
-                break;
-            case cookState.run:
-                canMove = true;
-                col.enabled = false;
-                dia.SetActive(false);
-                foreach(GameObject g in colliders)
-                {
-                    g.SetActive(true);
-                }
-                if (isEnemy)
-                {
-                    ene.canMove = true;
-                }
-                else
-                {
-                    dem.canMove = true;
-                    dem.isNonAttack = false;
-                }
-                break;
+            //卖串中
             case cookState.sell:
                 canMove = false;
+                //不能被攻击
                 foreach (GameObject g in colliders)
                 {
                     g.SetActive(false);
                 }
-                if (isEnemy)
+                break;
+            //走路中
+            case cookState.walk:
+                canMove = true;
+                dia.SetActive(false);
+                //能被攻击
+                foreach (GameObject g in colliders)
                 {
-                    ene.canMove = false;
+                    g.SetActive(true);
                 }
-                else
+                break;
+            //发现目标
+            case cookState.find:
+                break;
+            //冲刺中
+            case cookState.run:
+                canMove = true;
+                foreach (GameObject g in colliders)
                 {
-                    dem.canMove = false;
+                    g.SetActive(true);
                 }
                 break;
+            //鲨人中
+            case cookState.cook:
+                break;
+            //返回中
+            case cookState.back:
+                break;
             default:
                 break;
         }
+        state = cs;
     }
 
     private void ChoosePlayer()
@@ -191,6 +194,10 @@ public class Spirits_Cook : MonoBehaviour
 
                 break;
             case cookState.run:
+                if (isEnemy)
+                {
+                    ene.targetCharacter = target.GetComponent<Character>();
+                }
                 break;
             case cookState.sell:
                 break;
@@ -211,7 +218,7 @@ public class Spirits_Cook : MonoBehaviour
                 col.enabled = true;
             }
         }
-        if (goAway && !once)
+        if (die && !once)
         {
             once = true;
             col.enabled = false;