605 lines
19 KiB
C#
605 lines
19 KiB
C#
using BestHTTP;
|
||
using DragonLi.Core;
|
||
using System;
|
||
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using DarkTonic.MasterAudio;
|
||
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,
|
||
Company1FloorShiwai=-999,
|
||
LiaoningAnShan = 1,
|
||
Liaoning_AnShan_Lishan_Dayuecheng =-1,
|
||
HangZhouLongHuTianJie = 2,
|
||
Nanjing_Yuhua_Wanxiang = 3,
|
||
Nanjing_Xianlin_WanDaMao = 4,
|
||
Yangzhou_Hanjiang_Tansuozhongxin = 5,
|
||
Yangzhou_Hanjiang_TansuoZhongxin_wai = -5,
|
||
Zhejiang_Jinhua_KeJiGuan = 6,
|
||
Anhui_Wuhu_Guanwei = 8,
|
||
Shandong_Jining_Wanhuicheng=9,
|
||
Shandong_Jining_Wanhuicheng_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,
|
||
Anhui_Suzhou_Yueshan_Guchengshangyejie = 18,
|
||
Anhui_Suzhou_Yueshan_Guchengshangyejie_2=-18,//--
|
||
Gansu_Longnan_Shicheng_Dongsheng = 19,
|
||
Shandong_Heze_Yuncheng_Gefuli = 20,
|
||
Wulanhaote_Ouya_Shangchang = 21,
|
||
Wulanhaote_Wanda_Shangchang = -21,
|
||
Yunnan_Mile_Jinchen_Shidaiguangchang = 22,
|
||
Xinjiang_Yili_Yining_Wanrong = 23,
|
||
Hunan_Hengyang_Zhuhui_Dongzhoudao = 24,
|
||
Hunan_Hengyang_Zhuhui_Dongzhoudao_nei = -24,
|
||
Yunnan_Lincang_Linxiang_Hengji = 25,
|
||
Yunnan_Lincang_Linxiang_Hengji_Dixia = -25,
|
||
Guangxi_Guilin_Gongcheng_Shijixincheng = 26,
|
||
Guangdong_shenzheng_Guangming_Shijiguangchang=27,
|
||
Gansu_Jinchang_Jinchuan_Shijiguangchang = 28,
|
||
Gansu_Jinchang_Jinchuan_Shijiguangchang_Shiwai=-28,
|
||
Jiangsu_Xvzhou_Fengxian_Wuyueguangchang = 29,//--
|
||
Hebei_Tangshan_Qianan_Tianyuangu = 30,
|
||
Guangdong_Guangzhou_Yanghaiyan = 31,
|
||
Guangdong_Guangzhou_Yanghaiyan_Lihu=-31,
|
||
Zhejiang_Hangzhou_Linping_Yintaicheng = 32,
|
||
Zhejiang_Hangzhou_Linping_Yintaicheng_Shinei = -32,
|
||
Henan_Xinxiang_Wandaguangchang = 33,
|
||
Henan_Xinxiang_Wandaguangchang_Shinei = -33,
|
||
Yangzhou_Hanjiang_TansuoZhongxin_Waidai =34,
|
||
Nanjing_Pukou_Longhutianjie=35,
|
||
Jiangsu_Xvzhou_Guolou_Oulebao=36,
|
||
Jiangsu_Xvzhou_Guolou_Oulebao_2=-36,
|
||
Jiangsu_Xvzhou_Suning_Guangchang =37,
|
||
Jiangsu_Xvzhou_Suning_Guangchang_1 = -37,//--
|
||
Shanxi_Baoji_Meixian_TianlongShangcheng = 38,
|
||
Hunan_Changde_Lixian_WandaGuangchang=39,
|
||
Jilin_Changchun_Beihu_WyueGuangchang=41,
|
||
Chongqing_Yuzhong_Hongyadong_Xiakexing=42,
|
||
Chongqing_Yuzhong_Hongyadong_Xiakexing_shiwan=-42,
|
||
Chengdu_Shuangliu_ShengfeiXuexiao =43,
|
||
Hebei_Hengshui_Xinji_WandaGuangchang=44,
|
||
Hebei_Hengshui_Taocheng_WandaGuangchang = -44,
|
||
Ningxia_Yinchuan_Jinfeng_XinhualianGuangchang = 45,
|
||
Hunan_Zhuzhou_Wanda_Shennongcheng_Chaowanshe = 46,
|
||
Anhui_Suzhou_Yueshan_Guchengshangyejie_Shinei=47,
|
||
Zhejiang_Wenzhou_Cangnan_Yintaicheng = 48,
|
||
Shandong_Jining_Shangchang_3=49,
|
||
Anhui_Manshan_XingyueGuangchang = 50,
|
||
Shandong_Weifang_Linqu_WandaGuangchang = 51,
|
||
Guangdong_Foushan_Haiyangguang = 52,
|
||
Jilin_Changchun_Chaoyang_OuyaMaichang=53,
|
||
Shandong_Weifang_Linqu_WandaGuangchang_Shinei = 54,
|
||
Liaoning_Panjin_Shuangtaizi_Shuangtaicheng = 55,
|
||
Liaoning_Dalian_Pulandian_WandaGuangchang = 56,
|
||
Jiangxi_Ganzhou_Longnan_WandaGuangchang=57,
|
||
Jiangxi_Ganzhou_Longnan_WandaGuangchang_Shinei=58,
|
||
Jiangxi_Ganzhou_Zhanggong_GanzhouShucheng = 59,
|
||
Henan_Shangqiu_Juyang_WuyueGuangchang = 60,
|
||
Guangdong_Meizhou_Meixian_TianhongShangchang = 61,
|
||
Beijing_Tongzhou_Luyijie_XiangrikuiGuangchang = 62,
|
||
Ningxia_Yinchuang_Shizuishan_WandaGuangchang = 63,
|
||
Jilin_Jilin_Chuangying_Zhongdongxinshenghuo = 64,
|
||
Jiangxi_Nanchang_Xinjian_XvhuiGuangchang=65,
|
||
Shandong_Weihai_Jingqu_W37=66,
|
||
Hunan_Xiangxi_Yongshun_XintiandiShangchang=67,
|
||
Shanxi_Yuncheng_Yanhu_WandaGuangchang = 68,
|
||
Bejing_Miyun_RuijiaShangchang = 69,
|
||
Henan_Kaifeng_Longting_XihuJingqu = 70,
|
||
Henan_Kaifeng_Longting_XihuJingqu_Shiwai = 71,
|
||
Jiangxi_Nanchang_Xihu_NanchangDongwuyuan = 72,
|
||
Liaoning_Panjin_Xinglongtai_Shuiyoucheng = 73,
|
||
Shanxi_Yulin_Shenmu_Liuta_Yuyuecheng = 74,
|
||
Sichuan_Liangshan_Mianning_GaoyangJiedao = 75,
|
||
Jiangxi_Nanchang_Xihu_NanchangDongwuyuan_Shinei = 76,
|
||
Ningxia_Yinchuan_Xingqing_XinhuaBaihuo = 77,
|
||
Liaoning_Huludao_Jianchang_XinglongDajiating = 78,
|
||
Ningxia_Yinchuan_Xingqing_XinhuaBaihuo_Shiwai = 79,
|
||
Ningxia_Wuzhong_Litong_YiwuShangmaocheng = 80,
|
||
Gansu_Dingxi_Anding_WandaGuangchang=81,
|
||
Guangdong_Shaoguan_Lechang_ZhigongwenhuGuangchang=82,
|
||
Guangdong_Shaoguan_Lechang_Dongjietingchechang=83,
|
||
Liaoning_Fushun_Xinbinmanzu_MinzuShangchang=84,
|
||
Wuhan_Jiangxia_LongwanBandao=85,
|
||
}
|
||
|
||
public enum GameKey
|
||
{
|
||
DinosaurPark2=0,//重返侏罗纪
|
||
SpongeBob=1,//深海冒险
|
||
XMen=2,//银河守护者
|
||
KOF=3,//幻影交锋
|
||
Valheim=4,//小小幻宠
|
||
FutureMen=5,//未来战警
|
||
AliceBall=6,//爱丽丝的舞会
|
||
Zombie=7,//僵尸来了
|
||
DefendNJ=8,//保卫金陵
|
||
Loong=9, //巨龙猎人
|
||
MRCS=10,//火力对决
|
||
SXDMystery=11,//三星堆之谜
|
||
XMen2=12,//银河守护者2异形
|
||
}
|
||
|
||
public class GameManager : MonoBehaviour
|
||
{
|
||
public static GameManager Ins { get; private set; }
|
||
|
||
// json数据库
|
||
private JsonLiteDB DB;
|
||
|
||
// Player子弹数据
|
||
public Dictionary<int, BulletData> PlayerBulletDataDic = new Dictionary<int, BulletData>();
|
||
|
||
public List<Enemy> curEnemyList = new List<Enemy>();
|
||
public Dictionary<int, EnemyData> EnemyDataDic = new Dictionary<int, EnemyData>();
|
||
|
||
[Header("道具")]
|
||
public GameObject gameStartPointPre;
|
||
public GameObject enemyDoorPre;
|
||
public GameObject enemySkillTipPre;
|
||
|
||
[Header("敌人")]
|
||
public GameObject[] enemyPre;
|
||
|
||
[Header("玩家")]
|
||
public GameObject playerPre;
|
||
public GameObject player;
|
||
|
||
public bool GameStart = false;
|
||
|
||
public bool isGameEnd = false;
|
||
|
||
public float curTime;
|
||
|
||
public float buffAtk = 0f;
|
||
public float buffDef = 0f;
|
||
|
||
public LoginInfo authInfo = new LoginInfo();
|
||
|
||
public Enemy curBoss;
|
||
|
||
public int curLevel = 0;
|
||
|
||
//添加
|
||
[Header("AI角色")]
|
||
public GameObject aiCharacterPre;//AI角色预制体
|
||
private GameObject aiCharacter;//AI角色实例
|
||
|
||
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);
|
||
});
|
||
authInfo.deviceSn = GetPicoSn();
|
||
authInfo.startAt = ConvertTimestampToDateTime(GetTimestamp()) + "";
|
||
authInfo.shop = 0;
|
||
#if !UNITY_EDITOR && UNITY_ANDROID && PICO
|
||
authInfo.shop = (int)GameInit.Ins.gamePlace;
|
||
if(GameInit.Ins.gamePlace== GamePlace.Liaoning_AnShan_Lishan_Dayuecheng)
|
||
authInfo.shop = 1;
|
||
if(GameInit.Ins.gamePlace== GamePlace.Yangzhou_Hanjiang_TansuoZhongxin_wai)
|
||
authInfo.shop = 5;
|
||
if (GameInit.Ins.gamePlace == GamePlace.Shandong_Jining_Wanhuicheng_nei)
|
||
authInfo.shop = 9;
|
||
if (GameInit.Ins.gamePlace == GamePlace.Shandong_Jinan_Huaiyin_ShengfutongShangmao_wai)
|
||
authInfo.shop = 15;
|
||
if (GameInit.Ins.gamePlace == GamePlace.Nanjing_Qixia_Yaohuamen_Jindiguangchang_nei)
|
||
authInfo.shop = 17;
|
||
if (GameInit.Ins.gamePlace == GamePlace.Anhui_Suzhou_Yueshan_Guchengshangyejie_2)
|
||
authInfo.shop = 18;
|
||
if (GameInit.Ins.gamePlace == GamePlace.Wulanhaote_Wanda_Shangchang)
|
||
authInfo.shop = 21;
|
||
if (GameInit.Ins.gamePlace == GamePlace.Hunan_Hengyang_Zhuhui_Dongzhoudao_nei)
|
||
authInfo.shop = 24;
|
||
if (GameInit.Ins.gamePlace == GamePlace.Yunnan_Lincang_Linxiang_Hengji_Dixia)
|
||
authInfo.shop = 25;
|
||
if (GameInit.Ins.gamePlace == GamePlace.Gansu_Jinchang_Jinchuan_Shijiguangchang_Shiwai)
|
||
authInfo.shop = 28;
|
||
if (GameInit.Ins.gamePlace == GamePlace.Guangdong_Guangzhou_Yanghaiyan_Lihu)
|
||
authInfo.shop = 31;
|
||
if (GameInit.Ins.gamePlace == GamePlace.Zhejiang_Hangzhou_Linping_Yintaicheng_Shinei)
|
||
authInfo.shop = 32;
|
||
if (GameInit.Ins.gamePlace == GamePlace.Henan_Xinxiang_Wandaguangchang_Shinei)
|
||
authInfo.shop = 33;
|
||
if (GameInit.Ins.gamePlace == GamePlace.Jiangsu_Xvzhou_Guolou_Oulebao_2)
|
||
authInfo.shop = 36;
|
||
if (GameInit.Ins.gamePlace == GamePlace.Jiangsu_Xvzhou_Suning_Guangchang_1)
|
||
authInfo.shop = 37;
|
||
if (GameInit.Ins.gamePlace == GamePlace.Chongqing_Yuzhong_Hongyadong_Xiakexing_shiwan)
|
||
authInfo.shop = 42;
|
||
if (GameInit.Ins.gamePlace == GamePlace. Hebei_Hengshui_Taocheng_WandaGuangchang )
|
||
authInfo.shop = 44;
|
||
if (GameInit.Ins.gamePlace == GamePlace.Company1FloorShiwai)
|
||
authInfo.shop = 0;
|
||
#endif
|
||
|
||
authInfo.gameId = (int)GameInit.Ins.gameId;
|
||
string authJson = JsonUtility.ToJson(authInfo);
|
||
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 = Resources.Load<TextAsset>("Data").text;
|
||
GetReaderJson(text);
|
||
}
|
||
|
||
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["EnemyInfo"].GetReader();
|
||
EnemyDataDic.Clear();
|
||
while (infoReader.Read())
|
||
{
|
||
EnemyData info = new EnemyData(infoReader);
|
||
EnemyDataDic.Add(info.Id, info);
|
||
}
|
||
|
||
// 玩家子弹数据
|
||
TableReader PlayerBulletReader = DB["PlayerBulletData"].GetReader();
|
||
PlayerBulletDataDic.Clear();
|
||
while (PlayerBulletReader.Read())
|
||
{
|
||
BulletData data = new BulletData(PlayerBulletReader);
|
||
PlayerBulletDataDic.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()
|
||
{
|
||
//修改处:创建AI角色
|
||
// CreateAICharacter();
|
||
// PlayerUIMessage(0);
|
||
// CoroutineTaskManager.Instance.WaitSecondTodo(() =>
|
||
// AudioManager.Ins?.SoundPlay("bgm2", true), 10f);
|
||
// CoroutineTaskManager.Instance.WaitSecondTodo(() =>
|
||
// AudioManager.Ins?.SoundPlay("2.39BGM", true), 30f);
|
||
isGamePlay = true;
|
||
CreateBoss(GameInit.Ins.allBossPos[0].position);
|
||
}
|
||
|
||
//修改处:添加AI介绍完成后的游戏开始方法
|
||
public void StartGameAfterIntroduction()
|
||
{
|
||
isAIIntroductionComplete = true;
|
||
isGamePlay = true;
|
||
|
||
Debug.Log("AI介绍完成,开始游戏正常流程");
|
||
|
||
|
||
//创建Boss
|
||
CreateBoss(GameInit.Ins.allBossPos[0].position);
|
||
|
||
PlayerUIMessage(0);
|
||
}
|
||
|
||
//修改处:添加创建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;
|
||
}
|
||
|
||
void Destroy()
|
||
{
|
||
|
||
#if !UNITY_EDITOR
|
||
PXR_Enterprise.UnBindEnterpriseService();
|
||
#endif
|
||
}
|
||
|
||
public void PlayerUIMessage(int index)
|
||
{
|
||
EventDispatcher.TriggerEvent("PromptMessage", index);
|
||
}
|
||
|
||
public void CreateGameStartPoint()
|
||
{
|
||
GameStart = true;
|
||
isGamePlay = false;
|
||
GameObject point = Instantiate(gameStartPointPre);
|
||
point.transform.position = GameInit.Ins.startDoorPos.position;
|
||
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;
|
||
}
|
||
|
||
public GameObject CreateEnemySkillTip(Vector3 pos,float dieTime)
|
||
{
|
||
GameObject crack = Instantiate(enemySkillTipPre);
|
||
crack.transform.position = new Vector3(pos.x, pos.y, pos.z);
|
||
SelfDie selfDie = crack.GetComponent<SelfDie>();
|
||
selfDie.SetDieTime(dieTime);
|
||
return crack;
|
||
}
|
||
|
||
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);
|
||
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 void CreateBoss(Vector3 startPos)
|
||
{
|
||
if(isGameEnd)
|
||
return;
|
||
AudioManager.Ins.SoundPlay(curLevel, true);
|
||
CreateEnemy(curLevel, startPos, Vector3.zero, true);
|
||
if (curLevel != 0)
|
||
GameInit.Ins.self.UserZeroGun();
|
||
}
|
||
|
||
public void WinEndGame()
|
||
{
|
||
isGameEnd = true;
|
||
|
||
ShowEndGameUI(true);
|
||
AudioManager.Ins.SoundPlay(4, true);
|
||
|
||
////修改处:销毁AI角色
|
||
if (aiCharacter != null)
|
||
{
|
||
//取消注册事件
|
||
AIController aiController = aiCharacter.GetComponent<AIController>();
|
||
if (aiController != null)
|
||
{
|
||
aiController.OnIntroductionComplete -= StartGameAfterIntroduction;
|
||
}
|
||
Destroy(aiCharacter);
|
||
}
|
||
}
|
||
|
||
public void LoseEndGame(bool isWin)
|
||
{
|
||
ShowEndGameUI(isWin);
|
||
if (curBoss != null)
|
||
{
|
||
curBoss.Dead();
|
||
}
|
||
|
||
GameInit.Ins.self.IsAlive = false;
|
||
GameInit.Ins.self.End();
|
||
isGameEnd = true;
|
||
//CurEnemyDie();
|
||
AudioManager.Ins.SoundPlay(5, true);
|
||
AudioManager.Ins.StopLoop();
|
||
//修改处:销毁AI角色
|
||
if (aiCharacter != null)
|
||
{
|
||
//取消注册事件
|
||
AIController aiController = aiCharacter.GetComponent<AIController>();
|
||
if (aiController != null)
|
||
{
|
||
aiController.OnIntroductionComplete -= StartGameAfterIntroduction;
|
||
}
|
||
|
||
Destroy(aiCharacter);
|
||
}
|
||
}
|
||
|
||
private void Update()
|
||
{
|
||
if (Input.GetKeyDown(KeyCode.Space))
|
||
{
|
||
curBoss.Dead();
|
||
}
|
||
}
|
||
|
||
public void PlaySound2D(string soundName)
|
||
{
|
||
MasterAudio.PlaySound(soundName);
|
||
}
|
||
|
||
public void PlaySound3D(string soundName, Transform tran, bool isStop=false)
|
||
{
|
||
if(isStop)
|
||
MasterAudio.StopAllSoundsOfTransform(tran);
|
||
MasterAudio.PlaySound3DAtTransform(soundName, tran);
|
||
}
|
||
} |