ManaData.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985
  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, TotalPerson_);
  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 string OfflineFml;
  243. public static double MaxCoin;
  244. public static double MaxTime;
  245. public static float SkillPlus;
  246. public static float SkillPerson_;
  247. public static float SkillPersonBuff;
  248. public static float SkillCoinPerson_;
  249. public static DateTime QuitTime;
  250. public static ManaData Instance;
  251. public static List<Skill> UseList = new List<Skill>();
  252. public static List<Skill> CoolList = new List<Skill>();
  253. public static List<Skill> FFCoolList = new List<Skill>();
  254. public static List<SkillRoot> SkillList = new List<SkillRoot>();
  255. public static List<List<Skill>> FFUseList = new List<List<Skill>>();
  256. public static Dictionary<string, SkillRoot> SkillDic = new Dictionary<string, SkillRoot>();
  257. #endregion
  258. private void Update()
  259. {
  260. if (ManaTutorial.TutorialA)
  261. {
  262. return;
  263. }
  264. OperateThread();
  265. }
  266. private void FixedUpdate()
  267. {
  268. if (ManaTutorial.TutorialA)
  269. {
  270. LoginThread();
  271. return;
  272. }
  273. SkillThread();
  274. MiniThread();
  275. MiniThread();
  276. SaveThread();
  277. LoginThread();
  278. IncomeThread();
  279. }
  280. private void SkillThread()
  281. {
  282. for (int i = 0; i < UseList.Count; i++)
  283. {
  284. if (UseList[i].DoUse())
  285. {
  286. UseList.RemoveAt(i--);
  287. }
  288. }
  289. for (int i = 0; i < CoolList.Count; i++)
  290. {
  291. if (CoolList[i].DoCool())
  292. {
  293. CoolList.RemoveAt(i--);
  294. }
  295. }
  296. }
  297. private void MiniThread()
  298. {
  299. if (Pause)
  300. {
  301. return;
  302. }
  303. if (MiniValid == false)
  304. {
  305. MiniTimer -= Time.deltaTime;
  306. if (MiniTimer < 0)
  307. {
  308. MiniValid = true;
  309. ManaReso.Get("C_MiniGame").TweenForCG();
  310. }
  311. }
  312. }
  313. private void SaveThread()
  314. {
  315. SaveTimer += Time.fixedDeltaTime;
  316. if (SaveTimer >= 60)
  317. {
  318. SaveTimer = 0;
  319. ManaServer.Save();
  320. }
  321. }
  322. private void LoginThread()
  323. {
  324. LoginTimer += Time.fixedDeltaTime;
  325. if (LoginTimer >= 10)
  326. {
  327. LoginTimer = 0;
  328. ManaServer.Login();
  329. }
  330. }
  331. private void IncomeThread()
  332. {
  333. CircleTimer -= Time.deltaTime;
  334. if (CircleTimer < 0)
  335. {
  336. CircleTimer = CircleTime;
  337. NewPerson = Person * (1 + SkillPersonBuff) + SkillPerson;
  338. NewCoinPerson = CoinPerson + SkillCoinPerson;
  339. TotalPerson += NewPerson * CircleTime;
  340. float temp = (NewPerson * NewCoinPerson * CircleTime) * (1 + SkillPlus);
  341. Coin += temp;
  342. ManaReso.Get("C_IncomeLab").TweenForGra();
  343. ManaReso.Get("C_IncomeLab").TweenForVec();
  344. ManaReso.SetText("C_IncomeLab", "+" + temp.ToString("0"));
  345. 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));
  346. }
  347. }
  348. private void OperateThread()
  349. {
  350. if (Pause)
  351. {
  352. return;
  353. }
  354. if (Auxiliary.AnyKeyUp)
  355. {
  356. OpTimer = 0;
  357. if (MainDepth == 0)
  358. {
  359. ManaReso.Get("C_Main").TweenConForCG();
  360. }
  361. }
  362. else
  363. {
  364. OpTimer += Time.deltaTime;
  365. if (OpTimer >= 90)
  366. {
  367. OpTimer = 0;
  368. if (MainDepth == -1)
  369. {
  370. ManaReso.Get("C_Main").TweenConBacCG();
  371. }
  372. }
  373. }
  374. }
  375. public static void Reload()
  376. {
  377. Reset = false;
  378. TabBtnValid = false;
  379. Person = 0;
  380. CoinPerson = 0;
  381. SkillPlus = 0;
  382. SkillPerson = 0;
  383. SkillPersonBuff = 0;
  384. SkillCoinPerson = 0;
  385. SaveTimer = 0;
  386. UseList = new List<Skill>();
  387. CoolList = new List<Skill>();
  388. Instance.RegistValueB();
  389. ManaTutorial.TutorialB_ = Data.GetPlayerBool("TutorialB");
  390. ManaTutorial.TutorialIndexB = Data.GetPlayerInt("TutorialIndexB");
  391. for (int i = 0; i < SkillList.Count; i++)
  392. {
  393. Ability ability = SkillList[i] as Ability;
  394. if (ability != null)
  395. {
  396. ability.ValidSlot = true;
  397. }
  398. }
  399. RegistSkill();
  400. RegistIncome();
  401. if (ManaServer.Connect)
  402. {
  403. if (!ManaTutorial.TutorialA && !ManaTutorial.TutorialB)
  404. {
  405. ManaReso.Get("B_SignIn").TweenConForCG();
  406. }
  407. }
  408. }
  409. public override void Reactive()
  410. {
  411. foreach (var kv in SkillDic)
  412. {
  413. kv.Value.Reactive();
  414. }
  415. RegistSkill();
  416. RegistIncome();
  417. if (ManaServer.Connect)
  418. {
  419. if (!ManaTutorial.TutorialA && !ManaTutorial.TutorialB)
  420. {
  421. ManaReso.Get("C_Main").TweenConBacCG();
  422. ManaReso.Get("B_SignIn").TweenConForCG();
  423. if (ManaMiniGame.Game || ManaMiniGame.Prepare)
  424. {
  425. ManaReso.Get<Button>("D_Quit").onClick.Invoke();
  426. }
  427. }
  428. }
  429. }
  430. public override void Instantiate()
  431. {
  432. #region 生成技能条
  433. #region 读技能配置
  434. List<XmlAttributeCollection> attributeList = Data.GetSkillConfig();
  435. for (int i = 0; i < attributeList.Count; i++)
  436. {
  437. SkillRoot skillRoot;
  438. #region MyRegion
  439. if (attributeList[i].Count == 17)
  440. {
  441. skillRoot = new Pack(attributeList[i]);
  442. }
  443. else if (attributeList[i].Count == 23)
  444. {
  445. skillRoot = new Ability(attributeList[i]);
  446. }
  447. else if (attributeList[i].Count == 33)
  448. {
  449. if (string.IsNullOrEmpty(attributeList[i][4].Value))
  450. {
  451. skillRoot = new Skill(attributeList[i]);
  452. }
  453. else
  454. {
  455. skillRoot = new BigSkill(attributeList[i]);
  456. }
  457. }
  458. else
  459. {
  460. throw new Exception(attributeList[i].Count.ToString());
  461. }
  462. #endregion
  463. SkillDic.Add(skillRoot.ID, skillRoot);
  464. SkillList.Add(skillRoot);
  465. }
  466. SkillList.Sort(SkillRoot.Sort);
  467. #endregion
  468. for (int i = 0; i < SkillList.Count; i++)
  469. {
  470. if (SkillList[i].SkillTab != SkillTab.Null)
  471. {
  472. ManaReso.GetSkillItem(SkillList[i]);
  473. }
  474. }
  475. #endregion
  476. }
  477. public override void RegistValueB()
  478. {
  479. Instance = this;
  480. ManaReso.Get<Graphic>("F_Elf").material = ManaReso.Load<Material>("GrayMat", Folder.Effect);
  481. ManaReso.Get<Graphic>("F_Store").material = ManaReso.Load<Material>("GrayMat", Folder.Effect);
  482. ManaReso.Get<Graphic>("F_Magic").material = ManaReso.Load<Material>("GrayMat", Folder.Effect);
  483. ManaReso.Get<Graphic>("F_ElfLab").material = ManaReso.Load<Material>("GrayMat", Folder.Effect);
  484. ManaReso.Get<Graphic>("F_StoreLab").material = ManaReso.Load<Material>("GrayMat", Folder.Effect);
  485. ManaReso.Get<Graphic>("F_MagicLab").material = ManaReso.Load<Material>("GrayMat", Folder.Effect);
  486. ManaReso.Get<Button>("F_Elf").interactable = false;
  487. ManaReso.Get<Button>("F_Store").interactable = false;
  488. ManaReso.Get<Button>("F_Magic").interactable = false;
  489. Coin = Data.GetPlayerDouble("Coin");
  490. Diamond = Data.GetPlayerDouble("Diamond");
  491. MiniTimer = Data.GetPlayerFloat("MiniTimer");
  492. CircleTimer = Data.GetPlayerFloat("CircleTimer");
  493. ManaServer.ID = Data.GetPlayerString("ID");
  494. ManaDebug.Log(string.Format("<color=red>{0:0}</color>秒后激活小游戏", MiniTimer));
  495. List<string> offlineList = Data.GetOfflineConfig();
  496. MaxCoin = Auxiliary.LongParse(offlineList[2], 999999999999999999);
  497. MaxTime = Auxiliary.LongParse(offlineList[1], 999999999999999999);
  498. OfflineFml = offlineList[0];
  499. List<double> dataList = Data.GetAchieveData();
  500. AdAmt = dataList[0];
  501. ElfLevel = dataList[4];
  502. SkillAmt = dataList[1];
  503. SignAmt = dataList[2];
  504. ShareAmt = dataList[3];
  505. FlowerCoin = dataList[6];
  506. TotalPerson = dataList[7];
  507. MiniGameAmt = dataList[5];
  508. }
  509. public static void RegistSkill()
  510. {
  511. QuitTime = DateTime.Parse(Data.GetPlayerString("QuitTime"));
  512. Elapse = (float)ManaServer.Time.Subtract(QuitTime).TotalSeconds;
  513. if (Elapse > MaxTime)
  514. {
  515. Elapse = (long)MaxTime;
  516. }
  517. if (!Data.GetPlayerBool("QuitFlag"))
  518. {
  519. Elapse = 0;
  520. }
  521. ManaDebug.Log(string.Format("离线时间<color=red>{0}</color>", Elapse));
  522. FFUseList = new List<List<Skill>>();
  523. FFCoolList = new List<Skill>();
  524. if (Elapse > CircleTimer)
  525. {
  526. int circle = 1 + Mathf.FloorToInt((Elapse - CircleTimer) / CircleTime);
  527. for (int i = 0; i < circle; i++)
  528. {
  529. FFUseList.Add(new List<Skill>());
  530. }
  531. ManaDebug.Log(string.Format("离线周期<color=red>{0}</color>", circle));
  532. }
  533. else
  534. {
  535. ManaDebug.Log(string.Format("离线周期<color=red>{0}</color>", 0));
  536. }
  537. List<XmlAttributeCollection> attributeList = Data.GetSkillList();
  538. for (int i = 0; i < attributeList.Count; i++)
  539. {
  540. SkillRoot skillRoot = SkillDic[attributeList[i][0].Value];
  541. skillRoot.RegistReference();
  542. skillRoot.RegistValue(Elapse, FFUseList, attributeList[i]);
  543. }
  544. Level = Data.GetPlayerInt("Level");
  545. }
  546. public static void RegistIncome()
  547. {
  548. double coin = 0;
  549. if (FFUseList.Count > 0)
  550. {
  551. for (int i = 0; i < FFUseList.Count; i++)
  552. {
  553. for (int j = 0; j < FFCoolList.Count; j++)
  554. {
  555. FFCoolList[j].CoolTimer -= CircleTime;
  556. }
  557. for (int j = 0; j < FFUseList[i].Count; j++)
  558. {
  559. FFUseList[i][j].Annul();
  560. FFCoolList.Add(FFUseList[i][j]);
  561. }
  562. NewPerson = Person * (1 + SkillPersonBuff) + SkillPerson;
  563. NewCoinPerson = CoinPerson + SkillCoinPerson;
  564. TotalPerson += NewPerson * CircleTime;
  565. coin += (NewPerson * NewCoinPerson * CircleTime) * (1 + SkillPlus);
  566. }
  567. CircleTimer = (Elapse - CircleTimer) % CircleTime;
  568. for (int j = 0; j < FFCoolList.Count; j++)
  569. {
  570. FFCoolList[j].CoolTimer -= CircleTime - CircleTimer;
  571. }
  572. coin = (long) Auxiliary.FmlParse(OfflineFml, "c", coin.ToString());
  573. if (coin > MaxCoin)
  574. {
  575. coin = MaxCoin;
  576. }
  577. Coin += coin;
  578. ManaReso.SetText("Ba_IconLab", coin.ToString("0"));
  579. }
  580. else
  581. {
  582. CircleTimer = CircleTimer - Elapse;
  583. ManaReso.SetText("Ba_IconLab", "0");
  584. }
  585. }
  586. public static void SwitchLanguage()
  587. {
  588. Coin = Coin;
  589. Diamond = Diamond;
  590. }
  591. public static void Pay(string id, double amt, Current current, UnityAction callback)
  592. {
  593. if (ManaTutorial.PayExempt)
  594. {
  595. callback.Invoke();
  596. return;
  597. }
  598. amt = Auxiliary.ShrinkNumber(amt);
  599. if (current == Current.Free)
  600. {
  601. callback.Invoke();
  602. }
  603. else if (current == Current.AD)
  604. {
  605. ManagerIAP.PlayAd(callback);
  606. }
  607. else if (current == Current.Cash)
  608. {
  609. ManagerIAP.Purchase(id);
  610. }
  611. else if (current == Current.Coin)
  612. {
  613. if (Coin >= amt)
  614. {
  615. Coin -= amt;
  616. callback.Invoke();
  617. }
  618. else
  619. {
  620. ManaReso.Get("Fe_Info").TweenBacCG();
  621. Bubble.Show
  622. (
  623. Language.GetStr("Common", "ShortCoin"),
  624. Language.GetStr("Common", "NavigateCoin"),
  625. ManaReso.LoadSprite("金币"),
  626. () =>
  627. {
  628. Tween tween = ManaReso.Get("K_Bubble0").GetTweenScale();
  629. tween.AddEventOnetime
  630. (
  631. EventType.BackwardFinish,
  632. () =>
  633. {
  634. ManaReso.Get<Button>("F_Magic").onClick.Invoke();
  635. Auxiliary.Instance.DelayCall
  636. (
  637. () =>
  638. {
  639. int index = ManaReso.Get("Fb_Grid").childCount - 1;
  640. ManaReso.Get<ScrollRect>("Fb_Scrr").Locate(index, 0.25f, Curve.EaseOutQuad, LocatePos.Down);
  641. },
  642. 1
  643. );
  644. }
  645. );
  646. }
  647. );
  648. }
  649. }
  650. else if (current == Current.Diamond)
  651. {
  652. if (Diamond >= amt)
  653. {
  654. Diamond -= amt;
  655. callback.Invoke();
  656. }
  657. else
  658. {
  659. ManaReso.Get("Fe_Info").TweenBacCG();
  660. Bubble.Show
  661. (
  662. Language.GetStr("Common", "ShortDiamond"),
  663. Language.GetStr("Common", "NavigateDiamond"),
  664. ManaReso.LoadSprite("钻石"),
  665. () =>
  666. {
  667. Tween tween = ManaReso.Get("K_Bubble0").GetTweenScale();
  668. tween.AddEventOnetime
  669. (
  670. EventType.BackwardFinish,
  671. () =>
  672. {
  673. ManaReso.Get<Button>("F_Store").onClick.Invoke();
  674. Auxiliary.Instance.DelayCall
  675. (
  676. () =>
  677. {
  678. int index = ManaReso.Get("Fc_Grid").childCount - 1;
  679. ManaReso.Get<ScrollRect>("Fc_Scrr").Locate(index, 0.25f, Curve.EaseOutQuad, LocatePos.Down);
  680. },
  681. 1
  682. );
  683. }
  684. );
  685. }
  686. );
  687. }
  688. }
  689. else
  690. {
  691. throw new Exception(current.ToString());
  692. }
  693. }
  694. public static void LoginCallbackInitial(JsonData jsonData)
  695. {
  696. if (!Initializer.LoadComplete || !ManaServer.LoginComplete)
  697. {
  698. return;
  699. }
  700. if (ManaServer.Connect)
  701. {
  702. if (Data.GetPlayerString("ID") == "Default")
  703. {
  704. ManaServer.ID = ManaServer.JsonData["o"].ToString();
  705. ManaReso.SetText("L_UserLab", ManaServer.ID);
  706. }
  707. }
  708. if (ManaServer.Connect && Data.GetPlayerBool("QuitFlag"))
  709. {
  710. if (!ManaTutorial.TutorialA)
  711. {
  712. ManaReso.Get("B_SignIn").TweenForCG();
  713. }
  714. }
  715. RegistSkill();
  716. RegistIncome();
  717. InitiateComplete = true;
  718. }
  719. public static void LoginCallbackReactive(JsonData jsonData)
  720. {
  721. for (int i = 0; i < Initializer.RegistList.Count; i++)
  722. {
  723. Initializer.RegistList[i].Reactive();
  724. }
  725. }
  726. public static void DownloadArchive()
  727. {
  728. ManaReso.SetText("La_Lab", "连接中");
  729. ManaReso.SetActive("La_Lab", true);
  730. ManaReso.SetActive("La_Mask", true);
  731. string id = ManaReso.Get<InputField>("La_InputField").text;
  732. ManaServer.Load(id, DownloadCallback);
  733. }
  734. public static void DownloadCallback(JsonData jsonData)
  735. {
  736. if (jsonData.Inst_Object.Keys.Contains("l"))
  737. {
  738. ManaReso.SetActive("La_Mask", false);
  739. ManaReso.SetText("La_Lab", Language.GetStr("UI", "La_Lab0"));
  740. int version = Data.GetPlayerInt("Version");
  741. Data.PlayerDoc.LoadXml(jsonData["l"].ToString());
  742. Data.PlayerNode = Data.PlayerDoc.SelectSingleNode("PlayerConfig");
  743. Data.SavePlayerInt("Version", version);
  744. ManaReso.SetText("L_UserLab", Data.GetPlayerString("ID"));
  745. ManaServer.ID = Data.GetPlayerString("ID");
  746. ManaMiniGame.MiniGameIndex = Data.GetPlayerInt("MiniGameIndex");
  747. Garden.Reload();
  748. ManaGarden.Reload();
  749. Reload();
  750. ManaAchieve.Reload();
  751. ManaPlayer.Reload();
  752. ManaSign.Reload();
  753. ManaReso.Get("La_Info").TweenBacCG();
  754. }
  755. else
  756. {
  757. ManaReso.SetText("La_Lab", Language.GetStr("UI", "La_Lab1"));
  758. ManaReso.SetActive("La_Mask", false);
  759. }
  760. }
  761. public void OnApplicationQuit()
  762. {
  763. if (Initializer.LoadComplete && !Reset)
  764. {
  765. Data.SavePlayerConfig();
  766. Data.SaveXml();
  767. }
  768. }
  769. public void OnApplicationPause(bool pause)
  770. {
  771. if (pause)
  772. {
  773. Data.SavePlayerConfig();
  774. Data.SaveXml();
  775. }
  776. else
  777. {
  778. if (FirstFrame)
  779. {
  780. FirstFrame = false;
  781. }
  782. else
  783. {
  784. ManaServer.Login(LoginCallbackReactive);
  785. }
  786. }
  787. }
  788. }