ManaData.cs 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125
  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 (Level_ >= 20)
  134. {
  135. if (ManaTutorial.TutorialC_)
  136. {
  137. ManaTutorial.PrepareStepC1();
  138. }
  139. else
  140. {
  141. ManaReso.SetActive("C_Visit", true);
  142. }
  143. }
  144. //if (Level_ >= 200)
  145. //{
  146. // if (ManaTutorial.TutorialB_)
  147. // {
  148. // ManaTutorial.TutorialB = true;
  149. // ManaTutorial.PrepareStepB1();
  150. // }
  151. //}
  152. }
  153. }
  154. public static bool Pause
  155. {
  156. get { return Pause_; }
  157. set
  158. {
  159. Pause_ = value;
  160. if (Pause_)
  161. {
  162. Time.timeScale = 0;
  163. ManaDebug.Log("<color=red>游戏暂停</color>");
  164. }
  165. else
  166. {
  167. Time.timeScale = 1;
  168. ManaDebug.Log("<color=red>游戏继续</color>");
  169. }
  170. }
  171. }
  172. public static float Person
  173. {
  174. get { return Person_; }
  175. set
  176. {
  177. Person_ = value;
  178. ManaReso.SetText("F_PersonLab", Mathf.FloorToInt(60*(Person_ * (1 + SkillPersonBuff_) + SkillPerson_)).ToString());
  179. }
  180. }
  181. public static float SkillPerson
  182. {
  183. get { return SkillPerson_; }
  184. set
  185. {
  186. SkillPerson_ = value;
  187. if (SkillPerson_.Equal(0))
  188. {
  189. ManaReso.Get("F_PersonLab").GetTweenOutline().Pause();
  190. ManaReso.Get<Outline>("F_PersonLab").enabled = false;
  191. }
  192. else
  193. {
  194. Tween tween = ManaReso.Get("F_PersonLab").GetTweenOutline();
  195. if (tween.InForward)
  196. {
  197. tween.StartForward();
  198. }
  199. else if (tween.InBackward)
  200. {
  201. tween.StartBackward();
  202. }
  203. else
  204. {
  205. tween.StartForward();
  206. }
  207. }
  208. ManaReso.SetText("F_PersonLab", Mathf.FloorToInt(60*(Person_ * (1 + SkillPersonBuff_) + SkillPerson_)).ToString());
  209. }
  210. }
  211. public static float CoinPerson
  212. {
  213. get { return CoinPerson_; }
  214. set
  215. {
  216. CoinPerson_ = value;
  217. ManaReso.SetText("F_CoinPersonLab", Mathf.FloorToInt(CoinPerson_ + SkillCoinPerson_).ToString());
  218. }
  219. }
  220. public static float SkillPersonBuff
  221. {
  222. get { return SkillPersonBuff_; }
  223. set
  224. {
  225. SkillPersonBuff_ = value;
  226. ManaReso.SetText("F_PersonLab", Mathf.FloorToInt(60 * (Person_ * (1 + SkillPersonBuff_) + SkillPerson_)).ToString());
  227. }
  228. }
  229. public static float SkillCoinPerson
  230. {
  231. get { return SkillCoinPerson_; }
  232. set
  233. {
  234. SkillCoinPerson_ = value;
  235. if (SkillCoinPerson_.Equal(0))
  236. {
  237. ManaReso.Get("F_CoinPersonLab").GetTweenOutline().Pause();
  238. ManaReso.Get<Outline>("F_CoinPersonLab").enabled = false;
  239. }
  240. else
  241. {
  242. Tween tween = ManaReso.Get("F_CoinPersonLab").GetTweenOutline();
  243. if (tween.InForward)
  244. {
  245. tween.StartForward();
  246. }
  247. else if (tween.InBackward)
  248. {
  249. tween.StartBackward();
  250. }
  251. else
  252. {
  253. tween.StartForward();
  254. }
  255. }
  256. ManaReso.SetText("F_CoinPersonLab", Mathf.FloorToInt(CoinPerson_ + SkillCoinPerson_).ToString());
  257. }
  258. }
  259. public static double Coin
  260. {
  261. get { return Coin_; }
  262. set
  263. {
  264. if (value - Coin_ > 0)
  265. {
  266. TotalCoin += value - Coin_;
  267. }
  268. Coin_ = value;
  269. ManaReso.SetText("F_CoinLab", Auxiliary.ShrinkNumberStr(Coin_, 0));
  270. ManaReso.SetText("C_CoinLab", Auxiliary.ShrinkNumberStr(Coin_, 0));
  271. ManaAchieve.UpdateStatus(AchieveType.CurrentCoin, Coin_);
  272. }
  273. }
  274. public static double Diamond
  275. {
  276. get { return Diamond_; }
  277. set
  278. {
  279. Diamond_ = value;
  280. ManaReso.SetText("F_DiamondLab", Auxiliary.ShrinkNumberStr(Diamond_, 0));
  281. }
  282. }
  283. private static int Level_;
  284. private static bool Pause_;
  285. private static float Person_;
  286. private static float CoinPerson_;
  287. private static double Coin_;
  288. private static double Diamond_;
  289. public static bool Reset;
  290. public static bool MiniValid;
  291. public static bool FirstFrame = true;
  292. public static bool OfflineValid;
  293. public static bool TabBtnValid;
  294. public static bool ReactiveRequest;
  295. public static bool InitiateComplete;
  296. public static float Elapse;
  297. public static float OpTimer;
  298. public static float MiniTimer;
  299. public static float SaveTimer;
  300. public static float LoginTimer;
  301. public static float CircleTime = 10;
  302. public static float CircleTimer;
  303. public static float NewPerson;
  304. public static float NewCoinPerson;
  305. public static string OfflineFml;
  306. public static double MaxCoin;
  307. public static double MaxTime;
  308. public static float SkillPlus;
  309. public static float SkillPerson_;
  310. public static float SkillPersonBuff_;
  311. public static float SkillCoinPerson_;
  312. public static DateTime QuitTime;
  313. public static ManaData Instance;
  314. public static List<Skill> UseList = new List<Skill>();
  315. public static List<Skill> CoolList = new List<Skill>();
  316. public static List<Skill> FFCoolList = new List<Skill>();
  317. public static List<SkillRoot> SkillList = new List<SkillRoot>();
  318. public static List<List<Skill>> FFUseList = new List<List<Skill>>();
  319. public static Dictionary<string, SkillRoot> SkillDic = new Dictionary<string, SkillRoot>();
  320. #endregion
  321. private void Update()
  322. {
  323. if (ManaTutorial.TutorialA)
  324. {
  325. return;
  326. }
  327. OperateThread();
  328. }
  329. private void FixedUpdate()
  330. {
  331. if (ManaTutorial.TutorialA)
  332. {
  333. LoginThread();
  334. return;
  335. }
  336. SkillThread();
  337. MiniThread();
  338. MiniThread();
  339. SaveThread();
  340. LoginThread();
  341. IncomeThread();
  342. }
  343. private void SkillThread()
  344. {
  345. for (int i = 0; i < UseList.Count; i++)
  346. {
  347. if (UseList[i].DoUse())
  348. {
  349. UseList.RemoveAt(i--);
  350. }
  351. }
  352. for (int i = 0; i < CoolList.Count; i++)
  353. {
  354. if (CoolList[i].DoCool())
  355. {
  356. CoolList.RemoveAt(i--);
  357. }
  358. }
  359. }
  360. private void MiniThread()
  361. {
  362. if (Pause)
  363. {
  364. return;
  365. }
  366. if (MiniValid == false)
  367. {
  368. MiniTimer -= Time.deltaTime;
  369. if (MiniTimer < 0)
  370. {
  371. MiniValid = true;
  372. ManaReso.Get("C_MiniGame").TweenForCG();
  373. }
  374. }
  375. }
  376. private void SaveThread()
  377. {
  378. SaveTimer += Time.fixedDeltaTime;
  379. if (SaveTimer >= 60)
  380. {
  381. SaveTimer = 0;
  382. ManaServer.Save();
  383. }
  384. }
  385. private void LoginThread()
  386. {
  387. LoginTimer += Time.fixedDeltaTime;
  388. if (LoginTimer >= 10)
  389. {
  390. LoginTimer = 0;
  391. ManaServer.Login();
  392. }
  393. }
  394. private void IncomeThread()
  395. {
  396. CircleTimer -= Time.deltaTime;
  397. if (CircleTimer < 0)
  398. {
  399. CircleTimer = CircleTime;
  400. NewPerson = Person * (1 + SkillPersonBuff) + SkillPerson;
  401. NewCoinPerson = CoinPerson + SkillCoinPerson;
  402. TotalPerson += NewPerson * CircleTime;
  403. float temp = (NewPerson * NewCoinPerson * CircleTime) * (1 + SkillPlus);
  404. Coin += temp;
  405. ManaReso.Get("C_IncomeLab").TweenForGra();
  406. ManaReso.Get("C_IncomeLab").TweenForVec();
  407. ManaReso.SetText("C_IncomeLab", "+" + temp.ToString("0.0"));
  408. 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));
  409. }
  410. }
  411. private void OperateThread()
  412. {
  413. if (Pause)
  414. {
  415. return;
  416. }
  417. if (Auxiliary.AnyKeyUp)
  418. {
  419. OpTimer = 0;
  420. ManaReso.Get("C_Group").TweenForCG();
  421. }
  422. else
  423. {
  424. OpTimer += Time.deltaTime;
  425. if (OpTimer >= 60)
  426. {
  427. OpTimer = 0;
  428. ManaReso.Get("C_Group").TweenBacCG();
  429. }
  430. }
  431. }
  432. public static void Reload()
  433. {
  434. Reset = false;
  435. TabBtnValid = false;
  436. Person = 0;
  437. CoinPerson = 0;
  438. SkillPlus = 0;
  439. SkillPerson = 0;
  440. SkillPersonBuff_ = 0;
  441. SkillCoinPerson = 0;
  442. SaveTimer = 0;
  443. UseList = new List<Skill>();
  444. CoolList = new List<Skill>();
  445. Instance.RegistValueB();
  446. ManaTutorial.TutorialB_ = Data.GetPlayerBool("TutorialB");
  447. ManaTutorial.TutorialIndexB = Data.GetPlayerInt("TutorialIndexB");
  448. for (int i = 0; i < SkillList.Count; i++)
  449. {
  450. Ability ability = SkillList[i] as Ability;
  451. if (ability != null)
  452. {
  453. ability.ValidSlot = true;
  454. }
  455. }
  456. RegistSkill();
  457. RegistIncome();
  458. if (ManaServer.Connect)
  459. {
  460. if (!ManaTutorial.TutorialA && !ManaTutorial.TutorialB)
  461. {
  462. ManaReso.Get("B_SignIn").TweenForCG();
  463. }
  464. }
  465. }
  466. public override void Reactive()
  467. {
  468. foreach (var kv in SkillDic)
  469. {
  470. kv.Value.Reactive();
  471. }
  472. RegistSkill();
  473. RegistIncome();
  474. if (OfflineValid)
  475. {
  476. if (!ManaTutorial.TutorialA && !ManaTutorial.TutorialB)
  477. {
  478. ManaReso.Get("C_Group").TweenBacCG();
  479. ManaReso.Get("B_SignIn").TweenForCG();
  480. ManaReso.Get("Ba_Notice").TweenForCG();
  481. }
  482. }
  483. }
  484. public override void Instantiate()
  485. {
  486. #region 生成技能条
  487. #region 读技能配置
  488. List<XmlAttributeCollection> attributeList = Data.GetSkillConfig();
  489. for (int i = 0; i < attributeList.Count; i++)
  490. {
  491. SkillRoot skillRoot;
  492. #region MyRegion
  493. if (attributeList[i].Count == 17)
  494. {
  495. skillRoot = new Pack(attributeList[i]);
  496. }
  497. else if (attributeList[i].Count == 23)
  498. {
  499. skillRoot = new Ability(attributeList[i]);
  500. }
  501. else if (attributeList[i].Count == 33)
  502. {
  503. if (string.IsNullOrEmpty(attributeList[i][4].Value))
  504. {
  505. skillRoot = new Skill(attributeList[i]);
  506. }
  507. else
  508. {
  509. skillRoot = new BigSkill(attributeList[i]);
  510. }
  511. }
  512. else
  513. {
  514. throw new Exception(attributeList[i].Count.ToString());
  515. }
  516. #endregion
  517. SkillDic.Add(skillRoot.ID, skillRoot);
  518. SkillList.Add(skillRoot);
  519. }
  520. SkillList.Sort(SkillRoot.Sort);
  521. #endregion
  522. for (int i = 0; i < SkillList.Count; i++)
  523. {
  524. if (SkillList[i].SkillTab != SkillTab.Null)
  525. {
  526. ManaReso.GetSkillItem(SkillList[i]);
  527. }
  528. }
  529. #endregion
  530. }
  531. public override void RegistValueB()
  532. {
  533. Instance = this;
  534. ManaReso.Get<Graphic>("F_Elf").material = ManaReso.Load<Material>("GrayMat", Folder.Effect);
  535. ManaReso.Get<Graphic>("F_Store").material = ManaReso.Load<Material>("GrayMat", Folder.Effect);
  536. ManaReso.Get<Graphic>("F_Magic").material = ManaReso.Load<Material>("GrayMat", Folder.Effect);
  537. ManaReso.Get<Graphic>("F_ElfLab").material = ManaReso.Load<Material>("GrayMat", Folder.Effect);
  538. ManaReso.Get<Graphic>("F_StoreLab").material = ManaReso.Load<Material>("GrayMat", Folder.Effect);
  539. ManaReso.Get<Graphic>("F_MagicLab").material = ManaReso.Load<Material>("GrayMat", Folder.Effect);
  540. ManaReso.Get<Button>("F_Elf").interactable = false;
  541. ManaReso.Get<Button>("F_Store").interactable = false;
  542. ManaReso.Get<Button>("F_Magic").interactable = false;
  543. Coin = Data.GetPlayerDouble("Coin");
  544. Diamond = Data.GetPlayerDouble("Diamond");
  545. MiniTimer = Data.GetPlayerFloat("MiniTimer");
  546. CircleTimer = Data.GetPlayerFloat("CircleTimer");
  547. ManaServer.ID = Data.GetPlayerString("ID");
  548. ManaDebug.Log(string.Format("<color=red>{0:0}</color>秒后激活小游戏", MiniTimer));
  549. List<string> offlineList = Data.GetOfflineConfig();
  550. MaxCoin = Auxiliary.LongParse(offlineList[2], 999999999999999999);
  551. MaxTime = Auxiliary.LongParse(offlineList[1], 999999999999999999);
  552. OfflineFml = offlineList[0];
  553. List<double> dataList = Data.GetAchieveData();
  554. AdAmt = dataList[0];
  555. ElfLevel = dataList[4];
  556. SkillAmt = dataList[1];
  557. SignAmt = dataList[2];
  558. ShareAmt = dataList[3];
  559. FlowerCoin = dataList[6];
  560. TotalPerson = dataList[7];
  561. MiniGameAmt = dataList[5];
  562. }
  563. public static void RegistSkill()
  564. {
  565. OfflineValid = false;
  566. if (ManaServer.Connect && Data.GetPlayerBool("QuitFlag"))
  567. {
  568. QuitTime = DateTime.Parse(Data.GetPlayerString("QuitTime"));
  569. Elapse = (float)ManaServer.Time.Subtract(QuitTime).TotalSeconds;
  570. ManaDebug.Log(string.Format("真实离线时间<color=red>{0}</color>", Elapse));
  571. if (Elapse <= 120)
  572. {
  573. Elapse = 0;
  574. }
  575. else
  576. {
  577. OfflineValid = true;
  578. }
  579. if (Elapse > MaxTime)
  580. {
  581. Elapse = (long)MaxTime;
  582. }
  583. }
  584. ManaDebug.Log(string.Format("计算离线时间<color=red>{0}</color>", Elapse));
  585. FFUseList = new List<List<Skill>>();
  586. FFCoolList = new List<Skill>();
  587. if (Elapse > CircleTimer)
  588. {
  589. int circle = 1 + Mathf.FloorToInt((Elapse - CircleTimer) / CircleTime);
  590. for (int i = 0; i < circle; i++)
  591. {
  592. FFUseList.Add(new List<Skill>());
  593. }
  594. ManaDebug.Log(string.Format("离线周期<color=red>{0}</color>", circle));
  595. }
  596. else
  597. {
  598. ManaDebug.Log(string.Format("离线周期<color=red>{0}</color>", 0));
  599. }
  600. List<XmlAttributeCollection> attributeList = Data.GetSkillList();
  601. for (int i = 0; i < attributeList.Count; i++)
  602. {
  603. SkillRoot skillRoot = SkillDic[attributeList[i][0].Value];
  604. skillRoot.RegistReference();
  605. skillRoot.RegistValue(Elapse, FFUseList, attributeList[i]);
  606. }
  607. Level = Data.GetPlayerInt("Level");
  608. }
  609. public static void RegistIncome()
  610. {
  611. double coin = 0;
  612. if (FFUseList.Count > 0)
  613. {
  614. for (int i = 0; i < FFUseList.Count; i++)
  615. {
  616. for (int j = 0; j < FFCoolList.Count; j++)
  617. {
  618. FFCoolList[j].CoolTimer -= CircleTime;
  619. }
  620. for (int j = 0; j < FFUseList[i].Count; j++)
  621. {
  622. FFUseList[i][j].Annul();
  623. FFCoolList.Add(FFUseList[i][j]);
  624. }
  625. NewPerson = Person * (1 + SkillPersonBuff_) + SkillPerson;
  626. NewCoinPerson = CoinPerson + SkillCoinPerson;
  627. TotalPerson += NewPerson * CircleTime;
  628. coin += (NewPerson * NewCoinPerson * CircleTime) * (1 + SkillPlus);
  629. }
  630. CircleTimer = (Elapse - CircleTimer) % CircleTime;
  631. for (int j = 0; j < FFCoolList.Count; j++)
  632. {
  633. FFCoolList[j].CoolTimer -= CircleTime - CircleTimer;
  634. }
  635. coin = (long) Auxiliary.FmlParse(OfflineFml, "c", coin.ToString());
  636. if (coin > MaxCoin)
  637. {
  638. coin = MaxCoin;
  639. }
  640. Coin += coin;
  641. ManaReso.SetText("Ba_IconLab", coin.ToString("0"));
  642. }
  643. else
  644. {
  645. CircleTimer = CircleTimer - Elapse;
  646. ManaReso.SetText("Ba_IconLab", "0");
  647. }
  648. }
  649. public static void SwitchLanguage()
  650. {
  651. Coin = Coin;
  652. Diamond = Diamond;
  653. }
  654. public static void Pay(string id, double amt, Current current, UnityAction callback, bool navigate = true)
  655. {
  656. if (ManaTutorial.PayExempt)
  657. {
  658. callback.Invoke();
  659. return;
  660. }
  661. amt = Auxiliary.ShrinkNumber(amt);
  662. if (current == Current.Free)
  663. {
  664. callback.Invoke();
  665. }
  666. else if (current == Current.AD)
  667. {
  668. ManaIAP.PlayAd(callback);
  669. }
  670. else if (current == Current.Cash)
  671. {
  672. ManaIAP.Purchase(id);
  673. }
  674. else if (current == Current.Coin)
  675. {
  676. #region MyRegion
  677. if (Coin >= amt)
  678. {
  679. Coin -= amt;
  680. callback.Invoke();
  681. }
  682. else
  683. {
  684. ManaReso.Get("Fe_Info").TweenBacCG();
  685. if (navigate)
  686. {
  687. Bubble.Show
  688. (
  689. Language.GetStr("Common", "ShortCoin"),
  690. Language.GetStr("Common", "NavigateCoin"),
  691. ManaReso.LoadSprite("金币"),
  692. () =>
  693. {
  694. Tween tween = ManaReso.Get("K_Bubble0").GetTweenScale();
  695. tween.AddEventOnetime
  696. (
  697. EventType.BackwardFinish,
  698. () =>
  699. {
  700. ManaReso.Get<Button>("F_Magic").onClick.Invoke();
  701. Auxiliary.Instance.DelayCall
  702. (
  703. () =>
  704. {
  705. int index = ManaReso.Get("Fb_Grid").childCount - 1;
  706. ManaReso.Get<ScrollRect>("Fb_Scrr").Locate(index, 0.25f, Curve.EaseOutQuad, LocatePos.Down);
  707. },
  708. 1
  709. );
  710. }
  711. );
  712. }
  713. );
  714. }
  715. else
  716. {
  717. Bubble.Show
  718. (
  719. Language.GetStr("Common", "ShortCoin"),
  720. null,
  721. ManaReso.LoadSprite("金币")
  722. );
  723. }
  724. }
  725. #endregion
  726. }
  727. else if (current == Current.Diamond)
  728. {
  729. #region MyRegion
  730. if (Diamond >= amt)
  731. {
  732. Diamond -= amt;
  733. callback.Invoke();
  734. }
  735. else
  736. {
  737. ManaReso.Get("Fe_Info").TweenBacCG();
  738. if (navigate)
  739. {
  740. Bubble.Show
  741. (
  742. Language.GetStr("Common", "ShortDiamond"),
  743. Language.GetStr("Common", "NavigateDiamond"),
  744. ManaReso.LoadSprite("钻石"),
  745. () =>
  746. {
  747. Tween tween = ManaReso.Get("K_Bubble0").GetTweenScale();
  748. tween.AddEventOnetime
  749. (
  750. EventType.BackwardFinish,
  751. () =>
  752. {
  753. ManaReso.Get<Button>("F_Store").onClick.Invoke();
  754. Auxiliary.Instance.DelayCall
  755. (
  756. () =>
  757. {
  758. int index = ManaReso.Get("Fc_Grid").childCount - 1;
  759. ManaReso.Get<ScrollRect>("Fc_Scrr").Locate(index, 0.25f, Curve.EaseOutQuad, LocatePos.Down);
  760. },
  761. 1
  762. );
  763. }
  764. );
  765. }
  766. );
  767. }
  768. else
  769. {
  770. Bubble.Show
  771. (
  772. Language.GetStr("Common", "ShortDiamond"),
  773. null,
  774. ManaReso.LoadSprite("钻石")
  775. );
  776. }
  777. }
  778. #endregion
  779. }
  780. else
  781. {
  782. throw new Exception(current.ToString());
  783. }
  784. }
  785. public static void LoginCallbackInitial(JsonData jsonData)
  786. {
  787. if (!Initializer.Complete || !ManaServer.Complete)
  788. {
  789. return;
  790. }
  791. if (ManaServer.Connect)
  792. {
  793. if (Data.GetPlayerString("ID") == "Default")
  794. {
  795. ManaServer.ID = ManaServer.JsonData["o"].ToString();
  796. ManaReso.SetText("L_UserLab", ManaServer.ID);
  797. }
  798. }
  799. RegistSkill();
  800. RegistIncome();
  801. if (OfflineValid)
  802. {
  803. if (!ManaTutorial.TutorialA)
  804. {
  805. ManaReso.Get("B_SignIn").TweenForCG();
  806. ManaReso.Get("Ba_Notice").TweenForCG();
  807. }
  808. }
  809. else
  810. {
  811. if (!ManaTutorial.TutorialA)
  812. {
  813. int daySpan = ManaServer.Time.Day - ManaSign.SignTime.Day;
  814. int yearSpan = ManaServer.Time.Year - ManaSign.SignTime.Year;
  815. int monthSpan = ManaServer.Time.Month - ManaSign.SignTime.Month;
  816. if (daySpan >= 1 || yearSpan >= 1 || monthSpan >= 1)
  817. {
  818. ManaReso.Get("B_SignIn").TweenForCG();
  819. ManaReso.Get("Bb_SignIn").TweenForCG();
  820. }
  821. }
  822. }
  823. InitiateComplete = true;
  824. Level = Level;
  825. }
  826. public static void LoginCallbackReactive(JsonData jsonData)
  827. {
  828. ReactiveRequest = false;
  829. for (int i = 0; i < Initializer.RegistList.Count; i++)
  830. {
  831. Initializer.RegistList[i].Reactive();
  832. }
  833. }
  834. public static void DownloadArchive()
  835. {
  836. ManaReso.SetText("La_Lab", "连接中");
  837. ManaReso.SetActive("La_Lab", true);
  838. ManaReso.SetActive("La_Mask", true);
  839. string id = ManaReso.Get<InputField>("La_InputField").text;
  840. ManaServer.Load(id, DownloadCallback);
  841. }
  842. public static void DownloadCallback(JsonData jsonData)
  843. {
  844. if (jsonData.Inst_Object.Keys.Contains("l"))
  845. {
  846. ManaReso.SetActive("La_Mask", false);
  847. ManaReso.SetText("La_Lab", Language.GetStr("UI", "La_Lab0"));
  848. int version = Data.GetPlayerInt("Version");
  849. Data.PlayerDoc.LoadXml(jsonData["l"].ToString());
  850. Data.PlayerNode = Data.PlayerDoc.SelectSingleNode("PlayerConfig");
  851. Data.SavePlayerInt("Version", version);
  852. ManaReso.SetText("L_UserLab", Data.GetPlayerString("ID"));
  853. ManaServer.ID = Data.GetPlayerString("ID");
  854. ManaMiniGame.MiniGameIndex = Data.GetPlayerInt("MiniGameIndex");
  855. Garden.Reload();
  856. ManaGarden.Reload();
  857. Reload();
  858. ManaAchieve.Reload();
  859. ManaPlayer.Reload();
  860. ManaSign.Reload();
  861. ManaReso.Get("La_Info").TweenBacCG();
  862. }
  863. else
  864. {
  865. ManaReso.SetText("La_Lab", Language.GetStr("UI", "La_Lab1"));
  866. ManaReso.SetActive("La_Mask", false);
  867. }
  868. }
  869. public void OnApplicationQuit()
  870. {
  871. if (Initializer.Complete && !Reset)
  872. {
  873. Data.SavePlayerConfig();
  874. Data.SaveXml();
  875. }
  876. }
  877. public void OnApplicationPause(bool pause)
  878. {
  879. if (pause)
  880. {
  881. Data.SavePlayerConfig();
  882. Data.SaveXml();
  883. }
  884. else
  885. {
  886. if (FirstFrame)
  887. {
  888. FirstFrame = false;
  889. }
  890. else
  891. {
  892. if (!Initializer.Complete)
  893. {
  894. return;
  895. }
  896. ManaVisit.DataRecover();
  897. if (ReactiveRequest)
  898. {
  899. return;
  900. }
  901. Auxiliary.DecryptXml(Data.PlayerDoc);
  902. ReactiveRequest = true;
  903. ManaServer.Login(LoginCallbackReactive);
  904. }
  905. }
  906. }
  907. }