711 lines
21 KiB
C#
711 lines
21 KiB
C#
using BestHTTP;
|
||
using DragonLi.Core;
|
||
using System;
|
||
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using Unity.Mathematics;
|
||
using Unity.XR.PXR;
|
||
using UnityEngine;
|
||
using XPlugin.Data.JsonLiteDB;
|
||
using static XPlugin.Data.JsonLiteDB.JsonLiteDB;
|
||
using Random = UnityEngine.Random;
|
||
|
||
|
||
/// <summary>
|
||
/// 游戏场地
|
||
/// </summary>
|
||
public enum GamePlace
|
||
{
|
||
Test = -1,
|
||
Company1Floor = 0,
|
||
LiaoningAnShan = 1,
|
||
HangZhouLongHuTianJie = 2,
|
||
Nanjing_Yuhua_Wanxiang = 3,
|
||
Nanjing_Xianlin_WanDaMao = 4,
|
||
Yangzhou_Hanjiang_Tansuozhongxin = 5,
|
||
Yangzhou_Hanjiang_TansuoZhongxin_wai = -5,
|
||
Zhejiang_Jinhua_KeJiGuan = 6,
|
||
Guangzhou_Panyv_Zhanting = 7,
|
||
Anhui_Wuhu_Guanwei = 8,
|
||
Shandong_Jining_Shangchang = 9,
|
||
Shandong_Jining_Shangchang_nei = -9,
|
||
ShanDong_Langfang_QingzhouTaihuacheng = 10,
|
||
Hubei_Xiangyang_Kejiguan = 11,
|
||
Zhejiang_Shaoxing_Shengzhou_WuyueGuangchang=12,
|
||
Hunan_Jishou_Qianzhou_Tianhong=13,
|
||
Jilin_Tonghua_Liuhe=14,
|
||
Shandong_Jinan_Huaiyin_ShengfutongShangmao = 15,
|
||
Shandong_Jinan_Huaiyin_ShengfutongShangmao_wai = -15,
|
||
Henan_Xinzheng_Shuanghudadao_Longhujinyicheng = 16,
|
||
Nanjing_Qixia_Yaohuamen_Jindiguangchang = 17,
|
||
Nanjing_Qixia_Yaohuamen_Jindiguangchang_nei = -17,
|
||
Anshan_Suzhou_Yueshan_Guchengshangyejie = 18,
|
||
Gansu_Longnan_Shicheng_Dongsheng = 19,
|
||
Shandong_Heze_Yuncheng_Gefuli = 20,
|
||
}
|
||
|
||
public class GameManager : MonoBehaviour
|
||
{
|
||
public static GameManager Ins { get; private set; }
|
||
/// <summary>
|
||
/// 是否时间到了
|
||
/// </summary>
|
||
public bool isTimeEnd = true;
|
||
// json数据库
|
||
private JsonLiteDB DB;
|
||
|
||
// Enemy子弹数据
|
||
public Dictionary<int, BulletData> EnemyBulletDataDic = new Dictionary<int, BulletData>();
|
||
|
||
// Player子弹数据
|
||
public Dictionary<int, BulletData> PlayerBulletDataDic = new Dictionary<int, BulletData>();
|
||
|
||
public Dictionary<int, PropData> PropDataDic = new Dictionary<int, PropData>();
|
||
|
||
public Dictionary<int, BossPosData> BossPosDataDic = new Dictionary<int, BossPosData>();
|
||
|
||
|
||
public List<Enemy> curEnemyList = new List<Enemy>();
|
||
public Dictionary<int, EnemyData> EnemyDataDic = new Dictionary<int, EnemyData>();
|
||
|
||
[Header("道具")]
|
||
public GameObject EnergyPumpPre;
|
||
public GameObject gameStartPointPre;
|
||
public GameObject enemyDoorPre;
|
||
|
||
[Header("敌人")]
|
||
public GameObject[] enemyPre;
|
||
|
||
public GameObject callEffectPre;//召唤特效
|
||
|
||
[Header("玩家")]
|
||
public GameObject playerPre;
|
||
public GameObject player;
|
||
|
||
/// <summary>
|
||
/// 血包
|
||
/// </summary>
|
||
public GameObject BloodBagPre;
|
||
/// <summary>
|
||
/// 武器道具
|
||
/// </summary>
|
||
public GameObject weaponItemPre;
|
||
/// <summary>
|
||
/// 攻击BUFF
|
||
/// </summary>
|
||
public GameObject AtkBuffPre;
|
||
|
||
public GameObject deffBuffPre;
|
||
|
||
public bool GameStart = false;
|
||
|
||
public bool isGameEnd = false;
|
||
|
||
public int EnergyPumpTag = 0;
|
||
|
||
public float EnergyPumpFillAmount = 0;
|
||
|
||
public float curTime;
|
||
|
||
public float buffAtk = 0f;
|
||
public float buffDef = 0f;
|
||
|
||
public LoginInfo loginInfo = new LoginInfo();
|
||
|
||
public Enemy curBoss;
|
||
|
||
public int curLevel = 0;
|
||
|
||
//添加
|
||
[Header("AI角色")]
|
||
public GameObject aiCharacterPre;//AI角色预制体
|
||
private GameObject aiCharacter;//AI角色实例
|
||
|
||
private void Awake()
|
||
{
|
||
|
||
}
|
||
|
||
public void Start()
|
||
{
|
||
Ins = this;
|
||
CreatePlayer();
|
||
LoginPanel.Show();
|
||
|
||
#if !UNITY_EDITOR
|
||
PXR_Enterprise.InitEnterpriseService();
|
||
PXR_Enterprise.BindEnterpriseService();
|
||
TrueGearEffectManager.Ins.StartRequestTrueGear();
|
||
#endif
|
||
CoroutineTaskManager.Instance.WaitSecondTodo(ShowPlayerUI, 1.5f);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 登录
|
||
/// </summary>
|
||
public void Request(Action<HTTPRequest, HTTPResponse> cb = null)
|
||
{
|
||
string url = "http://www.pineappletech.cn/startcount";
|
||
HTTPRequest request = new HTTPRequest(new Uri(url), HTTPMethods.Post, (req, response) =>
|
||
{
|
||
if (response != null)
|
||
{
|
||
Debug.Log("收到数据 ->" + response.DataAsText);
|
||
}
|
||
cb?.Invoke(req, response);
|
||
});
|
||
loginInfo.deviceSn = GetPicoSn();
|
||
loginInfo.startAt = ConvertTimestampToDateTime(GetTimestamp()) + "";
|
||
loginInfo.shop = 17;
|
||
#if !UNITY_EDITOR && UNITY_ANDROID && PICO
|
||
loginInfo.shop = (int)GameInit.Ins.gamePlace;
|
||
if(GameInit.Ins.gamePlace== GamePlace.Yangzhou_Hanjiang_TansuoZhongxin_wai)
|
||
loginInfo.shop = 5;
|
||
if(GameInit.Ins.gamePlace== GamePlace.Shandong_Jining_Shangchang_nei)
|
||
loginInfo.shop = 9;
|
||
if(GameInit.Ins.gamePlace== GamePlace.Shandong_Jinan_Huaiyin_ShengfutongShangmao_wai)
|
||
loginInfo.shop = 15;
|
||
if(GameInit.Ins.gamePlace== GamePlace.Nanjing_Qixia_Yaohuamen_Jindiguangchang_nei)
|
||
loginInfo.shop = 17;
|
||
#endif
|
||
//loginInfo.shop = 0;
|
||
loginInfo.gameId = 5;
|
||
string authJson = JsonUtility.ToJson(loginInfo);
|
||
Debug.Log("发送数据 -> " + authJson);
|
||
request.RawData = System.Text.Encoding.UTF8.GetBytes(authJson);
|
||
request.AddHeader("Content-Type", "application/json");
|
||
request.Send();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 更新配置表
|
||
/// </summary>
|
||
public void InitData()
|
||
{
|
||
string text = "";
|
||
string text0 = Resources.Load<TextAsset>(string.Format("zh/{0}Data", GameInit.Ins.gamePlace)).text;
|
||
GetReaderJson(text0);
|
||
}
|
||
|
||
public static string ConvertTimestampToDateTime(long timestamp)
|
||
{
|
||
// Unix时间戳是从1970年1月1日00:00:00开始的秒数或毫秒数
|
||
// 这里以秒为单位,如果时间戳是毫秒则除以1000
|
||
DateTime dateTime = DateTimeOffset.FromUnixTimeSeconds(timestamp).DateTime;
|
||
return dateTime.ToString("yyyy-MM-dd HH:mm:ss");
|
||
}
|
||
|
||
public void GetReaderJson(string text)
|
||
{
|
||
DB = new JsonLiteDB();
|
||
DB.Load(text);
|
||
// 读取Info表数据
|
||
TableReader infoReader = DB["EnemyData"].GetReader();
|
||
EnemyDataDic.Clear();
|
||
while (infoReader.Read())
|
||
{
|
||
EnemyData info = new EnemyData(infoReader);
|
||
EnemyDataDic.Add(info.Id, info);
|
||
}
|
||
|
||
// 敌人子弹数据
|
||
TableReader EnemyBulletReader = DB["EnemyBulletData"].GetReader();
|
||
EnemyBulletDataDic.Clear();
|
||
while (EnemyBulletReader.Read())
|
||
{
|
||
BulletData data = new BulletData(EnemyBulletReader);
|
||
EnemyBulletDataDic.Add(data.ID, data);
|
||
}
|
||
|
||
// 玩家子弹数据
|
||
TableReader PlayerBulletReader = DB["PlayerBulletData"].GetReader();
|
||
PlayerBulletDataDic.Clear();
|
||
while (PlayerBulletReader.Read())
|
||
{
|
||
BulletData data = new BulletData(PlayerBulletReader);
|
||
PlayerBulletDataDic.Add(data.ID, data);
|
||
}
|
||
|
||
// 道具表
|
||
TableReader PropReader = DB["PropData"].GetReader();
|
||
PropDataDic.Clear();
|
||
while (PropReader.Read())
|
||
{
|
||
PropData data = new PropData(PropReader);
|
||
PropDataDic.Add(data.PropId, data);
|
||
}
|
||
|
||
// Boss位置
|
||
TableReader BossPosReader = DB["BossPosData"].GetReader();
|
||
BossPosDataDic.Clear();
|
||
while (BossPosReader.Read())
|
||
{
|
||
BossPosData data = new BossPosData(BossPosReader);
|
||
BossPosDataDic.Add(data.ID, data);
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// Get sn
|
||
/// </summary>
|
||
public string GetPicoSn()
|
||
{
|
||
string res = "UnityEditor";
|
||
|
||
#if !UNITY_EDITOR && UNITY_ANDROID && PICO
|
||
res = PXR_Enterprise.StateGetDeviceInfo(SystemInfoEnum.EQUIPMENT_SN);
|
||
#endif
|
||
return res;
|
||
}
|
||
|
||
public long GetTimestamp()
|
||
{
|
||
return (long)DateTime.Now.Subtract(new DateTime(1970, 1, 1)).TotalSeconds;
|
||
}
|
||
|
||
public bool isGamePlay;
|
||
|
||
//AI介绍是否完成
|
||
private bool isAIIntroductionComplete = false;
|
||
|
||
// 游戏开始
|
||
public void GamePlay()
|
||
{
|
||
//TODO:添加一个玩家进入游戏AI进行游戏介绍,介绍完后,AI自动回到玩家左侧
|
||
//修改处:创建AI角色
|
||
CreateAICharacter();
|
||
|
||
//isGamePlay = true;
|
||
//CreateBoss();
|
||
//PlayerUIMessage(0);
|
||
//CoroutineTaskManager.Instance.WaitSecondTodo(() =>
|
||
// AudioManager.Ins?.SoundPlay("bgm2", true), 10f);
|
||
//CoroutineTaskManager.Instance.WaitSecondTodo(() =>
|
||
// AudioManager.Ins?.SoundPlay("2.39BGM", true), 30f);
|
||
}
|
||
|
||
//修改处:添加AI介绍完成后的游戏开始方法
|
||
public void StartGameAfterIntroduction()
|
||
{
|
||
isAIIntroductionComplete = true;
|
||
isGamePlay = true;
|
||
|
||
Debug.Log("AI介绍完成,开始游戏正常流程");
|
||
|
||
//创建Boss
|
||
CreateBoss();
|
||
|
||
PlayerUIMessage(0);
|
||
CoroutineTaskManager.Instance.WaitSecondTodo(() =>
|
||
AudioManager.Ins?.SoundPlay("bgm2", true), 10f);
|
||
CoroutineTaskManager.Instance.WaitSecondTodo(() =>
|
||
AudioManager.Ins?.SoundPlay("2.39BGM", true), 30f);
|
||
}
|
||
|
||
//修改处:添加创建AI角色的方法
|
||
private void CreateAICharacter()
|
||
{
|
||
//检查是否已经存在AI角色
|
||
if (aiCharacter != null)
|
||
{
|
||
Debug.Log("AI角色已经存在,不再创建新的");
|
||
return;
|
||
}
|
||
|
||
if (aiCharacterPre != null)
|
||
{
|
||
Debug.Log("创建AI角色");
|
||
|
||
//在玩家前方创建AI角色
|
||
Vector3 spawnPosition = player.transform.position + player.transform.forward * 3f;
|
||
aiCharacter = Instantiate(aiCharacterPre, spawnPosition, Quaternion.identity);
|
||
|
||
//获取AIController并启动开场白
|
||
AIController aiController = aiCharacter.GetComponent<AIController>();
|
||
if (aiController != null)
|
||
{
|
||
//注册AI介绍完成回调
|
||
aiController.OnIntroductionComplete += StartGameAfterIntroduction;
|
||
|
||
//添加延迟,确保所有组件已经完成初始化
|
||
StartCoroutine(DelayedStartIntroduction(aiController));
|
||
}
|
||
else
|
||
{
|
||
Debug.LogError("AI预制体中的AIController组件丢失");
|
||
}
|
||
}
|
||
else
|
||
{
|
||
Debug.LogError("AI预制体没有在GameManager分配!");
|
||
}
|
||
}
|
||
|
||
private IEnumerator DelayedStartIntroduction(AIController aiController)
|
||
{
|
||
yield return new WaitForSeconds(0.1f); // 短暂延迟
|
||
aiController.StartIntroduction();
|
||
}
|
||
|
||
public void ShowPlayerUI()
|
||
{
|
||
OverlayUI.Ins.Cover("UI/PlayerUI", false);
|
||
}
|
||
|
||
public void ShowEndGameUI(bool isWin)
|
||
{
|
||
CurEnemyDie();
|
||
GameEndPanel.Show(isWin);
|
||
}
|
||
public GameObject CreateEnemy(int id, Vector3 pos, Vector3 eulerAngles, bool isBoss)
|
||
{
|
||
GameObject go = Instantiate(enemyPre[id], pos, Quaternion.identity);
|
||
go.transform.localEulerAngles = eulerAngles;
|
||
Enemy enemy = go.GetComponent<Enemy>();
|
||
enemy.Init();
|
||
if (isBoss)
|
||
{
|
||
curBoss = enemy;
|
||
}
|
||
else
|
||
{
|
||
curEnemyList.Add(enemy);
|
||
}
|
||
return go;
|
||
}
|
||
|
||
public GameObject CreateCallEnemyEffect(Vector3 pos)
|
||
{
|
||
GameObject go = Instantiate(callEffectPre, pos, quaternion.identity);
|
||
MonoSingleton<CoroutineTaskManager>.Instance.WaitSecondTodo(() =>
|
||
{
|
||
Destroy(go);
|
||
}, 3f);
|
||
return go;
|
||
}
|
||
|
||
void Destroy()
|
||
{
|
||
|
||
#if !UNITY_EDITOR
|
||
PXR_Enterprise.UnBindEnterpriseService();
|
||
#endif
|
||
}
|
||
|
||
public void CreateEnergyPump(Vector3 pos)
|
||
{
|
||
isGamePlay = false;
|
||
GameObject EnergyPump = Instantiate(EnergyPumpPre);
|
||
//EnergyPump.transform.position = pos;
|
||
EnergyPump.transform.position = new Vector3(2, 0, 2);
|
||
if (GameInit.Ins.gamePlace == GamePlace.Nanjing_Xianlin_WanDaMao)
|
||
{
|
||
EnergyPump.transform.position = new Vector3(-1.2f, 0, 1.5f);
|
||
}
|
||
if (GameInit.Ins.gamePlace == GamePlace.Nanjing_Yuhua_Wanxiang)
|
||
{
|
||
EnergyPump.transform.position = new Vector3(-3, 0, 2);
|
||
}
|
||
if (GameInit.Ins.gamePlace == GamePlace.Yangzhou_Hanjiang_Tansuozhongxin)
|
||
{
|
||
EnergyPump.transform.position = new Vector3(-1.2f, 0, 0f);
|
||
}
|
||
if (GameInit.Ins.gamePlace == GamePlace.Yangzhou_Hanjiang_TansuoZhongxin_wai)
|
||
{
|
||
EnergyPump.transform.position = new Vector3(0, 0, 2f);
|
||
}
|
||
if (GameInit.Ins.gamePlace == GamePlace.Zhejiang_Jinhua_KeJiGuan)
|
||
{
|
||
EnergyPump.transform.position = new Vector3(0, 0, 2f);
|
||
}
|
||
if (GameInit.Ins.gamePlace == GamePlace.Jilin_Tonghua_Liuhe)
|
||
{
|
||
EnergyPump.transform.position = new Vector3(0, 0, 2f);
|
||
}
|
||
if (GameInit.Ins.gamePlace == GamePlace.Guangzhou_Panyv_Zhanting)
|
||
{
|
||
EnergyPump.transform.position = new Vector3(0, 0, 2f);
|
||
}
|
||
if (GameInit.Ins.gamePlace == GamePlace.Zhejiang_Shaoxing_Shengzhou_WuyueGuangchang)
|
||
{
|
||
EnergyPump.transform.position = new Vector3(-0.23f, 0, 1.1f);
|
||
}
|
||
if (GameInit.Ins.gamePlace == GamePlace.ShanDong_Langfang_QingzhouTaihuacheng)
|
||
{
|
||
EnergyPump.transform.position = pos;
|
||
}
|
||
if (GameInit.Ins.gamePlace == GamePlace.Hunan_Jishou_Qianzhou_Tianhong)
|
||
{
|
||
EnergyPump.transform.position = new Vector3(5f, 0, 1f);
|
||
}
|
||
if (GameInit.Ins.gamePlace == GamePlace.Shandong_Jinan_Huaiyin_ShengfutongShangmao)
|
||
{
|
||
EnergyPump.transform.position = new Vector3(0.62f, 0, 1f);
|
||
}
|
||
if (GameInit.Ins.gamePlace == GamePlace.Shandong_Heze_Yuncheng_Gefuli)
|
||
{
|
||
EnergyPump.transform.position = new Vector3(-10.9f, 0, 1.6f);
|
||
}
|
||
if (GameInit.Ins.gamePlace == GamePlace.Henan_Xinzheng_Shuanghudadao_Longhujinyicheng)
|
||
{
|
||
EnergyPump.transform.position = new Vector3(-2.08f, 0, -0.75f);
|
||
}
|
||
EnergyPumpTag++;
|
||
EnergyPump.GetComponent<EnergyPump>().Init(EnergyPumpTag);
|
||
}
|
||
|
||
public void PlayerUIMessage(int index)
|
||
{
|
||
EventDispatcher.TriggerEvent("PromptMessage", index);
|
||
}
|
||
|
||
public void CreateGameStartPoint()
|
||
{
|
||
GameStart = true;
|
||
isGamePlay = false;
|
||
GameObject point = Instantiate(gameStartPointPre);
|
||
if (GameInit.Ins.gamePlace == GamePlace.LiaoningAnShan)
|
||
{
|
||
point.transform.position = new Vector3(-2, 0, 2);
|
||
}
|
||
if (GameInit.Ins.gamePlace == GamePlace.ShanDong_Langfang_QingzhouTaihuacheng)
|
||
{
|
||
point.transform.position = new Vector3(7.46f, 0, 1.65f);
|
||
}
|
||
else
|
||
{
|
||
point.transform.position = Vector3.zero;
|
||
}
|
||
|
||
CoroutineTaskManager.Instance.WaitSecondTodo(() =>
|
||
{
|
||
if (isGamePlay)
|
||
return;
|
||
Destroy(point.gameObject);
|
||
GamePlay();
|
||
}, 5f);
|
||
}
|
||
public GameObject CreateEnemyDoor(Vector3 pos, Vector3 angle, Vector3 scale)
|
||
{
|
||
GameObject crack = Instantiate(enemyDoorPre);
|
||
crack.transform.position = new Vector3(pos.x, pos.y, pos.z);
|
||
crack.transform.localEulerAngles = angle;
|
||
crack.transform.localScale = scale;
|
||
return crack;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 创建攻击BUFF
|
||
/// </summary>
|
||
/// <param name="pos"></param>
|
||
public void CreateAtkBuff(Vector3 pos)
|
||
{
|
||
GameObject atkBuff = Instantiate(AtkBuffPre);
|
||
atkBuff.transform.position = new Vector3(pos.x, 0, pos.z);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 创建防御BUFF
|
||
/// </summary>
|
||
/// <param name="pos"></param>
|
||
public void CreateDeeBuff(Vector3 pos)
|
||
{
|
||
GameObject deeBuff = Instantiate(deffBuffPre);
|
||
deeBuff.transform.position = new Vector3(pos.x, 0, pos.z);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 创建血包
|
||
/// </summary>
|
||
public void CreateBloodBag(Vector3 pos)
|
||
{
|
||
GameObject bloodBag = Instantiate(BloodBagPre);
|
||
bloodBag.transform.position = new Vector3(pos.x, 0, pos.z);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 创建武器道具
|
||
/// </summary>
|
||
public void CreatePlayerWeapon(PlayerWeaponType type, Vector3 pos)
|
||
{
|
||
GameObject prop = Instantiate(weaponItemPre);
|
||
prop.GetComponent<WeaponProp>().Init(type);
|
||
prop.transform.position = new Vector3(pos.x, 1f, pos.z);
|
||
}
|
||
|
||
public bool isFirstGetWeapon;
|
||
public void EnemyDisGetWeapon(Vector3 pos)
|
||
{
|
||
|
||
bool isGet = Random.Range(0, 100) > 70;
|
||
if (!isGet) return;
|
||
|
||
int index = Random.Range(0, 100);
|
||
int id = 2;
|
||
if (index <= 10)
|
||
id = Random.Range(8, 10);
|
||
if (index is > 10 and <= 50)
|
||
id = Random.Range(5, 8);
|
||
if (index is > 50)
|
||
id = Random.Range(2, 5);
|
||
CreatePlayerWeapon((PlayerWeaponType)id, pos);
|
||
if (!isFirstGetWeapon)
|
||
{
|
||
GameInit.Ins.PlayAudio("1.5", GameInit.Ins.self.transform, true);
|
||
isFirstGetWeapon = true;
|
||
}
|
||
}
|
||
|
||
public void CurEnemyDie()
|
||
{
|
||
foreach (var enemy in curEnemyList)
|
||
{
|
||
if (enemy != null)
|
||
enemy.Dead();
|
||
}
|
||
curEnemyList.Clear();
|
||
}
|
||
|
||
public int GetCurEnemyListCount()
|
||
{
|
||
int count = 0;
|
||
foreach (var enemy in curEnemyList)
|
||
{
|
||
if (enemy != null)
|
||
count++;
|
||
}
|
||
|
||
return count;
|
||
}
|
||
|
||
public void CreatePlayer()
|
||
{
|
||
player = Instantiate(playerPre);
|
||
}
|
||
|
||
public bool IsAllBossPetDie()
|
||
{
|
||
foreach (var enemy in curEnemyList)
|
||
{
|
||
if (enemy != null && enemy.health > 0)
|
||
return false;
|
||
}
|
||
|
||
return true;
|
||
}
|
||
|
||
public void CurLevelWin(Vector3 pos)
|
||
{
|
||
curLevel++;
|
||
CurEnemyDie();
|
||
CreateEnergyPump(pos);
|
||
}
|
||
|
||
public void CreateBoss()
|
||
{
|
||
BossPosData data = BossPosDataDic[curLevel];
|
||
GameObject door = null;
|
||
if (curLevel != 0)
|
||
door = CreateEnemyDoor(data.DoorPos, data.DoorAng, Vector3.one * data.DoorScale);
|
||
switch (curLevel)
|
||
{
|
||
case 0:
|
||
CreateEnemy(0, data.BossPos, Vector3.zero, true);
|
||
break;
|
||
case 1:
|
||
//舰载机
|
||
MonoSingleton<CoroutineTaskManager>.Instance.WaitSecondTodo(() =>
|
||
{
|
||
door.GetComponent<EnemyDoor>().desTime = 6;
|
||
door.GetComponent<EnemyDoor>().InitData();
|
||
}, 1f);
|
||
MonoSingleton<CoroutineTaskManager>.Instance.WaitSecondTodo(() =>
|
||
{
|
||
CreateEnemy(2, data.BossPos, data.BossAng, true);
|
||
}, 3f);
|
||
break;
|
||
case 2:
|
||
MonoSingleton<CoroutineTaskManager>.Instance.WaitSecondTodo(() =>
|
||
{
|
||
door.GetComponent<EnemyDoor>().desTime = 10;
|
||
door.GetComponent<EnemyDoor>().InitData();
|
||
}, 1f);
|
||
MonoSingleton<CoroutineTaskManager>.Instance.WaitSecondTodo(() =>
|
||
{
|
||
CreateEnemy(3, data.BossPos, data.BossAng, true);
|
||
}, 3f);
|
||
break;
|
||
case 3:
|
||
MonoSingleton<CoroutineTaskManager>.Instance.WaitSecondTodo(() =>
|
||
{
|
||
door.GetComponent<EnemyDoor>().desTime = 10;
|
||
door.GetComponent<EnemyDoor>().InitData();
|
||
}, 1f);
|
||
MonoSingleton<CoroutineTaskManager>.Instance.WaitSecondTodo(() =>
|
||
{
|
||
CreateEnemy(5, data.BossPos, data.BossAng, true);
|
||
}, 3f);
|
||
break;
|
||
case 4:
|
||
MonoSingleton<CoroutineTaskManager>.Instance.WaitSecondTodo(() =>
|
||
{
|
||
door.GetComponent<EnemyDoor>().desTime = 6;
|
||
door.GetComponent<EnemyDoor>().InitData();
|
||
}, 1f);
|
||
MonoSingleton<CoroutineTaskManager>.Instance.WaitSecondTodo(() =>
|
||
{
|
||
CreateEnemy(7, data.BossPos, data.BossAng, true);
|
||
}, 1f);
|
||
break;
|
||
}
|
||
}
|
||
|
||
public void WinEndGame()
|
||
{
|
||
isGameEnd = true;
|
||
ShowEndGameUI(true);
|
||
GameInit.Ins.PlayAudio("1.17", GameInit.Ins.self.transform, true);
|
||
AudioManager.Ins?.SoundPlay("bgm4", true);
|
||
|
||
////修改处:销毁AI角色
|
||
if (aiCharacter != null)
|
||
{
|
||
//取消注册事件
|
||
AIController aiController = aiCharacter.GetComponent<AIController>();
|
||
if (aiController != null)
|
||
{
|
||
aiController.OnIntroductionComplete -= StartGameAfterIntroduction;
|
||
}
|
||
|
||
Destroy(aiCharacter);
|
||
}
|
||
}
|
||
|
||
public void LoseEndGame()
|
||
{
|
||
ShowEndGameUI(false);
|
||
if (curBoss != null)
|
||
{
|
||
Destroy(curBoss.gameObject);
|
||
}
|
||
|
||
GameInit.Ins.self.IsAlive = false;
|
||
GameInit.Ins.self.End();
|
||
isGameEnd = true;
|
||
CurEnemyDie();
|
||
AudioManager.Ins?.SoundPlay("bgm4", true);
|
||
|
||
//修改处:销毁AI角色
|
||
if (aiCharacter != null)
|
||
{
|
||
//取消注册事件
|
||
AIController aiController = aiCharacter.GetComponent<AIController>();
|
||
if (aiController != null)
|
||
{
|
||
aiController.OnIntroductionComplete -= StartGameAfterIntroduction;
|
||
}
|
||
|
||
Destroy(aiCharacter);
|
||
}
|
||
}
|
||
} |