Jelajahi Sumber

厨师基本功能

SZAND\msx_2 1 tahun lalu
induk
melakukan
64bb6009c0

+ 6 - 0
ActionTowerDefense/Assets/Resources/Prefab/Demonic_Giant.prefab

@@ -426,6 +426,7 @@ MonoBehaviour:
   m_Script: {fileID: 11500000, guid: c1bedfb340186164dbac1499b49b879e, type: 3}
   m_Name: 
   m_EditorClassIdentifier: 
+  cookNum: 10
   mecanim: {fileID: 7573527827155227431}
   meshRenderer: {fileID: 0}
   ani: {fileID: 3333436509305836838}
@@ -475,6 +476,7 @@ MonoBehaviour:
   rope: {fileID: 0}
   hasHpUp: 0
   beLarger: 0
+  canMove: 1
   foot: {fileID: 5440846222604650418}
   extraRiseGravity: -28.8
   extraFallGravity: -14.4
@@ -495,13 +497,17 @@ MonoBehaviour:
   maxRotateSpeed: 20
   minRotateSpeed: 5
   floatTime: 20
+  floatState: 0
   outlineMats:
   - {fileID: 2100000, guid: a30e0c3d2b8bf4e43a76fc2d5b3884cd, type: 2}
   id: 0
   costMp: 150
+  totalSummonTime: 0.5
   searchState: 0
   attackDistance: 3
   canFly: 0
+  flyHeight: 0
+  flyUpSpeed: 10
   sortingOrder: 0
   playerID: 0
   hasEffect: 0

+ 6 - 0
ActionTowerDefense/Assets/Resources/Prefab/Demonic_Sword.prefab

@@ -165,6 +165,7 @@ MonoBehaviour:
   m_Script: {fileID: 11500000, guid: c1bedfb340186164dbac1499b49b879e, type: 3}
   m_Name: 
   m_EditorClassIdentifier: 
+  cookNum: 6
   mecanim: {fileID: 5617185463097218335}
   meshRenderer: {fileID: 0}
   ani: {fileID: 6496896669866891404}
@@ -214,6 +215,7 @@ MonoBehaviour:
   rope: {fileID: 0}
   hasHpUp: 0
   beLarger: 0
+  canMove: 1
   foot: {fileID: 2437299196663985756}
   extraRiseGravity: -28.8
   extraFallGravity: -14.4
@@ -234,13 +236,17 @@ MonoBehaviour:
   maxRotateSpeed: 20
   minRotateSpeed: 5
   floatTime: 20
+  floatState: 0
   outlineMats:
   - {fileID: 2100000, guid: 7d50f910288e95b4285a5fb549c94fe6, type: 2}
   id: 0
   costMp: 100
+  totalSummonTime: 0.5
   searchState: 0
   attackDistance: 1.5
   canFly: 0
+  flyHeight: 0
+  flyUpSpeed: 10
   sortingOrder: 1000
   playerID: 0
   hasEffect: 0

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

@@ -325,21 +325,19 @@ MonoBehaviour:
   m_EditorClassIdentifier: 
   text: {fileID: 979388067414062712}
   chuan: 5
-  isGood: 0
+  isGood: 1
   colliders:
   - {fileID: 4480734502875862885}
   - {fileID: 2460330936527559963}
   walkSpeed: 3
   runSpeed: 5
-  minX: 0
-  maxX: 0
+  minX: 8.5
+  maxX: 20
   value: 20
   effect: {fileID: 2123904437201259524, guid: 24cf2b33715a9e04b9aabcb789c31067, type: 3}
   activeAniTime: 1.3
   larger: 1.2
-  canMove: 0
   lockEffect: {fileID: 2123904437201259524, guid: 24cf2b33715a9e04b9aabcb789c31067, type: 3}
-  cookKillEffect: {fileID: 0}
   cookTime: 0.967
 --- !u!1 &3483054690158852324
 GameObject:
@@ -808,6 +806,7 @@ MonoBehaviour:
   m_Script: {fileID: 11500000, guid: 7475a7d33f657b146a4994b1e02710ad, type: 3}
   m_Name: 
   m_EditorClassIdentifier: 
+  cookNum: 0
   mecanim: {fileID: 7573527827155227431}
   meshRenderer: {fileID: 0}
   ani: {fileID: 3333436509305836838}

+ 2 - 0
ActionTowerDefense/Assets/Resources/Prefab/Enemy_Arrow.prefab

@@ -959,6 +959,7 @@ MonoBehaviour:
   m_Script: {fileID: 11500000, guid: 7475a7d33f657b146a4994b1e02710ad, type: 3}
   m_Name: 
   m_EditorClassIdentifier: 
+  cookNum: 3
   mecanim: {fileID: 3354085511906294621}
   meshRenderer: {fileID: 0}
   ani: {fileID: 5978259926173120695}
@@ -1075,6 +1076,7 @@ MonoBehaviour:
   haveDownRush: 0
   downRushTime: 0
   finishRushTime: 0
+  isBack: 0
 --- !u!54 &8639832132491289349
 Rigidbody:
   m_ObjectHideFlags: 0

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

@@ -759,6 +759,7 @@ MonoBehaviour:
   m_Script: {fileID: 11500000, guid: 0b46e3a90d8fc304caef18f1c373478c, type: 3}
   m_Name: 
   m_EditorClassIdentifier: 
+  cookNum: 10
   mecanim: {fileID: 6843453365888964567}
   meshRenderer: {fileID: 0}
   ani: {fileID: 6197716555580445942}
@@ -882,7 +883,6 @@ MonoBehaviour:
   cacheJumpTime: 0
   totalCacheJumpTime: 0.1
   summonTime: 0
-  totalSummonTime: 0.2
   cacheAttackTime: 0
   totalCacheAttackTime: 0.1
   cachePullRopeTime: 0

+ 2 - 0
ActionTowerDefense/Assets/Scripts/Character.cs

@@ -45,6 +45,8 @@ public enum HpUpType
 
 public class Character : MonoBehaviour
 {
+    public int cookNum;   //ÄÜ×ö¶àÉÙ´®
+
     public SkeletonMecanim mecanim;
     public Skeleton skeleton;
     public MeshRenderer meshRenderer;

+ 50 - 15
ActionTowerDefense/Assets/Scripts/Spirits/ESpirits_Cook.cs

@@ -3,6 +3,7 @@ using System.Collections.Generic;
 using UnityEngine;
 using TMPro;
 using System;
+using Random = UnityEngine.Random;
 
 public class ESpirits_Cook : MonoBehaviour
 {
@@ -28,14 +29,14 @@ public class ESpirits_Cook : MonoBehaviour
 
     private bool once = false;      //死一次
     private bool die = false;       //厨子命尽
-    private bool toCatch = false;   //没串了去抓人
+    //private bool toCatch = false;   //没串了去抓人
     private bool isRunning = false; //开跑
 
     private float activeTime;       //厨子已出现的时长
     public float activeAniTime;     //厨子出现动画的时长
     private bool isAct = false;     //厨子已经完整出现
 
-    private GameObject[] customers; //厨子的所有顾客
+    private List<GameObject> customers; //厨子的所有顾客
     private int count;              //顾客数量
 
     public float larger;            //顾客变大的程度
@@ -51,6 +52,8 @@ public class ESpirits_Cook : MonoBehaviour
     private float pastTime;
     public float cookTime;
 
+    private float destX;
+
     public enum cookState
     {
         sell = 0,
@@ -59,6 +62,7 @@ public class ESpirits_Cook : MonoBehaviour
         run = 3,
         cook = 4,
         back = 5,
+        first = 6,  //刚出生
     }
 
     private cookState state;
@@ -73,32 +77,39 @@ public class ESpirits_Cook : MonoBehaviour
         col.enabled = false;
         dia = text.transform.parent.gameObject;
         dia.SetActive(false);
-        customers = new GameObject[chuan];
-        state = 0;
+        customers = new List<GameObject>();
+        destX = DestinationX();
+        text.text = chuan.ToString();
         //curLock = Instantiate(lockEffect, cook.transform.position, new Quaternion(0, 0, 0, 0), cook.transform);
     }
 
+    private float DestinationX()
+    {
+        float x = Random.Range(minX, maxX);
+        return x;
+    }
+
     private void OnTriggerEnter(Collider other)
     {
         //路过发串
-        if (state == cookState.sell && !die && 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)
             {
                 GameObject ga = other.transform.parent.parent.parent.gameObject;
                 Character ca = ga.GetComponent<Character>();
-                if (Array.IndexOf(customers, ga) == -1)
+                if (!customers.Exists(T => T == ga))
                 {
                     chuan -= 1;
                     text.text = chuan.ToString();
                     ani.Play("attack_march", 0, 0);
                     ca.HpUp(value, larger);
-                    customers[count] = ga;
+                    customers.Add(ga);
                     count += 1;
                     //Instantiate(effect, ga.transform.position, new Quaternion(0, 0, 0, 0), ga.transform);
                     if (chuan == 0)
                     {
-                        toCatch = true;
+                        //toCatch = true;
                         ChangeState(cookState.walk);
                     }
                 }
@@ -107,26 +118,30 @@ public class ESpirits_Cook : MonoBehaviour
         //抓人
         else if (state == cookState.run || state == cookState.find || state == cookState.walk && !once)
         {
-            if (other.gameObject.layer == 7 || other.gameObject.layer == 6)
+            if (other.gameObject.layer == 6 || other.gameObject.layer == 7)
             {
                 food = other.transform.parent.parent.parent.gameObject;
                 if (food.layer == 7 && !food.GetComponent<Demonic>().isDie)
                 {
-                    print(11111111);
                     food.GetComponent<Demonic>().ChangeState(CharacterState.Die);
                     //cookKillEffect.SetActive(true);
                     ChangeState(cookState.cook);
-                    print(22222222);
                 }
-                else if (food.layer == 6 && !food.GetComponent<Demonic>().isDie)
+                else if (food.layer == 6 && !food.GetComponent<PlayerController>().isDie)
                 {
                     food.GetComponent<PlayerController>().ChangeState(CharacterState.Die);
                     //cookKillEffect.SetActive(true);
                     ChangeState(cookState.cook);
-                    print(state);
                 }
+                chuan = food.GetComponent<Character>().cookNum;
+                text.text = chuan.ToString();
             }
         }
+        //回家卖串
+        else if (state == cookState.back && !die && other.gameObject.layer == 8)
+        {
+            ChangeState(cookState.sell);
+        }
     }
 
     private void ChangeState(cookState cs)
@@ -135,7 +150,9 @@ public class ESpirits_Cook : MonoBehaviour
         {
             //卖串中
             case cookState.sell:
+                dia.SetActive(true);
                 ene.isBack = false;
+                ene.canMove = false;
                 //不能被攻击
                 foreach (GameObject g in colliders)
                 {
@@ -157,7 +174,6 @@ public class ESpirits_Cook : MonoBehaviour
             case cookState.find:
                 ene.ChangeState(CharacterState.FindPlayer);
                 break;
-
             //冲刺中
             case cookState.run:
                 foreach (GameObject g in colliders)
@@ -167,14 +183,22 @@ public class ESpirits_Cook : MonoBehaviour
                 break;
             //鲨人中
             case cookState.cook:
-                ani.Play("attack_march", 0, 0);
                 ene.canMove = false;
+                ani.Play("attack_march", 0, 0);
                 break;
             //返回中
             case cookState.back:
                 ene.canMove = true;
                 ene.isBack = true;
                 break;
+            case cookState.first:
+                dia.SetActive(false);
+                ene.canMove = true;
+                foreach (GameObject g in colliders)
+                {
+                    g.SetActive(true);
+                }
+                break;
             default:
                 break;
         }
@@ -215,6 +239,10 @@ public class ESpirits_Cook : MonoBehaviour
                 }
                 break;
             case cookState.back:
+                if (cook.transform.position.x <= destX)
+                {
+                    ChangeState(cookState.sell);
+                }
                 break;
             case cookState.cook:
                 pastTime += Time.deltaTime;
@@ -229,6 +257,12 @@ public class ESpirits_Cook : MonoBehaviour
                 break;
             case cookState.sell:
                 break;
+            case cookState.first:
+                if (cook.transform.position.x >= destX)
+                {
+                    ChangeState(cookState.sell);
+                }
+                break;
             default:
                 break;
         }
@@ -244,6 +278,7 @@ public class ESpirits_Cook : MonoBehaviour
                 dia.SetActive(true);
                 isAct = true;
                 col.enabled = true;
+                ChangeState(cookState.first);
             }
         }
         else