GameMgr.cs 37 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309
  1. using UnityEngine;
  2. using System.Collections;
  3. using LuaInterface;
  4. using System.Collections.Generic;
  5. using System;
  6. public class GameMgr : SingletonMono<GameMgr>
  7. {
  8. public const string VersionUpdateState = "VersionUpdateState";
  9. public const string LoginState = "LoginState";
  10. public const string LoadingState = "LoadingState";
  11. public const string BattleState = "BattleState";
  12. public static int RandSeed = 100000;
  13. public float mGameSpeed = 1.0f;
  14. private bool mIsSingle = false;
  15. private string mGameVersion;
  16. public string GameVersion
  17. {
  18. get { return mGameVersion; }
  19. }
  20. private string mResVersion;
  21. public string ResVersion
  22. {
  23. get { return mResVersion; }
  24. }
  25. public bool IsSingle
  26. {
  27. get { return mIsSingle; }
  28. }
  29. public float GameSpeed
  30. {
  31. get { return mGameSpeed; }
  32. }
  33. private LuaFunction OnSceneLoaded2Lua;
  34. private LuaFunction mPlayStoryLuaFun;
  35. private static GameMgr instance;
  36. public static new GameMgr Instance
  37. {
  38. get { return instance; }
  39. }
  40. private bool mIsStartDungeon = false;
  41. public bool InStartDungeon
  42. {
  43. get { return mIsStartDungeon; }
  44. }
  45. private bool mIsEditorMode = false;
  46. public bool IsEditorMode
  47. {
  48. get { return mIsEditorMode; }
  49. }
  50. public GameObject CreateMaleRoot
  51. {
  52. get { return CreateRoleMgr.Instance.MaleRoot; }
  53. }
  54. public GameObject CreateFemaleRoot
  55. {
  56. get { return CreateRoleMgr.Instance.FemaleRoot; }
  57. }
  58. public GameObject CreateShowRoot
  59. {
  60. get { return CreateRoleMgr.Instance.ShowRoot; }
  61. }
  62. public eNetType NetStatus
  63. {
  64. get { return DeviceInfo.GetNetType(); }
  65. }
  66. private MainCharacter mCharacterInfo;
  67. public MainCharacter CharacterInfo
  68. {
  69. get { return mCharacterInfo; }
  70. }
  71. public string DeviceId
  72. {
  73. get { return DeviceInfo.m_deviceId; }
  74. }
  75. public string CurLangKey
  76. {
  77. get { return ConfigMgr.CurLangKey; }
  78. set { ConfigMgr.CurLangKey = value; }
  79. }
  80. public bool IsMobileDevice
  81. {
  82. get
  83. {
  84. #if UNITY_EDITOR
  85. return false;
  86. #elif UNITY_ANDROID || UNITY_IPHONE
  87. return true;
  88. #else
  89. return false;
  90. #endif
  91. }
  92. }
  93. public bool IsBadDevice
  94. {
  95. get { return DeviceInfo.m_DeviceState == DeviceInfo.eDeviceState.BAD_DEVICE; }
  96. }
  97. public bool IsNormalDevice
  98. {
  99. get { return DeviceInfo.m_DeviceState == DeviceInfo.eDeviceState.NORMAL_DEVICE; }
  100. }
  101. public bool IsGoodDevice
  102. {
  103. get { return DeviceInfo.m_DeviceState == DeviceInfo.eDeviceState.GOOD_DEVICE; }
  104. }
  105. NPack.MersenneTwister rand = null;
  106. private SceneType mEnterSceneType = 0;
  107. private BattleSubMode mbossMode = BattleSubMode.None;
  108. private bool bInited = false;
  109. public string sDKName = "";
  110. private void Awake()
  111. {
  112. #if !UNITY_EDITOR
  113. DebugHelper.LogLevel = LogLevel.Error;
  114. #endif
  115. instance = this;
  116. DontDestroyOnLoad(this.gameObject);
  117. rand = new NPack.MersenneTwister(int.MaxValue);
  118. System.Globalization.CultureInfo.DefaultThreadCurrentCulture = new System.Globalization.CultureInfo("en-US");
  119. }
  120. bool bPaused = false;
  121. float mPausedTime = 0;
  122. private void OnApplicationFocus(bool focus)
  123. {
  124. if (bPaused && focus)
  125. {
  126. float pausePassedTime = Time.realtimeSinceStartup - mPausedTime;
  127. // if (pausePassedTime >= 300) //切后台5分钟网络重新连接
  128. // {
  129. // NetworkMgr.Instance.Resume();
  130. // }
  131. }
  132. }
  133. private void OnApplicationPause(bool pause)
  134. {
  135. bPaused = pause;
  136. if (bPaused)
  137. {
  138. mPausedTime = Time.realtimeSinceStartup;
  139. GameSettings.Instance.Save();
  140. }
  141. }
  142. protected override void OnApplicationQuit()
  143. {
  144. GameSettings.Instance.Save();
  145. base.OnApplicationQuit();
  146. }
  147. private void InitSDK_E()
  148. {
  149. StartCoroutine(initSdk_E());
  150. }
  151. private IEnumerator initSdk_E()
  152. {
  153. SDKMgr.Instance.Init();
  154. yield return null;
  155. }
  156. private void Start()
  157. {
  158. if (bInited) return;
  159. SDKMgr.Instance.ReportActivation(SDKMgr.Instance.GetInt64TimeStamp());
  160. Screen.sleepTimeout = SleepTimeout.NeverSleep;
  161. QualitySettings.vSyncCount = 0;
  162. RegisterEvents();
  163. #if UNITY_IOS && !UNITY_EDITOR
  164. InitSDK_E();
  165. #endif
  166. //InitSDK_E();
  167. StartDetector();
  168. DeviceInfo.GetDeviceState();
  169. if (DeviceInfo.m_DeviceState <= DeviceInfo.eDeviceState.NORMAL_DEVICE)
  170. {
  171. Application.targetFrameRate = 60;
  172. BattleMgr.c_updateFPS = 15;
  173. }
  174. else
  175. {
  176. Application.targetFrameRate = 60;
  177. BattleMgr.c_updateFPS = 30;
  178. }
  179. Input.multiTouchEnabled = false;
  180. //启用日志
  181. StartLog();
  182. //读取Apk设置文件
  183. //yield return StartCoroutine(ReadVersionFile());
  184. //InitData();
  185. //InitBuildConfig();
  186. //InitData();
  187. LaunchLoadMgr lanuchLoadMgr = new LaunchLoadMgr();
  188. lanuchLoadMgr.StartLaunch(OnLanuchLoadCompleted, OnAssetMapInitComplete);
  189. //检测非法修改
  190. AntiCheatMgr.Instance.GetOrCreateAnti(EnAntiCheatType.enSystemTime).Init(AntiCheatCfg.c_fTimeSysteCheckTime);
  191. AntiCheatMgr.Instance.GetOrCreateAnti(EnAntiCheatType.enScaleTime).Init(AntiCheatCfg.c_fTimeScaleCheckTime);
  192. bInited = true;
  193. }
  194. public void DoTaskByCorutine(Func<IEnumerator> func)
  195. {
  196. StartCoroutine(func.Invoke());
  197. }
  198. private void OnLanuchLoadCompleted(bool success)
  199. {
  200. EnterLuaLogin(false);
  201. }
  202. private void OnAssetMapInitComplete()
  203. {
  204. CheckVersion();
  205. InitBugly();
  206. }
  207. public void CheckVersion()
  208. {
  209. mGameVersion = Application.version;
  210. mResVersion = "0.0.0.0";
  211. string resversion = DownloadMgr.Instance.ResVersion;
  212. if (!String.IsNullOrEmpty(resversion))
  213. {
  214. mResVersion = resversion;
  215. }
  216. //int versionCodeInt = 0;// Wenting.Lebian.LeBianSDK.instance.GetResVerCode();
  217. //VersionCode versionCode1;
  218. //if (versionCodeInt <= 0)
  219. //{
  220. // versionCode1 = mGameVersion;
  221. //}
  222. //else
  223. //{
  224. // versionCode1 = (VersionCode)(uint)versionCodeInt;
  225. //}
  226. //VersionCode versionCode2 = AssetsMgr.Instance.resVersionCode;
  227. //if (versionCode1 < versionCode2)
  228. //{
  229. // mResVersion = versionCode2.ToString();
  230. //}
  231. //else
  232. //{
  233. // mResVersion = versionCode1.ToString();
  234. //}
  235. }
  236. void InitBugly()
  237. {
  238. #if BUGLY
  239. #if UNITY_IPHONE || UNITY_IOS
  240. string channel = ""; //Wenting.Lebian.LeBianSDK.instance.GetClientChId();
  241. BuglyAgent.ConfigDefault(channel, mResVersion, string.Empty, 0);
  242. BuglyAgent.InitWithAppId("3e7f97a53b");
  243. BuglyAgent.EnableExceptionHandler();
  244. #elif UNITY_ANDROID
  245. string channel = "";//Wenting.Lebian.LeBianSDK.instance.GetClientChId();
  246. BuglyAgent.ConfigDefault(channel, mResVersion, string.Empty, 0);
  247. #if LEBIAN_YUN_CLIENT
  248. BuglyAgent.InitWithAppId("96a729256a");
  249. #else
  250. BuglyAgent.InitWithAppId("c7177b1ae7");
  251. #endif
  252. BuglyAgent.EnableExceptionHandler();
  253. #endif
  254. #endif
  255. }
  256. public void StartDetector()
  257. {
  258. DataCheatingDetector.StartDetection(OnDataCheatingDetected);
  259. SpeedHackDetector.StartDetection(OnSpeedHackDetected);
  260. }
  261. bool speedHackDetected = false;
  262. bool dataCheatingDetected = false;
  263. void OnDataCheatingDetected()
  264. {
  265. dataCheatingDetected = true;
  266. //LocalPlayerInfo.SendCheat(ECheatType.CHEAT_DATA);
  267. DebugHelper.LogError("Data Cheating Detected!");
  268. }
  269. void OnSpeedHackDetected()
  270. {
  271. speedHackDetected = true;
  272. //LocalPlayerInfo.SendCheat(ECheatType.CHEAT_SPEED);
  273. DebugHelper.LogError("Speed hack Detected!");
  274. }
  275. private void Update()
  276. {
  277. AntiCheatMgr.Instance.Update();
  278. ResourceMgr.Instance.Update();
  279. TimerManager.Instance.Update();
  280. NetworkMgr.Instance.Update();
  281. UpdateFPS();
  282. #if UNITY_EDITOR || OPENGM
  283. if (Input.GetMouseButtonDown(0))
  284. {
  285. Rect validRect = SafeRectCheck.Instance.safeArea;
  286. validRect.width = validRect.height * 0.025f;
  287. validRect.y = validRect.height + validRect.y - validRect.width;
  288. validRect.height = validRect.width;
  289. if (validRect.Contains(Input.mousePosition))
  290. {
  291. mouseDown = true;
  292. dragged = false;
  293. mouseDownTime = Time.time;
  294. mouseDownPos = Input.mousePosition;
  295. }
  296. else
  297. {
  298. clickCount = 0;
  299. }
  300. }
  301. if (mouseDown && !dragged && Vector3.Distance(Input.mousePosition, mouseDownPos) >= 5.0f)
  302. {
  303. dragged = true;
  304. }
  305. if (Input.GetMouseButtonUp(0))
  306. {
  307. if (mouseDown)
  308. {
  309. mouseDown = false;
  310. if (dragged)
  311. {
  312. clickCount = 0;
  313. }
  314. else
  315. {
  316. dragged = false;
  317. Rect validRect = SafeRectCheck.Instance.safeArea;
  318. validRect.width = validRect.height * 0.025f;
  319. validRect.y = validRect.height + validRect.y - validRect.width;
  320. validRect.height = validRect.width;
  321. if (Time.time - mouseDownTime < 2 && validRect.Contains(Input.mousePosition))
  322. {
  323. clickCount = clickCount + 1;
  324. if (clickCount >= 2)
  325. {
  326. clickCount = 0;
  327. var pLuaState = LuaMgr.GetMainState();
  328. if (null != pLuaState)
  329. {
  330. LuaMgr.GetMainState().DoString("local curUIId = ManagerContainer.LuaUIMgr:GetCurUIId()\nManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIGM, nil, curUIId)");
  331. }
  332. }
  333. }
  334. else
  335. {
  336. clickCount = 0;
  337. }
  338. }
  339. }
  340. }
  341. }
  342. // private void OnGUI() {
  343. // Rect validRect = SafeRectCheck.Instance.safeArea;
  344. // validRect.width = validRect.height * 0.025f;
  345. // validRect.y = SafeRectCheck.Instance.screenHeight - validRect.height - validRect.y;
  346. // validRect.height = validRect.width;
  347. // GUI.DrawTexture(validRect, Texture2D.whiteTexture);
  348. // }
  349. private int clickCount = 0;
  350. private bool mouseDown = false;
  351. private bool dragged = false;
  352. private float mouseDownTime = 0f;
  353. private Vector2 mouseDownPos = Vector2.zero;
  354. #else
  355. }
  356. #endif
  357. protected override void Dispose()
  358. {
  359. base.Dispose();
  360. }
  361. private const float m_FrameUpdateInterval = 0.5f;
  362. private float m_FrameUpdateTime = 0f;
  363. private float m_MaxTimeAccumulator = 0;
  364. private int m_FrameCounter = 0;
  365. private int m_MaxFrameTime = 0;
  366. public int maxFrameTime
  367. {
  368. get { return m_MaxFrameTime; }
  369. }
  370. private void UpdateFPS()
  371. {
  372. float deltaTime = Time.deltaTime;
  373. if (deltaTime > 0)
  374. {
  375. m_FrameUpdateTime -= deltaTime;
  376. m_MaxTimeAccumulator += Time.timeScale / deltaTime;
  377. m_FrameCounter++;
  378. }
  379. if (m_FrameUpdateTime <= 0)
  380. {
  381. m_MaxFrameTime = Mathf.RoundToInt(m_MaxTimeAccumulator / m_FrameCounter);
  382. m_FrameUpdateTime = m_FrameUpdateInterval;
  383. m_MaxTimeAccumulator = 0;
  384. m_FrameCounter = 0;
  385. }
  386. }
  387. void EnterLuaLogin(bool relogin)
  388. {
  389. if (mCharacterInfo == null)
  390. {
  391. mCharacterInfo = new MainCharacter();
  392. }
  393. LuaMgr.Instance.EnterLogin(relogin);
  394. }
  395. void DisposeCharactorInfo()
  396. {
  397. mCharacterInfo.Dispose();
  398. mCharacterInfo = null;
  399. }
  400. void OnLogout(CoreEvent<int> ce)
  401. {
  402. }
  403. public void SetOnSceneLoadedLuaFunc(LuaFunction func)
  404. {
  405. OnSceneLoaded2Lua = func;
  406. }
  407. public void ReLogin()
  408. {
  409. ShutDownBattle(false);//清空战斗数据 逻辑 (等待loading界面完成 清空战斗实例)
  410. DisposeCharactorInfo();
  411. EnterLuaLogin(true);
  412. }
  413. public void ReLoginClearData()
  414. {
  415. ClearMainCharacter();
  416. ActorDataMgr.Instance.Clear();
  417. DisposeBattle();//销毁战斗实例
  418. BattleMgr.Instance.ClearSkillDirty();//销毁待更新技能
  419. SceneMgr.Instance.LoadMainScene("relogin");
  420. }
  421. void ClearMainCharacter()
  422. {
  423. if (mCharacterInfo != null)
  424. {
  425. mCharacterInfo.Clear();
  426. }
  427. }
  428. public void SetLuaPlayStoryFunc(LuaFunction func)
  429. {
  430. mPlayStoryLuaFun = func;
  431. }
  432. public void LoadCurrentBattle()
  433. {
  434. GameStateCtrl.Instance.GotoState(LoadingState);
  435. }
  436. public void CloseLoading()
  437. {
  438. if (BattleMgr.Instance.Battle == null) return;
  439. if (BattleMgr.Instance.Battle.IsBossBattle && BattleMgr.Instance.Battle.SubBattleMode == BattleSubMode.NewbieBoss)
  440. {
  441. BattleMgr.Instance.StartStoryScript();
  442. }
  443. }
  444. public void SetTeamData(LuaTable teamParam, LuaTable tbIsForce)
  445. {
  446. if (mCharacterInfo != null)
  447. {
  448. mCharacterInfo.SetTeamActors(teamParam);
  449. bool bIsForce = false;//是否强制同步
  450. if (tbIsForce[1] != null)
  451. {
  452. bool.TryParse(tbIsForce[1].ToString(), out bIsForce);
  453. }
  454. BattleMgr.Instance.SyncTeams(bIsForce);
  455. }
  456. }
  457. public void RefreshTeamData()
  458. {
  459. for (int idx = 0; idx < mCharacterInfo.TeamActors.Count; idx++)
  460. {
  461. ActorDataMgr.Instance.RefreshFellowActorData(mCharacterInfo.TeamActors[idx].ID, mCharacterInfo.TeamActors[idx].BaseId);
  462. }
  463. }
  464. public void UpdateTeamSkills(LuaTable skillsParam)
  465. {
  466. if (mCharacterInfo != null)
  467. {
  468. BattleMgr.Instance.UpdateTeamSkills(skillsParam);
  469. }
  470. }
  471. /// <summary>
  472. /// 完成角色创建
  473. /// </summary>
  474. /// <param name="modelGo"></param>
  475. public void CreateRoleViewComplete(GameObject modelGo, int roleId = 1)
  476. {
  477. BattleMgr.Instance.OnLoadRoleCompleted(modelGo, false, false, roleId);
  478. }
  479. /// <summary>
  480. /// 角色形象更新完成
  481. /// </summary>
  482. /// <param name="modelGo"></param>
  483. public void RefreshRoleViewComplete(GameObject modelGo, bool isNew, int roleId = 1)
  484. {
  485. BattleMgr.Instance.OnLoadRoleCompleted(modelGo, true, isNew, roleId);
  486. }
  487. /// <summary>
  488. /// 时装或者其它功能更新了角色形象,战斗内需要自行调用形象更新 参数 是否为转职后的新角色
  489. /// </summary>
  490. public void NotifyRefreshRoleView()
  491. {
  492. BattleMgr.Instance.NotifyRefreshRoleView();
  493. }
  494. public void SetMapLevelId(int mapId, int levelId)
  495. {
  496. if (mCharacterInfo == null) return;
  497. if (mCharacterInfo.CurMapId != mapId)
  498. {
  499. mCharacterInfo.CurMapId = mapId;
  500. mCharacterInfo.CurLevelId = levelId;
  501. }
  502. else
  503. {
  504. if (mCharacterInfo.CurLevelId != levelId)
  505. {
  506. mCharacterInfo.CurLevelId = levelId;
  507. BattleMgr.Instance.EnterNextBattle();
  508. }
  509. }
  510. //BattleMgr.Instance?.SetMapLevelId(mapId,levelId);
  511. Debug.Log($"=========SetMapLevelId============={mCharacterInfo.CurMapId} --- {mCharacterInfo.CurLevelId}");
  512. }
  513. public void PreloadCreateRoleScene()
  514. {
  515. mEnterSceneType = SceneType.CreateRoleScene;
  516. CreateRoleMgr.Instance.LoadScene();
  517. }
  518. public void GotoLogin()
  519. {
  520. BattleMgr.Instance.ShutDownCurrentBattle();
  521. }
  522. //进入公会大厅
  523. public void PreloadGuildLobby()
  524. {
  525. mEnterSceneType = SceneType.GuildLobbyScene;
  526. BattleMgr.Instance.ShutDownCurrentBattle();
  527. GuildLobbyMgr.Instance.EnterGuildLobby();
  528. }
  529. public void PreloadAllFellows(ActorData[] actors)
  530. {
  531. if (actors == null || actors.Length == 0) return;
  532. for (int idx = 0; idx < actors.Length; idx++)
  533. {
  534. var actor = actors[idx];
  535. if (actor != null)
  536. {
  537. BattlePrepareManager.Instance.PrecacheModel(actor.AvatarData.prefab, actor.AType);
  538. BattlePrepareManager.Instance.PrecacheAnimatorCtrl(actor.ShowAnimCtrlName);
  539. }
  540. }
  541. }
  542. public void PreloadBattle(LuaTable teamParam)
  543. {
  544. mEnterSceneType = SceneType.NormalBattleScene;
  545. GuildLobbyMgr.Instance.Clear();
  546. mCharacterInfo.SetTeamActors(teamParam);
  547. LogicBattleStartInfo startInfo = new LogicBattleStartInfo(mCharacterInfo.CurMapId, mCharacterInfo.CurLevelId);
  548. Debug.Log($"============PreloadBattle=========={mCharacterInfo.CurMapId} --- {mCharacterInfo.CurLevelId}");
  549. BattleMgr.Instance.ShutDownCurrentBattle();
  550. BattleMgr.Instance.StartBattle(startInfo);
  551. }
  552. public List<ActorData> StartNewbieBossBattle(int sceneId, int roleSex)
  553. {
  554. mEnterSceneType = SceneType.BossBattleScene;
  555. BattleMgr.Instance.ShutDownCurrentBattle();
  556. return BattleMgr.Instance.StartNewbieBossBattle(sceneId, roleSex);
  557. }
  558. public void PreloadViewTeam(ActorData[] teamActors, string sceneName, LuaTable tbl)
  559. {
  560. mEnterSceneType = SceneType.TowerBattleScene;
  561. BattleMgr.Instance.ShutDownCurrentBattle();
  562. PreviewTeamMgr.Instance.LoadPreviewActorsAndScene(teamActors, sceneName, tbl);
  563. }
  564. public void PreloadVersusBattle(BattleSubMode mode,
  565. ActorData[] teamActors,
  566. ActorData[] enemyActors,
  567. string sceneName,
  568. float maxFightingTime,
  569. BattleEndCondition[] endConds,
  570. GvGMark[] OurMarks,
  571. GvGMark[] EnemyMarks,
  572. bool IsPresspoint,
  573. int nPresspoint)
  574. {
  575. mEnterSceneType = SceneType.TowerBattleScene;
  576. BattleMgr.Instance.ShutDownCurrentBattle();
  577. BattleMgr.Instance.StartVersusBattle(mode, teamActors, enemyActors, sceneName, maxFightingTime, endConds, OurMarks, EnemyMarks, IsPresspoint, nPresspoint);
  578. }
  579. public void PreloadBossBattle(ActorData[] actors,
  580. int bossId,
  581. int sceneId,
  582. BattleEndCondition[] endConds)
  583. {
  584. mEnterSceneType = SceneType.BossBattleScene;
  585. BattleMgr.Instance.ShutDownCurrentBattle();
  586. BattleMgr.Instance.StartBossBattle(actors, bossId, sceneId, endConds);
  587. }
  588. public bool PreloadTimeBattle(LuaTable luaTbl,
  589. BattleSubMode mode,
  590. float maxFightingTime,
  591. string sceneName,
  592. string bgmMusic,
  593. ActorData[] ourActors,
  594. ActorData[] enemyActors,
  595. ServerFighterParam[] fighterParams,
  596. BattleEndCondition[] endConds,
  597. ValType[] factors,
  598. int nRestoreSp,
  599. GvGMark[] OurMarks,
  600. GvGMark[] EnemyMarks
  601. )
  602. {
  603. mEnterSceneType = SceneType.TimeBattleScene;
  604. return BattleMgr.Instance.StartTimeBattle(luaTbl, mode, maxFightingTime, sceneName, bgmMusic, ourActors, enemyActors, fighterParams, endConds, factors, nRestoreSp, OurMarks, EnemyMarks);
  605. }
  606. public bool ReplayTimeBattle(LuaTable luaTbl, BattleSubMode mode, float maxFightingTime, string sceneName, string bgmMusic, string battleRecordStr)
  607. {
  608. mEnterSceneType = SceneType.TimeBattleScene;
  609. return BattleMgr.Instance.ReplayTimeBattle(luaTbl, mode, maxFightingTime, sceneName, bgmMusic, battleRecordStr);
  610. }
  611. public void ForceStopBattle()
  612. {
  613. BattleMgr.Instance.ForceStopBattle();
  614. }
  615. //关闭清空战斗
  616. public void ShutDownBattle(bool bIsDispose = true)
  617. {
  618. BattleMgr.Instance.ShutDownCurrentBattle(bIsDispose);
  619. }
  620. //销毁战斗
  621. public void DisposeBattle()
  622. {
  623. BattleMgr.Instance.DisposeCurrentBattle();
  624. }
  625. public void SetGameSpeed(float speed)
  626. {
  627. BattleMgr.Instance.SetSpeedUp(speed);
  628. }
  629. public void SaveGameSpeed(float speed)
  630. {
  631. mGameSpeed = speed;
  632. BattleMgr.Instance.SetSpeedUp(speed);
  633. }
  634. public float GetGameSpeed()
  635. {
  636. return BattleMgr.speed_up_rate;
  637. }
  638. private void OnLoadComplete(CoreEvent<bool> ce)
  639. {
  640. #if USE_LUA
  641. if (OnSceneLoaded2Lua != null)
  642. {
  643. OnSceneLoaded2Lua.Call(this, mEnterSceneType, BattleMgr.Instance.Battle != null ? BattleMgr.Instance.Battle.SubBattleMode : BattleSubMode.None);
  644. }
  645. #else
  646. EnterBattleState();
  647. #endif
  648. }
  649. public int Random(int min, int max)
  650. {
  651. return max > min ? rand.Next(min, max) : min;
  652. }
  653. public uint CalcPassedTime(long timeStr)
  654. {
  655. ulong time = (ulong)timeStr;
  656. time = TimerManager.Instance.serverTime - time;
  657. if (time > uint.MaxValue)
  658. {
  659. return uint.MaxValue;
  660. }
  661. else if (time < 0)
  662. {
  663. return 0;
  664. }
  665. else
  666. {
  667. return (uint)time;
  668. }
  669. }
  670. public void QuitGame(bool isShowView = false)
  671. {
  672. //需要打开退出页面
  673. if (isShowView)
  674. {
  675. //如果sdk有就打开
  676. if (SDKMgr.Instance.CheckHasModul(SDKModulType.EXIT_VIEW))
  677. {
  678. SDKMgr.Instance.OpenModul(SDKModulType.EXIT_VIEW);
  679. }
  680. else
  681. {
  682. if (!SDKMgr.Instance.Exit())
  683. {
  684. KillApplication();
  685. }
  686. }
  687. }
  688. else
  689. {
  690. if (!SDKMgr.Instance.Exit())
  691. {
  692. KillApplication();
  693. }
  694. }
  695. }
  696. private void KillApplication()
  697. {
  698. // 游戏需要保存数据的在这里保存
  699. GameSettings.Instance.Save();
  700. if (SDKMgr.Instance.Quit()) return;
  701. #if UNITY_EDITOR
  702. UnityEditor.EditorApplication.isPlaying = false;
  703. #else
  704. Application.Quit();
  705. #endif
  706. }
  707. public void PlayDialog(int dialogueType, int dialogueId = 0)
  708. {
  709. if (mPlayStoryLuaFun != null)
  710. mPlayStoryLuaFun.Call(this, dialogueType, dialogueId);
  711. }
  712. public void RequestHttpServer(string url, LuaFunction luaFunc_)
  713. {
  714. StartCoroutine(DoRequestHttpServer(url, luaFunc_));
  715. }
  716. IEnumerator DoRequestHttpServer(string url, LuaFunction luaFunc_)
  717. {
  718. if (string.IsNullOrEmpty(url))
  719. {
  720. yield break;
  721. }
  722. WWW httpReq = new WWW(url);
  723. yield return httpReq;
  724. if (!string.IsNullOrEmpty(httpReq.error))
  725. {
  726. DebugHelper.LogError("DoRequestHttpServer failed:{0}[url = {1}]", httpReq.error,url);
  727. httpReq.Dispose();
  728. httpReq = null;
  729. yield break;
  730. }
  731. string content = httpReq.text;
  732. httpReq.Dispose();
  733. httpReq = null;
  734. if (luaFunc_ != null)
  735. {
  736. luaFunc_.Call(content);
  737. }
  738. }
  739. public void CleanUnusedAssets()
  740. {
  741. StartCoroutine(UnloadAssets_Coroutine());
  742. }
  743. public void OpenUrl(string url)
  744. {
  745. if (string.IsNullOrEmpty(url)) return;
  746. SDKMgr.Instance.OpenWebview(url);
  747. //Application.OpenURL(url);
  748. }
  749. public void CopyBuff(string buff)
  750. {
  751. if (string.IsNullOrEmpty(buff)) return;
  752. GUIUtility.systemCopyBuffer = buff;
  753. }
  754. public void EnableAntiAliasing()
  755. {
  756. if (DeviceInfo.m_DeviceState == DeviceInfo.eDeviceState.NORMAL_DEVICE)
  757. {
  758. QualitySettings.antiAliasing = 2;
  759. }
  760. else if (DeviceInfo.m_DeviceState == DeviceInfo.eDeviceState.GOOD_DEVICE)
  761. {
  762. QualitySettings.antiAliasing = 4;
  763. }
  764. //DebugHelper.LogError("antiAliasing" + QualitySettings.antiAliasing);
  765. }
  766. public void DisableAntiAliasing()
  767. {
  768. QualitySettings.antiAliasing = 0;
  769. //DebugHelper.LogError("antiAliasing" + QualitySettings.antiAliasing);
  770. }
  771. IEnumerator UnloadAssets_Coroutine()
  772. {
  773. yield return 0;
  774. yield return Resources.UnloadUnusedAssets();
  775. System.GC.Collect();
  776. }
  777. #region inner_methods
  778. private void RegisterEvents()
  779. {
  780. EventMgr.AddEventListener<int>(ECoreEventType.EID_Logout, OnLogout);
  781. EventMgr.AddEventListener<bool>(ECoreEventType.EID_LOAD_COMPLETE, OnLoadComplete);
  782. //EventMgr.AddEventListener<bool,string>(ECoreEventType.EID_SDK_INIT_RESULT, OnSdkInitRet);
  783. //EventMgr.AddEventListener<bool, UserInfo>(ECoreEventType.EID_SDK_LOGIN_RESULT_NEW, OnSdkLoginRet);
  784. //EventMgr.AddEventListener<bool, UserInfo>(ECoreEventType.EID_SDK_SWITCH_ACCOUNT_NEW, OnSdkSwitchAccount);
  785. //EventMgr.AddEventListener<bool>(ECoreEventType.EID_SDK_LOGOUT, OnSdkLogout);
  786. //EventMgr.AddEventListener<bool>(ECoreEventType.EID_SDK_EXIT, OnSdkExit);
  787. //EventMgr.AddEventListener<bool>(ECoreEventType.EID_SDK_PAY_SUCCESS, OnSdkPaySuccess);
  788. EventMgr.AddEventListener<bool>(ECoreEventType.EID_SDK_PAY_CANCEL, OnSdkPayCancel);
  789. //EventMgr.AddEventListener<bool>(ECoreEventType.EID_SDK_PAY_FAILED, OnSdkPayFailed);
  790. EventMgr.AddEventListener<bool>(ECoreEventType.EID_SDK_QUESTION_REWARD_RESULT, OnSdkQuestionRewardResult);
  791. SDKEventUtil.AddListener(SDKCBEnum.EXIT_SUCCESS_CB, OnSdkExit);
  792. SDKEventUtil.AddListener(SDKCBEnum.INIT_FAILED_CB, OnSdkInitFail);
  793. SDKEventUtil.AddListener(SDKCBEnum.INIT_SUCCESS_CB, OnSdkInitSuccess);
  794. SDKEventUtil.AddListener(SDKCBEnum.LOGIN_FAILED_CB, OnSdkLoginFail);
  795. SDKEventUtil.AddListener(SDKCBEnum.LOGIN_SUCCESS_CB, OnSdkLoginSuccess);
  796. SDKEventUtil.AddListener(SDKCBEnum.LOGOUT_SUCCESS_CB, OnSdkLogoutSuccess);
  797. SDKEventUtil.AddListener(SDKCBEnum.PAY_FAILED_CB, OnSdkPayFailed);
  798. SDKEventUtil.AddListener(SDKCBEnum.PAY_SUCCESS_CB, OnSdkPaySuccess);
  799. SDKEventUtil.AddListener(SDKCBEnum.SWITCH_FAILED_CB, OnSdkSwitchAccountFailed);
  800. SDKEventUtil.AddListener(SDKCBEnum.SWITCH_SUCCESS_CB, OnSdkSwitchAccountSuccess);
  801. SDKEventUtil.AddListener(SDKCBEnum.CAN_ENTER_SERVER_JUDGE_CB, OnSdkCanEnterServerJudge);
  802. }
  803. private void UnRegisterEvents()
  804. {
  805. EventMgr.RemoveEventListener<int>(ECoreEventType.EID_Logout, OnLogout);
  806. EventMgr.RemoveEventListener<bool>(ECoreEventType.EID_LOAD_COMPLETE, OnLoadComplete);
  807. //EventMgr.RemoveEventListener<bool,string>(ECoreEventType.EID_SDK_INIT_RESULT, OnSdkInitRet);
  808. //EventMgr.RemoveEventListener<bool, UserInfo>(ECoreEventType.EID_SDK_LOGIN_RESULT_NEW, OnSdkLoginRet);
  809. //EventMgr.RemoveEventListener<bool, UserInfo>(ECoreEventType.EID_SDK_SWITCH_ACCOUNT_NEW, OnSdkSwitchAccount);
  810. //EventMgr.RemoveEventListener<bool>(ECoreEventType.EID_SDK_LOGOUT, OnSdkLogout);
  811. //EventMgr.RemoveEventListener<bool>(ECoreEventType.EID_SDK_EXIT, OnSdkExit);
  812. //EventMgr.RemoveEventListener<bool>(ECoreEventType.EID_SDK_PAY_SUCCESS, OnSdkPaySuccess);
  813. EventMgr.RemoveEventListener<bool>(ECoreEventType.EID_SDK_PAY_CANCEL, OnSdkPayCancel);
  814. EventMgr.RemoveEventListener<bool>(ECoreEventType.EID_SDK_PAY_FAILED, OnSdkPayFailed);
  815. EventMgr.RemoveEventListener<bool>(ECoreEventType.EID_SDK_QUESTION_REWARD_RESULT, OnSdkQuestionRewardResult);
  816. SDKEventUtil.RemoveListener(SDKCBEnum.EXIT_SUCCESS_CB, OnSdkExit);
  817. SDKEventUtil.RemoveListener(SDKCBEnum.INIT_FAILED_CB, OnSdkInitFail);
  818. SDKEventUtil.RemoveListener(SDKCBEnum.INIT_SUCCESS_CB, OnSdkInitSuccess);
  819. SDKEventUtil.RemoveListener(SDKCBEnum.LOGIN_FAILED_CB, OnSdkLoginFail);
  820. SDKEventUtil.RemoveListener(SDKCBEnum.LOGIN_SUCCESS_CB, OnSdkLoginSuccess);
  821. SDKEventUtil.RemoveListener(SDKCBEnum.LOGOUT_SUCCESS_CB, OnSdkLogoutSuccess);
  822. SDKEventUtil.RemoveListener(SDKCBEnum.PAY_FAILED_CB, OnSdkPayFailed);
  823. SDKEventUtil.RemoveListener(SDKCBEnum.PAY_SUCCESS_CB, OnSdkPaySuccess);
  824. SDKEventUtil.RemoveListener(SDKCBEnum.SWITCH_FAILED_CB, OnSdkSwitchAccountFailed);
  825. SDKEventUtil.RemoveListener(SDKCBEnum.SWITCH_SUCCESS_CB, OnSdkSwitchAccountSuccess);
  826. SDKEventUtil.RemoveListener(SDKCBEnum.CAN_ENTER_SERVER_JUDGE_CB, OnSdkCanEnterServerJudge);
  827. }
  828. private void StartLog()
  829. {
  830. DebugHelper debugHelper = this.gameObject.GetComponent<DebugHelper>();
  831. if (debugHelper == null)
  832. {
  833. this.gameObject.AddComponent<DebugHelper>();
  834. }
  835. DebugHelper.enableLog = true;
  836. DebugHelper.BeginLogs();
  837. }
  838. private IEnumerator ReadVersionFile()
  839. {
  840. string path = FileSystem.LocalPackagePath;
  841. #if !UNITY_STANDALONE_WIN
  842. #if UNITY_EDITOR //editor
  843. path = string.Format("{0}/", Application.dataPath);
  844. #elif UNITY_ANDROID && !UNITY_EDITOR//android release;
  845. path = FileSystem.LocalPackagePath;
  846. #elif UNITY_IPHONE && !UNITY_EDITOR //ios release;
  847. path = FileSystem.LocalPackagePath;
  848. #else //pc release;
  849. path = Application.dataPath;
  850. #endif
  851. #else
  852. path = FileSystem.LocalPackagePath;
  853. #endif
  854. //热更地址从新整合的配置中提取
  855. string UpdateFilePath = string.Format("{0}appbuildconfig.xml", path);
  856. WWW www = new WWW(UpdateFilePath);
  857. DebugHelper.Log("ReadUpdateFile : LocalPackagePath {0}", UpdateFilePath);
  858. yield return www;
  859. if (www.error == null)
  860. {
  861. DebugHelper.Log("ReadUpdateFile : {0}", www.text);
  862. www.Dispose();
  863. www = null;
  864. }
  865. else
  866. {
  867. DebugHelper.LogError("ReadUpdateFile {0} , {1}", www.error, UpdateFilePath);
  868. www.Dispose();
  869. www = null;
  870. }
  871. }
  872. #endregion
  873. #region ACCOUNT_SDK
  874. //private SDKMgr SdkManager = SDKMgr.Instance;
  875. private LuaFunction mSdkInitedLuaCB = null;
  876. private LuaFunction mSdkLoginedLuaCB = null;
  877. private LuaFunction mSdkLoginFuncOtherArgLuaCB = null;
  878. private LuaFunction mSdkLogoutLuaCB = null;
  879. private LuaFunction mSdkPayLuaCB = null;
  880. private LuaFunction msdkQuestionLuaCB = null;
  881. private LuaFunction mSdkCanEnterServerJudgeCB = null;
  882. public void SdkInitFunc(LuaFunction func)
  883. {
  884. mSdkInitedLuaCB = func;
  885. //mSdkInitedLuaCB.Call(this, true, "");
  886. }
  887. public void SdkLoginFunc(LuaFunction func)
  888. {
  889. mSdkLoginedLuaCB = func;
  890. }
  891. public void SdkLoginFuncOtherArg(LuaFunction func)
  892. {
  893. mSdkLoginFuncOtherArgLuaCB = func;
  894. }
  895. private void CallSdkLoginFuncOtherArgLuaCB(string time)
  896. {
  897. if (mSdkLoginFuncOtherArgLuaCB != null)
  898. {
  899. mSdkLoginFuncOtherArgLuaCB.Call(this,time);
  900. }
  901. }
  902. public void SdkLogoutFunc(LuaFunction func)
  903. {
  904. mSdkLogoutLuaCB = func;
  905. }
  906. public void SdkPayFunc(LuaFunction func)
  907. {
  908. mSdkPayLuaCB = func;
  909. }
  910. public void SdkQuestionFunc(LuaFunction func)
  911. {
  912. msdkQuestionLuaCB = func;
  913. }
  914. public void SdkCanEnterServerJudgeFunc(LuaFunction func)
  915. {
  916. mSdkCanEnterServerJudgeCB = func;
  917. }
  918. public void SetSDKName(string name)
  919. {
  920. sDKName = name;
  921. }
  922. public void InitSdkCfg()
  923. {
  924. string cname = "";
  925. #if UNITY_ANDROID
  926. cname = "AndroidShopProductIDCfg";
  927. #elif UNITY_IOS
  928. cname = "IOSShopProductIDCfg";
  929. #endif
  930. Dictionary<string, Dictionary<string, string>> datas = ConfigMgr.Instance.getTable(cname);
  931. if (datas != null)
  932. SDKMgr.Instance.InitProductCfg(datas);
  933. }
  934. public void SDKInit_P()
  935. {
  936. if (!string.IsNullOrEmpty(sDKName))
  937. {
  938. SDKMgr.Instance.SetSDKName(sDKName);
  939. }
  940. }
  941. public void SdkInit()
  942. {
  943. SDKInit_P();
  944. SDKMgr.Instance.Init();
  945. #if UNITY_IOS
  946. YouYiSDKiOS youYiSDKiOS = SDKMgr.Instance.sdk as YouYiSDKiOS;
  947. if (youYiSDKiOS != null)
  948. {
  949. youYiSDKiOS.qKGamesdk.InitProductCfg(ConfigMgr.Instance.getTable("IOSShopProductIDCfg"));
  950. }
  951. #endif
  952. InitSdkCfg();
  953. }
  954. public void SdkLogin()
  955. {
  956. SDKMgr.Instance.Login();
  957. }
  958. public void SdkPay(int goodsId, string goodsName, string goodsDesc,
  959. int count, float amount,
  960. string cpOrderId, string extrasParams)
  961. {
  962. int decimalVal = 1000;
  963. int tempVal = Mathf.FloorToInt((amount + 0.0005f) * decimalVal);
  964. amount = (float)tempVal / decimalVal;
  965. if (string.IsNullOrEmpty(goodsName))
  966. {
  967. goodsName = "初心者";
  968. }
  969. SDKMgr.Instance.Pay(goodsId, goodsName, goodsDesc,
  970. count, amount,
  971. cpOrderId, extrasParams);
  972. //Debug.Log($"goodsId = {goodsId} ==== goodsName = {goodsName} ===== goodsDesc = {goodsDesc} ===== count = {count} ===== amount = {amount} ====== cpOrderId = {cpOrderId} ==== extrasParams = {extrasParams}");
  973. }
  974. public void SdkLogout()
  975. {
  976. SDKMgr.Instance.Logout();
  977. }
  978. public void SdkExit()
  979. {
  980. }
  981. public void SdkShowToolbar()
  982. {
  983. //int ret = quicksdk.QuickSDK.getInstance().showToolBar(quicksdk.ToolbarPlace.QUICK_SDK_TOOLBAR_MID_LEFT);
  984. //DebugHelper.LogError("SdkShowToolbar:" + ret);
  985. }
  986. public void SdkHideToolBar()
  987. {
  988. //SdkManager.SdkHideToolBar();
  989. }
  990. private void OnSdkInitFail(object obj)
  991. {
  992. if (mSdkInitedLuaCB != null)
  993. {
  994. mSdkInitedLuaCB.Call(this, false, SDKMgr.Instance.GetSDKName());
  995. }
  996. }
  997. private void OnSdkInitSuccess(object obj)
  998. {
  999. if (mSdkInitedLuaCB != null)
  1000. {
  1001. mSdkInitedLuaCB.Call(this, true, SDKMgr.Instance.GetSDKName());
  1002. }
  1003. }
  1004. private void OnSdkLoginFail(object obj)
  1005. {
  1006. if (mSdkLoginedLuaCB != null)
  1007. {
  1008. mSdkLoginedLuaCB.Call(this, false, "", "", false);
  1009. SDKMgr.Instance.ReportRoleEnterFail();
  1010. }
  1011. }
  1012. private void OnSdkLoginSuccess(object obj)
  1013. {
  1014. if (mSdkLoginedLuaCB != null)
  1015. {
  1016. if (obj != null)
  1017. {
  1018. UserInfo userInfo = (UserInfo)obj;
  1019. CallSdkLoginFuncOtherArgLuaCB(userInfo.timeSp);
  1020. mSdkLoginedLuaCB.Call(this, true, userInfo.uid, userInfo.token, false);
  1021. SDKMgr.Instance.ReportIdentification(SDKMgr.Instance.GetInt64TimeStamp());
  1022. }
  1023. else
  1024. {
  1025. mSdkLoginedLuaCB.Call(this, true, "", "", false);
  1026. }
  1027. }
  1028. }
  1029. private void OnSdkSwitchAccountFailed(object obj)
  1030. {
  1031. if (mSdkLoginedLuaCB != null)
  1032. {
  1033. UserInfo userInfo = (UserInfo)obj;
  1034. CallSdkLoginFuncOtherArgLuaCB(userInfo.timeSp);
  1035. mSdkLoginedLuaCB.Call(this, false, userInfo.uid, userInfo.token, true);
  1036. }
  1037. }
  1038. private void OnSdkSwitchAccountSuccess(object obj)
  1039. {
  1040. if (mSdkLoginedLuaCB != null)
  1041. {
  1042. UserInfo userInfo = (UserInfo)obj;
  1043. CallSdkLoginFuncOtherArgLuaCB(userInfo.timeSp);
  1044. mSdkLoginedLuaCB.Call(this, true, userInfo.uid, userInfo.token, true);
  1045. }
  1046. }
  1047. private void OnSdkLogoutSuccess(object obj)
  1048. {
  1049. if (mSdkLogoutLuaCB != null)
  1050. {
  1051. mSdkLogoutLuaCB.Call(this);
  1052. }
  1053. }
  1054. private void OnSdkExit(object obj)
  1055. {
  1056. KillApplication();
  1057. }
  1058. private void OnSdkPaySuccess(object obj)
  1059. {
  1060. if (mSdkPayLuaCB != null)
  1061. {
  1062. mSdkPayLuaCB.Call(this, true);
  1063. }
  1064. }
  1065. private void OnSdkPayCancel(CoreEvent<bool> ce)
  1066. {
  1067. if (mSdkPayLuaCB != null)
  1068. {
  1069. mSdkPayLuaCB.Call(this, false);
  1070. }
  1071. }
  1072. private void OnSdkPayFailed(object obj)
  1073. {
  1074. if (mSdkPayLuaCB != null)
  1075. {
  1076. mSdkPayLuaCB.Call(this, false);
  1077. }
  1078. }
  1079. private void OnSdkQuestionRewardResult(CoreEvent<bool> ce)
  1080. {
  1081. if (msdkQuestionLuaCB != null)
  1082. {
  1083. msdkQuestionLuaCB.Call(this, true);
  1084. }
  1085. }
  1086. private void OnSdkCanEnterServerJudge(object obj)
  1087. {
  1088. if (mSdkCanEnterServerJudgeCB != null)
  1089. {
  1090. mSdkCanEnterServerJudgeCB.Call(this, "" + obj);
  1091. }
  1092. }
  1093. #endregion
  1094. #region 新加
  1095. private Dictionary<int, int> mDifAttrs = new Dictionary<int, int>();
  1096. public void ClearDifAttr()
  1097. {
  1098. mDifAttrs.Clear();
  1099. }
  1100. public void AddDifAttr(int type,int attr)
  1101. {
  1102. mDifAttrs.Add(type, attr);
  1103. }
  1104. public void AddDifAttrs(Dictionary<object, object> difAttrs)
  1105. {
  1106. foreach (var item in difAttrs)
  1107. {
  1108. mDifAttrs.Add((int)item.Key,(int)item.Value);
  1109. }
  1110. }
  1111. public Dictionary<int, int> GetDifAttrs()
  1112. {
  1113. return mDifAttrs;
  1114. }
  1115. #endregion
  1116. }