Manager.cs 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491
  1. using LitJson;
  2. using UnityEngine;
  3. using UnityEngine.UI;
  4. using UnityEngine.Events;
  5. using UnityEngine.Analytics;
  6. using UnityEngine.EventSystems;
  7. using System;
  8. using System.Xml;
  9. using System.Collections;
  10. using System.Collections.Generic;
  11. public class Manager : Regist
  12. {
  13. #region Config
  14. #region 成就
  15. public static double PlayADsAmt
  16. {
  17. get { return playADsAmt; }
  18. set
  19. {
  20. playADsAmt = value;
  21. AchieveManager.UpdateStatus(AchieveType.PlayADsAmt, playADsAmt);
  22. }
  23. }
  24. private static double playADsAmt;
  25. public static double UseSkillAmt
  26. {
  27. get { return useSkillAmt; }
  28. set
  29. {
  30. useSkillAmt = value;
  31. AchieveManager.UpdateStatus(AchieveType.UseSkillAmt, useSkillAmt);
  32. }
  33. }
  34. private static double useSkillAmt;
  35. public static double SignAmt
  36. {
  37. get { return signAmt; }
  38. set
  39. {
  40. signAmt = value;
  41. AchieveManager.UpdateStatus(AchieveType.SignAmt, signAmt);
  42. }
  43. }
  44. private static double signAmt;
  45. public static double CloseAmt
  46. {
  47. get { return closeAmt; }
  48. set
  49. {
  50. closeAmt = value;
  51. AchieveManager.UpdateStatus(AchieveType.CloseAmt, closeAmt);
  52. }
  53. }
  54. private static double closeAmt;
  55. public static double ShareAmt
  56. {
  57. get { return shareAmt; }
  58. set
  59. {
  60. shareAmt = value;
  61. AchieveManager.UpdateStatus(AchieveType.ShareAmt, shareAmt);
  62. }
  63. }
  64. private static double shareAmt;
  65. public static double PlayMinigameAmt
  66. {
  67. get { return playMinigameAmt; }
  68. set
  69. {
  70. playMinigameAmt = value;
  71. AchieveManager.UpdateStatus(AchieveType.PlayMinigameAmt, playMinigameAmt);
  72. }
  73. }
  74. private static double playMinigameAmt;
  75. public static double AllElfLevel
  76. {
  77. get { return allElfLevel; }
  78. set
  79. {
  80. allElfLevel = value;
  81. AchieveManager.UpdateStatus(AchieveType.AllElfLevel, allElfLevel);
  82. }
  83. }
  84. private static double allElfLevel;
  85. public static double TotalCoin
  86. {
  87. get { return totalCoin; }
  88. set
  89. {
  90. totalCoin = value;
  91. AchieveManager.UpdateStatus(AchieveType.TotalCoin, totalCoin);
  92. }
  93. }
  94. private static double totalCoin;
  95. public static double TotalFlowerAwardCoin
  96. {
  97. get { return totalFlowerAwardCoin; }
  98. set
  99. {
  100. totalFlowerAwardCoin = value;
  101. AchieveManager.UpdateStatus(AchieveType.TotalFlowerAwardCoin, totalFlowerAwardCoin);
  102. }
  103. }
  104. private static double totalFlowerAwardCoin;
  105. public static double TotalVisitPerson
  106. {
  107. get { return totalVisitPerson; }
  108. set
  109. {
  110. totalVisitPerson = value;
  111. AchieveManager.UpdateStatus(AchieveType.TotalVisitPerson, totalVisitPerson);
  112. }
  113. }
  114. private static double totalVisitPerson;
  115. public static double TotalSpendDiamond
  116. {
  117. get { return totalSpendDiamond; }
  118. set
  119. {
  120. totalSpendDiamond = value;
  121. AchieveManager.UpdateStatus(AchieveType.TotalSpendDiamond, totalSpendDiamond);
  122. }
  123. }
  124. private static double totalSpendDiamond;
  125. public static double CreateRoomAmt
  126. {
  127. get { return createRoomAmt; }
  128. set
  129. {
  130. createRoomAmt = value;
  131. AchieveManager.UpdateStatus(AchieveType.CreateRoomAmt, createRoomAmt);
  132. }
  133. }
  134. private static double createRoomAmt;
  135. public static double CreateChestAmt
  136. {
  137. get { return createChestAmt; }
  138. set
  139. {
  140. createChestAmt = value;
  141. AchieveManager.UpdateStatus(AchieveType.CreateChestAmt, createChestAmt);
  142. }
  143. }
  144. private static double createChestAmt;
  145. public static double CreateLuckyChestAmt
  146. {
  147. get { return createLuckyChestAmt; }
  148. set
  149. {
  150. createLuckyChestAmt = value;
  151. AchieveManager.UpdateStatus(AchieveType.CreateLuckyChestAmt, createLuckyChestAmt);
  152. }
  153. }
  154. private static double createLuckyChestAmt;
  155. public static double CreateGuessColorChestAmt
  156. {
  157. get { return createGuessColorChestAmt; }
  158. set
  159. {
  160. createGuessColorChestAmt = value;
  161. AchieveManager.UpdateStatus(AchieveType.CreateGuessColorChestAmt, createGuessColorChestAmt);
  162. }
  163. }
  164. private static double createGuessColorChestAmt;
  165. public static double CreateGuessNumberChestAmt
  166. {
  167. get { return createGuessNumberChestAmt; }
  168. set
  169. {
  170. createGuessNumberChestAmt = value;
  171. AchieveManager.UpdateStatus(AchieveType.CreateGuessNumberChestAmt, createGuessNumberChestAmt);
  172. }
  173. }
  174. private static double createGuessNumberChestAmt;
  175. public static double GetChestAwardAmt
  176. {
  177. get { return getChestAwardAmt; }
  178. set
  179. {
  180. getChestAwardAmt = value;
  181. AchieveManager.UpdateStatus(AchieveType.GetChestAwardAmt, getChestAwardAmt);
  182. }
  183. }
  184. private static double getChestAwardAmt;
  185. #endregion
  186. public static Action<int> OnLevelChange;
  187. public static Action<double> OnCoinChange;
  188. public static Action<double> OnDiamondChange;
  189. public static int GardenLevel
  190. {
  191. get { return gardenLevel; }
  192. set
  193. {
  194. gardenLevel = value;
  195. if (!Inited)
  196. {
  197. return;
  198. }
  199. LanguageManager.Add(ResourceManager.Get<Text>(CanvasLabel.C_LevelText), new MulLanStr(LanguageLabel.UI__C_Level), gardenLevel.ToString());
  200. VisitManager.UpdateVisitCost();
  201. AchieveManager.UpdateStatus(AchieveType.GardenLevel, gardenLevel);
  202. for (int i = 0; i < SkillList.Count; i++)
  203. {
  204. SkillList[i].UpdateStatus();
  205. }
  206. foreach (var kv in PlayerManager.CloseItemDictionary)
  207. {
  208. kv.Value.OnLevelChange();
  209. }
  210. if (OnLevelChange != null)
  211. {
  212. OnLevelChange.Invoke(gardenLevel);
  213. }
  214. if (gardenLevel >= TutorialManager.MemoryMinigameTutorialLevel)
  215. {
  216. if (TutorialManager.memoryMinigameTutorial)
  217. {
  218. TutorialManager.MemoryMinigameTutorial = true;
  219. }
  220. }
  221. if (GardenLevel < TutorialManager.DressroomTutorialLevel)
  222. {
  223. ResourceManager.Get<Image>(CanvasLabel.C_DressRoom).material = Lib.GrayMat;
  224. }
  225. else
  226. {
  227. ResourceManager.Get<Image>(CanvasLabel.C_DressRoom).material = null;
  228. }
  229. if (GardenManager.TotalUnlockFlower >= TutorialManager.MinFlowerForFindSoloGame && gardenLevel >= TutorialManager.FindSoloMinigameTutorialLevel)
  230. {
  231. if (TutorialManager.findSoloMinigameTutorial)
  232. {
  233. TutorialManager.PlayFindSoloGame();
  234. }
  235. }
  236. if (GardenManager.TotalUnlockFlower >= TutorialManager.MinFlowerForFindMissingGame && gardenLevel >= TutorialManager.FindMissingMinigameTutorialLevel)
  237. {
  238. if (TutorialManager.findMissingMinigameTutorial)
  239. {
  240. TutorialManager.PlayFindMissingGame();
  241. }
  242. }
  243. if (gardenLevel >= TutorialManager.CommentTutorialLevel)
  244. {
  245. ResourceManager.Get(CanvasLabel.C_CommentParent).TweenForCG();
  246. }
  247. if (gardenLevel >= TutorialManager.VisitTutorialLevel)
  248. {
  249. if (TutorialManager.visitTutorial)
  250. {
  251. TutorialManager.ClickVisitBtn();
  252. return;
  253. }
  254. else
  255. {
  256. ResourceManager.SetActive(CanvasLabel.C_Visit, true);
  257. }
  258. }
  259. if (gardenLevel >= TutorialManager.DressroomTutorialLevel)
  260. {
  261. if (TutorialManager.dressroomTutorial)
  262. {
  263. TutorialManager.ClickDressroomButton();
  264. return;
  265. }
  266. }
  267. if (gardenLevel >= TutorialManager.PlazaRoomTutorialLevel)
  268. {
  269. if (TutorialManager.plazaRoomTutorial)
  270. {
  271. TutorialManager.ClickPlazaRoomBtn();
  272. return;
  273. }
  274. else
  275. {
  276. ResourceManager.SetActive(CanvasLabel.C_EnterPlazaRoom, true);
  277. ResourceManager.SetActive(CanvasLabel.C_EnterPlazaRoom0, true);
  278. }
  279. }
  280. }
  281. }
  282. private static int gardenLevel;
  283. public static float Person
  284. {
  285. get { return person; }
  286. set
  287. {
  288. person = value;
  289. ResourceManager.SetText(CanvasLabel.F_PersonLab, Auxiliary.ShrinkBigNumberStr(CurrentPerson*60));
  290. }
  291. }
  292. private static float person;
  293. public static List<string> ExtraPersonSourceSpritesName = new List<string>();
  294. public static float CoinPerson
  295. {
  296. get { return coinPerson; }
  297. set
  298. {
  299. coinPerson = value;
  300. ResourceManager.SetText(CanvasLabel.F_CoinPersonLab, Auxiliary.ShrinkBigNumberStr(CurrentCoinPerson));
  301. }
  302. }
  303. private static float coinPerson;
  304. public static List<string> ExtraCoinPersonSourceSpritesName = new List<string>();
  305. public static float SkillPerson
  306. {
  307. get { return skillPerson; }
  308. set
  309. {
  310. skillPerson = value;
  311. //TweenOutline tween = ResourceManager.Get(CanvasLabel.F_PersonLab).GetTweenOutline();
  312. //if (skillPerson.Equal(0))
  313. //{
  314. // tween.Pause();
  315. // tween.Target.enabled = false;
  316. //}
  317. //else
  318. //{
  319. // if (tween.InPause)
  320. // {
  321. // tween.Resume();
  322. // tween.Target.enabled = true;
  323. // }
  324. // else
  325. // {
  326. // tween.StartForward();
  327. // }
  328. //}
  329. Person = Person;
  330. }
  331. }
  332. public static float skillPerson;
  333. public static float TempSkillPerson
  334. {
  335. get { return tempSkillPerson; }
  336. set
  337. {
  338. tempSkillPerson = value;
  339. TweenOutline tween = ResourceManager.Get(CanvasLabel.F_PersonLab).GetTweenOutline();
  340. if (tempSkillPerson.Equal(0) && tempSkillPersonBuff.Equal(0))
  341. {
  342. tween.Pause();
  343. tween.Target.enabled = false;
  344. }
  345. else
  346. {
  347. if (tween.InPause)
  348. {
  349. tween.Resume();
  350. tween.Target.enabled = true;
  351. }
  352. else
  353. {
  354. tween.StartForward();
  355. }
  356. }
  357. Person = Person;
  358. }
  359. }
  360. public static float tempSkillPerson;
  361. public static float SkillPersonBuff
  362. {
  363. get { return skillPersonBuff; }
  364. set
  365. {
  366. skillPersonBuff = value;
  367. Person = Person;
  368. }
  369. }
  370. public static float skillPersonBuff;
  371. public static float TempSkillPersonBuff
  372. {
  373. get { return tempSkillPersonBuff; }
  374. set
  375. {
  376. tempSkillPersonBuff = value;
  377. TweenOutline tween = ResourceManager.Get(CanvasLabel.F_PersonLab).GetTweenOutline();
  378. if (tempSkillPerson.Equal(0) && tempSkillPersonBuff.Equal(0))
  379. {
  380. tween.Pause();
  381. tween.Target.enabled = false;
  382. }
  383. else
  384. {
  385. if (tween.InPause)
  386. {
  387. tween.Resume();
  388. tween.Target.enabled = true;
  389. }
  390. else
  391. {
  392. tween.StartForward();
  393. }
  394. }
  395. Person = Person;
  396. }
  397. }
  398. public static float tempSkillPersonBuff;
  399. public static float SkillCoinPerson
  400. {
  401. get { return skillCoinPerson; }
  402. set
  403. {
  404. skillCoinPerson = value;
  405. CoinPerson = CoinPerson;
  406. }
  407. }
  408. public static float skillCoinPerson;
  409. public static float TempSkillCoinPerson
  410. {
  411. get { return tempSkillCoinPerson; }
  412. set
  413. {
  414. tempSkillCoinPerson = value;
  415. TweenOutline tween = ResourceManager.Get(CanvasLabel.F_CoinPersonLab).GetTweenOutline();
  416. if (tempSkillCoinPerson.Equal(0) && tempSkillCoinPersonBuff.Equal(0))
  417. {
  418. tween.Pause();
  419. tween.Target.enabled = false;
  420. }
  421. else
  422. {
  423. if (tween.InPause)
  424. {
  425. tween.Resume();
  426. tween.Target.enabled = true;
  427. }
  428. else
  429. {
  430. tween.StartForward();
  431. }
  432. }
  433. CoinPerson = CoinPerson;
  434. }
  435. }
  436. public static float tempSkillCoinPerson;
  437. public static float SkillCoinPersonBuff
  438. {
  439. get { return skillCoinPersonBuff; }
  440. set
  441. {
  442. skillCoinPersonBuff = value;
  443. CoinPerson = CoinPerson;
  444. }
  445. }
  446. public static float skillCoinPersonBuff;
  447. public static float TempSkillCoinPersonBuff
  448. {
  449. get { return tempSkillCoinPersonBuff; }
  450. set
  451. {
  452. tempSkillCoinPersonBuff = value;
  453. TweenOutline tween = ResourceManager.Get(CanvasLabel.F_CoinPersonLab).GetTweenOutline();
  454. if (tempSkillCoinPersonBuff.Equal(0) && tempSkillCoinPerson.Equal(0))
  455. {
  456. tween.Pause();
  457. tween.Target.enabled = false;
  458. }
  459. else
  460. {
  461. if (tween.InPause)
  462. {
  463. tween.Resume();
  464. tween.Target.enabled = true;
  465. }
  466. else
  467. {
  468. tween.StartForward();
  469. }
  470. }
  471. CoinPerson = CoinPerson;
  472. }
  473. }
  474. public static float tempSkillCoinPersonBuff;
  475. public static float IncomeBuff
  476. {
  477. get { return SkillCoinPersonBuff + FlowerPlus; }
  478. }
  479. public static float FlowerPlus
  480. {
  481. get { return flowerPlus; }
  482. set
  483. {
  484. flowerPlus = value;
  485. }
  486. }
  487. public static float flowerPlus;
  488. public static float CurrentPerson
  489. {
  490. get
  491. {
  492. //Debug.Log(Person * (1 + SkillPersonBuff + TempSkillPersonBuff) + SkillPerson + TempSkillPerson);
  493. return Person*(1 + SkillPersonBuff + TempSkillPersonBuff) + SkillPerson + TempSkillPerson;
  494. }
  495. }
  496. public static float CurrentCoinPerson
  497. {
  498. get
  499. {
  500. //Debug.Log(CoinPerson * (1 + SkillCoinPersonBuff + TempSkillCoinPersonBuff) + SkillCoinPerson + TempSkillCoinPerson);
  501. return CoinPerson*(1 + SkillCoinPersonBuff + TempSkillCoinPersonBuff) + SkillCoinPerson + TempSkillCoinPerson;
  502. }
  503. }
  504. public static double Coin
  505. {
  506. get { return coin; }
  507. set
  508. {
  509. coin = value;
  510. ResourceManager.SetText(CanvasLabel.F_CoinLab, Auxiliary.ShrinkBigNumberStr(coin));
  511. ResourceManager.SetText(CanvasLabel.C_CoinLab, Auxiliary.ShrinkBigNumberStr(coin));
  512. ResourceManager.SetText(CanvasLabel.P_CoinLab, Auxiliary.ShrinkBigNumberStr(coin));
  513. AchieveManager.UpdateStatus(AchieveType.CurrentCoin, coin);
  514. OnCoinChange.SafeInvoke(coin);
  515. }
  516. }
  517. public static double coin;
  518. public static double Diamond
  519. {
  520. get { return diamond; }
  521. set
  522. {
  523. diamond = value;
  524. ResourceManager.SetText(CanvasLabel.F_DiamondLab, Auxiliary.ShrinkBigNumberStr(diamond));
  525. ResourceManager.SetText(CanvasLabel.P_DiamondLab, Auxiliary.ShrinkBigNumberStr(diamond));
  526. OnDiamondChange.SafeInvoke(diamond);
  527. }
  528. }
  529. public static double diamond;
  530. public static bool MinigameFlag;
  531. public static bool UploadConfigFlag;
  532. public static bool LoginFlag;
  533. public static bool OfflineFlag;
  534. public static bool ReactiveFlag;
  535. public static bool DownloadConfigFlag;
  536. public static bool SceneSwitchFlag;
  537. public static bool Inited;
  538. public static bool IsFirstFrame = true;
  539. public static bool InBackground;
  540. public static float IncomeDisplayTime = 60f;
  541. public static float IncomeCircleTime = 10;
  542. public static float IncomeCircleTimer;
  543. public static float CircleIncome
  544. {
  545. get
  546. {
  547. return CurrentPerson * IncomeCircleTime * CurrentCoinPerson * (1 + FlowerPlus);
  548. }
  549. }
  550. public static float OfflineTime;
  551. public static string OfflineIncomeFml;
  552. public static double OfflineMaxCoin;
  553. public static double OfflineMaxTime;
  554. public static double OfflineMinTime = 120f;
  555. public static float InputDetectTime = 60f;
  556. public static float InputDetectTimer;
  557. public static float LoginTime = 10f;
  558. public static float LoginTimer;
  559. public static float MinigameCDTimer;
  560. public static float UploadConfigTime = 60f;
  561. public static float UploadConfigTimer;
  562. public static Manager Instance;
  563. public static DateTime LastQuitTime;
  564. public static List<Skill> UsingSkillList = new List<Skill>();
  565. public static List<Skill> CoolSkillList = new List<Skill>();
  566. public static List<Skill> OfflineCoolSkillList = new List<Skill>();
  567. public static List<List<Skill>> OfflineUsingSkillList = new List<List<Skill>>();
  568. public static List<SkillRoot> SkillList = new List<SkillRoot>();
  569. public static Dictionary<string, SkillRoot> SkillDictionary = new Dictionary<string, SkillRoot>();
  570. #endregion
  571. private void Update()
  572. {
  573. LoginThread();
  574. if (TutorialManager.NewplayerTutorial)
  575. {
  576. return;
  577. }
  578. InputDetectThread();
  579. ProcessSkillThread();
  580. MinigameCDThread();
  581. UploadConfigThread();
  582. IncomeCircleThread();
  583. }
  584. private void InputDetectThread()
  585. {
  586. if (VisitManager.InVisit)
  587. {
  588. return;
  589. }
  590. if (Auxiliary.AnyKeyUp)
  591. {
  592. InputDetectTimer = 0;
  593. ResourceManager.Get(CanvasLabel.C_Group).TweenForCG();
  594. }
  595. else
  596. {
  597. InputDetectTimer += Time.deltaTime;
  598. if (InputDetectTimer >= InputDetectTime)
  599. {
  600. InputDetectTimer = 0;
  601. ResourceManager.Get(CanvasLabel.C_Group).TweenBacCG();
  602. }
  603. }
  604. }
  605. private void ProcessSkillThread()
  606. {
  607. for (int i = 0; i < UsingSkillList.Count; i++)
  608. {
  609. if (UsingSkillList[i].DoUpdate())
  610. {
  611. UsingSkillList.RemoveAt(i--);
  612. }
  613. }
  614. for (int i = 0; i < CoolSkillList.Count; i++)
  615. {
  616. if (CoolSkillList[i].DoCD())
  617. {
  618. CoolSkillList.RemoveAt(i--);
  619. }
  620. }
  621. }
  622. private void MinigameCDThread()
  623. {
  624. if (!MinigameFlag)
  625. {
  626. MinigameCDTimer -= Time.deltaTime;
  627. ResourceManager.SetText(CanvasLabel.C_MiniGameLab, Mathf.CeilToInt(MinigameCDTimer).ToString());
  628. if (MinigameCDTimer < 0)
  629. {
  630. MinigameFlag = true;
  631. ResourceManager.Get(CanvasLabel.C_MiniGame).TweenBacRect();
  632. ResourceManager.SetText(CanvasLabel.C_MiniGameLab, "");
  633. StaticsManager.GetInstance().RewardItem(StaticsManager.ItemID.获得小游戏, StaticsManager.ItemType.小游戏, "1", StaticsManager.ConsumeModule.None);
  634. }
  635. }
  636. }
  637. private void UploadConfigThread()
  638. {
  639. if (DownloadConfigFlag)
  640. {
  641. return;
  642. }
  643. UploadConfigTimer += Time.deltaTime;
  644. if (UploadConfigTimer >= UploadConfigTime)
  645. {
  646. UploadConfigTimer = 0;
  647. if (!PlayerPrefManager.GetBool(PlayerPrefManager.INTERACT_CONFIG, false))
  648. {
  649. HttpManager.GetSelfConfig();
  650. }
  651. else
  652. {
  653. HttpManager.UploadConfig();
  654. }
  655. }
  656. }
  657. private void LoginThread()
  658. {
  659. LoginTimer += Time.deltaTime;
  660. if (LoginTimer >= LoginTime)
  661. {
  662. LoginTimer = 0;
  663. HttpManager.Login();
  664. StaticsManager.GetInstance().Online();
  665. }
  666. }
  667. private void IncomeCircleThread()
  668. {
  669. IncomeCircleTimer -= Time.deltaTime;
  670. if (IncomeCircleTimer < 0)
  671. {
  672. IncomeCircleTimer = IncomeCircleTime;
  673. TotalVisitPerson += CurrentPerson * IncomeCircleTime;
  674. float circleIncome = CircleIncome;
  675. AddCoin(circleIncome, StaticsManager.ItemID.获得金币, StaticsManager.ConsumeModule.Income);
  676. ResourceManager.Get(CanvasLabel.C_IncomeLab).TweenReForGra();
  677. ResourceManager.Get(CanvasLabel.C_IncomeLab).TweenReForVec();
  678. ResourceManager.SetText(CanvasLabel.C_IncomeLab, "+" + Auxiliary.ShrinkBigNumberStr(circleIncome, 0));
  679. }
  680. }
  681. public static void AddCoin(double amt, StaticsManager.ItemID itemId, StaticsManager.ConsumeModule consumeModule)
  682. {
  683. Coin += amt;
  684. if (amt > 0)
  685. {
  686. TotalCoin += amt;
  687. StaticsManager.GetInstance().RewardItem(itemId, StaticsManager.ItemType.金币, amt.ToString("0"), consumeModule);
  688. }
  689. }
  690. public static void AddDiamond(double amt, StaticsManager.ItemID itemId, StaticsManager.ConsumeModule consumeModule)
  691. {
  692. Diamond += amt;
  693. if (amt > 0)
  694. {
  695. StaticsManager.GetInstance().RewardItem(itemId, StaticsManager.ItemType.钻石, amt.ToString("0"), consumeModule);
  696. }
  697. }
  698. public override void Reactive()
  699. {
  700. foreach (var kv in SkillDictionary)
  701. {
  702. kv.Value.Reactive();
  703. }
  704. InitAllSkill(false);
  705. GetOfflineIncome();
  706. SignManager.ShowPanels();
  707. }
  708. public override void InstantiatePrefabs()
  709. {
  710. #region 生成技能条
  711. #region 读技能配置
  712. List<XmlAttributeCollection> attributeList = ConfigManager.GetSkillConfig();
  713. for (int i = 0; i < attributeList.Count; i++)
  714. {
  715. SkillRoot skillRoot;
  716. #region MyRegion
  717. if (attributeList[i].Count == 18)
  718. {
  719. skillRoot = new Pack(attributeList[i]);
  720. }
  721. else if (attributeList[i].Count == 24)
  722. {
  723. skillRoot = new Ability(attributeList[i]);
  724. }
  725. else if (attributeList[i].Count == 34)
  726. {
  727. if (string.IsNullOrEmpty(attributeList[i][4].Value))
  728. {
  729. skillRoot = new Skill(attributeList[i]);
  730. }
  731. else
  732. {
  733. skillRoot = new BigSkill(attributeList[i]);
  734. }
  735. }
  736. else
  737. {
  738. throw new Exception(attributeList[i].Count.ToString());
  739. }
  740. #endregion
  741. SkillDictionary.Add(skillRoot.FullID, skillRoot);
  742. SkillList.Add(skillRoot);
  743. }
  744. SkillList.Sort(SkillRoot.Sort);
  745. #endregion
  746. for (int i = 0; i < SkillList.Count; i++)
  747. {
  748. if (SkillList[i].SkillTab != SkillTab.Null)
  749. {
  750. ResourceManager.GetSkillItem(SkillList[i]);
  751. }
  752. }
  753. #endregion
  754. }
  755. public override void FirstInit()
  756. {
  757. ResourceManager.Get<Graphic>(CanvasLabel.F_Elf).material = Lib.GrayMat;
  758. ResourceManager.Get<Graphic>(CanvasLabel.F_Store).material = Lib.GrayMat;
  759. ResourceManager.Get<Graphic>(CanvasLabel.F_Magic).material = Lib.GrayMat;
  760. ResourceManager.Get<Graphic>(CanvasLabel.F_ElfLab).material = Lib.GrayMat;
  761. ResourceManager.Get<Graphic>(CanvasLabel.F_StoreLab).material = Lib.GrayMat;
  762. ResourceManager.Get<Graphic>(CanvasLabel.F_MagicLab).material = Lib.GrayMat;
  763. ResourceManager.Get<Button>(CanvasLabel.F_Elf).interactable = false;
  764. ResourceManager.Get<Button>(CanvasLabel.F_Store).interactable = false;
  765. ResourceManager.Get<Button>(CanvasLabel.F_Magic).interactable = false;
  766. List<XmlAttributeCollection> attributeList = ConfigManager.GetSkillList();
  767. for (int i = 0; i < attributeList.Count; i++)
  768. {
  769. SkillRoot skillRoot = SkillDictionary[attributeList[i][0].Value];
  770. if (!(skillRoot is Skill))
  771. {
  772. skillRoot.RegistReference();
  773. skillRoot.Init(true, OfflineTime, OfflineUsingSkillList, attributeList[i]);
  774. }
  775. }
  776. }
  777. public override void SecondInit()
  778. {
  779. Instance = this;
  780. Coin = ConfigManager.GetDoubleFormConfig(PlayerConfigLabel.Coin);
  781. Diamond = ConfigManager.GetDoubleFormConfig(PlayerConfigLabel.Diamond);
  782. MinigameCDTimer = ConfigManager.GetFloatFormConfig(PlayerConfigLabel.MiniTimer);
  783. IncomeCircleTimer = ConfigManager.GetFloatFormConfig(PlayerConfigLabel.CircleTimer);
  784. if (MinigameCDTimer > 0)
  785. {
  786. ResourceManager.Get(CanvasLabel.C_MiniGame).TweenForRect();
  787. }
  788. else
  789. {
  790. MinigameFlag = true;
  791. }
  792. HttpManager.ID = ConfigManager.GetStringFormConfig(PlayerConfigLabel.ID);
  793. HttpManager.SerialNumber = ConfigManager.GetStringFormConfig(PlayerConfigLabel.SerialNumber);
  794. List<string> offlineList = ConfigManager.GetOfflineConfig();
  795. OfflineMaxCoin = Auxiliary.StringToLong(offlineList[1], 999999999999999999);
  796. OfflineMaxTime = Auxiliary.StringToLong(offlineList[2], 999999999999999999);
  797. OfflineIncomeFml = offlineList[0];
  798. List<double> dataList = ConfigManager.GetAchieveValues();
  799. PlayADsAmt = dataList[0];
  800. AllElfLevel = dataList[4];
  801. UseSkillAmt = dataList[1];
  802. SignAmt = dataList[2];
  803. ShareAmt = dataList[3];
  804. TotalFlowerAwardCoin = dataList[6];
  805. TotalVisitPerson = dataList[7];
  806. TotalSpendDiamond = dataList[8];
  807. PlayMinigameAmt = dataList[5];
  808. CreateRoomAmt = dataList[9];
  809. CreateChestAmt = dataList[10];
  810. CreateLuckyChestAmt = dataList[11];
  811. CreateGuessColorChestAmt = dataList[12];
  812. CreateGuessNumberChestAmt = dataList[13];
  813. GetChestAwardAmt = dataList[14];
  814. }
  815. public static void InitAllSkill(bool firstRegist)
  816. {
  817. OfflineFlag = false;
  818. float realOfflineTime = 0;
  819. ResourceManager.SetActive(CanvasLabel.Ba_Lab2, false);
  820. if (HttpManager.IsConnect && ConfigManager.GetBoolFormConfig(PlayerConfigLabel.QuitFlag))
  821. {
  822. LastQuitTime = DateTime.Parse(ConfigManager.GetStringFormConfig(PlayerConfigLabel.QuitTime));
  823. OfflineTime = (float)HttpManager.CurrentDateTime.Subtract(LastQuitTime).TotalSeconds;
  824. MinigameCDTimer -= OfflineTime;
  825. if (OfflineTime <= OfflineMinTime)
  826. {
  827. realOfflineTime = OfflineTime;
  828. OfflineTime = 0;
  829. }
  830. else
  831. {
  832. OfflineFlag = true;
  833. }
  834. if (OfflineTime > OfflineMaxTime)
  835. {
  836. OfflineTime = (long)OfflineMaxTime;
  837. ResourceManager.SetText(CanvasLabel.Ba_Lab2, Language.GetStr(LanguageLabel.UI__Ba_Lab2));
  838. ResourceManager.SetActive(CanvasLabel.Ba_Lab2, true);
  839. }
  840. }
  841. OfflineUsingSkillList = new List<List<Skill>>();
  842. OfflineCoolSkillList = new List<Skill>();
  843. if (OfflineTime > IncomeCircleTimer)
  844. {
  845. int circle = 1 + Mathf.FloorToInt((OfflineTime - IncomeCircleTimer) / IncomeCircleTime);
  846. for (int i = 0; i < circle; i++)
  847. {
  848. OfflineUsingSkillList.Add(new List<Skill>());
  849. }
  850. }
  851. List<XmlAttributeCollection> attributeList = ConfigManager.GetSkillList();
  852. for (int i = 0; i < attributeList.Count; i++)
  853. {
  854. SkillRoot skillRoot = SkillDictionary[attributeList[i][0].Value];
  855. if (skillRoot is Skill)
  856. {
  857. skillRoot.RegistReference();
  858. skillRoot.Init(firstRegist, OfflineTime, OfflineUsingSkillList, attributeList[i]);
  859. }
  860. }
  861. if (OfflineFlag == false)
  862. {
  863. foreach (var skill in CoolSkillList)
  864. {
  865. skill.CoolTimer -= realOfflineTime;
  866. }
  867. }
  868. }
  869. public static void GetOfflineIncome()
  870. {
  871. double coin = 0;
  872. for (int i = 0; i < OfflineUsingSkillList.Count; i++)
  873. {
  874. for (int j = 0; j < OfflineCoolSkillList.Count; j++)
  875. {
  876. OfflineCoolSkillList[j].CoolTimer -= IncomeCircleTime;
  877. }
  878. for (int j = 0; j < OfflineUsingSkillList[i].Count; j++)
  879. {
  880. OfflineUsingSkillList[i][j].AnnulEffect();
  881. OfflineCoolSkillList.Add(OfflineUsingSkillList[i][j]);
  882. }
  883. TotalVisitPerson += CurrentPerson*IncomeCircleTime;
  884. coin += CircleIncome;
  885. }
  886. IncomeCircleTimer = (OfflineTime - IncomeCircleTimer)%IncomeCircleTime;
  887. for (int j = 0; j < OfflineCoolSkillList.Count; j++)
  888. {
  889. OfflineCoolSkillList[j].CoolTimer -= IncomeCircleTime - IncomeCircleTimer;
  890. }
  891. coin = (long) Auxiliary.FmlParse(OfflineIncomeFml, "c", coin.ToString());
  892. if (coin > OfflineMaxCoin)
  893. {
  894. coin = OfflineMaxCoin;
  895. ResourceManager.SetText(CanvasLabel.Ba_Lab2, Language.GetStr(LanguageLabel.UI__Ba_Lab2));
  896. ResourceManager.SetActive(CanvasLabel.Ba_Lab2, true);
  897. }
  898. AddCoin(coin, StaticsManager.ItemID.获得金币, StaticsManager.ConsumeModule.Income);
  899. ResourceManager.SetText(CanvasLabel.Ba_IconLab, Auxiliary.ShrinkBigNumberStr(coin));
  900. }
  901. public new static void SwitchLanguage()
  902. {
  903. Coin = Coin;
  904. AddDiamond(0, StaticsManager.ItemID.None, StaticsManager.ConsumeModule.None);
  905. }
  906. public static void Pay(string id, double amt, Current current, UnityAction succeedCallback, StaticsManager.ItemID itemId, StaticsManager.ConsumeModule consumeModule, bool navigate = true, bool useBubbleTweenNavigate = true, UnityAction navigateCall = null, int buyAmount = 1)
  907. {
  908. if (TutorialManager.PayExempt)
  909. {
  910. succeedCallback.Invoke();
  911. return;
  912. }
  913. amt = Auxiliary.ShrinkNumber(amt);
  914. if (current == Current.Free)
  915. {
  916. succeedCallback.Invoke();
  917. }
  918. else if (current == Current.AD)
  919. {
  920. IAPManager.PlayAD(succeedCallback);
  921. }
  922. else if (current == Current.Cash)
  923. {
  924. IAPManager.TryPurchase(id);
  925. }
  926. else if (current == Current.Coin)
  927. {
  928. #region MyRegion
  929. if (Coin >= amt)
  930. {
  931. Coin -= amt;
  932. succeedCallback.Invoke();
  933. StaticsManager.GetInstance().UseItem(itemId, StaticsManager.ItemType.金币, buyAmount.ToString(), consumeModule);
  934. }
  935. else
  936. {
  937. ResourceManager.Get(CanvasLabel.Fe_Info).TweenBacCG();
  938. if (navigate)
  939. {
  940. Bubble.Show
  941. (
  942. Language.GetStr(LanguageLabel.Common__ShortCoin),
  943. Language.GetStr(LanguageLabel.Common__NavigateCoin),
  944. null,
  945. Lib.GoldSprite,
  946. () =>
  947. {
  948. navigateCall.SafeInvoke();
  949. if (useBubbleTweenNavigate)
  950. {
  951. TweenRoot tween = ResourceManager.Get(CanvasLabel.K_Bubble0).GetTweenScale();
  952. tween.AddEventOnetime
  953. (
  954. EventType.BackwardFinish,
  955. () =>
  956. {
  957. UIManager.NavigateToBuyCoin();
  958. }
  959. );
  960. }
  961. else
  962. {
  963. TweenRoot tween = ResourceManager.Get(CanvasLabel.F_Manage0).GetTweenVec();
  964. tween.AddEventOnetime
  965. (
  966. EventType.ForwardFinish,
  967. () =>
  968. {
  969. UIManager.NavigateToBuyCoin();
  970. }
  971. );
  972. }
  973. }
  974. );
  975. }
  976. else
  977. {
  978. Bubble.Show
  979. (
  980. Language.GetStr(LanguageLabel.Common__ShortCoin),
  981. null,
  982. null,
  983. Lib.GoldSprite
  984. );
  985. }
  986. }
  987. #endregion
  988. }
  989. else if (current == Current.Diamond)
  990. {
  991. #region MyRegion
  992. if (Diamond >= amt)
  993. {
  994. Diamond -= amt;
  995. TotalSpendDiamond += amt;
  996. succeedCallback.Invoke();
  997. StaticsManager.GetInstance().PurchaseItem(itemId, StaticsManager.ItemType.钻石, buyAmount.ToString(), amt.ToString("0"), consumeModule);
  998. }
  999. else
  1000. {
  1001. ResourceManager.Get(CanvasLabel.Fe_Info).TweenBacCG();
  1002. if (navigate)
  1003. {
  1004. Bubble.Show
  1005. (
  1006. Language.GetStr(LanguageLabel.Common__ShortDiamond),
  1007. Language.GetStr(LanguageLabel.Common__NavigateDiamond),
  1008. null,
  1009. Lib.DiamondSprite,
  1010. () =>
  1011. {
  1012. navigateCall.SafeInvoke();
  1013. if (useBubbleTweenNavigate)
  1014. {
  1015. TweenRoot tween = ResourceManager.Get(CanvasLabel.K_Bubble0).GetTweenScale();
  1016. tween.AddEventOnetime
  1017. (
  1018. EventType.BackwardFinish,
  1019. () =>
  1020. {
  1021. UIManager.NavigateToBuyDiamond();
  1022. }
  1023. );
  1024. }
  1025. else
  1026. {
  1027. TweenRoot tween = ResourceManager.Get(CanvasLabel.F_Manage0).GetTweenVec();
  1028. tween.AddEventOnetime
  1029. (
  1030. EventType.ForwardFinish,
  1031. () =>
  1032. {
  1033. UIManager.NavigateToBuyDiamond();
  1034. }
  1035. );
  1036. }
  1037. }
  1038. );
  1039. }
  1040. else
  1041. {
  1042. Bubble.Show
  1043. (
  1044. Language.GetStr(LanguageLabel.Common__ShortDiamond),
  1045. null,
  1046. null,
  1047. Lib.DiamondSprite
  1048. );
  1049. }
  1050. }
  1051. #endregion
  1052. }
  1053. else
  1054. {
  1055. throw new Exception(current.ToString());
  1056. }
  1057. }
  1058. public static void FirstTimeLoginCallback(JsonData jsonData)
  1059. {
  1060. if (!Initializer.Inited || !HttpManager.Inited || Inited)
  1061. {
  1062. return;
  1063. }
  1064. HttpManager.GetBuyPackLimitFlag();
  1065. if (HttpManager.IsConnect)
  1066. {
  1067. if (ConfigManager.GetStringFormConfig(PlayerConfigLabel.ID) == PlayerConfigLabel.DefaultID)
  1068. {
  1069. HttpManager.ID = HttpManager.LoginCallbackData["o"].ToString();
  1070. ResourceManager.SetText(CanvasLabel.L_UserLab, HttpManager.ID);
  1071. }
  1072. if (ConfigManager.GetStringFormConfig(PlayerConfigLabel.SerialNumber) == PlayerConfigLabel.DefaultSerialNumber)
  1073. {
  1074. HttpManager.SerialNumber = HttpManager.LoginCallbackData["i"].ToString();
  1075. }
  1076. }
  1077. InitAllSkill(true);
  1078. GetOfflineIncome();
  1079. SignManager.ShowPanels();
  1080. Analytics.SetUserId(HttpManager.ID);
  1081. Inited = true;
  1082. GardenLevel = GardenLevel;
  1083. if (!PlayerPrefManager.GetBool(PlayerPrefManager.INTERACT_CONFIG, false))
  1084. {
  1085. HttpManager.GetSelfConfig();
  1086. }
  1087. else
  1088. {
  1089. HttpManager.UploadConfig();
  1090. }
  1091. }
  1092. public static void ReactiveLoginCallback(JsonData jsonData)
  1093. {
  1094. LoginFlag = false;
  1095. for (int i = 0; i < Initializer.RegistList.Count; i++)
  1096. {
  1097. Initializer.RegistList[i].Reactive();
  1098. }
  1099. }
  1100. public static void SwitchConfig(string id)
  1101. {
  1102. ResourceManager.SetText(CanvasLabel.La_Lab, Language.GetStr(LanguageLabel.UI__L_Downloading));
  1103. ResourceManager.SetActive(CanvasLabel.La_Lab, true);
  1104. ResourceManager.SetActive(CanvasLabel.La_Mask, true);
  1105. HttpManager.GetConfigByID(id, SwitchConfigCallback);
  1106. }
  1107. public static void SwitchConfigCallback(JsonData jsonData)
  1108. {
  1109. if (jsonData.Inst_Object.Keys.Contains("l"))
  1110. {
  1111. ResourceManager.Get(CanvasLabel.La_Info).TweenBacCG();
  1112. ResourceManager.SetText(CanvasLabel.La_Lab, Language.GetStr(LanguageLabel.UI__La_Lab0));
  1113. ConfigManager.ConfigDocument.LoadXml(jsonData["l"].ToString());
  1114. ConfigManager.ConfigRootNode = ConfigManager.ConfigDocument.SelectSingleNode(PlayerConfigLabel.RootNode);
  1115. ResourceManager.SetText(CanvasLabel.L_UserLab, ConfigManager.GetStringFormConfig(PlayerConfigLabel.ID));
  1116. HttpManager.ID = ConfigManager.GetStringFormConfig(PlayerConfigLabel.ID);
  1117. HttpManager.SerialNumber = ConfigManager.GetStringFormConfig(PlayerConfigLabel.SerialNumber);
  1118. Bubble.Show(null, Language.GetStr(LanguageLabel.UI__La_Lab0), null, null, () => { Application.Quit(); }, null, false);
  1119. UploadConfigFlag = true;
  1120. DownloadConfigFlag = true;
  1121. ConfigManager.SaveConfigDocumentToDisk();
  1122. PlayerPrefs.SetString(Lib.ConfigPrefs, "");
  1123. }
  1124. else
  1125. {
  1126. ResourceManager.SetText(CanvasLabel.La_Lab, Language.GetStr(LanguageLabel.UI__La_Lab1));
  1127. ResourceManager.SetActive(CanvasLabel.La_Mask, false);
  1128. }
  1129. }
  1130. public void OnApplicationQuit()
  1131. {
  1132. if (!UploadConfigFlag)
  1133. {
  1134. VisitManager.ReverseConfigData();
  1135. ConfigManager.SaveConfigDocument();
  1136. ConfigManager.SaveConfigDocumentToDisk();
  1137. }
  1138. }
  1139. public void OnApplicationPause(bool pause)
  1140. {
  1141. if (pause)
  1142. {
  1143. InBackground = true;
  1144. if (DownloadConfigFlag)
  1145. {
  1146. return;
  1147. }
  1148. VisitManager.ReverseConfigData();
  1149. ConfigManager.SaveConfigDocument();
  1150. ConfigManager.SaveConfigDocumentToDisk();
  1151. }
  1152. else
  1153. {
  1154. StaticsManager.GetInstance().StartSession();
  1155. InBackground = false;
  1156. if (IsFirstFrame)
  1157. {
  1158. IsFirstFrame = false;
  1159. }
  1160. else
  1161. {
  1162. if (TutorialManager.NewplayerTutorial)
  1163. {
  1164. return;
  1165. }
  1166. if (!Initializer.Inited)
  1167. {
  1168. return;
  1169. }
  1170. if (!Initializer.IsGameActivated)
  1171. {
  1172. return;
  1173. }
  1174. if (DownloadConfigFlag)
  1175. {
  1176. return;
  1177. }
  1178. VisitManager.RecoverConfigData();
  1179. if (LoginFlag)
  1180. {
  1181. return;
  1182. }
  1183. if (ReactiveFlag)
  1184. {
  1185. ReactiveFlag = false;
  1186. return;
  1187. }
  1188. LoginFlag = true;
  1189. HttpManager.Login(ReactiveLoginCallback);
  1190. HttpManager.GetMailAwardData();
  1191. }
  1192. }
  1193. }
  1194. }