ManaData.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967
  1. using LitJson;
  2. using UnityEngine;
  3. using UnityEngine.UI;
  4. using UnityEngine.Events;
  5. using UnityEngine.EventSystems;
  6. using System;
  7. using System.Xml;
  8. using System.Collections;
  9. using System.Collections.Generic;
  10. public class ManaData : Regist
  11. {
  12. #region 变量
  13. #region 成就
  14. public static double TotalPerson
  15. {
  16. get { return TotalPerson_; }
  17. set
  18. {
  19. TotalPerson_ = value;
  20. ManaAchieve.UpdateStatus(AchieveType.TotalPerson, FlowerCoin_);
  21. }
  22. }
  23. public static double ElfLevel
  24. {
  25. get { return ElfLevel_; }
  26. set
  27. {
  28. ElfLevel_ = value;
  29. ManaAchieve.UpdateStatus(AchieveType.ElfLevel, ElfLevel_);
  30. }
  31. }
  32. public static double AdAmt
  33. {
  34. get { return AdAmt_; }
  35. set
  36. {
  37. AdAmt_ = value;
  38. ManaAchieve.UpdateStatus(AchieveType.AdAmt, AdAmt_);
  39. }
  40. }
  41. public static double SkillAmt
  42. {
  43. get { return SkillAmt_; }
  44. set
  45. {
  46. SkillAmt_ = value;
  47. ManaAchieve.UpdateStatus(AchieveType.SkillAmt, SkillAmt_);
  48. }
  49. }
  50. public static double SignAmt
  51. {
  52. get { return SignAmt_; }
  53. set
  54. {
  55. SignAmt_ = value;
  56. ManaAchieve.UpdateStatus(AchieveType.SignAmt, SignAmt_);
  57. }
  58. }
  59. public static double ShareAmt
  60. {
  61. get { return ShareAmt_; }
  62. set
  63. {
  64. ShareAmt_ = value;
  65. ManaAchieve.UpdateStatus(AchieveType.ShareAmt, ShareAmt_);
  66. }
  67. }
  68. public static double TotalCoin
  69. {
  70. get { return TotalCoin_; }
  71. set
  72. {
  73. TotalCoin_ = value;
  74. ManaAchieve.UpdateStatus(AchieveType.TotalCoin, TotalCoin_);
  75. }
  76. }
  77. public static double MiniGameAmt
  78. {
  79. get { return MiniGameAmt_; }
  80. set
  81. {
  82. MiniGameAmt_ = value;
  83. ManaAchieve.UpdateStatus(AchieveType.MiniGameAmt, MiniGameAmt_);
  84. }
  85. }
  86. public static double FlowerCoin
  87. {
  88. get { return FlowerCoin_; }
  89. set
  90. {
  91. FlowerCoin_ = value;
  92. ManaAchieve.UpdateStatus(AchieveType.FlowerCoin, FlowerCoin_);
  93. }
  94. }
  95. private static double TotalPerson_;
  96. private static double ElfLevel_;
  97. private static double AdAmt_;
  98. private static double SkillAmt_;
  99. private static double SignAmt_;
  100. private static double ShareAmt_;
  101. private static double MiniGameAmt_;
  102. private static double TotalCoin_;
  103. private static double FlowerCoin_;
  104. #endregion
  105. public static int Level
  106. {
  107. get { return Level_; }
  108. set
  109. {
  110. Level_ = value;
  111. ManaDebug.Log(string.Format("已升级 花园等级 : <color=red>{0}</color>", Level_));
  112. ManaAchieve.UpdateStatus(AchieveType.GardenLevel, Level_);
  113. for (int i = 0; i < SkillList.Count; i++)
  114. {
  115. SkillList[i].UpdateStatus();
  116. }
  117. if (TabBtnValid == false)
  118. {
  119. if (Level_ >= 1)
  120. {
  121. TabBtnValid = true;
  122. ManaReso.Get<Graphic>("F_Elf").material = null;
  123. ManaReso.Get<Graphic>("F_Store").material = null;
  124. ManaReso.Get<Graphic>("F_Magic").material = null;
  125. ManaReso.Get<Graphic>("F_ElfLab").material = null;
  126. ManaReso.Get<Graphic>("F_StoreLab").material = null;
  127. ManaReso.Get<Graphic>("F_MagicLab").material = null;
  128. ManaReso.Get<Button>("F_Elf").interactable = true;
  129. ManaReso.Get<Button>("F_Store").interactable = true;
  130. ManaReso.Get<Button>("F_Magic").interactable = true;
  131. }
  132. }
  133. if (ManaTutorial.TutorialB_ && !ManaTutorial.TutorialB)
  134. {
  135. if (Level_ >= 200)
  136. {
  137. ManaTutorial.TutorialB = true;
  138. ManaTutorial.PrepareStep10();
  139. }
  140. }
  141. }
  142. }
  143. public static bool Pause
  144. {
  145. get { return Pause_; }
  146. set
  147. {
  148. Pause_ = value;
  149. if (Pause_)
  150. {
  151. Time.timeScale = 0;
  152. ManaDebug.Log("<color=red>游戏暂停</color>");
  153. }
  154. else
  155. {
  156. Time.timeScale = 1;
  157. ManaDebug.Log("<color=red>游戏继续</color>");
  158. }
  159. }
  160. }
  161. public static float Person
  162. {
  163. get { return Person_; }
  164. set
  165. {
  166. Person_ = value;
  167. ManaReso.SetText("F_PersonLab", Mathf.FloorToInt(60*(Person_ + SkillPerson_)).ToString());
  168. }
  169. }
  170. public static float SkillPerson
  171. {
  172. get { return SkillPerson_; }
  173. set
  174. {
  175. SkillPerson_ = value;
  176. ManaReso.SetText("F_PersonLab", Mathf.FloorToInt(Person_ + SkillPerson_).ToString());
  177. }
  178. }
  179. public static float CoinPerson
  180. {
  181. get { return CoinPerson_; }
  182. set
  183. {
  184. CoinPerson_ = value;
  185. ManaReso.SetText("F_CoinPersonLab", Mathf.FloorToInt(CoinPerson_ + SkillCoinPerson_).ToString());
  186. }
  187. }
  188. public static float SkillCoinPerson
  189. {
  190. get { return SkillCoinPerson_; }
  191. set
  192. {
  193. SkillCoinPerson_ = value;
  194. ManaReso.SetText("F_CoinPersonLab", Mathf.FloorToInt(CoinPerson_ + SkillCoinPerson_).ToString());
  195. }
  196. }
  197. public static double Coin
  198. {
  199. get { return Coin_; }
  200. set
  201. {
  202. if (value - Coin_ > 0)
  203. {
  204. TotalCoin += value - Coin_;
  205. }
  206. Coin_ = value;
  207. ManaReso.SetText("F_CoinLab", Auxiliary.ShrinkNumberStr(Coin_, 0));
  208. ManaReso.SetText("C_CoinLab", Auxiliary.ShrinkNumberStr(Coin_, 0));
  209. ManaAchieve.UpdateStatus(AchieveType.CurrentCoin, Coin_);
  210. }
  211. }
  212. public static double Diamond
  213. {
  214. get { return Diamond_; }
  215. set
  216. {
  217. Diamond_ = value;
  218. ManaReso.SetText("F_DiamondLab", Auxiliary.ShrinkNumberStr(Diamond_, 0));
  219. }
  220. }
  221. private static int Level_;
  222. private static bool Pause_;
  223. private static float Person_;
  224. private static float CoinPerson_;
  225. private static double Coin_;
  226. private static double Diamond_;
  227. public static int MainDepth;
  228. public static bool Reset;
  229. public static bool MiniValid;
  230. public static bool FirstFrame = true;
  231. public static bool TabBtnValid;
  232. public static bool InitiateComplete;
  233. public static float Elapse;
  234. public static float OpTimer;
  235. public static float MiniTimer;
  236. public static float SaveTimer;
  237. public static float LoginTimer;
  238. public static float CircleTime = 10;
  239. public static float CircleTimer;
  240. public static float NewPerson;
  241. public static float NewCoinPerson;
  242. public static float SkillPlus;
  243. public static float SkillPerson_;
  244. public static float SkillPersonBuff;
  245. public static float SkillCoinPerson_;
  246. public static DateTime QuitTime;
  247. public static ManaData Instance;
  248. public static List<Skill> UseList = new List<Skill>();
  249. public static List<Skill> CoolList = new List<Skill>();
  250. public static List<Skill> FFCoolList = new List<Skill>();
  251. public static List<SkillRoot> SkillList = new List<SkillRoot>();
  252. public static List<List<Skill>> FFUseList = new List<List<Skill>>();
  253. public static Dictionary<string, SkillRoot> SkillDic = new Dictionary<string, SkillRoot>();
  254. #endregion
  255. private void Update()
  256. {
  257. if (ManaTutorial.TutorialA)
  258. {
  259. return;
  260. }
  261. OperateThread();
  262. }
  263. private void FixedUpdate()
  264. {
  265. if (ManaTutorial.TutorialA)
  266. {
  267. LoginThread();
  268. return;
  269. }
  270. SkillThread();
  271. MiniThread();
  272. MiniThread();
  273. SaveThread();
  274. LoginThread();
  275. IncomeThread();
  276. }
  277. private void SkillThread()
  278. {
  279. for (int i = 0; i < UseList.Count; i++)
  280. {
  281. if (UseList[i].DoUse())
  282. {
  283. UseList.RemoveAt(i--);
  284. }
  285. }
  286. for (int i = 0; i < CoolList.Count; i++)
  287. {
  288. if (CoolList[i].DoCool())
  289. {
  290. CoolList.RemoveAt(i--);
  291. }
  292. }
  293. }
  294. private void MiniThread()
  295. {
  296. if (Pause)
  297. {
  298. return;
  299. }
  300. if (MiniValid == false)
  301. {
  302. MiniTimer -= Time.deltaTime;
  303. if (MiniTimer < 0)
  304. {
  305. MiniValid = true;
  306. ManaReso.Get("C_MiniGame").TweenForCG();
  307. }
  308. }
  309. }
  310. private void SaveThread()
  311. {
  312. SaveTimer += Time.fixedDeltaTime;
  313. if (SaveTimer >= 60)
  314. {
  315. SaveTimer = 0;
  316. ManaServer.Save();
  317. }
  318. }
  319. private void LoginThread()
  320. {
  321. LoginTimer += Time.fixedDeltaTime;
  322. if (LoginTimer >= 10)
  323. {
  324. LoginTimer = 0;
  325. ManaServer.Login();
  326. }
  327. }
  328. private void IncomeThread()
  329. {
  330. CircleTimer -= Time.deltaTime;
  331. if (CircleTimer < 0)
  332. {
  333. CircleTimer = CircleTime;
  334. NewPerson = Person * (1 + SkillPersonBuff) + SkillPerson;
  335. NewCoinPerson = CoinPerson + SkillCoinPerson;
  336. TotalPerson += NewPerson;
  337. float temp = (NewPerson * NewCoinPerson * CircleTime) * (1 + SkillPlus);
  338. Coin += temp;
  339. ManaReso.Get("C_IncomeLab").TweenForGra();
  340. ManaReso.Get("C_IncomeLab").TweenForVec();
  341. ManaReso.SetText("C_IncomeLab", "+" + temp.ToString("0"));
  342. ManaDebug.Log(string.Format("参观收益<color=red>{0:0.0}</color> = <color=red>{1}</color> * <color=red>{2}</color> * <color=red>{3}</color> * <color=red>{4}</color> (人次*金币*时间*加成)", temp, NewPerson, NewCoinPerson, CircleTime, 1 + SkillPlus));
  343. }
  344. }
  345. private void OperateThread()
  346. {
  347. if (Pause)
  348. {
  349. return;
  350. }
  351. if (Auxiliary.AnyKeyUp)
  352. {
  353. OpTimer = 0;
  354. if (MainDepth == 0)
  355. {
  356. ManaReso.Get("C_Main").TweenConForCG();
  357. }
  358. }
  359. else
  360. {
  361. OpTimer += Time.deltaTime;
  362. if (OpTimer >= 90)
  363. {
  364. OpTimer = 0;
  365. if (MainDepth == -1)
  366. {
  367. ManaReso.Get("C_Main").TweenConBacCG();
  368. }
  369. }
  370. }
  371. }
  372. public static void Reload()
  373. {
  374. Reset = false;
  375. TabBtnValid = false;
  376. Person = 0;
  377. CoinPerson = 0;
  378. SkillPlus = 0;
  379. SkillPerson = 0;
  380. SkillPersonBuff = 0;
  381. SkillCoinPerson = 0;
  382. SaveTimer = 0;
  383. UseList = new List<Skill>();
  384. CoolList = new List<Skill>();
  385. Instance.RegistValueB();
  386. ManaTutorial.TutorialB_ = Data.GetPlayerBool("TutorialB");
  387. ManaTutorial.TutorialIndexB = Data.GetPlayerInt("TutorialIndexB");
  388. for (int i = 0; i < SkillList.Count; i++)
  389. {
  390. Ability ability = SkillList[i] as Ability;
  391. if (ability != null)
  392. {
  393. ability.ValidSlot = true;
  394. }
  395. }
  396. RegistSkill();
  397. RegistIncome();
  398. if (ManaServer.Connect)
  399. {
  400. if (!ManaTutorial.TutorialA && !ManaTutorial.TutorialB)
  401. {
  402. ManaReso.Get("B_SignIn").TweenConForCG();
  403. }
  404. }
  405. }
  406. public override void Reactive()
  407. {
  408. foreach (var kv in SkillDic)
  409. {
  410. kv.Value.Reactive();
  411. }
  412. RegistSkill();
  413. RegistIncome();
  414. if (ManaServer.Connect)
  415. {
  416. if (!ManaTutorial.TutorialA && !ManaTutorial.TutorialB)
  417. {
  418. ManaReso.Get("C_Main").TweenConBacCG();
  419. ManaReso.Get("B_SignIn").TweenConForCG();
  420. if (ManaMiniGame.Game || ManaMiniGame.Prepare)
  421. {
  422. ManaReso.Get<Button>("D_Quit").onClick.Invoke();
  423. }
  424. }
  425. }
  426. }
  427. public override void Instantiate()
  428. {
  429. #region 生成技能条
  430. #region 读技能配置
  431. List<XmlAttributeCollection> attributeList = Data.GetSkillConfig();
  432. for (int i = 0; i < attributeList.Count; i++)
  433. {
  434. SkillRoot skillRoot;
  435. #region MyRegion
  436. if (attributeList[i].Count == 17)
  437. {
  438. skillRoot = new Pack(attributeList[i]);
  439. }
  440. else if (attributeList[i].Count == 23)
  441. {
  442. skillRoot = new Ability(attributeList[i]);
  443. }
  444. else if (attributeList[i].Count == 33)
  445. {
  446. if (string.IsNullOrEmpty(attributeList[i][4].Value))
  447. {
  448. skillRoot = new Skill(attributeList[i]);
  449. }
  450. else
  451. {
  452. skillRoot = new BigSkill(attributeList[i]);
  453. }
  454. }
  455. else
  456. {
  457. throw new Exception(attributeList[i].Count.ToString());
  458. }
  459. #endregion
  460. SkillDic.Add(skillRoot.ID, skillRoot);
  461. SkillList.Add(skillRoot);
  462. }
  463. SkillList.Sort(SkillRoot.Sort);
  464. #endregion
  465. for (int i = 0; i < SkillList.Count; i++)
  466. {
  467. if (SkillList[i].SkillTab != SkillTab.Null)
  468. {
  469. ManaReso.GetSkillItem(SkillList[i]);
  470. }
  471. }
  472. #endregion
  473. }
  474. public override void RegistValueB()
  475. {
  476. Instance = this;
  477. ManaReso.Get<Graphic>("F_Elf").material = ManaReso.Load<Material>("GrayMat", Folder.Effect);
  478. ManaReso.Get<Graphic>("F_Store").material = ManaReso.Load<Material>("GrayMat", Folder.Effect);
  479. ManaReso.Get<Graphic>("F_Magic").material = ManaReso.Load<Material>("GrayMat", Folder.Effect);
  480. ManaReso.Get<Graphic>("F_ElfLab").material = ManaReso.Load<Material>("GrayMat", Folder.Effect);
  481. ManaReso.Get<Graphic>("F_StoreLab").material = ManaReso.Load<Material>("GrayMat", Folder.Effect);
  482. ManaReso.Get<Graphic>("F_MagicLab").material = ManaReso.Load<Material>("GrayMat", Folder.Effect);
  483. ManaReso.Get<Button>("F_Elf").interactable = false;
  484. ManaReso.Get<Button>("F_Store").interactable = false;
  485. ManaReso.Get<Button>("F_Magic").interactable = false;
  486. Coin = Data.GetPlayerDouble("Coin");
  487. Diamond = Data.GetPlayerDouble("Diamond");
  488. MiniTimer = Data.GetPlayerFloat("MiniTimer");
  489. CircleTimer = Data.GetPlayerFloat("CircleTimer");
  490. ManaServer.ID = Data.GetPlayerString("ID");
  491. ManaDebug.Log(string.Format("<color=red>{0:0}</color>秒后激活小游戏", MiniTimer));
  492. List<double> dataList = Data.GetAchieveData();
  493. AdAmt = dataList[0];
  494. SkillAmt = dataList[1];
  495. SignAmt = dataList[2];
  496. ShareAmt = dataList[3];
  497. MiniGameAmt = dataList[4];
  498. FlowerCoin = dataList[5];
  499. TotalPerson = dataList[6];
  500. }
  501. public static void RegistSkill()
  502. {
  503. QuitTime = DateTime.Parse(Data.GetPlayerString("QuitTime"));
  504. Elapse = (float)ManaServer.Time.Subtract(QuitTime).TotalSeconds;
  505. if (Elapse > 43200)
  506. {
  507. Elapse = 43200;
  508. }
  509. if (!Data.GetPlayerBool("QuitFlag"))
  510. {
  511. Elapse = 0;
  512. }
  513. ManaDebug.Log(string.Format("离线时间<color=red>{0}</color>", Elapse));
  514. FFUseList = new List<List<Skill>>();
  515. FFCoolList = new List<Skill>();
  516. if (Elapse > CircleTimer)
  517. {
  518. int circle = 1 + Mathf.FloorToInt((Elapse - CircleTimer) / CircleTime);
  519. for (int i = 0; i < circle; i++)
  520. {
  521. FFUseList.Add(new List<Skill>());
  522. }
  523. ManaDebug.Log(string.Format("离线周期<color=red>{0}</color>", circle));
  524. }
  525. else
  526. {
  527. ManaDebug.Log(string.Format("离线周期<color=red>{0}</color>", 0));
  528. }
  529. List<XmlAttributeCollection> attributeList = Data.GetSkillList();
  530. for (int i = 0; i < attributeList.Count; i++)
  531. {
  532. SkillRoot skillRoot = SkillDic[attributeList[i][0].Value];
  533. skillRoot.RegistReference();
  534. skillRoot.RegistValue(Elapse, FFUseList, attributeList[i]);
  535. }
  536. Level = Data.GetPlayerInt("Level");
  537. }
  538. public static void RegistIncome()
  539. {
  540. float coin = 0;
  541. if (FFUseList.Count > 0)
  542. {
  543. for (int i = 0; i < FFUseList.Count; i++)
  544. {
  545. for (int j = 0; j < FFCoolList.Count; j++)
  546. {
  547. FFCoolList[j].CoolTimer -= CircleTime;
  548. }
  549. for (int j = 0; j < FFUseList[i].Count; j++)
  550. {
  551. FFUseList[i][j].Annul();
  552. FFCoolList.Add(FFUseList[i][j]);
  553. }
  554. NewPerson = Person * (1 + SkillPersonBuff) + SkillPerson;
  555. NewCoinPerson = CoinPerson + SkillCoinPerson;
  556. coin += (NewPerson * NewCoinPerson * CircleTime) * (1 + SkillPlus);
  557. }
  558. CircleTimer = (Elapse - CircleTimer) % CircleTime;
  559. for (int j = 0; j < FFCoolList.Count; j++)
  560. {
  561. FFCoolList[j].CoolTimer -= CircleTime - CircleTimer;
  562. }
  563. Coin += coin;
  564. ManaReso.SetText("Ba_IconLab", coin.ToString("0"));
  565. }
  566. else
  567. {
  568. CircleTimer = CircleTimer - Elapse;
  569. ManaReso.SetText("Ba_IconLab", "0");
  570. }
  571. }
  572. public static void SwitchLanguage()
  573. {
  574. Coin = Coin;
  575. Diamond = Diamond;
  576. }
  577. public static bool Pay(double amt, Current current)
  578. {
  579. if (ManaTutorial.PayExempt)
  580. {
  581. return true;
  582. }
  583. amt = Auxiliary.ShrinkNumber(amt);
  584. if (current == Current.Free)
  585. {
  586. return true;
  587. }
  588. else if (current == Current.AD)
  589. {
  590. return true;
  591. }
  592. else if (current == Current.Cash)
  593. {
  594. return true;
  595. }
  596. else if (current == Current.Coin)
  597. {
  598. if (Coin >= amt)
  599. {
  600. Coin -= amt;
  601. return true;
  602. }
  603. else
  604. {
  605. Bubble.Show
  606. (
  607. Language.GetStr("Common", "ShortCoin"),
  608. Language.GetStr("Common", "NavigateCoin"),
  609. ManaReso.LoadSprite("金币"),
  610. () =>
  611. {
  612. ManaReso.Get("Fe_Info").TweenBacCG();
  613. Tween tween = ManaReso.Get("K_Bubble0").GetTweenScale();
  614. tween.AddEventOnetime
  615. (
  616. EventType.BackwardFinish,
  617. () =>
  618. {
  619. ManaReso.Get<Button>("F_Magic").onClick.Invoke();
  620. Auxiliary.Instance.DelayCall
  621. (
  622. () =>
  623. {
  624. int index = ManaReso.Get("Fb_Grid").childCount - 1;
  625. ManaReso.Get<ScrollRect>("Fb_Scrr").Locate(index, 0.25f, Curve.EaseOutQuad, LocatePos.Down);
  626. },
  627. 1
  628. );
  629. }
  630. );
  631. }
  632. );
  633. return false;
  634. }
  635. }
  636. else if (current == Current.Diamond)
  637. {
  638. if (Diamond >= amt)
  639. {
  640. Diamond -= amt;
  641. return true;
  642. }
  643. else
  644. {
  645. Bubble.Show
  646. (
  647. Language.GetStr("Common", "ShortDiamond"),
  648. Language.GetStr("Common", "NavigateDiamond"),
  649. ManaReso.LoadSprite("钻石"),
  650. () =>
  651. {
  652. ManaReso.Get("Fe_Info").TweenBacCG();
  653. Tween tween = ManaReso.Get("K_Bubble0").GetTweenScale();
  654. tween.AddEventOnetime
  655. (
  656. EventType.BackwardFinish,
  657. () =>
  658. {
  659. ManaReso.Get<Button>("F_Store").onClick.Invoke();
  660. Auxiliary.Instance.DelayCall
  661. (
  662. () =>
  663. {
  664. int index = ManaReso.Get("Fc_Grid").childCount - 1;
  665. ManaReso.Get<ScrollRect>("Fc_Scrr").Locate(index, 0.25f, Curve.EaseOutQuad, LocatePos.Down);
  666. },
  667. 1
  668. );
  669. }
  670. );
  671. }
  672. );
  673. return false;
  674. }
  675. }
  676. else
  677. {
  678. throw new Exception(current.ToString());
  679. }
  680. }
  681. public static void LoginCallbackInitial(JsonData jsonData)
  682. {
  683. if (!Initializer.LoadComplete || !ManaServer.LoginComplete)
  684. {
  685. return;
  686. }
  687. if (ManaServer.Connect)
  688. {
  689. if (Data.GetPlayerString("ID") == "Default")
  690. {
  691. ManaServer.ID = ManaServer.JsonData["o"].ToString();
  692. ManaReso.SetText("L_UserLab", ManaServer.ID);
  693. }
  694. }
  695. if (ManaServer.Connect && Data.GetPlayerBool("QuitFlag"))
  696. {
  697. if (!ManaTutorial.TutorialA)
  698. {
  699. ManaReso.Get("B_SignIn").TweenForCG();
  700. }
  701. }
  702. RegistSkill();
  703. RegistIncome();
  704. InitiateComplete = true;
  705. }
  706. public static void LoginCallbackReactive(JsonData jsonData)
  707. {
  708. for (int i = 0; i < Initializer.RegistList.Count; i++)
  709. {
  710. Initializer.RegistList[i].Reactive();
  711. }
  712. }
  713. public static void DownloadArchive()
  714. {
  715. ManaReso.SetText("La_Lab", "连接中");
  716. ManaReso.SetActive("La_Lab", true);
  717. ManaReso.SetActive("La_Mask", true);
  718. string id = ManaReso.Get<InputField>("La_InputField").text;
  719. ManaServer.Load(id, DownloadCallback);
  720. }
  721. public static void DownloadCallback(JsonData jsonData)
  722. {
  723. if (jsonData.Inst_Object.Keys.Contains("l"))
  724. {
  725. ManaReso.SetActive("La_Mask", false);
  726. ManaReso.SetText("La_Lab", Language.GetStr("UI", "La_Lab0"));
  727. int version = Data.GetPlayerInt("Version");
  728. Data.PlayerDoc.LoadXml(jsonData["l"].ToString());
  729. Data.PlayerNode = Data.PlayerDoc.SelectSingleNode("PlayerConfig");
  730. Data.SavePlayerInt("Version", version);
  731. ManaReso.SetText("L_UserLab", Data.GetPlayerString("ID"));
  732. ManaServer.ID = Data.GetPlayerString("ID");
  733. ManaMiniGame.MiniGameIndex = Data.GetPlayerInt("MiniGameIndex");
  734. Garden.Reload();
  735. ManaGarden.Reload();
  736. Reload();
  737. ManaAchieve.Reload();
  738. ManaPlayer.Reload();
  739. ManaSign.Reload();
  740. ManaReso.Get("La_Info").TweenBacCG();
  741. }
  742. else
  743. {
  744. ManaReso.SetText("La_Lab", Language.GetStr("UI", "La_Lab1"));
  745. ManaReso.SetActive("La_Mask", false);
  746. }
  747. }
  748. public void OnApplicationQuit()
  749. {
  750. if (Initializer.LoadComplete && !Reset)
  751. {
  752. Data.SavePlayerConfig();
  753. Data.SaveXml();
  754. }
  755. }
  756. public void OnApplicationPause(bool pause)
  757. {
  758. if (pause)
  759. {
  760. Data.SavePlayerConfig();
  761. Data.SaveXml();
  762. }
  763. else
  764. {
  765. if (FirstFrame)
  766. {
  767. FirstFrame = false;
  768. }
  769. else
  770. {
  771. ManaServer.Login(LoginCallbackReactive);
  772. }
  773. }
  774. }
  775. }