FightingManager.cs 33 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084
  1. using UnityEngine;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine.UI;
  5. using System;
  6. namespace YLBattle
  7. {
  8. /// <summary>
  9. /// 战斗管理者
  10. /// </summary>
  11. public partial class FightingManager : MonoSingleton<FightingManager>
  12. {
  13. #region 战斗结果
  14. /// <summary>
  15. /// 参展己方ID
  16. /// </summary>
  17. private List<string> mHeros = new List<string>();
  18. /// <summary>
  19. /// 星级
  20. /// </summary>
  21. private int mStar = 0;
  22. /// <summary>
  23. ///
  24. /// </summary>
  25. private int mBattleForever_leaveState = 0;
  26. #endregion
  27. #region 关卡变量(pve)
  28. /// <summary>
  29. /// 战斗关卡
  30. /// </summary>
  31. private int mGateId = 0;
  32. /// <summary>
  33. /// 波次总数
  34. /// </summary>
  35. private int mLevelTotal = 0;
  36. /// <summary>
  37. /// 当前波次
  38. /// </summary>
  39. private int mLevelState = 0;
  40. /// <summary>
  41. /// 当前关卡难度
  42. /// </summary>
  43. private int mLevelDif = 0;
  44. /// <summary>
  45. /// 购买buff需要的金钱
  46. /// </summary>
  47. private int mBuyBuffGold = 0;
  48. /// <summary>
  49. /// 关卡名称
  50. /// </summary>
  51. private string mLevelName = string.Empty;
  52. /// <summary>
  53. /// 关卡模式 [0=普通关卡 1=无穷尽 2=pvp 3=test 4=guide]
  54. /// </summary>
  55. private int mLevelMode = 0;
  56. /// <summary>
  57. /// 副本ID
  58. /// </summary>
  59. private int mCarbonId = 0;
  60. #endregion
  61. #region 关卡变量(pvp)
  62. /// <summary>
  63. ///
  64. /// </summary>
  65. private string mPvpPlayerUID = string.Empty;
  66. /// <summary>
  67. ///
  68. /// </summary>
  69. private string mPvpType = string.Empty;
  70. #endregion
  71. #region 变量
  72. /// <summary>
  73. /// 战斗者列表
  74. /// </summary>
  75. private Dictionary<string, Fighter> mFighterList = new Dictionary<string, Fighter>();
  76. /// <summary>
  77. /// 战斗者ID对应的TID
  78. /// </summary>
  79. private Dictionary<string, string> mFighterTIDs = new Dictionary<string, string>();
  80. /// <summary>
  81. /// 战斗者ID对应的IID
  82. /// </summary>
  83. private Dictionary<string, string> mFighterIIDs = new Dictionary<string, string>();
  84. /// <summary>
  85. /// 援军IID
  86. /// </summary>
  87. private Dictionary<int, string> mFriendIIDs = new Dictionary<int, string>();
  88. /// <summary>
  89. /// UFF 资源对象表
  90. /// </summary>
  91. private Dictionary<string, GameObject> mBuffEffTemplate = new Dictionary<string, GameObject>();
  92. /// <summary>
  93. /// 战斗外部数据接口
  94. /// </summary>
  95. private IBattleGlobalOper mBFM = null;
  96. /// <summary>
  97. /// 是否更新
  98. /// </summary>
  99. private bool mUpdate = false;
  100. /// <summary>
  101. /// 是否暂停
  102. /// </summary>
  103. private bool mGetFocus = false;
  104. /// <summary>
  105. /// 是否开启连击模式
  106. /// </summary>
  107. private bool mOpenAombos = false;
  108. /// <summary>
  109. /// 上次连击操作点击时间
  110. /// </summary>
  111. private float mLastClick = 0f;
  112. #endregion
  113. #region 属性(对外)
  114. /// <summary>
  115. /// 是否暂停
  116. /// </summary>
  117. private bool isPause = false;
  118. /// <summary>
  119. /// 战斗结束
  120. /// </summary>
  121. private bool isGameOver = false;
  122. #endregion
  123. /// <summary>
  124. /// 实例
  125. /// </summary>
  126. static FightingManager mInstance;
  127. /// <summary>
  128. /// 获取单键
  129. /// </summary>
  130. /// <returns>单键实例</returns>
  131. public static FightingManager Instance
  132. {
  133. get
  134. {
  135. if (mInstance == null)
  136. {
  137. GameObject obj = GameObject.Find("FightingManager");
  138. if (obj != null)
  139. {
  140. mInstance = obj.AddComponent<FightingManager>();
  141. obj.AddComponent<InApplication>();
  142. }
  143. }
  144. return mInstance;
  145. }
  146. }
  147. /// <summary>
  148. /// 设置暂停
  149. /// </summary>
  150. /// <param name="_pause"></param>
  151. public void SetGameOver(bool _over)
  152. {
  153. this.isGameOver = _over;
  154. }
  155. /// <summary>
  156. /// 设置暂停
  157. /// </summary>
  158. /// <param name="_pause"></param>
  159. public void SetPause(bool _pause)
  160. {
  161. this.isPause = _pause;
  162. if (this.isPause)
  163. {
  164. this.FightingPause();
  165. }
  166. else
  167. {
  168. this.FightingContinue();
  169. }
  170. }
  171. /// <summary>
  172. /// 战斗暂停
  173. /// </summary>
  174. public void FightingPause()
  175. {
  176. //TimeScale.Instance().Pause();
  177. //if (this.mBFM != null)
  178. //{
  179. // this.mBFM.Pause();
  180. //}
  181. }
  182. /// <summary>
  183. /// 战斗继续
  184. /// </summary>
  185. public void FightingContinue()
  186. {
  187. //if (this.isPause && this.isGameOver == false)
  188. //{
  189. // return;
  190. //}
  191. //TimeScale.Instance().PauseOver();
  192. //if (this.mBFM != null)
  193. //{
  194. // this.mBFM.Continue();
  195. //}
  196. }
  197. /// <summary>
  198. /// 更新
  199. /// </summary>
  200. void Update()
  201. {
  202. #region 总开关
  203. if (!mUpdate)
  204. {
  205. return;
  206. }
  207. GameBattleManager.Instance().Update();
  208. #endregion
  209. if (InApplication.Instance.Focus != this.mGetFocus)
  210. {
  211. this.mGetFocus = InApplication.Instance.Focus;
  212. if (this.mGetFocus)
  213. {
  214. this.FightingContinue();
  215. }
  216. else
  217. {
  218. this.FightingPause();
  219. }
  220. }
  221. #region //是否打开连击模式
  222. if (this.mOpenAombos == false)
  223. {
  224. return;
  225. }
  226. //如果左键按下
  227. if (Input.GetMouseButtonDown(0))
  228. {
  229. //从主这相机到鼠标点发射一条射线
  230. Ray ray = CameraManager.Instance.SenceCamara.ScreenPointToRay(Input.mousePosition);
  231. //接受射线返回的碰撞信息
  232. RaycastHit hitInfo;
  233. //如果射线碰撞到东西
  234. if (Physics.Raycast(ray, out hitInfo))
  235. {
  236. // if (hitInfo.collider.gameObject.tag == "BattleMonster")
  237. if (hitInfo.collider.gameObject.CompareTag("BattleMonster"))
  238. {
  239. Fighter fighter = hitInfo.collider.gameObject.GetComponent<Fighter>();
  240. if (fighter != null && fighter.IsDead == false)
  241. {
  242. fighter.SetLianjiEffect(true);
  243. this.mLastClick = Time.realtimeSinceStartup;
  244. SkillControl.Instance.createPosEffect(fighter.mID, "UI_SKILL_dianji", fighter.mBodyCenterPos, 2, 1.0f);
  245. this.mBFM.ConfirmUIClickCritical(hitInfo.collider.gameObject.GetComponent<Fighter>().mID);
  246. }
  247. }
  248. }
  249. }
  250. bool _showEffect = Time.realtimeSinceStartup - this.mLastClick > BattleConst.BattleLianjiSpanTime;
  251. //fighter的特效更新
  252. foreach (Fighter f in this.mFighterList.Values)
  253. {
  254. if (f.IsDead == false && f.mTeam == EBattleTeam.REDTEAM)
  255. {
  256. f.SetLianjiEffect(_showEffect);
  257. }
  258. }
  259. #endregion
  260. }
  261. #region 战场动态
  262. /// <summary>
  263. /// 获取战斗操作接口
  264. /// </summary>
  265. /// <returns> IBattlingOpr 对象</returns>
  266. public IBattleGlobalOper FiledBattlingHandler()
  267. {
  268. return this.mBFM;
  269. }
  270. /// <summary>
  271. /// BattleManager=>设置本次战斗信息(波次初始化)
  272. /// </summary>
  273. /// <param name="bfm"> 对象管理器</param>
  274. /// <param name="scene">地图</param>
  275. internal void SetLevelInfo(IBattleGlobalOper op, string scene, string bg, int mode)
  276. {
  277. this.mLevelMode = mode;
  278. this.isGameOver = false;
  279. this.ClearAllFighter();
  280. ///清空技能数据和实例
  281. LogHelper.Log("清空技能数据和实例");
  282. if (SkillControl.Instance)
  283. {
  284. SkillControl.Instance.ClearAllSkill();
  285. }
  286. mBFM = op;
  287. SkillControl.Instance.SetOp(mBFM);
  288. if (this.mLevelState == 0)
  289. {
  290. FightingMap.Instance.SetMapMode(mode);
  291. ///初始化状态需要去加载地图
  292. FightingMap.Instance.GetState().ChangeState(EMapState.Loading, new List<string>() { bg, scene });
  293. }
  294. }
  295. /// <summary>
  296. /// 设置更新状态
  297. /// </summary>
  298. /// <param name="b">状态</param>
  299. public void SetUpdateState(bool _bolState)
  300. {
  301. mUpdate = _bolState;
  302. }
  303. /// <summary>
  304. /// 设置是否开启必杀状态
  305. /// </summary>
  306. /// <param name="_bol"></param>
  307. internal void SetCriticalState(bool _bol)
  308. {
  309. this.mOpenAombos = _bol;
  310. this.mLastClick = 0f;
  311. if (this.mOpenAombos == false)
  312. {
  313. foreach (Fighter f in this.mFighterList.Values)
  314. {
  315. if (f.IsDead == false && f.mTeam == EBattleTeam.REDTEAM)
  316. {
  317. f.SetLianjiEffect(false);
  318. }
  319. }
  320. }
  321. }
  322. /// <summary>
  323. /// Arrival.Enter=>设置关卡信息
  324. /// </summary>
  325. /// <param name="status"></param>
  326. internal void SetFightingLevelInfo(int _gateID, int _status, int total, int dif,
  327. string _gateName, int _buybuffgold, int _levelmode)
  328. {
  329. LogHelper.Log("........准备开始........:::波次::" + _status);
  330. this.mGateId = _gateID;
  331. this.mLevelState = _status;
  332. this.mLevelTotal = total;
  333. this.mLevelDif = dif;
  334. this.mLevelName = _gateName;
  335. this.mBuyBuffGold = _buybuffgold;
  336. this.mLevelMode = _levelmode;
  337. if (_status == 0)
  338. {
  339. //PlayerGuideManager.Instance.OnOutTrigger(EGuideEventType.EnterSence, new Dictionary<string, string>() { { "senceName", "Battle" } });
  340. UI_LoadingWindow.Instance().Hide();
  341. }
  342. }
  343. /// <summary>
  344. /// Arrival.Enter=>设置关卡信息
  345. /// </summary>
  346. /// <param name="status"></param>
  347. internal void SetPVPLevelInfo(int levelID, string pvpPlayerID, string pvpType)
  348. {
  349. LogHelper.Log("........准备开始........");
  350. this.mGateId = levelID;
  351. this.mPvpPlayerUID = pvpPlayerID;
  352. this.mPvpType = pvpType;
  353. this.mLevelMode = 2;
  354. UI_LoadingWindow.Instance().Hide();
  355. }
  356. /// <summary>
  357. /// Arrival=>战斗开始
  358. /// </summary>
  359. /// <param name="status">进度</param>
  360. internal void FightingStart(int _status)
  361. {
  362. LogHelper.Log("战斗开始,刷新界面数据......");
  363. this.OnShowBattleUI();
  364. BUI_TopUIWindow.Instance.SetData(this.mLevelState + 1, this.mLevelTotal, this.mLevelMode);
  365. BUI_BattleControl.Instance.SetBattleMode(this.mLevelMode);
  366. BUI_ButtomUIWindow.Instance.SetData(this.mLevelMode);
  367. BUI_FighterUIWindow.Instance.SetSlotData(this.mLevelMode);
  368. BUI_FighterUIWindow.Instance.SetLockedState(false);
  369. BUI_ButtomUIWindow.Instance.SetActive();
  370. BUI_BattleInfoBar.Instance.SetAcive();
  371. }
  372. /// <summary>
  373. /// 战斗计时刷新
  374. /// </summary>
  375. /// <param name="leftMil">剩余毫秒数</param>
  376. internal void BattleTime(long leftMil)
  377. {
  378. BUI_ButtomUIWindow.Instance.SetBattleTime((int)leftMil);
  379. }
  380. /// <summary>
  381. /// Leave=>下一场战斗
  382. /// </summary>
  383. internal void BattleLeave()
  384. {
  385. LogHelper.Log("------战场离开------");
  386. BUI_FighterUIWindow.Instance.SetLockedState(true);
  387. }
  388. /// <summary>
  389. /// 清除战斗资源
  390. /// </summary>
  391. public void ClearBattleBundle()
  392. {
  393. LogHelper.Log("------清除战斗资源------");
  394. ///战斗结果窗体
  395. BUI_MainWindow.Instance.UnloadAllBUIBundle();
  396. ///清理bundle,放在此,主要是为了避免战斗中有些技能或者其他效果未播放完毕,就被清理~~~(特效播放有延迟)
  397. ResourceHelper.Instance.UnloadAssetBundle("DragonBone_Mon");
  398. ResourceHelper.Instance.UnloadAssetBundle("DragonBone_Role");
  399. ResourceHelper.Instance.UnloadAssetBundle("UI_carbon_605021_siwang"); //死亡
  400. ResourceHelper.Instance.UnloadAssetBundle("SKILL_604001_Arrival"); //出场动画
  401. ResourceHelper.Instance.UnloadAssetBundle("UI_SKILL_kaishizhandou"); //开战动画
  402. ResourceHelper.Instance.UnloadAssetBundle("UI_SKILL_LianjiFiger");
  403. ResourceHelper.Instance.UnloadAssetBundle("UI_SKILL_dianji");
  404. //ResourceHelper.Instance.UnloadAssetBundle(IconPrefixConst.Battle_BossIcon);
  405. ResourceHelper.Instance.UnloadAssetBundle(IconPrefixConst.LianJi0_Icon);
  406. ResourceHelper.Instance.UnloadAssetBundle(IconPrefixConst.LianJi1_Icon);
  407. ResourceHelper.Instance.UnloadAssetBundle(IconPrefixConst.SkillNameIcon);
  408. ResourceHelper.Instance.UnloadAssetBundle(IconPrefixConst.Battle_BossIcon);
  409. this.ClearBuffBundle();
  410. FightingMap.Instance.UnloadMapBundle();
  411. foreach (string sID in this.mLoadedMonsterDragons)
  412. {
  413. FightingResManager.Instance.UnloadDragonBone(sID);
  414. }
  415. FightingResManager.Instance.Clear();
  416. this.mLoadedMonsterDragons.Clear();
  417. /// 清除延迟调用的函数
  418. //CancelInvoke("LateShowSuccessAniWindow");
  419. //CancelInvoke("LateShowFailAniWindow");
  420. CancelInvoke("LateShowBattleSuccessWindow");
  421. CancelInvoke("LateShowBattleFailWindow");
  422. //CancelInvoke("LateShowBattleForeverSuccessWindow");
  423. //CancelInvoke("LateShowBattleForeverFailWindow");
  424. CancelInvoke("LateShowBattlePVPSuccessWindow");
  425. CancelInvoke("LateShowBattlePVPFailWindow");
  426. }
  427. /// <summary>
  428. /// 清理战场(龙骨,UI隐藏,角色数据,地图归位
  429. /// </summary>
  430. public void ClearBattleData()
  431. {
  432. BUI_BattleInfoBar.Instance.Clear();
  433. this.ClearAllFighter();
  434. if (SkillControl.Instance)
  435. {
  436. SkillControl.Instance.ClearAllSkill();
  437. SkillControl.Instance.UnLoadAllBundle();
  438. }
  439. this.SetUpdateState(false);
  440. }
  441. #endregion
  442. #region 战斗结果
  443. /// <summary>
  444. /// 战斗失败
  445. /// </summary>
  446. /// <param name="levelid">本次战斗关卡id</param>
  447. /// <param name="record">伤害统计</param>
  448. public void BattleFailed(int levelid)
  449. {
  450. this.mGateId = levelid;
  451. this.isGameOver = true;
  452. AudioManager.Instance.PlayUISoundEffect(AudioManager.BattleSepcial_LoseSound);
  453. if (this.mLevelMode == 4) //引导
  454. {
  455. Invoke("LateShowGuideBattleWindow", 1.5f);
  456. }
  457. if (this.mLevelMode == 0)
  458. {
  459. //Invoke("LateShowFailAniWindow", 1.0f);
  460. Invoke("LateShowBattleFailWindow", 1.0f);
  461. }
  462. if (this.mLevelMode == 1)
  463. {
  464. if (this.mLevelState == 0)
  465. {
  466. Invoke("LateShowBattleForeverFailWindow", 1.0f);
  467. }
  468. else
  469. {
  470. Invoke("LateShowBattleForeverSuccessWindow", 1.0f);
  471. }
  472. }
  473. if (this.mLevelMode == 2)
  474. {
  475. Invoke("LateShowBattlePVPFailWindow", 1.0f);
  476. }
  477. if (this.mLevelMode == 3)
  478. {
  479. Invoke("LateShowFailAniWindow", 1.0f);
  480. }
  481. }
  482. /// <summary>
  483. /// 战斗胜利
  484. /// </summary>
  485. /// <param name="result">战斗结果信息</param>
  486. public void BattleVictory(IBattleResult result)
  487. {
  488. return;
  489. this.isGameOver = true;
  490. if (this.mLevelMode == 4)
  491. {
  492. Invoke("LateShowGuideBattleWindow", 1.5f);
  493. }
  494. mHeros = new List<string>();
  495. for (int i = 0; i < result.BlueTeamFighter().Count; ++i)
  496. {
  497. mHeros.Add(result.BlueTeamFighter()[i].IID());
  498. }
  499. this.mStar = result.Star();
  500. this.mLevelDif = result.Diflv();
  501. this.mGateId = result.LevelID();
  502. this.mCarbonId = result.CarbonID();
  503. this.mBattleForever_leaveState = result.BattleForever_leaveState();
  504. AudioManager.Instance.PlayUISoundEffect(AudioManager.BattleSepcial_WinSound);
  505. if (this.mLevelMode == 0)
  506. {
  507. //Invoke("LateShowSuccessAniWindow", 1.0f);
  508. // Invoke("LateShowBattleSuccessWindow", 1.0f);
  509. }
  510. if (this.mLevelMode == 1)
  511. {
  512. Invoke("LateShowBattleForeverSuccessWindow", 1.0f);
  513. }
  514. if (this.mLevelMode == 2)
  515. {
  516. Invoke("LateShowBattlePVPSuccessWindow", 1.0f);
  517. }
  518. //if (this.mLevelMode == 3)
  519. //{
  520. // Invoke("LateShowSuccessAniWindow", 1.0f);
  521. //}
  522. }
  523. /// <summary>
  524. /// 战斗超时
  525. /// </summary>
  526. /// <param name="levelid">本次战斗关卡id</param>
  527. /// <param name="record">伤害统计</param>
  528. public void BattleTimeOut(int levelid)
  529. {
  530. this.isGameOver = true;
  531. this.mGateId = levelid;
  532. //Invoke("LateShowFailAniWindow", 1.0f);
  533. Invoke("LateShowBattleFailWindow", 2.5f);
  534. }
  535. #endregion
  536. #region Map
  537. /// <summary>
  538. /// 技能触发的地图被攻击动作(Bomb阶段)
  539. /// </summary>
  540. /// <param name="lv"></param>
  541. public void SetMapDraging(int shakeType)
  542. {
  543. FightingMap.Instance.GetState().ChangeState(EMapState.Drag, shakeType);
  544. }
  545. /// <summary>
  546. /// 技能触发的地图被攻击动作(Bomb阶段)
  547. /// </summary>
  548. /// <param name="lv"></param>
  549. public void SetMapShaking(int shakeType)
  550. {
  551. FightingMap.Instance.SetShaking(shakeType);
  552. }
  553. /// <summary>
  554. /// 地图行为
  555. /// </summary>
  556. /// <param name="who"></param>
  557. public void SetMapMove(string who)
  558. {
  559. if (FightingMap.Instance.Locked)
  560. {
  561. return;
  562. }
  563. if (mFighterList.ContainsKey(who))
  564. {
  565. if (mFighterList[who].mTeam == EBattleTeam.REDTEAM)
  566. {
  567. #region old 角色在地图转动时的隐藏效果
  568. //int hideSeat = -1;
  569. //if (mFighterList[who].mSeat == 1)
  570. //{
  571. // hideSeat = 2;
  572. //}
  573. //if (mFighterList[who].mSeat == 2)
  574. //{
  575. // hideSeat = 1;
  576. //}
  577. //foreach (Fighter f in mFighterList.Values)
  578. //{
  579. // if (f.mTeam != EBattleTeam.REDTEAM || f.IsDead == true)
  580. // {
  581. // continue;
  582. // }
  583. // if (f.mSeat != hideSeat)
  584. // {
  585. // BUI_BattleInfoBar.Instance.SetFade(false, f.mID);
  586. // f.SetLight();
  587. // }
  588. // else
  589. // {
  590. // BUI_BattleInfoBar.Instance.SetFade(true, f.mID);
  591. // f.SetDark();
  592. // }
  593. //}
  594. #endregion
  595. FightingMap.Instance.GetState().ChangeState(EMapState.Move, mFighterList[who].mSeat);
  596. }
  597. }
  598. else
  599. {
  600. FightingMap.Instance.GetState().ChangeState(EMapState.Move, 0);
  601. //foreach (Fighter f in mFighterList.Values)
  602. //{
  603. // if (f.mTeam != EBattleTeam.REDTEAM || f.IsDead == true)
  604. // {
  605. // continue;
  606. // }
  607. // BUI_BattleInfoBar.Instance.SetFade(false, f.mID);
  608. // f.SetLight();
  609. //}
  610. }
  611. }
  612. /// <summary>
  613. /// 锁定地图状态
  614. /// </summary>
  615. /// <param name="_bol"></param>
  616. internal void SetMapLock(bool _bol)
  617. {
  618. FightingMap.Instance.SetLock(_bol);
  619. }
  620. /// <summary>
  621. /// Arrival.Enter=>设置地图平板的状态
  622. /// </summary>
  623. /// <param name="status"></param>
  624. internal void SetMapPlatState(int _status, string _aniName)
  625. {
  626. FightingMap.Instance.GetState().ChangeState((EMapState)_status, _aniName);
  627. }
  628. /// <summary>
  629. /// Arrival.IsComplete=>转盘是否处于指定状态
  630. /// </summary>
  631. /// <returns></returns>
  632. internal bool CheckMapState(EMapState state)
  633. {
  634. return FightingMap.Instance.GetState().GetCurrentState().Type() == state;
  635. }
  636. #endregion
  637. #region Fighter操作
  638. /// <summary>
  639. /// 进入攻击状态
  640. /// </summary>
  641. /// <param name="_strWhoId">攻击者</param>
  642. /// <param name="_strSkill">技能ID</param>
  643. /// <param name="_atkactiontype">攻击动作</param>
  644. public void FighterAttack(string _who, string _strSkill, int _atkactiontype)
  645. {
  646. if (mFighterList.ContainsKey(_who))
  647. {
  648. mFighterList[_who].SetAttack(_strSkill, _atkactiontype);
  649. }
  650. }
  651. /// <summary>
  652. /// 目标受伤
  653. /// </summary>
  654. /// <param name="who"></param>
  655. public void BattleFighterBeHit(string who, int _atkactiontype = 0)
  656. {
  657. if (mFighterList.ContainsKey(who))
  658. {
  659. AudioManager.Instance.PlayHeroSound(this.mFighterList[who].mTID, this.mFighterList[who].mBeattackSound, ESoundType.HERO_SOUND_BEATTACK);
  660. if (mFighterList[who].mTeam == EBattleTeam.BLUETEAM)
  661. {
  662. BUI_FighterUIWindow.Instance.GetFighterSlot(who).SetHit();
  663. }
  664. else
  665. {
  666. mFighterList[who].SetHit();
  667. /**
  668. * 增加地图配合动画(向后拉)
  669. */
  670. FightingMap.Instance.GetState().ChangeState(EMapState.BeHit, null);
  671. }
  672. }
  673. }
  674. /// <summary>
  675. /// 目标被选择
  676. /// </summary>
  677. /// <param name="who"></param>
  678. public void BattleFighterBeSelect(string who, bool isSelect = false)
  679. {
  680. if (mFighterList.ContainsKey(who))
  681. {
  682. Fighter fighter = mFighterList[who];
  683. if (fighter.mTeam == EBattleTeam.BLUETEAM)
  684. {
  685. if (isSelect)
  686. {
  687. BUI_FighterUIWindow.Instance.GetFighterSlot(who).SetBeSelect();
  688. }
  689. else
  690. {
  691. BUI_FighterUIWindow.Instance.GetFighterSlot(who).SetBeForget();
  692. }
  693. }
  694. else
  695. {
  696. if (isSelect)
  697. {
  698. SkillControl.Instance.createPosEffect(mFighterList[who].mID, "UI_SKILL_beijitishi", Vector3.zero, 1, 1.20f);
  699. //fighter.SetBeSelect();
  700. }
  701. else
  702. {
  703. fighter.SetBeForget();
  704. }
  705. }
  706. }
  707. }
  708. /// <summary>
  709. /// 目标死亡
  710. /// </summary>
  711. /// <param name="who"></param>
  712. public void BattleFighterBeDead(string who)
  713. {
  714. if (mFighterList.ContainsKey(who))
  715. {
  716. mFighterList[who].SetDead();
  717. BUI_BattleInfoBar.Instance.SetDead(who);
  718. ///己方,通知管理是否有队友支援
  719. if (mFighterList[who].mTeam == EBattleTeam.BLUETEAM)
  720. {
  721. this.mBFM.SetFriendHelp(mFighterList[who].mSeat);
  722. }
  723. ///敌方,播放死亡动画
  724. if (mFighterList[who].mTeam == EBattleTeam.REDTEAM)
  725. {
  726. SkillControl.Instance.createPosEffect(mFighterList[who].mID, "UI_carbon_605021_siwang", Vector3.zero, 1, 1.0f);
  727. }
  728. }
  729. else
  730. {
  731. LogHelper.LogError("someOne is not exist...." + who);
  732. }
  733. // ------------------------ 新手引导 ----------------------------------------
  734. //GuideStepAdapter adp = PlayerGuideServer.Instance.GetCurtNoviceNodeType(EGuideEventType.FighterDead);
  735. //if (adp != null && adp.TriggerEventType == EGuideEventType.FighterDead)
  736. //{
  737. // adp.mNoviceEvent(gameObject, mFighterList[who].mTID);
  738. //}
  739. // ------------------------ 新手引导 ----------------------------------------
  740. }
  741. /// <summary>
  742. /// 目标等待
  743. /// </summary>
  744. /// <param name="who"></param>
  745. public void BattleFighterDisapper(string who)
  746. {
  747. if (mFighterList.ContainsKey(who))
  748. {
  749. if (mFighterList[who].mTeam == EBattleTeam.REDTEAM)
  750. {
  751. mFighterList[who].SetDisapper();
  752. }
  753. }
  754. }
  755. public void BattleFighterLight(string who)
  756. {
  757. if (mFighterList.ContainsKey(who))
  758. {
  759. BUI_BattleInfoBar.Instance.SetFade(false, mFighterList[who].mID);
  760. mFighterList[who].SetLight();
  761. }
  762. }
  763. public void BattleFigherDark(string who)
  764. {
  765. if (mFighterList.ContainsKey(who))
  766. {
  767. BUI_BattleInfoBar.Instance.SetFade(true, mFighterList[who].mID);
  768. mFighterList[who].SetDark();
  769. }
  770. }
  771. /// <summary>
  772. /// 目标隐藏
  773. /// </summary>
  774. /// <param name="who"></param>
  775. public void BattleFighterHidden(string who)
  776. {
  777. if (mFighterList.ContainsKey(who))
  778. {
  779. mFighterList[who].SetHidden();
  780. }
  781. }
  782. /// <summary>
  783. /// 目标显示及出场
  784. /// </summary>
  785. /// <param name="who"></param>
  786. public void BattleFighterArrival(string who, bool boleffect)
  787. {
  788. if (mFighterList.ContainsKey(who))
  789. {
  790. mFighterList[who].SetArrival();
  791. }
  792. if (boleffect)
  793. {
  794. SkillControl.Instance.createPosEffect(mFighterList[who].mID, "SKILL_604001_Arrival", Vector3.zero, 0, 2.6f);
  795. }
  796. }
  797. /// <summary>
  798. /// 进入静止状态
  799. /// </summary>
  800. /// <param name="_strId">who</param>
  801. /// <param name="_force">是否强制执行静止状态</param>
  802. public void BattleFighterIdle(string who, bool _force)
  803. {
  804. if (mFighterList.ContainsKey(who))
  805. {
  806. mFighterList[who].SetIdle(_force);
  807. }
  808. }
  809. /// <summary>
  810. /// 进入特定动画状态
  811. /// </summary>
  812. /// <param name="_strId">who</param>
  813. /// <param name="_strAniName">动画名字</param>
  814. /// <param name="ac">回调</param>
  815. public void BattleSpecialAni(string who, string _strAniName = "", Action ac = null)
  816. {
  817. if (mFighterList.ContainsKey(who))
  818. {
  819. if (_strAniName.Length <= 0)
  820. {
  821. //Debug.LogError("re false");
  822. mFighterList[who].SetActiveBodyTexture(false);
  823. }
  824. else
  825. {
  826. mFighterList[who].SetActiveBodyTexture(true, "Attack", () =>
  827. {
  828. if (ac != null)
  829. {
  830. ac.Invoke();
  831. }
  832. });
  833. }
  834. }
  835. }
  836. #endregion
  837. #region Buff
  838. /// <summary>
  839. /// 添加一个BUFF 缓存
  840. /// </summary>
  841. /// <param name="name"></param>
  842. public void AddOneBuffCache(string name)
  843. {
  844. ResourceHelper.Instance.LoadAssetBundle(name, ab =>
  845. {
  846. if (ab != null && !mBuffEffTemplate.ContainsKey(name))
  847. {
  848. //LogHelper.LogError("###加载buff资源" + name);
  849. GameObject buffEff = ab.LoadAsset<GameObject>(name);
  850. mBuffEffTemplate.Add(name, buffEff);
  851. }
  852. });
  853. }
  854. /// <summary>
  855. /// 增加icon
  856. /// </summary>
  857. /// <param name="who"></param>
  858. public void AddNewBuffRes(string who, int iid, string res)
  859. {
  860. if (!mFighterList.ContainsKey(who))
  861. {
  862. return;
  863. }
  864. SkillControl.Instance.createPosEffect(who, res, Vector3.zero, 0);
  865. }
  866. /// <summary>
  867. /// 增加icon
  868. /// </summary>
  869. /// <param name="who"></param>
  870. public void AddNewBuffIcon(string who, int iid, string tid, string icon)
  871. {
  872. if (mFighterList.ContainsKey(who))
  873. {
  874. GameObject buffObj = null;
  875. if (!this.mBuffEffTemplate.ContainsKey(icon))
  876. {
  877. return;
  878. }
  879. else
  880. {
  881. buffObj = this.mBuffEffTemplate[icon];
  882. }
  883. if (mFighterList[who].mTeam == EBattleTeam.REDTEAM)
  884. {
  885. BUI_BattleUIMovedInfoBar A = BUI_BattleInfoBar.Instance.GetFighterBar(who);
  886. if (A != null)
  887. {
  888. A.AddBuff(tid, iid, buffObj);
  889. }
  890. else
  891. {
  892. //Debug.LogError("血条Null id=" + who);
  893. }
  894. }
  895. else
  896. {
  897. BUI_FighterUIWindow.Instance.GetFighterSlot(who).AddBuff(tid, iid, buffObj);
  898. }
  899. }
  900. }
  901. /// <summary>
  902. /// 删除icon
  903. /// </summary>
  904. /// <param name="who"></param>
  905. /// <param name="iid"></param>
  906. public void RemoveBuffIcon(string who, int iid)
  907. {
  908. if (mFighterList.ContainsKey(who))
  909. {
  910. if (mFighterList[who].mTeam == EBattleTeam.REDTEAM)
  911. {
  912. BUI_BattleUIMovedInfoBar bar = BUI_BattleInfoBar.Instance.GetFighterBar(who);
  913. if (bar != null)
  914. {
  915. bar.DelBuff(iid);
  916. }
  917. }
  918. else
  919. {
  920. BUI_FighterUIWindow.Instance.GetFighterSlot(who).DelBuff(iid);
  921. }
  922. }
  923. }
  924. /// <summary>
  925. /// 清除所有buff的bundle
  926. /// </summary>
  927. public void ClearBuffBundle()
  928. {
  929. foreach (KeyValuePair<string, GameObject> keyvalue in this.mBuffEffTemplate)
  930. {
  931. ResourceHelper.Instance.UnloadAssetBundle(keyvalue.Key);
  932. }
  933. this.mBuffEffTemplate.Clear();
  934. }
  935. #endregion
  936. }
  937. }