Explorar el Código

怪物表新增敌方厨师

SZAND\msx_2 hace 1 año
padre
commit
560d0a4aa0

+ 18 - 7
ActionTowerDefense/Assets/Resources/Prefab/ESpirits_Cook.prefab

@@ -218,10 +218,16 @@ MonoBehaviour:
   m_EditorClassIdentifier: 
   text: {fileID: 979388067414062712}
   chuan: 10
+  isGood: 0
+  colliders: []
+  walkSpeed: 0
+  runSpeed: 0
   value: 50
   effect: {fileID: 417478504669294145, guid: 07c7a53ff610e0b45898f0f09276d995, type: 3}
   activeAniTime: 3.3
   larger: 1.2
+  canMove: 0
+  lockEffect: {fileID: 0}
 --- !u!1 &3483054690158852324
 GameObject:
   m_ObjectHideFlags: 0
@@ -711,6 +717,7 @@ MonoBehaviour:
   rope: {fileID: 0}
   hasHpUp: 0
   beLarger: 0
+  canMove: 1
   foot: {fileID: 5440846222604650418}
   extraRiseGravity: 0
   extraFallGravity: 0
@@ -724,22 +731,26 @@ MonoBehaviour:
   minHurtKeepTime: 0
   hurtKeepTime: 0
   hurtChangeVelocity: 0
-  maxTime: 0
-  minTime: 0
-  maxHeight: 0
-  minHeight: 0
-  maxRotateSpeed: 0
-  minRotateSpeed: 0
-  floatTime: 0
+  maxTime: 1.5
+  minTime: 0.1
+  maxHeight: 9
+  minHeight: 4
+  maxRotateSpeed: 20
+  minRotateSpeed: 5
+  floatTime: 20
+  floatState: 0
   outlineMats:
   - {fileID: 2100000, guid: 30969c92738eb7d4da3885e08f1ec2f0, type: 2}
   - {fileID: 2100000, guid: 98fc94309ab120b4c83b2cebb9226222, type: 2}
   - {fileID: 2100000, guid: 30969c92738eb7d4da3885e08f1ec2f0, type: 2}
   id: 0
   costMp: 1
+  totalSummonTime: 0.5
   searchState: 0
   attackDistance: 0
   canFly: 0
+  flyHeight: 0
+  flyUpSpeed: 10
   sortingOrder: 10000
   playerID: 0
   hasEffect: 0

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

@@ -0,0 +1,216 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+using TMPro;
+using System;
+
+public class ESpirits_Cook : MonoBehaviour
+{
+    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;          //冲刺速度
+
+    public float value;             //加血程度百分比
+    public GameObject effect;       //加血效果
+
+    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 GameObject[] customers; //厨子的所有顾客
+    private int count;              //顾客数量
+
+    public float larger;            //顾客变大的程度
+
+    public bool canMove = false;    //厨师可移动
+
+    private GameObject player1;
+    private GameObject player2;
+    private GameObject target;
+
+    public GameObject lockEffect;
+    private GameObject curLock;
+
+    public enum cookState
+    {
+        sell = 0,
+        walk = 1,
+        find = 2,
+        run = 3,
+        cook = 4,
+        back = 5,
+    }
+
+    private cookState state;
+    private GameObject food;    //被抓的食材
+
+    private void Start()
+    {
+        cook = transform.parent;
+        ene = cook.GetComponent<Enemy>();
+        ani = ene.ani;
+        col = GetComponent<Collider>();
+        col.enabled = false;
+        dia = text.transform.parent.gameObject;
+        dia.SetActive(false);
+        customers = new GameObject[chuan];
+        state = 0;
+        curLock = Instantiate(lockEffect, cook.transform.position, new Quaternion(0, 0, 0, 0), cook.transform);
+    }
+
+    private void OnTriggerEnter(Collider other)
+    {
+        //路过发串
+        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)
+                {
+                    chuan -= 1;
+                    text.text = chuan.ToString();
+                    ani.Play("attack_march", 0, 0);
+                    ca.HpUp(value, larger);
+                    customers[count] = ga;
+                    count += 1;
+                    Instantiate(effect, ga.transform.position, new Quaternion(0, 0, 0, 0), ga.transform);
+                    if (chuan == 0)
+                    {
+                        toCatch = true;
+                        ChangeState(cookState.run);
+                    }
+                }
+            }
+        }
+        //抓人
+        else if (state == cookState.run || state == cookState.find || state == cookState.walk && !once)
+        {
+            if (other.gameObject.layer == 7 || other.gameObject.layer == 6)
+            {
+                food = other.gameObject;
+                ChangeState(cookState.cook);
+            }
+        }
+    }
+
+    private void ChangeState(cookState cs)
+    {
+        switch (cs)
+        {
+            //卖串中
+            case cookState.sell:
+                canMove = false;
+                //不能被攻击
+                foreach (GameObject g in colliders)
+                {
+                    g.SetActive(false);
+                }
+                break;
+            //走路中
+            case cookState.walk:
+                canMove = true;
+                dia.SetActive(false);
+                //能被攻击
+                foreach (GameObject g in colliders)
+                {
+                    g.SetActive(true);
+                }
+                break;
+            //发现目标
+            case cookState.find:
+                break;
+            //冲刺中
+            case cookState.run:
+                canMove = true;
+                foreach (GameObject g in colliders)
+                {
+                    g.SetActive(true);
+                }
+                break;
+            //鲨人中
+            case cookState.cook:
+                break;
+            //返回中
+            case cookState.back:
+                break;
+            default:
+                break;
+        }
+        state = cs;
+    }
+
+    private void ChoosePlayer()
+    {
+        player1 = PlayersInput.instance[0].gameObject;
+        player2 = PlayersInput.instance[1].gameObject;
+        float dis1 = Vector2.Distance(player1.transform.position, transform.position);
+        float dis2 = Vector2.Distance(player2.transform.position, transform.position);
+        if (dis1 < dis2)
+        {
+            target = player1;
+        }
+        else
+        {
+            target = player2;
+        }
+    }
+
+    private void AimAtPlayer()
+    {
+        lockEffect.transform.position = transform.position;
+    }
+
+    private void StateAct(cookState cs)
+    {
+        switch (cs)
+        {
+            case cookState.cook:
+
+                break;
+            case cookState.run:
+                ene.targetCharacter = target.GetComponent<Character>();
+                break;
+            case cookState.sell:
+                break;
+            default:
+                break;
+        }
+    }
+
+    private void Update()
+    {
+        if (!isAct)
+        {
+            activeTime += Time.deltaTime;
+            if (activeTime >= activeAniTime)
+            {
+                dia.SetActive(true);
+                isAct = true;
+                col.enabled = true;
+            }
+        }
+        if (die && !once)
+        {
+            once = true;
+            col.enabled = false;
+            ene.ChangeState(CharacterState.Die);
+        }
+    }
+}

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

@@ -13,7 +13,6 @@ public class Spirits_Cook : MonoBehaviour
     private Animator ani;           //厨子动画
     private Collider col;           //厨子的碰撞体
     public int chuan;               //厨子拥有多少串
-    public bool isEnemy;            //厨子是否是敌方
     public bool isGood;             //厨子是否是好厨子
     public GameObject[] colliders;  //一些要开要关的collider
     public float walkSpeed;         //走路速度
@@ -23,7 +22,6 @@ public class Spirits_Cook : MonoBehaviour
     public GameObject effect;       //加血效果
 
     private Demonic dem;            //厨子的demonic脚本
-    private Enemy ene;              //厨子的enemy脚本
 
     private bool once = false;      //死一次
     private bool die = false;       //厨子命尽
@@ -64,14 +62,7 @@ public class Spirits_Cook : MonoBehaviour
     private void Start()
     {
         cook = transform.parent;
-        if (isEnemy)
-        {
-            ene = cook.GetComponent<Enemy>();
-        }
-        else
-        {
-            dem = cook.GetComponent<Demonic>();
-        }
+        dem = cook.GetComponent<Demonic>();
         ani = dem.ani;
         col = GetComponent<Collider>();
         col.enabled = false;
@@ -111,7 +102,7 @@ public class Spirits_Cook : MonoBehaviour
         //抓人
         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))
+            if (other.gameObject.layer == 8)
             {
                 food = other.gameObject;
                 ChangeState(cookState.cook);
@@ -165,23 +156,7 @@ public class Spirits_Cook : MonoBehaviour
         state = cs;
     }
 
-    private void ChoosePlayer()
-    {
-        player1 = PlayersInput.instance[0].gameObject;
-        player2 = PlayersInput.instance[1].gameObject;
-        float dis1 = Vector2.Distance(player1.transform.position, transform.position);
-        float dis2 = Vector2.Distance(player2.transform.position, transform.position);
-        if (dis1 < dis2)
-        {
-            target = player1;
-        }
-        else
-        {
-            target = player2;
-        }
-    }
-
-    private void AimAtPlayer()
+    private void AimAt()
     {
         lockEffect.transform.position = transform.position;
     }
@@ -194,10 +169,6 @@ public class Spirits_Cook : MonoBehaviour
 
                 break;
             case cookState.run:
-                if (isEnemy)
-                {
-                    ene.targetCharacter = target.GetComponent<Character>();
-                }
                 break;
             case cookState.sell:
                 break;

BIN
ActionTowerDefense/Luban/Config/Datas/怪物表.xlsx