BattleSystemNew.cs 76 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425
  1. using UnityEngine;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using LuaInterface;
  5. using Mono.Xml;
  6. public class BattleMgr : SingletonMono<BattleMgr>
  7. {
  8. public delegate void DoSomethingCallback(object arg);
  9. public static int c_updateFPS = 30;
  10. public static float c_targetFrameTime = 1.0f / (float)c_updateFPS;
  11. public static float speed_up_rate = 1f;
  12. public static Vector3 s_reward_pos = Vector3.zero;
  13. private bool m_bIsShutDown = false;
  14. private Dictionary<int, BattleStatistics> mBattleStatisticDic = new Dictionary<int, BattleStatistics>();
  15. private Dictionary<long, string> mBattleRecordList = new Dictionary<long, string>();
  16. #region fields
  17. public bool IsCameraDoingStart
  18. {
  19. get { return BattleCamera.Instance != null && BattleCamera.Instance.IsDoingSpecialCamera; }
  20. }
  21. private bool mInFighting = false;
  22. public bool InFighting { get { return mInFighting; } }
  23. private bool bShowBossIntroEnd = false;
  24. public bool ShowBossIntroEnd
  25. {
  26. get { return bShowBossIntroEnd; }
  27. set { bShowBossIntroEnd = value; }
  28. }
  29. BaseBattle mBattle;
  30. public BaseBattle Battle { get { return mBattle; } }
  31. [HideInInspector]
  32. public LuaTable LuaBattleMgr
  33. {
  34. set { mLuaBattleMgr = value; }
  35. get { return mLuaBattleMgr; }
  36. }
  37. private LuaTable mLuaVersusMgr;
  38. public LuaTable LuaTowerMgr
  39. {
  40. get { return mLuaVersusMgr; }
  41. set { mLuaVersusMgr = value; }
  42. }
  43. private LuaTable mLuaBossBattleMgr;
  44. public LuaTable LuaBossBattleMgr
  45. {
  46. get { return mLuaBossBattleMgr; }
  47. set { mLuaBossBattleMgr = value; }
  48. }
  49. private LuaTable mLuaTimeBattleMgr;
  50. public LuaTable LuaTimeBattleMgr
  51. {
  52. get { return mLuaTimeBattleMgr; }
  53. set { mLuaTimeBattleMgr = value; }
  54. }
  55. private LevelItem mCurrentLevelItem;
  56. private LuaTable mLuaBattleMgr = null;
  57. public int CurExp
  58. {
  59. get { return (mCurrentLevelItem != null) ? mCurrentLevelItem.Exp : 0; }
  60. }
  61. public int CurParnterExp
  62. {
  63. get { return (mCurrentLevelItem != null) ? mCurrentLevelItem.PartnerExp : 0; }
  64. }
  65. public int CurZeny
  66. {
  67. get { return (mCurrentLevelItem != null) ? mCurrentLevelItem.Zeny : 0; }
  68. }
  69. public int CurCruise
  70. {
  71. get { return (mCurrentLevelItem != null) ? mCurrentLevelItem.CruiseVal : 0; }
  72. }
  73. public int CurGold
  74. {
  75. get { return (mCurrentLevelItem != null) ? mCurrentLevelItem.Gold : 0; }
  76. }
  77. public int CurEvil
  78. {
  79. get { return (mCurrentLevelItem != null) ? mCurrentLevelItem.Evil : 0; }
  80. }
  81. public int ChallengeLevel
  82. {
  83. get { return (mCurrentLevelItem != null) ? mCurrentLevelItem.ChallengeLv : 0; }
  84. }
  85. public bool IsKillBoss
  86. {
  87. get { return mBattle != null && mBattle.CurBattleField != null && mBattle.CurBattleField.killBoss; }
  88. }
  89. public float FightingTime
  90. {
  91. get { return (mBattle != null && mBattle.CurBattleField != null) ? mBattle.CurBattleField.FightingTime : 0; }
  92. }
  93. public override void InitMgr()
  94. {
  95. base.InitMgr();
  96. }
  97. public bool IsRotatingCam
  98. {
  99. get; private set;
  100. }
  101. private List<int> mCommonEffectIds = new List<int>();
  102. public List<int> CommonEffectIds
  103. {
  104. get { return mCommonEffectIds; }
  105. }
  106. public bool SkillDirty
  107. {
  108. get { return skillDirty; }
  109. }
  110. public bool TeamDirty
  111. {
  112. get { return teamDataDirty; }
  113. }
  114. protected override void Dispose()
  115. {
  116. EventMgr.RemoveEventListener<ValType[]>(ECoreEventType.EID_Click_Challenge, OnChallengeBoss);
  117. EventMgr.RemoveEventListener<Fighter>(ECoreEventType.EID_BOSS_SPAWNED, OnBossSpawned);
  118. EventMgr.RemoveEventListener<Fighter>(ECoreEventType.EID_CLONE_NEW_BOSS, OnCloneNewBoss);
  119. EventMgr.RemoveEventListener<string>(ECoreEventType.EID_BATTLE_NEW_NEXT_WAVE, OnBattleNewWave);
  120. EventMgr.RemoveEventListener<bool>(ECoreEventType.EID_BATTLE_CONTINUE_WAVE, OnContinueBattle);
  121. EventMgr.RemoveEventListener<bool>(ECoreEventType.EID_BEGIN_BOSS_RAGE_TIME, OnShowBossRage);
  122. EventMgr.RemoveEventListener<int>(ECoreEventType.EID_SHOW_BOSS_RAGE_LEFTTIME, OnShowBossRageLeftTime);
  123. EventMgr.RemoveEventListener<bool>(ECoreEventType.EID_BOSS_IN_RAGE, OnBossInRage);
  124. //EventMgr.RemoveEventListener<string>(ECoreEventType.EID_SHOW_SCENE_GO, OnSwitchScene);
  125. //EventMgr.RemoveEventListener<bool>(ECoreEventType.EID_RESTORE_SCENE, OnRestoreScene);
  126. EventMgr.RemoveEventListener<bool>(ECoreEventType.EID_FIGHTERS_LOAD_OK, OnLoadTeam);
  127. EventMgr.RemoveEventListener<bool>(ECoreEventType.EID_PREPARE_LOAD_OK, OnPrepareLoadOk);
  128. EventMgr.RemoveEventListener<bool>(ECoreEventType.EID_LOAD_BEGIN, OnLoadBegin);
  129. EventMgr.RemoveEventListener<bool>(ECoreEventType.EID_LOAD_COMPLETE, OnLoadComplete);
  130. EventMgr.RemoveEventListener<float>(ECoreEventType.EID_LOAD_PROGRESS, OnLoadProgress);
  131. EventMgr.RemoveEventListener<UIEventParamFighterHurt>(ECoreEventType.EID_FIGHTER_HURT, OnFighterHurt);
  132. EventMgr.RemoveEventListener<CastSkillData>(ECoreEventType.EID_Refresh_Skill, OnFighterCastSkill);
  133. EventMgr.RemoveEventListener<Fighter>(ECoreEventType.EID_FIGHTER_LIFE_CHANGED, OnFighterLifeChanged);
  134. EventMgr.RemoveEventListener<Fighter>(ECoreEventType.EID_FIGHTER_ENERGY_CHAGNED, OnFighterEnergyChanged);
  135. EventMgr.RemoveEventListener<stBuffParam>(ECoreEventType.EID_SHOW_BUFF_ICON, OnShowBossBuffIcon);
  136. //EventMgr.RemoveEventListener<string>(ECoreEventType.EID_SHOW_DEBUFF_ICON, OnShowBossDebuffIcon);
  137. EventMgr.RemoveEventListener<stBuffParam>(ECoreEventType.EID_REMOVE_BUFF_ICON, OnRemoveBuffIcon);
  138. EventMgr.RemoveEventListener<SkillCDParam>(ECoreEventType.EID_REFRESH_SKILL_CD, OnFighterSkillCDChanged);
  139. EventMgr.RemoveEventListener<Fighter>(ECoreEventType.EID_SHOW_FIGHTER, OnShowFighter);
  140. EventMgr.RemoveEventListener<string>(ECoreEventType.EID_PLAY_SKILL_PREFAB, OnShowSkillPrefab);
  141. EventMgr.RemoveEventListener<string>(ECoreEventType.EID_CLOSE_SKILL_PREFAB, OnCloseSkillPrefab);
  142. EventMgr.RemoveEventListener<bool>(ECoreEventType.EID_BattleUI_Visible, OnBattleUIVis);
  143. EventMgr.RemoveEventListener<Vector2>(ECoreEventType.EID_START_MOVE_MOUSE, OnStartMoveMouse);
  144. //EventMgr.RemoveEventListener<Vector2>(ECoreEventType.EID_MOUSE_DELTA, OnMouseMove);
  145. EventMgr.RemoveEventListener<Vector2>(ECoreEventType.EID_END_MOVE_MOUSE, OnEndMoveMouse);
  146. EventMgr.RemoveEventListener<bool>(ECoreEventType.EID_REPLAY_BATTLE_LOADOK, OnReplayBattleLoadedOk);
  147. base.Dispose();
  148. }
  149. protected override void OnApplicationQuit()
  150. {
  151. base.OnApplicationQuit();
  152. }
  153. #endregion
  154. void Start()
  155. {
  156. EventMgr.AddEventListener<ValType[]>(ECoreEventType.EID_Click_Challenge, OnChallengeBoss);
  157. EventMgr.AddEventListener<Fighter>(ECoreEventType.EID_BOSS_SPAWNED, OnBossSpawned);
  158. EventMgr.AddEventListener<Fighter>(ECoreEventType.EID_CLONE_NEW_BOSS, OnCloneNewBoss);
  159. EventMgr.AddEventListener<string>(ECoreEventType.EID_BATTLE_NEW_NEXT_WAVE, OnBattleNewWave);
  160. EventMgr.AddEventListener<bool>(ECoreEventType.EID_BATTLE_CONTINUE_WAVE, OnContinueBattle);
  161. EventMgr.AddEventListener<bool>(ECoreEventType.EID_BEGIN_BOSS_RAGE_TIME, OnShowBossRage);
  162. EventMgr.AddEventListener<int>(ECoreEventType.EID_SHOW_BOSS_RAGE_LEFTTIME, OnShowBossRageLeftTime);
  163. EventMgr.AddEventListener<bool>(ECoreEventType.EID_BOSS_IN_RAGE, OnBossInRage);
  164. //EventMgr.AddEventListener<string>(ECoreEventType.EID_SHOW_SCENE_GO, OnSwitchScene);
  165. //EventMgr.AddEventListener<bool>(ECoreEventType.EID_RESTORE_SCENE, OnRestoreScene);
  166. EventMgr.AddEventListener<bool>(ECoreEventType.EID_FIGHTERS_LOAD_OK, OnLoadTeam);
  167. EventMgr.AddEventListener<bool>(ECoreEventType.EID_PREPARE_LOAD_OK, OnPrepareLoadOk);
  168. EventMgr.AddEventListener<bool>(ECoreEventType.EID_LOAD_BEGIN, OnLoadBegin);
  169. EventMgr.AddEventListener<bool>(ECoreEventType.EID_LOAD_COMPLETE, OnLoadComplete);
  170. EventMgr.AddEventListener<float>(ECoreEventType.EID_LOAD_PROGRESS, OnLoadProgress);
  171. EventMgr.AddEventListener<UIEventParamFighterHurt>(ECoreEventType.EID_FIGHTER_HURT, OnFighterHurt);
  172. EventMgr.AddEventListener<CastSkillData>(ECoreEventType.EID_Refresh_Skill, OnFighterCastSkill);
  173. EventMgr.AddEventListener<Fighter>(ECoreEventType.EID_FIGHTER_LIFE_CHANGED, OnFighterLifeChanged);
  174. EventMgr.AddEventListener<Fighter>(ECoreEventType.EID_FIGHTER_ENERGY_CHAGNED, OnFighterEnergyChanged);
  175. EventMgr.AddEventListener<stBuffParam>(ECoreEventType.EID_SHOW_BUFF_ICON, OnShowBossBuffIcon);
  176. //EventMgr.AddEventListener<string>(ECoreEventType.EID_SHOW_DEBUFF_ICON, OnShowBossDebuffIcon);
  177. EventMgr.AddEventListener<stBuffParam>(ECoreEventType.EID_REMOVE_BUFF_ICON, OnRemoveBuffIcon);
  178. EventMgr.AddEventListener<SkillCDParam>(ECoreEventType.EID_REFRESH_SKILL_CD, OnFighterSkillCDChanged);
  179. EventMgr.AddEventListener<Fighter>(ECoreEventType.EID_SHOW_FIGHTER, OnShowFighter);
  180. EventMgr.AddEventListener<string>(ECoreEventType.EID_PLAY_SKILL_PREFAB, OnShowSkillPrefab);
  181. EventMgr.AddEventListener<string>(ECoreEventType.EID_CLOSE_SKILL_PREFAB, OnCloseSkillPrefab);
  182. EventMgr.AddEventListener<bool>(ECoreEventType.EID_BattleUI_Visible, OnBattleUIVis);
  183. EventMgr.AddEventListener<Vector2>(ECoreEventType.EID_START_MOVE_MOUSE, OnStartMoveMouse);
  184. //EventMgr.AddEventListener<Vector2>(ECoreEventType.EID_MOUSE_DELTA, OnMouseMove);
  185. EventMgr.AddEventListener<Vector2>(ECoreEventType.EID_END_MOVE_MOUSE, OnEndMoveMouse);
  186. EventMgr.AddEventListener<bool>(ECoreEventType.EID_REPLAY_BATTLE_LOADOK, OnReplayBattleLoadedOk);
  187. Time.timeScale = speed_up_rate;
  188. Init();
  189. }
  190. void Init()
  191. {
  192. BattleFlyWordMgr.Instance.InitMgr();
  193. mRecordTime2 = Time.realtimeSinceStartup;
  194. }
  195. void Update()
  196. {
  197. if (null == mBattle)
  198. return;
  199. if (mBattle.IsShutDown)
  200. return;
  201. UpdateLogic();
  202. UpdateTrigger();
  203. UpdateElse();
  204. }
  205. float mNextActionTime;
  206. float mRecordTime2 = 0;
  207. float passedTime = 0;
  208. void UpdateLogic()
  209. {
  210. if (mBattle != null)
  211. {
  212. if (mNextActionTime > 0f)
  213. {
  214. mNextActionTime -= Time.deltaTime;
  215. passedTime += Time.deltaTime;
  216. }
  217. if (mNextActionTime > 0f)
  218. return;
  219. #if PROFILE
  220. UnityEngine.Profiling.Profiler.BeginSample("LogicBattle Update");
  221. #endif
  222. mBattle.Update(passedTime);
  223. EffectManager.Instance.Update(passedTime);
  224. #if PROFILE
  225. UnityEngine.Profiling.Profiler.EndSample();
  226. #endif
  227. mNextActionTime = c_targetFrameTime;
  228. passedTime = 0;
  229. }
  230. else
  231. {
  232. passedTime = 0;
  233. }
  234. }
  235. void UpdateTrigger()
  236. {
  237. if (mBattle != null && mBattle.globalTrigger != null)
  238. {
  239. mBattle.globalTrigger.UpdateLogic(Time.deltaTime);
  240. }
  241. }
  242. void UpdateElse()
  243. {
  244. if (mBattle != null)
  245. {
  246. #if PROFILE
  247. UnityEngine.Profiling.Profiler.BeginSample("BattleDropMgr Update");
  248. #endif
  249. BattleDropMgr.Instance.Update(Time.deltaTime);
  250. #if PROFILE
  251. UnityEngine.Profiling.Profiler.EndSample();
  252. #endif
  253. #if PROFILE
  254. UnityEngine.Profiling.Profiler.BeginSample("ScaleTimeInfo Update");
  255. #endif
  256. //ScaleTimeInfo.Instance.Update(Time.deltaTime);
  257. #if PROFILE
  258. UnityEngine.Profiling.Profiler.EndSample();
  259. #endif
  260. #if PROFILE
  261. UnityEngine.Profiling.Profiler.BeginSample("EffectManager Update");
  262. #endif
  263. //EffectManager.Instance.Update(Time.deltaTime);
  264. #if PROFILE
  265. UnityEngine.Profiling.Profiler.EndSample();
  266. #endif
  267. }
  268. }
  269. public BattleStatistics GetBattleStatistics(BattleMode mode, BattleSubMode subMode)
  270. {
  271. int type = ((int)mode) * 100 + ((int)subMode);
  272. BattleStatistics data;
  273. mBattleStatisticDic.TryGetValue(type, out data);
  274. return data;
  275. }
  276. public bool HasBattleStatistics(BattleMode mode, BattleSubMode subMode)
  277. {
  278. var data = GetBattleStatistics(mode, subMode);
  279. if (data == null) return false;
  280. return data.Exist;
  281. }
  282. public void SetSpeedUp(float speedUp)
  283. {
  284. if (speed_up_rate != speedUp)
  285. {
  286. speed_up_rate = speedUp;
  287. Time.timeScale = speed_up_rate;
  288. }
  289. }
  290. private void LateUpdate()
  291. {
  292. if (mBattle != null)
  293. {
  294. BattleCamera.Instance.Update(Time.deltaTime);
  295. }
  296. }
  297. public float GetLeftFightingTime()
  298. {
  299. if (mBattle == null) return 0;
  300. if (mBattle.IsTimeBattle)
  301. {
  302. return mBattle.CurBattleField.MaxFightingTime - mBattle.CurBattleField.FightingTime;
  303. }
  304. return 0;
  305. }
  306. public void SetMapLevelId(int mapId, int levelId)
  307. {
  308. if (mBattle != null && mBattle.CurLevelItem != null && mBattle is LogicBattle)
  309. {
  310. //(mBattle as LogicBattle)?.StartInfo.Reset(mapId,levelId);
  311. //LogicBattleStartInfo startInfo = new LogicBattleStartInfo(mapId, levelId);
  312. //Debug.Log($"============PreloadBattle=========={mapId} --- {levelId}");
  313. //ShutDownCurrentBattle();
  314. //StartBattle(startInfo);
  315. }
  316. }
  317. public void StartBattle(LogicBattleStartInfo startInfo)
  318. {
  319. try
  320. {
  321. List<BattleEndCondition> endConds = new List<BattleEndCondition>();
  322. BattleEndCondition con = new BattleEndCondition(Constants.EndBattle_By_UndeadCount, Constants.ResultType_Normal);
  323. endConds.Add(con);
  324. mCommonEffectIds.Clear();
  325. mBattle = new LogicBattle(startInfo, false, endConds);
  326. mBattle.Start();
  327. mCurrentLevelItem = mBattle.CurLevelItem;
  328. Debug.Log($"==============StartBattle== Bossid={mCurrentLevelItem.bossId}====={mCurrentLevelItem.MapId} --- {mCurrentLevelItem.LevelId}");
  329. SaveBattleStat();
  330. }
  331. catch (System.Exception e)
  332. {
  333. DebugHelper.LogError(e.StackTrace);
  334. }
  335. }
  336. public void StartVersusBattle(BattleSubMode mode, ActorData[] teamActors, ActorData[] enemyActors, string sceneName, float maxBattlingTime, BattleEndCondition[] endConds,
  337. GvGMark[] OurMarks, GvGMark[] EnemyMarks,bool IsPresspoint,int nPresspoint)
  338. {
  339. mCommonEffectIds.Clear();
  340. if (teamActors == null || enemyActors == null || string.IsNullOrEmpty(sceneName)) return;
  341. if (endConds == null || endConds.Length == 0) return;
  342. try
  343. {
  344. List<BattleEndCondition> conds = new List<BattleEndCondition>();
  345. conds.AddRange(endConds);
  346. ForceSyncSkill();
  347. TowerBattleInfo bi = TowerBattleCfgMgr.Instance.GetTowerBattleInfo();
  348. mBattle = new VersusBattle(mode, bi, teamActors, enemyActors, sceneName, maxBattlingTime, conds, OurMarks,EnemyMarks,IsPresspoint, nPresspoint);
  349. mBattle.Start();
  350. SaveBattleStat();
  351. }
  352. catch (System.Exception e)
  353. {
  354. DebugHelper.LogError(e.StackTrace);
  355. }
  356. }
  357. public void StartBossBattle(ActorData[] actors, int bossId, int sceneId, BattleEndCondition[] endConds)
  358. {
  359. mCommonEffectIds.Clear();
  360. if (actors == null || actors.Length == 0)
  361. {
  362. DebugHelper.LogError("传入的玩家信息为空");
  363. return;
  364. }
  365. if (bossId == 0)
  366. {
  367. DebugHelper.LogError("挑战的bossid不能为0");
  368. return;
  369. }
  370. if (sceneId == 0)
  371. {
  372. DebugHelper.LogError("挑战boss的boss场景id不能为0");
  373. return;
  374. }
  375. ForceSyncSkill();
  376. ActorData bossActor = ActorData.CreateNpcPlayerActor(bossId, bossId, 1);
  377. bossActor.IsBoss = true;
  378. if (!bossActor.valid)
  379. {
  380. DebugHelper.LogError(string.Format("挑战{0}boss配置正确,请查看npc配表", bossId));
  381. return;
  382. }
  383. if (endConds == null || endConds.Length == 0)
  384. {
  385. Debugger.LogError("战斗结束条件不能配置为空");
  386. return;
  387. }
  388. try
  389. {
  390. List<BattleEndCondition> conds = new List<BattleEndCondition>();
  391. conds.AddRange(endConds);
  392. mBattle = new BossBattle(actors, bossActor, sceneId, BattleSubMode.WorldBoss, conds);
  393. mBattle.Start();
  394. SaveBattleStat();
  395. }
  396. catch (System.Exception e)
  397. {
  398. DebugHelper.LogError(e.StackTrace);
  399. }
  400. }
  401. public bool StartTimeBattle(LuaTable luaTbl,
  402. BattleSubMode mode, float maxFightingTime, string sceneName, string bgmMusic,
  403. ActorData[] ourActors, ActorData[] enemyActors, ServerFighterParam[] fighterParams,
  404. BattleEndCondition[] endConds, ValType[] factors,int nRestoreSp, GvGMark[] OurMarks,
  405. GvGMark[] EnemyMarks)
  406. {
  407. if (mode == BattleSubMode.None) return false;
  408. if (string.IsNullOrEmpty(sceneName)) return false;
  409. if (ourActors == null || enemyActors == null || ourActors.Length == 0 || enemyActors.Length == 0) return false;
  410. if (mBattle != null && mBattle.IsTimeBattle) return false;
  411. if (endConds == null || endConds.Length == 0)
  412. {
  413. Debugger.LogError("战斗结束条件不能配置为空");
  414. return false;
  415. }
  416. try
  417. {
  418. List<BattleEndCondition> conds = new List<BattleEndCondition>();
  419. conds.AddRange(endConds);
  420. ShutDownCurrentBattle();
  421. ForceSyncSkill();
  422. mLuaTimeBattleMgr = luaTbl;
  423. mBattle = new TimeBattle(mode, ourActors, enemyActors, sceneName, maxFightingTime, bgmMusic, fighterParams, conds, nRestoreSp, OurMarks, EnemyMarks);
  424. mBattle.Start(0, factors);
  425. SaveBattleStat();
  426. return true;
  427. }
  428. catch (System.Exception e)
  429. {
  430. DebugHelper.LogError(e.StackTrace);
  431. return false;
  432. }
  433. }
  434. public bool ReplayTimeBattle(LuaTable luaTbl, BattleSubMode mode, float maxFightingTime, string sceneName, string bgmMusic, string battleRecordStr)
  435. {
  436. if (mode == BattleSubMode.None) return false;
  437. if (string.IsNullOrEmpty(sceneName)) return false;
  438. if (string.IsNullOrEmpty(battleRecordStr)) return false;
  439. if (mBattle != null && mBattle.IsTimeBattle) return false;
  440. if (mBattle != null && mBattle.IsPlayRecord) return false;
  441. ShutDownCurrentBattle();
  442. mLuaTimeBattleMgr = luaTbl;
  443. JSONObject json = JSONObject.Create(CompressionUtil.UnCompress(battleRecordStr));
  444. BattleRecorder battleRecord = new BattleRecorder(json);
  445. List<BattleEndCondition> endConds = new List<BattleEndCondition>();
  446. BattleEndCondition con = new BattleEndCondition(Constants.EndBattle_By_UndeadCount, Constants.ResultType_Normal);
  447. endConds.Add(con);
  448. mBattle = new TimeBattle(mode, sceneName, maxFightingTime, bgmMusic, battleRecord, endConds);
  449. mBattle.Start();
  450. SaveBattleStat();
  451. return true;
  452. }
  453. public void SaveBattleStat()
  454. {
  455. if (mBattle.IsNormalBattle ||
  456. mBattle.IsVersusBattle ||
  457. mBattle.IsTimeBattle)
  458. {
  459. if (mBattle.BattleStatistics != null)
  460. {
  461. int type = ((int)mBattle.Mode) * 100 + ((int)mBattle.SubBattleMode);
  462. if (mBattleStatisticDic.ContainsKey(type))
  463. {
  464. mBattleStatisticDic[type] = mBattle.BattleStatistics;
  465. }
  466. else
  467. {
  468. mBattleStatisticDic.Add(type, mBattle.BattleStatistics);
  469. }
  470. }
  471. }
  472. }
  473. public List<ActorData> StartNewbieBossBattle(int sceneId, int sex)
  474. {
  475. mCommonEffectIds.Clear();
  476. if (sceneId == 0)
  477. {
  478. DebugHelper.LogError("挑战boss的boss场景id不能为0");
  479. return null;
  480. }
  481. string ta = ConfigMgr.Instance.GetXmlCfg("Newbie_Design");
  482. if (ta == null)
  483. {
  484. DebugHelper.LogError("新手训练没有配置全局触发器文件");
  485. return null;
  486. }
  487. SecurityParser doc = new SecurityParser();
  488. try
  489. {
  490. doc.LoadXml(ta);
  491. }
  492. catch (System.Exception e)
  493. {
  494. DebugHelper.Assert(false, "exception = {0}", e.Message);
  495. return null;
  496. }
  497. List<ActorData> fellows = new List<ActorData>();
  498. ActorData bossActor = null;
  499. System.Security.SecurityElement root = doc.SelectSingleNode("GlobalTrigger");
  500. if (root == null || root.Children == null) return null;
  501. for (int idx = 0; idx < root.Children.Count; idx++)
  502. {
  503. var node = root.Children[idx] as System.Security.SecurityElement;
  504. if (node.Tag.CompareTo("TriggerSpawnGroup") == 0)
  505. {
  506. for (int jdx = 0; jdx < node.Children.Count; jdx++)
  507. {
  508. var spawnNode = node.Children[jdx] as System.Security.SecurityElement;
  509. if (spawnNode.Tag.CompareTo("Spawn") == 0)
  510. {
  511. int id = 0, type;
  512. int.TryParse(spawnNode.Attribute("id"), out id);
  513. int.TryParse(spawnNode.Attribute("actorType"), out type);
  514. if (id > 0)
  515. {
  516. ActorType aType = (ActorType)type;
  517. if (aType == ActorType.Hero)
  518. {
  519. int newId = id;
  520. if (sex == (int)Role_Gender.Female)
  521. {
  522. newId = newId + 1;
  523. }
  524. ActorData fellow = ActorData.CreateFellowActor(sceneId * 1000 + 100 + jdx, newId, 1, null);
  525. fellows.Add(fellow);
  526. fellow.BaseId = id;
  527. fellow.Gender = sex;
  528. }
  529. else if (aType == ActorType.Fellow)
  530. {
  531. ActorData fellow = ActorData.CreateFellowActor(sceneId * 1000 + 100 + jdx, id, 1, null);
  532. fellows.Add(fellow);
  533. }
  534. else if (aType == ActorType.Monster)
  535. {
  536. bossActor = ActorData.CreateNpcPlayerActor(sceneId * 1000 + 110, id, 1);
  537. bossActor.IsBoss = true;
  538. bossActor.PositionValue = 2;
  539. }
  540. }
  541. }
  542. }
  543. }
  544. else if (node.Tag.CompareTo("EffectGroup") == 0)
  545. {
  546. for (int jdx = 0; jdx < node.Children.Count; jdx++)
  547. {
  548. var effectNode = node.Children[jdx] as System.Security.SecurityElement;
  549. if (effectNode.Tag.CompareTo("Effect") == 0)
  550. {
  551. int effectId = 0;
  552. int.TryParse(effectNode.Attribute("id"), out effectId);
  553. if (effectId > 0 && !mCommonEffectIds.Contains(effectId))
  554. {
  555. mCommonEffectIds.Add(effectId);
  556. }
  557. }
  558. }
  559. }
  560. }
  561. if (fellows.Count == 0 || bossActor == null)
  562. {
  563. DebugHelper.LogError("新手训练营没有配置伙伴或者boss");
  564. return null;
  565. }
  566. List<BattleEndCondition> endConds = new List<BattleEndCondition>();
  567. BattleEndCondition con = new BattleEndCondition(Constants.EndBattle_By_UndeadCount, Constants.ResultType_Normal);
  568. endConds.Add(con);
  569. mBattle = new BossBattle(fellows.ToArray(), bossActor, sceneId, BattleSubMode.NewbieBoss, endConds);
  570. mBattle.Start();
  571. return fellows;
  572. }
  573. public void EnterNextBattle()
  574. {
  575. if (mBattle == null) return;
  576. if (mBattle.IsNormalBattle)
  577. {
  578. if (mBattle.CurBattleField.IsIdleState)
  579. {
  580. mBattle.EnterNextBattle();
  581. }
  582. else
  583. {
  584. mBattle.ServerAckOk = true;
  585. }
  586. }
  587. }
  588. public void DoPauseFighting(bool pause)
  589. {
  590. if (mBattle != null && mBattle.CurBattleField != null)
  591. {
  592. mBattle.CurBattleField.DoPauseFight(pause);
  593. }
  594. }
  595. public void AddActorToBossBattle(ActorData actor)
  596. {
  597. if (mBattle == null || actor == null) return;
  598. mBattle.AddActor(actor);
  599. }
  600. public void SetActorDead(long actorId)
  601. {
  602. if (mBattle == null) return;
  603. mBattle.SyncActorLife(actorId, 0);
  604. }
  605. public void RemoveActorFromBossBattle(long actorId)
  606. {
  607. if (mBattle == null) return;
  608. mBattle.RemoveActor(actorId);
  609. }
  610. public void SyncBossLife(int life)
  611. {
  612. if (mBattle == null) return;
  613. mBattle.SyncBossLife(life);
  614. }
  615. public void SetVersusActors(ActorData[] teamActors, ActorData[] enemyActors, float maxBattlingTime)
  616. {
  617. if (teamActors == null || enemyActors == null || mBattle == null || teamActors.Length == 0 || enemyActors.Length == 0)
  618. {
  619. DebugHelper.LogError("对战数据不能为空");
  620. return;
  621. }
  622. if (mBattle.Mode != BattleMode.Versus) return;
  623. VersusBattle tb = mBattle as VersusBattle;
  624. tb.SetVersusActors(teamActors, enemyActors, maxBattlingTime);
  625. }
  626. public void BeginVersus()
  627. {
  628. if (mBattle == null) return;
  629. if (mBattle.Mode != BattleMode.Versus) return;
  630. VersusBattle tb = mBattle as VersusBattle;
  631. tb.StartVersus();
  632. }
  633. public void StartStoryScript()
  634. {
  635. if (mBattle == null) return;
  636. mBattle.StartStoryScript();
  637. if (mBattle.IsBossBattle)
  638. {
  639. if (mLuaBossBattleMgr == null) return;
  640. mLuaBossBattleMgr.CallCS2Lua("OpenNewbieBattleUI");
  641. }
  642. }
  643. private List<ActorData> ParseTeamActors(ActorParam[] paramList)
  644. {
  645. if (paramList == null) return null;
  646. List<ActorData> actors = new List<ActorData>();
  647. for (int idx = 0; idx < paramList.Length; idx++)
  648. {
  649. ActorParam param = paramList[idx];
  650. ActorData ad = null;
  651. if (param.isRole)
  652. {
  653. ad = ActorData.CreatePlayerActor(param);
  654. }
  655. else
  656. {
  657. ad = ActorData.CreateFellowActor(param);
  658. }
  659. ad.IsMainRole = param.isMainRole;
  660. if (ad.valid)
  661. actors.Add(ad);
  662. }
  663. return actors;
  664. }
  665. public void DisposeCurrentBattle()
  666. {
  667. if (mSkillPrefabs != null && mSkillPrefabs.Count > 0)
  668. {
  669. foreach (var p in mSkillPrefabs)
  670. {
  671. ResourceMgr.Instance.RecycleGO(Constants.UIPath, p.Key, p.Value);
  672. }
  673. mSkillPrefabs.Clear();
  674. }
  675. if (mBattle != null)
  676. {
  677. mBattle.Dispose();
  678. mBattle = null;
  679. }
  680. }
  681. public void ShutDownCurrentBattle(bool bIsDispose = true)
  682. {
  683. if (mBattle != null)
  684. {
  685. mBattle.ShutDown();
  686. }
  687. if (bIsDispose)
  688. DisposeCurrentBattle();
  689. mLuaBattleMgr = null;
  690. mLuaBossBattleMgr = null;
  691. mLuaVersusMgr = null;
  692. mLuaTimeBattleMgr = null;
  693. bHasLoadedRole = false;
  694. bRoleModelDirty = false;
  695. mRoleModelGo = null;
  696. bLoadingRoleModel = false;
  697. //ScaleTimeInfo.Instance.Stop();
  698. EffectManager.Instance.Clear();
  699. if (BattleFlyWordMgr.HasInstance())
  700. BattleFlyWordMgr.Instance.Clear();
  701. if (MusicMgr.HasInstance())
  702. MusicMgr.Instance.CleanBeforeChangeScene();
  703. }
  704. public void Replay(BattleRecorder recorder)
  705. {
  706. if (mBattle == null)
  707. return;
  708. if (mBattle.IsNormalBattle)
  709. {
  710. mBattle.CurBattleField.PeaceEnd();
  711. mBattle.ReplayRecords(recorder);
  712. }
  713. }
  714. public void ClearBattleLog()
  715. {
  716. if (mBattle == null)
  717. return;
  718. mBattle.BattleOut.Clean();//清空本场战斗
  719. if (mBattle.IsNormalBattle)
  720. {
  721. if (mLuaBattleMgr == null) return;
  722. mLuaBattleMgr.CallCS2Lua("ClearBattleLog");//清空历史所有
  723. }
  724. }
  725. public void ForceStopBattle()
  726. {
  727. if (mBattle == null)
  728. return;
  729. mBattle.CurBattleField.PeaceEnd();
  730. }
  731. public void ShowStartFighting()
  732. {
  733. EventMgr.DispatchEvent<bool>(new CoreEvent<bool>(ECoreEventType.EID_BATTLE_NEW_START_FIGHTING, true));
  734. }
  735. public void SetBattleCamera()
  736. {
  737. if (BattleCamera.Instance != null)
  738. {
  739. EnableBattleCamera();
  740. }
  741. }
  742. public void DisableBattleCamera()
  743. {
  744. if (BattleCamera.Instance != null)
  745. {
  746. BattleCamera.Instance.DisableBattleCam();
  747. }
  748. }
  749. int mCurrentBattlePageId = 0;
  750. public void HideBattleUI()
  751. {
  752. mCurrentBattlePageId = UIMgr.Instance.GetCurrentBattlePageId();
  753. if (mCurrentBattlePageId > 0)
  754. UIMgr.Instance.Hide(mCurrentBattlePageId);
  755. }
  756. public void ShowBattleUI()
  757. {
  758. if (mCurrentBattlePageId > 0)
  759. {
  760. UIMgr.Instance.Show(mCurrentBattlePageId);
  761. }
  762. }
  763. public void EnableBattleCamera()
  764. {
  765. if (BattleCamera.Instance != null && UIMgr.Instance.HasBattleMainPage() && !IsPlayingComingCamera())
  766. {
  767. BattleCamera.Instance.EnableBattleCam();
  768. }
  769. }
  770. public void SetBossBattleCamera()
  771. {
  772. if (BattleCamera.Instance != null)
  773. {
  774. EnableBattleCamera();
  775. BattleCamera.Instance.SetCameraPosAndRot(mBattle.BattleBossCamPos, mBattle.BattleBossCamRot, 0, mBattle.BattleCamFar);
  776. }
  777. }
  778. public void SetFollowCamera(Vector3 forward, bool immediate = false)
  779. {
  780. if (BattleCamera.Instance != null)
  781. {
  782. EnableBattleCamera();
  783. if(0 < mBattle.FighterMgr.TeamFighters.Count)
  784. BattleCamera.Instance.LockFighter(mBattle.FighterMgr.TeamFighters[0], BattleCamera.Instance.CamCfg.followCamOffset, forward, BattleCamera.Instance.CamCfg.followCameraFov, BattleCamera.Instance.CamCfg.followDist, immediate);
  785. }
  786. }
  787. public void LookAtBattleFieldCenter()
  788. {
  789. if (mBattle.IsKillingBoss) return;
  790. Vector3 focusForward = mBattle.CurBattleField.FighterForward;
  791. Vector3 toFocus = mBattle.CurBattleField.FieldFocus;
  792. Vector3 toPosition = BattleCamera.Instance.CamPosition + BattleCamera.Instance.CamCfg.batttleCamOffset;
  793. BattleCamera.Instance.SetCameraWithFocus(toPosition, toFocus, BattleCamera.Instance.CamCfg.battleCameraFov);
  794. }
  795. public void PerformStartCamera(List<MapCameraConfig> cfgs, bool tweenTo)
  796. {
  797. EnableBattleCamera();
  798. BattleCamera.Instance.PerformStartCamera(cfgs, tweenTo);
  799. }
  800. public void EnterBossIntro()
  801. {
  802. ShowBossIntroEnd = false;
  803. BattleFlyWordMgr.Instance.SetHudVisible(false);
  804. UIMgr.Instance.Hide(UIPageIDs.PAGE_ID_BATTLE);
  805. BattleCamera.Instance.EnterBossIntroCam();
  806. }
  807. public void ExitBossIntro()
  808. {
  809. BattleFlyWordMgr.Instance.SetHudVisible(true);
  810. UIMgr.Instance.Show(UIPageIDs.PAGE_ID_BATTLE);
  811. UIMgr.Instance.Close(UIPageIDs.PAGE_ID_BOSS_INTRO);
  812. BattleCamera.Instance.ExitBossIntroCam();
  813. }
  814. public void ShowComingCamera()
  815. {
  816. if (BattleCamera.Instance.ComingCameraGo != null)
  817. {
  818. BattleCamera.Instance.ComingCameraGo.SetActive(true);
  819. }
  820. }
  821. public void PlayComingCameraAnim(string goName, string anim)
  822. {
  823. if (string.IsNullOrEmpty(anim) || string.IsNullOrEmpty(goName)) return;
  824. GameObject animGo = GameObject.Find(goName);
  825. if (animGo != null)
  826. {
  827. Animator animator = animGo.GetComponent<Animator>();
  828. if (animator != null)
  829. animator.Play(anim);
  830. }
  831. }
  832. public void HideComingCamera()
  833. {
  834. if (BattleCamera.Instance.ComingCameraGo != null)
  835. {
  836. BattleCamera.Instance.ComingCameraGo.SetActive(false);
  837. }
  838. }
  839. public bool IsPlayingComingCamera()
  840. {
  841. if (BattleCamera.Instance.ComingCameraGo != null)
  842. {
  843. return BattleCamera.Instance.ComingCameraGo.activeInHierarchy;
  844. }
  845. return false;
  846. }
  847. public void ActiveSceneAnim(string goName, string animName, bool active)
  848. {
  849. if (string.IsNullOrEmpty(goName))
  850. return;
  851. GameObject go = GameObject.Find(goName);
  852. if (go != null)
  853. {
  854. if (active)
  855. PocHelper.PlayGoAnim(go, animName);
  856. else
  857. PocHelper.StopGoAnim(go);
  858. }
  859. }
  860. public void ActiveSceneGo(string goName, bool active)
  861. {
  862. GameObject go = GameObject.Find(goName);
  863. if (go != null)
  864. go.SetActive(active);
  865. }
  866. public void SetUINodeVis(string nodePath)
  867. {
  868. if (string.IsNullOrEmpty(nodePath)) return;
  869. if (mBattle == null) return;
  870. if (mBattle.IsBossBattle)
  871. {
  872. if (mLuaBossBattleMgr == null) return;
  873. mLuaBossBattleMgr.CallCS2Lua("SetUINodeVis", nodePath);
  874. }
  875. }
  876. public void OnRefreshBattleOutput()
  877. {
  878. if (mBattle.IsNormalBattle)
  879. {
  880. if (mLuaBattleMgr == null) return;
  881. mLuaBattleMgr.CallCS2Lua("OnRefreshBattleOutput");
  882. }
  883. }
  884. public void OnFightingStart()
  885. {
  886. mInFighting = true;
  887. BattleCamera.Instance.MoveSpeed = BattleCamera.Instance.CamCfg.CamMoveSpeed;
  888. UIMgr.Instance.RestoreBattleUIVisible();
  889. BattleFlyWordMgr.Instance.SetHudVisible(true);
  890. EventMgr.DispatchEvent<bool>(new CoreEvent<bool>(ECoreEventType.EID_BATTLE_NEW_FIGHTING_START, true));
  891. if (mBattle.IsNormalBattle)
  892. {
  893. if (mLuaBattleMgr == null) return;
  894. mLuaBattleMgr.CallCS2Lua("OnFightingStart", IsKillBoss);
  895. }
  896. else if (mBattle.IsTimeBattle)
  897. {
  898. if (mLuaTimeBattleMgr == null) return;
  899. mLuaTimeBattleMgr.CallCS2Lua("OnFightingStart");
  900. }
  901. else if (mBattle.IsVersusBattle)
  902. {
  903. if (mLuaVersusMgr != null)
  904. mLuaVersusMgr.CallCS2Lua("OnFightingStart");
  905. }
  906. }
  907. bool teamDataDirty = false;
  908. public bool TeamDataDirty { get { return teamDataDirty; } }
  909. List<ActorData> needChangeActors = new List<ActorData>();
  910. public void SyncTeams(bool bIsForce)
  911. {
  912. if (mBattle == null) return;
  913. teamDataDirty = true;
  914. if (mInFighting)
  915. {
  916. if(bIsForce)// 强制结束战斗 同步属性(巡游战斗中)
  917. {
  918. ForceStopBattle();
  919. ClearBattleLog();
  920. }
  921. else
  922. {
  923. return; //下场战斗开始 同步
  924. }
  925. }
  926. BattleMgr.Instance.SyncTeamData(); //同步数据
  927. }
  928. public void ClearSkillDirty()
  929. {
  930. dirtySkills.Clear();
  931. skillDirty = false;
  932. }
  933. Dictionary<int, List<SkillParam>> dirtySkills = new Dictionary<int, List<SkillParam>>();
  934. bool skillDirty = false;
  935. public void UpdateTeamSkills(LuaTable heroSkills)
  936. {
  937. if (heroSkills == null) return;
  938. dirtySkills.Clear();
  939. for (int i = heroSkills.Length; i >= 1; i--)
  940. {
  941. int uid = 0;
  942. LuaTable ltt = (LuaTable)heroSkills[i];
  943. int.TryParse(ltt["uid"].ToString(), out uid);
  944. if (uid == 0) continue;
  945. if (ltt["skills"] == null) continue;
  946. List<SkillParam> skillParams = ActorData.ParseSkillParam((LuaTable)ltt["skills"]);
  947. dirtySkills.Add(uid, skillParams);
  948. }
  949. if (mInFighting)
  950. {
  951. //skillDirty = true;
  952. //return;
  953. ForceStopBattle();
  954. ClearBattleLog();
  955. }
  956. skillDirty = true;
  957. CheckSkill();
  958. }
  959. public void UpdateTeamSkills(int uid, List<SkillParam> skillParams)
  960. {
  961. if (skillParams == null) return;
  962. bool bIsFind = dirtySkills.ContainsKey(uid);
  963. if(bIsFind)
  964. {
  965. dirtySkills[uid] = skillParams;
  966. }
  967. else
  968. {
  969. dirtySkills.Add(uid, skillParams);
  970. }
  971. if (mInFighting)
  972. {
  973. //skillDirty = true;
  974. //return;
  975. ForceStopBattle();
  976. ClearBattleLog();
  977. }
  978. skillDirty = true;
  979. CheckSkill();
  980. }
  981. bool professionDirty = false;
  982. int mCacheJobId = 0;
  983. public void SetProfessionDirty(bool dirty, int jobId)
  984. {
  985. professionDirty = dirty;
  986. mCacheJobId = jobId;
  987. }
  988. public void SetTeamData()
  989. {
  990. if (teamDataDirty)
  991. {
  992. //var teamActors = GameMgr.Instance.CharacterInfo.NormleBattleTeamActors;
  993. var teamActors = GameMgr.Instance.CharacterInfo.TeamActors;
  994. bool ret = mBattle.AddNewActors(teamActors);
  995. teamDataDirty = false;
  996. for (int idx = 0; idx < teamActors.Count; idx++)
  997. {
  998. ActorDataMgr.Instance.RefreshFellowActorData(teamActors[idx].ID, teamActors[idx].BaseId);
  999. }
  1000. }
  1001. }
  1002. private void OnChallengeBoss(CoreEvent<ValType[]> ce)
  1003. {
  1004. if (mBattle == null) return;
  1005. mBattle.ChallengeBoss = true;
  1006. mBattle.Factors = ce.Data;
  1007. if (mBattle.CurBattleField != null)
  1008. {
  1009. if (mBattle.CurBattleField.CanKillBoss)
  1010. {
  1011. mBattle.CurBattleField.killBoss = true;
  1012. }
  1013. }
  1014. }
  1015. public void ReplayBattle(string recordStr)
  1016. {
  1017. if (string.IsNullOrEmpty(recordStr)) return;
  1018. if (mBattle == null) return;
  1019. if (mBattle.IsPlayRecord) return;
  1020. if (mBattle.IsKillingBoss) return;
  1021. string recordContent = CompressionUtil.UnCompress(recordStr);
  1022. JSONObject json = JSONObject.Create(recordContent);
  1023. BattleRecorder battleRecord = new BattleRecorder(json);
  1024. Replay(battleRecord);
  1025. }
  1026. private void OnCloneNewBoss(CoreEvent<Fighter> ce)
  1027. {
  1028. Fighter f = ce.Data;
  1029. if (mBattle.IsNormalBattle)
  1030. {
  1031. if (mLuaBattleMgr == null) return;
  1032. mLuaBattleMgr.CallCS2Lua("OnCloneNewBoss", f.Name, (float)f.Life, (float)f.MaxLife, f.CastSkill);
  1033. }
  1034. }
  1035. private void OnBossSpawned(CoreEvent<Fighter> ce)
  1036. {
  1037. Fighter f = ce.Data;
  1038. if (mBattle.IsNormalBattle)
  1039. {
  1040. if (mLuaBattleMgr == null) return;
  1041. SetDifModeBossAttr(f);
  1042. //Debug.Log("--------------OnBossSpawned-----Level-" + f.Actor.Level);
  1043. //f.Actor.SetLevel(1200);
  1044. mLuaBattleMgr.CallCS2Lua("OnBossSpawned", f.Actor, f.Name, (float)f.Life, (float)f.MaxLife, f.CastSkill, mBattle.IsPlayRecord);
  1045. }
  1046. else if (mBattle.IsBossBattle)
  1047. {
  1048. if (mLuaBossBattleMgr == null) return;
  1049. mLuaBossBattleMgr.CallCS2Lua("OnBossSpawned", f.Name, (float)f.Life, (float)f.MaxLife, f.CastSkill);
  1050. }
  1051. }
  1052. private void SetDifModeBossAttr(Fighter f)
  1053. {
  1054. Dictionary<int, int> attrs = GameMgr.Instance.GetDifAttrs();
  1055. NpcActorData npc = null;
  1056. if (f.IsNpc)
  1057. {
  1058. npc = f.Actor as NpcActorData;
  1059. }
  1060. if (npc == null) return;
  1061. npc.NpcDifRateData.Reset();
  1062. NpcBaseData data = npc.NpcData;
  1063. //attrs.Add(-156, 1200);
  1064. if (attrs.ContainsKey(-156))
  1065. {
  1066. int newLv = attrs[-156];
  1067. f.Actor.SetLevel(newLv);
  1068. //f.Actor.ShowLevel = newLv;
  1069. foreach (var item in attrs)
  1070. {
  1071. if (item.Key == -156) continue;
  1072. float val = item.Value;// * 0.01f;
  1073. val = val < 0 ? 0 : val;
  1074. npc.NpcDifRateData.SetAttr(item.Key, val);
  1075. }
  1076. int size = NpcDifRateAttr.AttKeys.Count - 1;
  1077. for (int i = 0; i < size; i++)
  1078. {
  1079. f.SetAttr(NpcDifRateAttr.AttKeys[i]);
  1080. }
  1081. }
  1082. else
  1083. {
  1084. foreach (var item in attrs)
  1085. {
  1086. float val = item.Value;// * 0.01f;
  1087. val = val < 0 ? 0 : val;
  1088. //Debug.Log($"--------------[key = {item.Key}---value = { item.Value}]-");
  1089. npc.NpcDifRateData.SetAttr(item.Key, val);
  1090. f.SetAttr(item.Key);
  1091. }
  1092. }
  1093. }
  1094. public void OnReplayEnd()
  1095. {
  1096. if (mBattle.IsNormalBattle)
  1097. {
  1098. if (mLuaBattleMgr == null) return;
  1099. mLuaBattleMgr.CallCS2Lua("OnReplayEnd");
  1100. }
  1101. else if (mBattle.IsBossBattle)
  1102. {
  1103. if (mLuaBossBattleMgr == null) return;
  1104. mLuaBossBattleMgr.CallCS2Lua("OnReplayEnd");
  1105. }
  1106. else if (mBattle.IsVersusBattle)
  1107. {
  1108. if (mLuaVersusMgr == null) return;
  1109. mLuaVersusMgr.CallCS2Lua("OnReplayEnd");
  1110. }
  1111. else if (mBattle.IsTimeBattle)
  1112. {
  1113. if (mLuaTimeBattleMgr == null) return;
  1114. mLuaTimeBattleMgr.CallCS2Lua("OnReplayEnd");
  1115. }
  1116. }
  1117. public void OnBattleEnd(int flag = 0, BattleEndInfo pEndInfo = null)
  1118. {
  1119. mInFighting = false;
  1120. BattleFlyWordMgr.Instance.SetHudVisible(false);
  1121. ActorDataMgr.Instance.ResetData();
  1122. if (mBattle.IsNormalBattle)
  1123. {
  1124. if (mBattle.CurBattleField.killBoss)
  1125. {
  1126. mBattle.ChallengeBoss = false;
  1127. }
  1128. StopCameraRelieveEffect();
  1129. CheckRoleModel();
  1130. if (mLuaBattleMgr == null) return;
  1131. bool bIsRecord = mBattle.CurBattleField.IsPlayingRecorder;
  1132. if (null != pEndInfo)
  1133. bIsRecord = pEndInfo.IsPlayRecord;
  1134. mLuaBattleMgr.CallCS2Lua("OnBattleEnd", mBattle.CurBattleField.killBoss, FightingTime, mBattle.CurBattleField.IsWin, bIsRecord);
  1135. }
  1136. else if (mBattle.IsVersusBattle)
  1137. {
  1138. if (mLuaVersusMgr != null)
  1139. {
  1140. mLuaVersusMgr.CallCS2Lua("OnBattleEnd");
  1141. }
  1142. }
  1143. else if (mBattle.IsBossBattle)
  1144. {
  1145. if (mLuaBossBattleMgr != null)
  1146. {
  1147. mLuaBossBattleMgr.CallCS2Lua("OnBattleEnd", flag);
  1148. }
  1149. }
  1150. else if (mBattle.IsTimeBattle)
  1151. {
  1152. if (mLuaTimeBattleMgr != null)
  1153. {
  1154. mLuaTimeBattleMgr.CallCS2Lua("OnBattleEnd", mBattle.CurBattleField.IsPlayingRecorder);
  1155. }
  1156. }
  1157. }
  1158. public void OnBattleForceStop(bool bossBattle)
  1159. {
  1160. if (mBattle.IsNormalBattle)
  1161. {
  1162. if (mLuaBattleMgr == null) return;
  1163. mLuaBattleMgr.CallCS2Lua("OnForceBattleFailed", bossBattle, mBattle.IsPlayRecord);
  1164. }
  1165. else if(mBattle.IsTimeBattle)
  1166. {
  1167. mLuaTimeBattleMgr.CallCS2Lua("OnForceBattleFailed");
  1168. }
  1169. }
  1170. public void OnBattleWin(bool bossBattle)
  1171. {
  1172. if (mBattle.IsNormalBattle)
  1173. {
  1174. if (mLuaBattleMgr == null) return;
  1175. long timeStamp = DateTimeUtil.GetCurrentTimeStamp();
  1176. string recordStr = mBattle.Recorder != null ? mBattle.Recorder.RecordStr : null;
  1177. if (!string.IsNullOrEmpty(recordStr))
  1178. {
  1179. mBattleRecordList.Add(timeStamp, recordStr);
  1180. }
  1181. int mapId = 0;
  1182. int levelId = 0;
  1183. if (mBattle.CurLevelItem != null)
  1184. {
  1185. mapId = mBattle.CurLevelItem.MapId;
  1186. levelId = mBattle.CurLevelItem.LevelId;
  1187. }
  1188. mLuaBattleMgr.CallCS2Lua("OnBattleWin", bossBattle, FightingTime, mapId, levelId, mBattle.IsPlayRecord, timeStamp);
  1189. }
  1190. else if (mBattle.IsBossBattle)
  1191. {
  1192. if (mLuaBossBattleMgr == null) return;
  1193. mLuaBossBattleMgr.CallCS2Lua("OnBattleWin");
  1194. }
  1195. else if (mBattle.IsVersusBattle)
  1196. {
  1197. if (mLuaVersusMgr == null) return;
  1198. mLuaVersusMgr.CallCS2Lua("OnBattleWin");
  1199. }
  1200. else if (mBattle.IsTimeBattle)
  1201. {
  1202. if (mLuaTimeBattleMgr == null) return;
  1203. long timeStamp = DateTimeUtil.GetCurrentTimeStamp();
  1204. if (!string.IsNullOrEmpty(mBattle.RecorderStr))
  1205. {
  1206. mBattleRecordList.Add(timeStamp, mBattle.RecorderStr);
  1207. }
  1208. List<ServerFighterParam> fighterParams = new List<ServerFighterParam>();
  1209. for (int idx = 0; idx < mBattle.CurBattleField.TeamFighters.Count; idx++)
  1210. {
  1211. var f = mBattle.CurBattleField.TeamFighters[idx];
  1212. if (f.IsPlayer)
  1213. {
  1214. TimeBattle pTimeBattle = mBattle as TimeBattle;
  1215. float fRestorSp = 0.0f;
  1216. if(null != pTimeBattle)
  1217. {
  1218. fRestorSp = pTimeBattle.GetRestoreSp();//远征之门 战斗胜利后的 回蓝
  1219. }
  1220. float fhpPercent = (f.Life * 1.0f) / f.MaxLife;
  1221. float fspPercent = f.Sp / f.MaxSp + fRestorSp;
  1222. MathUtil.ConverFloatRound(ref fhpPercent);
  1223. MathUtil.ConverFloatRound(ref fspPercent);
  1224. fhpPercent = Mathf.Min(fhpPercent, 1.0f);
  1225. fspPercent = Mathf.Min(fspPercent, 1.0f);
  1226. fighterParams.Add(new ServerFighterParam(f.Actor.ID, 0, 0, fhpPercent, fspPercent));
  1227. }
  1228. }
  1229. mLuaTimeBattleMgr.CallCS2Lua("OnBattleWin", mBattle.CurBattleField.BattleFrame / Constants.frame_to_time, mBattle.IsPlayRecord, timeStamp, fighterParams);
  1230. }
  1231. }
  1232. public void OnBattleFailed(bool bossBattle, int bossLife = 0, int bossSp = 0,bool bIsShowFailedUi = true)
  1233. {
  1234. if (mBattle.IsNormalBattle)
  1235. {
  1236. if (mLuaBattleMgr == null) return;
  1237. mLuaBattleMgr.CallCS2Lua("OnBattleFailed", bossBattle, mBattle.IsPlayRecord);
  1238. }
  1239. else if (mBattle.IsBossBattle)
  1240. {
  1241. if (mLuaBossBattleMgr == null) return;
  1242. mLuaBossBattleMgr.CallCS2Lua("OnBattleFailed");
  1243. }
  1244. else if (mBattle.IsVersusBattle)
  1245. {
  1246. if (mLuaVersusMgr == null) return;
  1247. mLuaVersusMgr.CallCS2Lua("OnBattleFailed");
  1248. }
  1249. else if (mBattle.IsTimeBattle)
  1250. {
  1251. if (mLuaTimeBattleMgr == null) return;
  1252. List<ServerFighterParam> fighterParams = new List<ServerFighterParam>();
  1253. for (int idx = 0; idx < mBattle.CurBattleField.TeamFighters.Count; idx++)
  1254. {
  1255. var f = mBattle.CurBattleField.TeamFighters[idx];
  1256. if (f.IsPlayer)
  1257. {
  1258. float fhpPercent = (f.Life * 1.0f) / f.MaxLife;
  1259. float fspPercent = f.Sp / f.MaxSp;
  1260. MathUtil.ConverFloatRound(ref fhpPercent);
  1261. MathUtil.ConverFloatRound(ref fspPercent);//防止丢之精度 2位后有值 向前进一位
  1262. fhpPercent = Mathf.Min(fhpPercent, 1.0f);
  1263. fspPercent = Mathf.Min(fspPercent, 1.0f);
  1264. fighterParams.Add(new ServerFighterParam(f.Actor.ID, 0,0, fhpPercent, fspPercent));
  1265. }
  1266. }
  1267. mLuaTimeBattleMgr.CallCS2Lua("OnBattleFailed", mBattle.CurBattleField.BattleFrame / Constants.frame_to_time, fighterParams, bossLife, bossSp);
  1268. }
  1269. }
  1270. private void OnBattleNewWave(CoreEvent<string> ce)
  1271. {
  1272. if (mBattle.IsNormalBattle)
  1273. {
  1274. if (mLuaBattleMgr == null) return;
  1275. mCurrentLevelItem = mBattle.CurBattleField.BattleInfo;
  1276. mLuaBattleMgr.CallCS2Lua("OnBattleNewWave", ce.Data);
  1277. }
  1278. }
  1279. private void OnContinueBattle(CoreEvent<bool> ce)
  1280. {
  1281. if (mBattle.IsNormalBattle)
  1282. {
  1283. if (mLuaBattleMgr == null) return;
  1284. mLuaBattleMgr.CallCS2Lua("OnContinueBattle");
  1285. }
  1286. }
  1287. private void OnShowBossRage(CoreEvent<bool> ce)
  1288. {
  1289. if (mBattle.IsNormalBattle)
  1290. {
  1291. if (mLuaBattleMgr == null) return;
  1292. mLuaBattleMgr.CallCS2Lua("OnShowBossRage", ce.Data, mBattle.IsPlayRecord);
  1293. }
  1294. }
  1295. private void OnShowBossRageLeftTime(CoreEvent<int> ce)
  1296. {
  1297. if (mBattle.IsNormalBattle)
  1298. {
  1299. if (mLuaBattleMgr == null) return;
  1300. mLuaBattleMgr.CallCS2Lua("OnShowBossRageLeftTime", ce.Data, mBattle.IsPlayRecord);
  1301. }
  1302. else if (mBattle.IsBossBattle)
  1303. {
  1304. if (mLuaBossBattleMgr == null) return;
  1305. mLuaBossBattleMgr.CallCS2Lua("OnShowBossRageLeftTime", ce.Data);
  1306. }
  1307. }
  1308. private void OnBossInRage(CoreEvent<bool> ce)
  1309. {
  1310. if (mBattle.IsNormalBattle)
  1311. {
  1312. if (mLuaBattleMgr == null) return;
  1313. mLuaBattleMgr.CallCS2Lua("OnBossInRage", mBattle.IsPlayRecord);
  1314. }
  1315. else if (mBattle.IsBossBattle)
  1316. {
  1317. if (mLuaBossBattleMgr == null) return;
  1318. mLuaBossBattleMgr.CallCS2Lua("OnBossInRage");
  1319. }
  1320. }
  1321. private void OnFighterHurt(CoreEvent<UIEventParamFighterHurt> ce)
  1322. {
  1323. if (mBattle != null)
  1324. {
  1325. if (mBattle.IsBossBattle)
  1326. {
  1327. if (mLuaBossBattleMgr == null) return;
  1328. UIEventParamFighterHurt hurtParam = ce.Data;
  1329. Fighter target = hurtParam.mTarget;
  1330. if (target.IsBoss)
  1331. {
  1332. mLuaBossBattleMgr.CallCS2Lua("OnSyncBossDamage", hurtParam.mHurtVal, mBattle.IsPlayRecord);
  1333. }
  1334. }
  1335. else if (mBattle.IsTimeBattle &&( mBattle.SubBattleMode == BattleSubMode.Guild || mBattle.SubBattleMode == BattleSubMode.GuildEx) )
  1336. {
  1337. if (mLuaTimeBattleMgr == null) return;
  1338. UIEventParamFighterHurt hurtParam = ce.Data;
  1339. Fighter target = hurtParam.mTarget;
  1340. if (target.TeamSide == eTeamType.Enemy)
  1341. {
  1342. mLuaTimeBattleMgr.CallCS2Lua("OnFighterHurt", hurtParam.mHurtVal);
  1343. }
  1344. }
  1345. }
  1346. }
  1347. private void OnFighterCastSkill(CoreEvent<CastSkillData> ce)
  1348. {
  1349. CastSkillData skillParam = ce.Data;
  1350. if (mBattle != null)
  1351. {
  1352. if (mBattle.IsNormalBattle && IsKillBoss && mLuaBattleMgr != null)
  1353. {
  1354. mLuaBattleMgr.CallCS2Lua("OnFighterCastSkill", skillParam, mBattle.IsPlayRecord);
  1355. }
  1356. else if (mBattle.IsBossBattle)
  1357. {
  1358. if (mLuaBossBattleMgr != null)
  1359. mLuaBossBattleMgr.CallCS2Lua("OnFighterCastSkill", skillParam);
  1360. }
  1361. else if (mBattle.IsVersusBattle)
  1362. {
  1363. if (mLuaVersusMgr != null)
  1364. {
  1365. mLuaVersusMgr.CallCS2Lua("OnFighterCastSkill", skillParam);
  1366. }
  1367. }
  1368. else if (mBattle.IsTimeBattle)
  1369. {
  1370. if (mLuaTimeBattleMgr != null)
  1371. {
  1372. mLuaTimeBattleMgr.CallCS2Lua("OnFighterCastSkill", skillParam);
  1373. }
  1374. }
  1375. }
  1376. }
  1377. private void OnShowBossBuffIcon(CoreEvent<stBuffParam> ce)
  1378. {
  1379. stBuffParam param = ce.Data;
  1380. if (mBattle != null)
  1381. {
  1382. if (mBattle.IsNormalBattle && IsKillBoss && mLuaBattleMgr != null)
  1383. {
  1384. mLuaBattleMgr.CallCS2Lua("OnShowBossBuff", param.actorId, param.isBoss, param.buffIcon, param.pointNum, mBattle.IsPlayRecord);
  1385. }
  1386. else if (mBattle.IsVersusBattle)
  1387. {
  1388. if (mLuaVersusMgr != null)
  1389. mLuaVersusMgr.CallCS2Lua("OnShowBossBuff", param.teamSide, param.actorId, param.isBoss, param.buffIcon, param.pointNum);
  1390. }
  1391. else if (mBattle.IsBossBattle)
  1392. {
  1393. if (mLuaBossBattleMgr != null)
  1394. mLuaBossBattleMgr.CallCS2Lua("OnShowBossBuff", param.actorId, param.isBoss, param.buffIcon, param.pointNum);
  1395. }
  1396. else if (mBattle.IsTimeBattle)
  1397. {
  1398. if (mLuaTimeBattleMgr != null)
  1399. mLuaTimeBattleMgr.CallCS2Lua("OnShowBossBuff", param.teamSide, param.actorId, param.isBoss, param.buffIcon, param.pointNum);
  1400. }
  1401. }
  1402. }
  1403. private void OnRemoveBuffIcon(CoreEvent<stBuffParam> ce)
  1404. {
  1405. stBuffParam param = ce.Data;
  1406. if (mBattle != null)
  1407. {
  1408. if (mBattle.IsNormalBattle && IsKillBoss && mLuaBattleMgr != null)
  1409. {
  1410. mLuaBattleMgr.CallCS2Lua("OnRemoveBossBuff", param.actorId, param.isBoss, param.buffIcon, mBattle.IsPlayRecord);
  1411. }
  1412. else if (mBattle.IsVersusBattle)
  1413. {
  1414. if (mLuaVersusMgr != null)
  1415. mLuaVersusMgr.CallCS2Lua("OnRemoveBossBuff", param.teamSide, param.actorId, param.isBoss, param.buffIcon);
  1416. }
  1417. else if (mBattle.IsBossBattle)
  1418. {
  1419. if (mLuaBossBattleMgr != null)
  1420. mLuaBossBattleMgr.CallCS2Lua("OnRemoveBossBuff", param.actorId, param.isBoss, param.buffIcon);
  1421. }
  1422. else if (mBattle.IsTimeBattle)
  1423. {
  1424. if (mLuaTimeBattleMgr != null)
  1425. mLuaTimeBattleMgr.CallCS2Lua("OnRemoveBossBuff", param.teamSide, param.actorId, param.isBoss, param.buffIcon);
  1426. }
  1427. }
  1428. }
  1429. private void OnFighterLifeChanged(CoreEvent<Fighter> ce)
  1430. {
  1431. if (mBattle == null) return;
  1432. Fighter f = ce.Data;
  1433. if (mBattle.IsNormalBattle)
  1434. {
  1435. if (IsKillBoss)
  1436. {
  1437. if (mLuaBattleMgr != null && (f.IsPlayer || f.IsBoss))
  1438. mLuaBattleMgr.CallCS2Lua("OnFighterLifeChanged", f.IsBoss, f.Actor.ID, (float)f.Life, (float)f.MaxLife);
  1439. }
  1440. }
  1441. else if (mBattle.IsBossBattle)
  1442. {
  1443. if (mLuaBossBattleMgr != null && (f.IsPlayer || f.IsBoss))
  1444. mLuaBossBattleMgr.CallCS2Lua("OnFighterLifeChanged", f.IsBoss, f.Actor.ID, (float)f.Life, (float)f.MaxLife);
  1445. }
  1446. else if (mBattle.IsVersusBattle)
  1447. {
  1448. if (mLuaVersusMgr != null && f.IsPlayer)
  1449. mLuaVersusMgr.CallCS2Lua("OnFighterLifeChanged", f.IsBoss, f.Actor.ID, (float)f.Life, (float)f.MaxLife, (int)f.TeamSide);
  1450. }
  1451. else if (mBattle.IsTimeBattle)
  1452. {
  1453. if (mLuaTimeBattleMgr != null)
  1454. {
  1455. if (f.IsPlayer || f.IsBoss)
  1456. {
  1457. mLuaTimeBattleMgr.CallCS2Lua("OnFighterLifeChanged", f.IsBoss,
  1458. f.Actor.ID,
  1459. (float)f.Life,
  1460. (float)f.MaxLife,
  1461. (int)f.Sp,
  1462. (int)f.MaxSp);
  1463. }
  1464. }
  1465. }
  1466. }
  1467. private void OnFighterEnergyChanged(CoreEvent<Fighter> ce)
  1468. {
  1469. Fighter f = ce.Data;
  1470. if (mBattle != null)
  1471. {
  1472. if (mBattle.IsNormalBattle)
  1473. {
  1474. if (IsKillBoss && mLuaBattleMgr != null && f.IsPlayer)
  1475. mLuaBattleMgr.CallCS2Lua("OnFighterEnergyChanged", f.Actor.ID, (int)f.Sp, (int)f.MaxSp, mBattle.IsPlayRecord);
  1476. }
  1477. else if (mBattle.IsBossBattle)
  1478. {
  1479. if (mLuaBossBattleMgr != null && f.IsPlayer)
  1480. mLuaBossBattleMgr.CallCS2Lua("OnFighterEnergyChanged", f.Actor.ID, (int)f.Sp, (int)f.MaxSp);
  1481. }
  1482. else if (mBattle.IsVersusBattle)
  1483. {
  1484. if (mLuaVersusMgr != null && f.IsPlayer)
  1485. {
  1486. mLuaVersusMgr.CallCS2Lua("OnFighterEnergyChanged", f.Actor.ID, (int)f.Sp, (int)f.MaxSp, (int)f.TeamSide);
  1487. }
  1488. }
  1489. else if (mBattle.IsTimeBattle)
  1490. {
  1491. if (mLuaTimeBattleMgr != null && (f.IsPlayer || f.IsBoss))
  1492. {
  1493. mLuaTimeBattleMgr.CallCS2Lua("OnFighterEnergyChanged", f.IsBoss,
  1494. f.Actor.ID,
  1495. (float)f.Life,
  1496. (float)f.MaxLife,
  1497. (int)f.Sp,
  1498. (int)f.MaxSp);
  1499. }
  1500. }
  1501. }
  1502. }
  1503. private void OnFighterSkillCDChanged(CoreEvent<SkillCDParam> ce)
  1504. {
  1505. if (mBattle != null && IsKillBoss)
  1506. {
  1507. SkillCDParam cdParam = ce.Data;
  1508. if (mLuaBattleMgr != null)
  1509. mLuaBattleMgr.CallCS2Lua("OnRefreshSkillCD", cdParam.isBoss, cdParam.actorId, cdParam.leftCD, cdParam.totalCD, mBattle.IsPlayRecord);
  1510. }
  1511. }
  1512. private void OnShowFighter(CoreEvent<Fighter> ce)
  1513. {
  1514. Fighter f = ce.Data;
  1515. if (mBattle != null)
  1516. {
  1517. if (mBattle.IsNormalBattle)
  1518. {
  1519. if (mLuaBattleMgr != null)
  1520. mLuaBattleMgr.CallCS2Lua("OnShowFighter", f.Id, mBattle.IsPlayRecord);
  1521. }
  1522. else if (mBattle.IsBossBattle)
  1523. {
  1524. if (mLuaBossBattleMgr != null)
  1525. mLuaBossBattleMgr.CallCS2Lua("OnShowFighter", f.Id);
  1526. }
  1527. }
  1528. }
  1529. Dictionary<string, GameObject> mSkillPrefabs = new Dictionary<string, GameObject>();
  1530. private void OnShowSkillPrefab(CoreEvent<string> ce)
  1531. {
  1532. string prefabName = ce.Data;
  1533. if (string.IsNullOrEmpty(prefabName)) return;
  1534. GameObject skillPrefab = ResourceMgr.Instance.GetGoFromPool(Constants.UIPath, prefabName);
  1535. if (skillPrefab != null)
  1536. {
  1537. Transform hudPanel = BattleFlyWordMgr.Instance.HudRootTrans;
  1538. if (hudPanel != null)
  1539. {
  1540. skillPrefab.transform.SetParent(hudPanel, true);
  1541. skillPrefab.transform.localScale = Vector3.one;
  1542. skillPrefab.transform.localRotation = Quaternion.identity;
  1543. }
  1544. RectTransform rt = skillPrefab.GetComponent<RectTransform>();
  1545. rt.anchorMin = Vector2.zero;
  1546. rt.anchorMax = Vector2.one;
  1547. rt.anchoredPosition3D = Vector3.zero;
  1548. rt.offsetMin = rt.offsetMax = Vector2.zero;
  1549. mSkillPrefabs.Add(prefabName, skillPrefab);
  1550. }
  1551. }
  1552. private void OnCloseSkillPrefab(CoreEvent<string> ce)
  1553. {
  1554. string prefabName = ce.Data;
  1555. if (string.IsNullOrEmpty(prefabName)) return;
  1556. if (mSkillPrefabs.ContainsKey(prefabName))
  1557. {
  1558. GameObject go = mSkillPrefabs[prefabName];
  1559. mSkillPrefabs.Remove(prefabName);
  1560. ResourceMgr.Instance.RecycleGO(Constants.UIPath, prefabName, go);
  1561. }
  1562. }
  1563. private void OnBattleUIVis(CoreEvent<bool> ce)
  1564. {
  1565. if (mBattle != null)
  1566. {
  1567. if (mBattle.IsNormalBattle)
  1568. {
  1569. if (mLuaBattleMgr != null)
  1570. mLuaBattleMgr.CallCS2Lua("OnBattleUIVis", ce.Data);
  1571. if (BattleFlyWordMgr.Instance.HudRoot != null)
  1572. BattleFlyWordMgr.Instance.HudRoot.SetActive(ce.Data);
  1573. }
  1574. }
  1575. }
  1576. public void ShowBossWarning()
  1577. {
  1578. if (mBattle.IsNormalBattle)
  1579. {
  1580. if (mLuaBattleMgr == null) return;
  1581. if (!mBattle.IsPlayRecord)
  1582. mLuaBattleMgr.CallCS2Lua("OnShowBossWarning");
  1583. }
  1584. else if (mBattle.IsBossBattle)
  1585. {
  1586. if (mLuaBossBattleMgr == null) return;
  1587. mLuaBossBattleMgr.CallCS2Lua("OnShowBossWarning");
  1588. }
  1589. }
  1590. public void ShowPVPPressPoint()
  1591. {
  1592. if (mLuaVersusMgr == null) return;
  1593. mLuaVersusMgr.CallCS2Lua("OnShowPvpPressPoint");
  1594. }
  1595. //显示战斗结束转场
  1596. public void ShowBattleEndInterlude()
  1597. {
  1598. if (mLuaVersusMgr != null)
  1599. {
  1600. mLuaVersusMgr.CallCS2Lua("ShowBattleEndInterlude");
  1601. }
  1602. }
  1603. //开始巡游
  1604. public void OnBeginSearch()
  1605. {
  1606. mBattle.TeamIntoBattlField();
  1607. SetFollowCamera(Vector3.zero);
  1608. }
  1609. //更新队伍数据 技能等级
  1610. public void SyncTeamData()
  1611. {
  1612. bool bIsProcessLoad = false;//是否有更新加载
  1613. if (!mBattle.IsPlayRecord)
  1614. {
  1615. SetTeamData();
  1616. CheckSkill();
  1617. bIsProcessLoad = CheckProfession();
  1618. SyncTeamName();
  1619. }
  1620. if (bIsProcessLoad || bRoleModelDirty) //是否需要刷新形象
  1621. {
  1622. NotifyRefreshRoleView(); //刷新形象
  1623. CheckRoleModel();
  1624. }
  1625. }
  1626. public void SyncTeamName()
  1627. {
  1628. //HeroActorData hero = GameMgr.Instance.CharacterInfo.Actor;
  1629. //HeroActorData Battlehero = GameMgr.Instance.CharacterInfo.mBattleActor;
  1630. //if(null != hero && null != Battlehero)
  1631. //{
  1632. // Battlehero.Name = hero.Name;//战斗数据同步 源数据
  1633. //}
  1634. }
  1635. public void CheckSkill()
  1636. {
  1637. //同步主属性
  1638. bool needLoad = false;
  1639. foreach (var p in dirtySkills)
  1640. {
  1641. ActorData ad = ActorDataMgr.Instance.GetActorsById(p.Key);
  1642. if (ad != null)
  1643. {
  1644. needLoad = ad.SkillMgr.SetSkillLevels(p.Value);
  1645. ad.ResetFirstSkill();
  1646. }
  1647. }
  1648. if (null == mBattle)
  1649. return;
  1650. //同步战斗属性
  1651. if (skillDirty)
  1652. {
  1653. foreach (var p in dirtySkills)
  1654. {
  1655. Fighter f = mBattle.FighterMgr.GetTeamMemberById(p.Key);
  1656. if (f != null)
  1657. {
  1658. bool ret = f.Actor.SkillMgr.SetSkillLevels(p.Value);
  1659. needLoad |= ret;
  1660. f.Actor.ResetFirstSkill();
  1661. }
  1662. }
  1663. if (needLoad)
  1664. {
  1665. BattlePrepareManager.Instance.StartLoad();
  1666. }
  1667. skillDirty = false;
  1668. }
  1669. }
  1670. public bool CheckProfession()
  1671. {
  1672. if (professionDirty)
  1673. {
  1674. HeroActorData hero = GameMgr.Instance.CharacterInfo.Actor; //更新源数据
  1675. //HeroActorData Battlehero = GameMgr.Instance.CharacterInfo.mBattleActor;//更新备份战斗数据
  1676. //Battlehero.SetProfessionId(mCacheJobId, true);
  1677. hero.SetProfessionId(mCacheJobId, true);
  1678. BattlePrepareManager.Instance.StartLoad();
  1679. if (IsLoadingBattleAssets)
  1680. {
  1681. for (int idx = 0; idx < mBattle.FighterMgr.TeamFighters.Count; idx++)
  1682. {
  1683. mBattle.FighterMgr.TeamFighters[idx].Ctrl.EnableNavAgent(false);
  1684. }
  1685. }
  1686. professionDirty = false;
  1687. //通知lua 主角转职正式完成
  1688. if (mBattle.IsNormalBattle)
  1689. {
  1690. if (mLuaBattleMgr != null)
  1691. mLuaBattleMgr.CallCS2Lua("HeroChangeProfessionSuccess");
  1692. }
  1693. else if (mBattle.IsBossBattle)
  1694. {
  1695. if (mLuaBossBattleMgr != null)
  1696. mLuaBossBattleMgr.CallCS2Lua("HeroChangeProfessionSuccess");
  1697. }
  1698. return true;
  1699. }
  1700. return false;
  1701. }
  1702. public void ForceSyncSkill()
  1703. {
  1704. if (skillDirty)
  1705. {
  1706. foreach (var p in dirtySkills)
  1707. {
  1708. ActorData actor = ActorDataMgr.Instance.GetActorsById(p.Key);
  1709. if (actor != null && p.Value != null)
  1710. {
  1711. actor.RefreshSkills(p.Value.ToArray());
  1712. }
  1713. }
  1714. skillDirty = false;
  1715. }
  1716. }
  1717. public void RefreshStatistics()
  1718. {
  1719. if (mBattle.IsNormalBattle)
  1720. {
  1721. if (mLuaBattleMgr != null)
  1722. mLuaBattleMgr.CallCS2Lua("RefreshStatistics");
  1723. }
  1724. else if (mBattle.IsTimeBattle)
  1725. {
  1726. if (mLuaTimeBattleMgr != null)
  1727. mLuaTimeBattleMgr.CallCS2Lua("RefreshStatistics");
  1728. }
  1729. else if (mBattle.IsVersusBattle)
  1730. {
  1731. if (mLuaVersusMgr != null)
  1732. mLuaVersusMgr.CallCS2Lua("RefreshStatistics");
  1733. }
  1734. }
  1735. int notifiedStatus = -1;
  1736. public void NotifyLoadingStatus(int status)
  1737. {
  1738. if (mBattle != null)
  1739. {
  1740. if (mLuaBattleMgr != null)
  1741. mLuaBattleMgr.CallCS2Lua("NotifyLoadingStatus", status);
  1742. }
  1743. }
  1744. public void NotifyLoadingStatusEnd()
  1745. {
  1746. if (mBattle != null)
  1747. {
  1748. if (mLuaBattleMgr != null)
  1749. mLuaBattleMgr.CallCS2Lua("NotifyLoadingStatusEnd", notifiedStatus);
  1750. }
  1751. }
  1752. public void StartingFight()
  1753. {
  1754. if (mBattle != null)
  1755. {
  1756. if (mLuaVersusMgr != null)
  1757. mLuaVersusMgr.CallCS2Lua("OnStartingFight");
  1758. }
  1759. }
  1760. public void Skip()
  1761. {
  1762. if (mBattle.IsPlayRecord)
  1763. mBattle.Recorder.Skip();
  1764. }
  1765. public const int m_angle_effect_id_cfgid = 32;
  1766. int cameraRelieveEffectIstanceId = 0;
  1767. public void PlayCameraReliveEffect()
  1768. {
  1769. if (cameraRelieveEffectIstanceId > 0) return;
  1770. int effectId = GlobalConfig.Instance.GetConfigIntValue(m_angle_effect_id_cfgid);
  1771. if (effectId > 0)
  1772. {
  1773. cameraRelieveEffectIstanceId = EffectManager.Instance.PlayEffect(effectId);
  1774. }
  1775. }
  1776. public void StopCameraRelieveEffect()
  1777. {
  1778. if (cameraRelieveEffectIstanceId > 0)
  1779. {
  1780. cameraRelieveEffectIstanceId = 0;
  1781. }
  1782. }
  1783. void WorldPos2MinimapPos(Vector3 pos, int mapSizeX, int mapSizeZ, int miniMapSizeX, int miniMapSizeZ, ref float x, ref float z)
  1784. {
  1785. float xRate = pos.x / mapSizeX;
  1786. float zRate = pos.z / mapSizeZ;
  1787. x = miniMapSizeX * xRate;
  1788. z = miniMapSizeZ * zRate;
  1789. }
  1790. public void RefreshMinimap(Vector3 center, int mapSizeX, int mapSizeZ, int miniMapSizeX, int miniMapSizeZ, GameObject hero, params RectTransform[] goes)
  1791. {
  1792. GetFightersPos();
  1793. int cnt = mFightersPos.Count;
  1794. if (cnt < 2 || goes.Length < 1 || hero == null) return;
  1795. //设置主角的位置
  1796. RectTransform miniMapGO = goes[0];
  1797. float mapX = 0, mapZ = 0;
  1798. WorldPos2MinimapPos(mFightersPos[0], mapSizeX, mapSizeZ, miniMapSizeX, miniMapSizeZ, ref mapX, ref mapZ);
  1799. Vector3 pos = miniMapGO.anchoredPosition;
  1800. pos.x = miniMapSizeX * ((float)center.x / mapSizeX) - mapX;
  1801. pos.y = miniMapSizeZ * ((float)center.z / mapSizeZ) - mapZ;
  1802. miniMapGO.anchoredPosition = pos;
  1803. //设置主角的朝向
  1804. Vector3 rot = mFightersPos[1];
  1805. rot.x = 0; rot.z = -rot.y; rot.y = 0;
  1806. hero.transform.localRotation = Quaternion.Euler(rot);
  1807. //设置怪物的位置
  1808. for (int idx = 1; idx < goes.Length; idx++)
  1809. {
  1810. if (idx + 1 >= cnt)
  1811. {
  1812. goes[idx].gameObject.SetActive(false);
  1813. }
  1814. else
  1815. {
  1816. goes[idx].gameObject.SetActive(true);
  1817. Vector3 deltaPos = mFightersPos[idx + 1] - mFightersPos[0];
  1818. float enemyX = 0, enemyZ = 0;
  1819. WorldPos2MinimapPos(deltaPos, mapSizeX, mapSizeZ, miniMapSizeX, miniMapSizeZ, ref enemyX, ref enemyZ);
  1820. var p = goes[idx].anchoredPosition;
  1821. p.x = enemyX;
  1822. p.y = enemyZ;
  1823. goes[idx].anchoredPosition = p;
  1824. }
  1825. }
  1826. }
  1827. List<Vector3> mFightersPos = new List<Vector3>();
  1828. public List<Vector3> GetFightersPos()
  1829. {
  1830. mFightersPos.Clear();
  1831. if (mBattle == null || mBattle.CurBattleField == null || !mBattle.IsNormalBattle) return mFightersPos;
  1832. if (mBattle.CurBattleField.TeamFighters.Count > 0)
  1833. {
  1834. mFightersPos.Add(mBattle.CurBattleField.TeamFighters[0].Position);
  1835. mFightersPos.Add(mBattle.CurBattleField.TeamFighters[0].Ctrl.transform.rotation.eulerAngles);
  1836. }
  1837. for (int idx = 0; idx < mBattle.CurBattleField.EnemyFighters.Count; idx++)
  1838. {
  1839. mFightersPos.Add(mBattle.CurBattleField.EnemyFighters[idx].Position);
  1840. }
  1841. return mFightersPos;
  1842. }
  1843. void OnStartMoveMouse(CoreEvent<Vector2> ce)
  1844. {
  1845. if (mBattle == null) return;
  1846. if (!mBattle.IsNormalBattle) return;
  1847. if (mBattle.IsKillingBoss) return;
  1848. IsRotatingCam = true;
  1849. BattleCamera.Instance.BeginCamRotate();
  1850. }
  1851. void OnEndMoveMouse(CoreEvent<Vector2> ce)
  1852. {
  1853. if (mBattle == null) return;
  1854. if (!mBattle.IsNormalBattle) return;
  1855. if (mBattle.IsKillingBoss) return;
  1856. IsRotatingCam = false;
  1857. BattleCamera.Instance.RestoreCamRotate();
  1858. }
  1859. //bool newScene = false;
  1860. //void OnSwitchScene(CoreEvent<string> ce)
  1861. //{
  1862. // newScene = true;
  1863. //}
  1864. //void OnRestoreScene(CoreEvent<bool> ce)
  1865. //{
  1866. // newScene = false;
  1867. //}
  1868. void OnLoadTeam(CoreEvent<bool> ce)
  1869. {
  1870. if (mBattle.IsLoadingActor)
  1871. {
  1872. NotifyLoadingStatus(1);
  1873. for (int idx = 0; idx < mBattle.FighterMgr.TeamFighters.Count; idx++)
  1874. {
  1875. mBattle.FighterMgr.TeamFighters[idx].Ctrl.EnableNavAgent(false);
  1876. }
  1877. }
  1878. else
  1879. {
  1880. if (!IsLoadingBattleAssets)
  1881. {
  1882. mBattle.MoveToNextBattleField(false);
  1883. }
  1884. NotifyLoadingStatusEnd();
  1885. }
  1886. }
  1887. void OnPrepareLoadOk(CoreEvent<bool> ce)
  1888. {
  1889. if (mBattle == null) return;
  1890. if (mBattle.Mode != BattleMode.Normal) return;
  1891. if (!IsLoadingBattleAssets)
  1892. {
  1893. NotifyLoadingStatusEnd();
  1894. }
  1895. }
  1896. void OnReplayBattleLoadedOk(CoreEvent<bool> ce)
  1897. {
  1898. if (mBattle == null) return;
  1899. if (mBattle.IsNormalBattle)
  1900. {
  1901. if (mLuaBattleMgr == null) return;
  1902. mLuaBattleMgr.CallCS2Lua("OnLoadComplete");
  1903. }
  1904. else if (mBattle.IsVersusBattle)
  1905. {
  1906. if (mLuaVersusMgr == null) return;
  1907. mLuaVersusMgr.CallCS2Lua("OnLoadComplete");
  1908. }
  1909. else if (mBattle.IsBossBattle)
  1910. {
  1911. if (mLuaBossBattleMgr == null) return;
  1912. mLuaBossBattleMgr.CallCS2Lua("OnLoadComplete");
  1913. }
  1914. else if (mBattle.IsTimeBattle)
  1915. {
  1916. if (mLuaTimeBattleMgr == null) return;
  1917. mLuaTimeBattleMgr.CallCS2Lua("OnLoadComplete");
  1918. }
  1919. }
  1920. public bool IsLoadingBattleAssets
  1921. {
  1922. get { return (mBattle != null && mBattle.IsLoadingActor) || BattlePrepareManager.Instance.IsLoading; }
  1923. }
  1924. public void CheckRoleModel()
  1925. {
  1926. if (!bRoleModelDirty) return;
  1927. mLuaBattleMgr.CallCS2Lua("RefreshRoleView");
  1928. bRoleModelDirty = false;
  1929. }
  1930. private bool bHasLoadedRole = false;
  1931. private bool bLoadingRoleModel = false;
  1932. private GameObject mRoleModelGo = null;
  1933. private bool bRoleModelDirty = false;
  1934. public bool LoadingRoleModel
  1935. {
  1936. get { return bLoadingRoleModel; }
  1937. }
  1938. public GameObject RoleModelGo
  1939. {
  1940. get
  1941. {
  1942. return mRoleModelGo;
  1943. }
  1944. }
  1945. public void LoadRole()
  1946. {
  1947. if (bHasLoadedRole) return;
  1948. bLoadingRoleModel = true;
  1949. mLuaBattleMgr.CallCS2Lua("CreateRoleView");
  1950. }
  1951. public void OnLoadRoleCompleted(GameObject go, bool bRefresh, bool isNew,int roleId = 1)
  1952. {
  1953. bLoadingRoleModel = false;
  1954. bHasLoadedRole = true;
  1955. mRoleModelGo = go;
  1956. if (bRefresh && isNew && mBattle != null)
  1957. {
  1958. var f = mBattle.FighterMgr.GetTeamMemberById(roleId);
  1959. if (f.Ctrl != null)
  1960. f.Ctrl.RebindAvatarGo(go);
  1961. mBattle.MoveToNextBattleField(false);
  1962. f.Ctrl.Animator.Play(FighterAnimatorHash.StateRun);
  1963. }
  1964. //for (int i =2; i < 7; i++)
  1965. //{
  1966. // GameObject ngo = Instantiate<GameObject>(go);
  1967. // var f = mBattle.FighterMgr.GetTeamMemberById(i);
  1968. // if (f.Ctrl != null)
  1969. // f.Ctrl.RebindAvatarGo(ngo);
  1970. // mBattle.MoveToNextBattleField(false);
  1971. // f.Ctrl.Animator.Play(FighterAnimatorHash.StateRun);
  1972. //}
  1973. }
  1974. public void NotifyRefreshRoleView()
  1975. {
  1976. bRoleModelDirty = true;
  1977. }
  1978. public string PopBattleRecord(long timeStamp)
  1979. {
  1980. if (mBattleRecordList.ContainsKey(timeStamp))
  1981. {
  1982. string recordStr = mBattleRecordList[timeStamp];
  1983. mBattleRecordList.Remove(timeStamp);
  1984. return recordStr;
  1985. }
  1986. return null;
  1987. }
  1988. public void ShowSkipBattle()
  1989. {
  1990. if (mBattle.IsBossBattle)
  1991. {
  1992. if (mLuaBossBattleMgr == null) return;
  1993. mLuaBossBattleMgr.CallCS2Lua("ShowSkipBattle");
  1994. }
  1995. }
  1996. void OnLoadBegin(CoreEvent<bool> ce)
  1997. {
  1998. if (mBattle == null) return;
  1999. if (mBattle.IsNormalBattle)
  2000. {
  2001. if (mLuaBattleMgr == null) return;
  2002. mLuaBattleMgr.CallCS2Lua("OnLoadBegin");
  2003. }
  2004. else if (mBattle.IsBossBattle)
  2005. {
  2006. if (mLuaBossBattleMgr == null) return;
  2007. mLuaBossBattleMgr.CallCS2Lua("OnLoadBegin");
  2008. }
  2009. else if (mBattle.IsVersusBattle)
  2010. {
  2011. if (mLuaVersusMgr == null) return;
  2012. mLuaVersusMgr.CallCS2Lua("OnLoadBegin");
  2013. }
  2014. else if (mBattle.IsTimeBattle)
  2015. {
  2016. if (mLuaTimeBattleMgr == null) return;
  2017. mLuaTimeBattleMgr.CallCS2Lua("OnLoadBegin");
  2018. }
  2019. }
  2020. void OnLoadComplete(CoreEvent<bool> ce)
  2021. {
  2022. if (mBattle == null) return;
  2023. if (mBattle.IsNormalBattle)
  2024. {
  2025. if (mLuaBattleMgr == null) return;
  2026. mLuaBattleMgr.CallCS2Lua("OnLoadComplete");
  2027. }
  2028. else if (mBattle.IsVersusBattle)
  2029. {
  2030. if (mLuaVersusMgr == null) return;
  2031. mLuaVersusMgr.CallCS2Lua("OnLoadComplete");
  2032. }
  2033. else if (mBattle.IsBossBattle)
  2034. {
  2035. if (mLuaBossBattleMgr == null) return;
  2036. mLuaBossBattleMgr.CallCS2Lua("OnLoadComplete");
  2037. }
  2038. else if (mBattle.IsTimeBattle)
  2039. {
  2040. if (mLuaTimeBattleMgr == null) return;
  2041. mLuaTimeBattleMgr.CallCS2Lua("OnLoadComplete");
  2042. }
  2043. }
  2044. void OnLoadProgress(CoreEvent<float> ce)
  2045. {
  2046. if (mBattle == null) return;
  2047. if (mBattle.IsNormalBattle)
  2048. {
  2049. if (mLuaBattleMgr == null) return;
  2050. mLuaBattleMgr.CallCS2Lua("OnLoadProgress", ce.Data);
  2051. }
  2052. else if (mBattle.IsVersusBattle)
  2053. {
  2054. if (mLuaVersusMgr == null) return;
  2055. mLuaVersusMgr.CallCS2Lua("OnLoadProgress", ce.Data);
  2056. }
  2057. else if (mBattle.IsBossBattle)
  2058. {
  2059. if (mLuaBossBattleMgr == null) return;
  2060. mLuaBossBattleMgr.CallCS2Lua("OnLoadProgress", ce.Data);
  2061. }
  2062. else if (mBattle.IsTimeBattle)
  2063. {
  2064. if (mLuaTimeBattleMgr == null) return;
  2065. mLuaTimeBattleMgr.CallCS2Lua("OnLoadProgress", ce.Data);
  2066. }
  2067. }
  2068. }