From 10b5f44b36f3dd0d3bdc2fcc06aa13caaa611760 Mon Sep 17 00:00:00 2001
From: liuzhiwei <liuzhiwei@qq.com>
Date: Wed, 11 Nov 2020 16:56:04 +0800
Subject: [PATCH] Merge branch 'master' of http://172.16.1.52:8090/r/GemBattle into master

---
 Assets/Scripts/TowerDefense/Level/EndlessWave.cs |   86 +++++++++++++++++++++++++++++++++++++-----
 1 files changed, 75 insertions(+), 11 deletions(-)

diff --git a/Assets/Scripts/TowerDefense/Level/EndlessWave.cs b/Assets/Scripts/TowerDefense/Level/EndlessWave.cs
index 23f760b..294f232 100644
--- a/Assets/Scripts/TowerDefense/Level/EndlessWave.cs
+++ b/Assets/Scripts/TowerDefense/Level/EndlessWave.cs
@@ -1,4 +1,5 @@
-using System;
+using UnityEngine;
+using System;
 using System.Collections.Generic;
 using Core.Utilities;
 using KTGMGemClient;
@@ -46,9 +47,9 @@
         public event Action WaveCompleted;
 
         /// <summary>
-        /// 波次发生改变
+        /// 有新的敌人生成
         /// </summary>
-        public event Action WaveChanged;
+        public event Action SpawnNewAgent;
 
         /// <summary>
         /// 怪出生开始节点
@@ -99,10 +100,18 @@
             isWaveStoped = true;
         }
 
-        /// <summary>
-        /// Handles spawning the current agent and sets up the next agent for spawning
-        /// 在场景内孵化出来一个Boss,这个核心函数最后被规则性的数据接管
-        /// </summary>
+        public void PauseWave()
+        {
+            PauseTimer(spawnTimer);
+            isWaveStoped = true;
+        }
+
+        public void RestartWave()
+        {
+            StartTimer(spawnTimer);
+            isWaveStoped = false;
+        }
+
         protected virtual void SpawnCurrent()
         {
             if (isWaveStoped) return;
@@ -114,21 +123,41 @@
                 SafelyBroadcastWaveCompletedEvent();
             }
             else
+            {
                 ++spawnedEnemies;
+
+                if (SpawnNewAgent != null)
+                    SpawnNewAgent();
+
+                if (spawnedEnemies >= waveData.Config.amount)
+                {
+                    StopWave();
+                    SafelyBroadcastWaveCompletedEvent();
+                }
+            }
         }
 
         /// <summary>
         /// 生成agent
         /// </summary>
         /// <returns>Agent</returns>
-        protected virtual Agent SpawnAgent()
+        protected virtual void SpawnAgent()
         {
             int index = GetIndexByResId(waveData.EnemyData.resource);
+            // 木属性小怪需要同时生成两个,先这么写吧(WTF)
+            bool isDouble = waveData.EnemyData.resource == 103;
 
             Poolable agentPoolable = Poolable.TryGetPoolable<Poolable>(AgentConfigurationList[index].agentPrefab.gameObject);
             Agent newAgent = agentPoolable.GetComponent<Agent>();
-
             newAgent.transform.position = StartingNode.transform.position;
+
+            if (isDouble)
+            {
+                Vector3 pos = newAgent.transform.position;
+                pos.x -= 2f;
+                newAgent.transform.position = pos;
+            }
+
             newAgent.transform.rotation = StartingNode.transform.rotation;
             newAgent.SetNode(StartingNode, WaveLineId - 1);
             newAgent.opponentAgent = false;
@@ -145,7 +174,42 @@
             // 加入Manager统一管理.
             AgentInsManager.instance.addAgent(newAgent);
 
-            return newAgent;
+            if (isDouble)
+            {
+                Poolable agentPoolable2 = Poolable.TryGetPoolable<Poolable>(AgentConfigurationList[index].agentPrefab.gameObject);
+                Agent doubleAgent = agentPoolable2.GetComponent<Agent>();
+                doubleAgent.transform.position = StartingNode.transform.position;
+
+                Vector3 pos = doubleAgent.transform.position;
+                pos.x += 2f;
+                doubleAgent.transform.position = pos;
+
+                doubleAgent.transform.rotation = StartingNode.transform.rotation;
+                doubleAgent.SetNode(StartingNode, WaveLineId - 1);
+                doubleAgent.opponentAgent = false;
+                doubleAgent.Initialize();
+
+                doubleAgent.SetAgentData(hp, speed, gold);
+                doubleAgent.healthBar.SetHealthLevel(1);
+                AgentInsManager.instance.addAgent(doubleAgent);
+            }
+        }
+
+        /// <summary>
+		/// 从Tower的AttributeId获取到怪物的数据
+		/// </summary>
+		/// <param name="id"></param>
+		/// <returns></returns>
+		protected List<int> GetMonsterDataFromAttributeId(int id)
+        {
+            geminfo tgem = new geminfo();
+            if (JsonDataCenter.gemInfoDic.TryGetValue(id, out tgem))
+                return tgem.summon;
+            else
+            {
+                Debug.Log("找不到对应ID的Gem:" + id);
+                return null;
+            }
         }
 
         /// <summary>
@@ -162,7 +226,7 @@
         }
 
         /// <summary>
-        /// 暂时先这么处理
+        /// 暂时先这么处理 cx test
         /// </summary>
         /// <param name="resId">endless_enemy表的资源id</param>
         /// <returns>所有可选的agent列表的索引</returns>

--
Gitblit v1.9.1