ManaData.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984
  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 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;
  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. SkillAmt = dataList[1];
  502. SignAmt = dataList[2];
  503. ShareAmt = dataList[3];
  504. MiniGameAmt = dataList[4];
  505. FlowerCoin = dataList[5];
  506. TotalPerson = dataList[6];
  507. }
  508. public static void RegistSkill()
  509. {
  510. QuitTime = DateTime.Parse(Data.GetPlayerString("QuitTime"));
  511. Elapse = (float)ManaServer.Time.Subtract(QuitTime).TotalSeconds;
  512. if (Elapse > MaxTime)
  513. {
  514. Elapse = (long)MaxTime;
  515. }
  516. if (!Data.GetPlayerBool("QuitFlag"))
  517. {
  518. Elapse = 0;
  519. }
  520. ManaDebug.Log(string.Format("离线时间<color=red>{0}</color>", Elapse));
  521. FFUseList = new List<List<Skill>>();
  522. FFCoolList = new List<Skill>();
  523. if (Elapse > CircleTimer)
  524. {
  525. int circle = 1 + Mathf.FloorToInt((Elapse - CircleTimer) / CircleTime);
  526. for (int i = 0; i < circle; i++)
  527. {
  528. FFUseList.Add(new List<Skill>());
  529. }
  530. ManaDebug.Log(string.Format("离线周期<color=red>{0}</color>", circle));
  531. }
  532. else
  533. {
  534. ManaDebug.Log(string.Format("离线周期<color=red>{0}</color>", 0));
  535. }
  536. List<XmlAttributeCollection> attributeList = Data.GetSkillList();
  537. for (int i = 0; i < attributeList.Count; i++)
  538. {
  539. SkillRoot skillRoot = SkillDic[attributeList[i][0].Value];
  540. skillRoot.RegistReference();
  541. skillRoot.RegistValue(Elapse, FFUseList, attributeList[i]);
  542. }
  543. Level = Data.GetPlayerInt("Level");
  544. }
  545. public static void RegistIncome()
  546. {
  547. double coin = 0;
  548. if (FFUseList.Count > 0)
  549. {
  550. for (int i = 0; i < FFUseList.Count; i++)
  551. {
  552. for (int j = 0; j < FFCoolList.Count; j++)
  553. {
  554. FFCoolList[j].CoolTimer -= CircleTime;
  555. }
  556. for (int j = 0; j < FFUseList[i].Count; j++)
  557. {
  558. FFUseList[i][j].Annul();
  559. FFCoolList.Add(FFUseList[i][j]);
  560. }
  561. NewPerson = Person * (1 + SkillPersonBuff) + SkillPerson;
  562. NewCoinPerson = CoinPerson + SkillCoinPerson;
  563. coin += (NewPerson * NewCoinPerson * CircleTime) * (1 + SkillPlus);
  564. }
  565. CircleTimer = (Elapse - CircleTimer) % CircleTime;
  566. for (int j = 0; j < FFCoolList.Count; j++)
  567. {
  568. FFCoolList[j].CoolTimer -= CircleTime - CircleTimer;
  569. }
  570. coin = (long) Auxiliary.FmlParse(OfflineFml, "c", coin.ToString());
  571. if (coin > MaxCoin)
  572. {
  573. coin = MaxCoin;
  574. }
  575. Coin += coin;
  576. ManaReso.SetText("Ba_IconLab", coin.ToString("0"));
  577. }
  578. else
  579. {
  580. CircleTimer = CircleTimer - Elapse;
  581. ManaReso.SetText("Ba_IconLab", "0");
  582. }
  583. }
  584. public static void SwitchLanguage()
  585. {
  586. Coin = Coin;
  587. Diamond = Diamond;
  588. }
  589. public static bool Pay(double amt, Current current)
  590. {
  591. if (ManaTutorial.PayExempt)
  592. {
  593. return true;
  594. }
  595. amt = Auxiliary.ShrinkNumber(amt);
  596. if (current == Current.Free)
  597. {
  598. return true;
  599. }
  600. else if (current == Current.AD)
  601. {
  602. return true;
  603. }
  604. else if (current == Current.Cash)
  605. {
  606. return true;
  607. }
  608. else if (current == Current.Coin)
  609. {
  610. if (Coin >= amt)
  611. {
  612. Coin -= amt;
  613. return true;
  614. }
  615. else
  616. {
  617. ManaReso.Get("Fe_Info").TweenBacCG();
  618. Bubble.Show
  619. (
  620. Language.GetStr("Common", "ShortCoin"),
  621. Language.GetStr("Common", "NavigateCoin"),
  622. ManaReso.LoadSprite("金币"),
  623. () =>
  624. {
  625. Tween tween = ManaReso.Get("K_Bubble0").GetTweenScale();
  626. tween.AddEventOnetime
  627. (
  628. EventType.BackwardFinish,
  629. () =>
  630. {
  631. ManaReso.Get<Button>("F_Magic").onClick.Invoke();
  632. Auxiliary.Instance.DelayCall
  633. (
  634. () =>
  635. {
  636. int index = ManaReso.Get("Fb_Grid").childCount - 1;
  637. ManaReso.Get<ScrollRect>("Fb_Scrr").Locate(index, 0.25f, Curve.EaseOutQuad, LocatePos.Down);
  638. },
  639. 1
  640. );
  641. }
  642. );
  643. }
  644. );
  645. return false;
  646. }
  647. }
  648. else if (current == Current.Diamond)
  649. {
  650. if (Diamond >= amt)
  651. {
  652. Diamond -= amt;
  653. return true;
  654. }
  655. else
  656. {
  657. ManaReso.Get("Fe_Info").TweenBacCG();
  658. Bubble.Show
  659. (
  660. Language.GetStr("Common", "ShortDiamond"),
  661. Language.GetStr("Common", "NavigateDiamond"),
  662. ManaReso.LoadSprite("钻石"),
  663. () =>
  664. {
  665. Tween tween = ManaReso.Get("K_Bubble0").GetTweenScale();
  666. tween.AddEventOnetime
  667. (
  668. EventType.BackwardFinish,
  669. () =>
  670. {
  671. ManaReso.Get<Button>("F_Store").onClick.Invoke();
  672. Auxiliary.Instance.DelayCall
  673. (
  674. () =>
  675. {
  676. int index = ManaReso.Get("Fc_Grid").childCount - 1;
  677. ManaReso.Get<ScrollRect>("Fc_Scrr").Locate(index, 0.25f, Curve.EaseOutQuad, LocatePos.Down);
  678. },
  679. 1
  680. );
  681. }
  682. );
  683. }
  684. );
  685. return false;
  686. }
  687. }
  688. else
  689. {
  690. throw new Exception(current.ToString());
  691. }
  692. }
  693. public static void LoginCallbackInitial(JsonData jsonData)
  694. {
  695. if (!Initializer.LoadComplete || !ManaServer.LoginComplete)
  696. {
  697. return;
  698. }
  699. if (ManaServer.Connect)
  700. {
  701. if (Data.GetPlayerString("ID") == "Default")
  702. {
  703. ManaServer.ID = ManaServer.JsonData["o"].ToString();
  704. ManaReso.SetText("L_UserLab", ManaServer.ID);
  705. }
  706. }
  707. if (ManaServer.Connect && Data.GetPlayerBool("QuitFlag"))
  708. {
  709. if (!ManaTutorial.TutorialA)
  710. {
  711. ManaReso.Get("B_SignIn").TweenForCG();
  712. }
  713. }
  714. RegistSkill();
  715. RegistIncome();
  716. InitiateComplete = true;
  717. }
  718. public static void LoginCallbackReactive(JsonData jsonData)
  719. {
  720. for (int i = 0; i < Initializer.RegistList.Count; i++)
  721. {
  722. Initializer.RegistList[i].Reactive();
  723. }
  724. }
  725. public static void DownloadArchive()
  726. {
  727. ManaReso.SetText("La_Lab", "连接中");
  728. ManaReso.SetActive("La_Lab", true);
  729. ManaReso.SetActive("La_Mask", true);
  730. string id = ManaReso.Get<InputField>("La_InputField").text;
  731. ManaServer.Load(id, DownloadCallback);
  732. }
  733. public static void DownloadCallback(JsonData jsonData)
  734. {
  735. if (jsonData.Inst_Object.Keys.Contains("l"))
  736. {
  737. ManaReso.SetActive("La_Mask", false);
  738. ManaReso.SetText("La_Lab", Language.GetStr("UI", "La_Lab0"));
  739. int version = Data.GetPlayerInt("Version");
  740. Data.PlayerDoc.LoadXml(jsonData["l"].ToString());
  741. Data.PlayerNode = Data.PlayerDoc.SelectSingleNode("PlayerConfig");
  742. Data.SavePlayerInt("Version", version);
  743. ManaReso.SetText("L_UserLab", Data.GetPlayerString("ID"));
  744. ManaServer.ID = Data.GetPlayerString("ID");
  745. ManaMiniGame.MiniGameIndex = Data.GetPlayerInt("MiniGameIndex");
  746. Garden.Reload();
  747. ManaGarden.Reload();
  748. Reload();
  749. ManaAchieve.Reload();
  750. ManaPlayer.Reload();
  751. ManaSign.Reload();
  752. ManaReso.Get("La_Info").TweenBacCG();
  753. }
  754. else
  755. {
  756. ManaReso.SetText("La_Lab", Language.GetStr("UI", "La_Lab1"));
  757. ManaReso.SetActive("La_Mask", false);
  758. }
  759. }
  760. public void OnApplicationQuit()
  761. {
  762. if (Initializer.LoadComplete && !Reset)
  763. {
  764. Data.SavePlayerConfig();
  765. Data.SaveXml();
  766. }
  767. }
  768. public void OnApplicationPause(bool pause)
  769. {
  770. if (pause)
  771. {
  772. Data.SavePlayerConfig();
  773. Data.SaveXml();
  774. }
  775. else
  776. {
  777. if (FirstFrame)
  778. {
  779. FirstFrame = false;
  780. }
  781. else
  782. {
  783. ManaServer.Login(LoginCallbackReactive);
  784. }
  785. }
  786. }
  787. }