GameMgr.cs 37 KB

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