ManaData.cs 25 KB

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