| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251 | 
							- using System.Collections;
 
- using System.Collections.Generic;
 
- using UnityEngine;
 
- namespace WildAttack
 
- {
 
-     /// <summary>
 
-     /// 关卡管理类
 
-     /// </summary>
 
-     public class ProcessManager : Singleton<ProcessManager>
 
-     {
 
-         #region Members
 
-         // 当前关卡
 
-         private int currLevel;
 
-         public int CurrLevel { get { return currLevel; } }
 
-         // 关卡开始后时间
 
-         private float currLevelTime;
 
-         //private int nextMonsterId;
 
-         private ProcessData configData;
 
-         // 怪物索引
 
-         private int currMonsterIndex;
 
-         // 当前关卡死亡数量
 
-         private int enemyDeadNum = 0;
 
-         public int EnemyDeadNum { get { return enemyDeadNum; } }
 
-         // 管理道具
 
-         private List<StageProperty> stagePropList;
 
-         private AudioSource audioSource;
 
-         // 气球生成时间
 
-         private float balloonTime;
 
-         // 遗留箭矢list
 
-         private List<GameObject> stayArrowList;
 
-         #endregion
 
-         #region Functions
 
-         public void Init()
 
-         {
 
-             stayArrowList = new List<GameObject>();
 
-             //RestartLevel();
 
-             audioSource = GameObject.Find("ProcessAudioSource").GetComponent<AudioSource>();
 
-             InitStageProp();
 
-             RestartLevel();
 
-             // init 存所有pos 所有obj restart destroyAll create addComponent
 
-         }
 
-         public void AddStayArrow(GameObject arrowObj)
 
-         {
 
-             stayArrowList.Add(arrowObj);
 
-         }
 
-         private void ResetStayArrows()
 
-         {
 
-             if (stayArrowList != null && stayArrowList.Count > 0)
 
-             {
 
-                 for (int i = stayArrowList.Count - 1; i >= 0; i--)
 
-                 {
 
-                     GameObject.Destroy(stayArrowList[i]);
 
-                     stayArrowList.RemoveAt(i);
 
-                 }
 
-             }
 
-             stayArrowList = new List<GameObject>();
 
-         }
 
-         /// <summary>
 
-         /// 初始化list 存放所有道具
 
-         /// </summary>
 
-         private void InitStageProp()
 
-         {
 
-             stagePropList = new List<StageProperty>();
 
-             Transform trans = GameObject.Find("BarrelTrans").transform;
 
-             for (int i = 0; i < trans.childCount; i++)
 
-             {
 
-                 stagePropList.Add(trans.GetChild(i).GetComponent<StageProperty>());
 
-             }
 
-         }
 
-         /// <summary>
 
-         /// 重置所有道具
 
-         /// </summary>
 
-         private void ResetStagePorperty()
 
-         {
 
-             foreach (var item in stagePropList)
 
-             {
 
-                 if (item != null)
 
-                 {
 
-                     item.ResetProp();
 
-                 }
 
-             }
 
-         }
 
-         /// <summary>
 
-         /// 关卡重开
 
-         /// </summary>
 
-         public void RestartLevel()
 
-         {
 
-             isOver = false;
 
-             Vector2 ballSpawn = GameModule.GetInstance().GetDoubleParams("balloonSpawnTime");
 
-             balloonTime = Random.Range(ballSpawn.x, ballSpawn.y);
 
-             ChangeLevel(0);
 
-             EnemyManager.GetInstance().CreateEnemy(1, -1);
 
-         }
 
-         private bool isOver = false;
 
-         private bool ableChanged = false;
 
-         /// <summary>
 
-         /// 切换新关卡
 
-         /// </summary>
 
-         /// <param name="curr"></param>
 
-         public void ChangeLevel(int curr)
 
-         {
 
-             currLevel = curr;
 
-             // 重开或开始游戏
 
-             if (curr == 0 || curr == 1)
 
-             {
 
-                 // 重置道具
 
-                 ResetStagePorperty();
 
-                 ResetStayArrows();
 
-                 GameMananger.GetInstance().barrelTriggerCount = 0;
 
-             }
 
-             // 判断是否为初始关卡
 
-             if (curr <= 0)
 
-             {
 
-                 enemyDeadNum = 0;
 
-                 UIManager.GetInstance().SetDefaultProcess(false);
 
-             }
 
-             else
 
-             {
 
-                 ResetStayArrows();
 
-                 // 关卡开启时播放
 
-                 audioSource.clip = Resources.Load<AudioClip>("Voice/Process/Change");
 
-                 if (UserSettings.ins.openEffect) audioSource.Play();
 
-                 // ui change
 
-                 UIManager.GetInstance().SetDefaultProcess(true);
 
-                 // 通关判断
 
-                 if (currLevel > ProcessModule.GetInstance().processDataDic.Count)
 
-                 {
 
-                     // 通关
 
-                     GameMananger.GetInstance().GameOver(true);
 
-                 }
 
-                 // 新关卡属性初始化
 
-                 currMonsterIndex = 0;
 
-                 configData = ProcessModule.GetInstance().GetData(currLevel);
 
-                 currLevelTime = 0;
 
-                 enemyDeadNum = 0;
 
-             }
 
-         }
 
-         private float processInterval = 0;
 
-         public void Update()
 
-         {
 
-             if (currLevel <= 0)
 
-             {
 
-                 // 初始关卡在随机时间生成气球
 
-                 if (balloonTime <= 0)
 
-                 {
 
-                     GameObject balloon = BalloonPool.GetInstance().GetGameObject();
 
-                     // 生成位置随机道具后
 
-                     Transform target = stagePropList[Random.Range(0, stagePropList.Count - 1)].transform;
 
-                     // 气球初始化
 
-                     balloon.transform.position = new Vector3(target.position.x, target.position.y, target.position.z) + Vector3.forward * 5;
 
-                     balloon.SetActive(true);
 
-                     Vector2 ballSpawn = GameModule.GetInstance().GetDoubleParams("balloonSpawnTime");
 
-                     balloonTime = Random.Range(ballSpawn.x, ballSpawn.y);
 
-                 }
 
-                 else
 
-                 {
 
-                     balloonTime -= Time.deltaTime;
 
-                 }
 
-                 // 初始关小怪死亡
 
-                 if (enemyDeadNum == 1)
 
-                 {
 
-                     ChangeLevel(++currLevel);
 
-                 }
 
-             }
 
-             else
 
-             {
 
-                 // 关卡间隔
 
-                 if (processInterval > 0)
 
-                 {
 
-                     processInterval -= Time.deltaTime;
 
-                     return;
 
-                 }
 
-                 else
 
-                 {
 
-                     if (ableChanged)
 
-                     {
 
-                         ChangeLevel(++currLevel);
 
-                         ableChanged = false;
 
-                         return;
 
-                     }
 
-                 }
 
-                 if (currLevel > ProcessModule.GetInstance().processDataDic.Count) return;
 
-                 currLevelTime += Time.deltaTime;
 
-                 if (currMonsterIndex + 1 <= configData.monsterId.Count && currLevelTime >= configData.refreshTime[currMonsterIndex])
 
-                 {
 
-                     // 生成怪物 随机路径组 Enemy中组内随机路线
 
-                     int weight = WeightRandomUtils.GetInstance().GetRandomId(configData.weight[currMonsterIndex]);
 
-                     EnemyManager.GetInstance().CreateEnemy(configData.monsterId[currMonsterIndex], weight);
 
-                     currMonsterIndex++;
 
-                 }
 
-                 // 当前关卡怪物死光
 
-                 if (enemyDeadNum == configData.monsterId.Count)
 
-                 {
 
-                     processInterval = GameModule.GetInstance().GetData("processInterval");
 
-                     ableChanged = true;
 
-                     //ChangeLevel(++currLevel);
 
-                 }
 
-             }
 
-         }
 
-         /// <summary>
 
-         /// 怪物死亡通知关卡类
 
-         /// </summary>
 
-         public void EnemyDead()
 
-         {
 
-             enemyDeadNum++;
 
-             if (currLevel <= 0) return;
 
-             if (enemyDeadNum >= configData.monsterId.Count) return;
 
-             if (EnemyManager.GetInstance().enemyList.Count <= 0 && currLevelTime <= configData.refreshTime[enemyDeadNum])
 
-             {
 
-                 currLevelTime = configData.refreshTime[enemyDeadNum];
 
-                 //currMonsterIndex++;
 
-             }
 
-         }
 
-         /// <summary>
 
-         /// 游戏结束
 
-         /// </summary>
 
-         /// <param name="isWin"></param>
 
-         public void GameOver(bool isWin)
 
-         {
 
-             if (isOver) return;
 
-             audioSource.clip = Resources.Load<AudioClip>($"Voice/Process/" + (isWin ? "Success" : "Defeat"));
 
-             if (UserSettings.ins.openEffect) audioSource.Play();
 
-             isOver = true;
 
-         }
 
-         #endregion
 
-     }
 
- }
 
 
  |