ManaSign.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844
  1. using UnityEngine;
  2. using UnityEngine.UI;
  3. using System;
  4. using System.Xml;
  5. using System.Linq;
  6. using System.Collections;
  7. using System.Collections.Generic;
  8. using Random = UnityEngine.Random;
  9. public class Sign
  10. {
  11. #region 变量
  12. public int Coin
  13. {
  14. get
  15. {
  16. if (RoundBuff.Equal(-1))
  17. {
  18. return Coin_;
  19. }
  20. else
  21. {
  22. return (int)(Coin_*RoundBuff*ManaSign.SignRound);
  23. }
  24. }
  25. set { Coin_ = value; }
  26. }
  27. public int Diamond
  28. {
  29. get
  30. {
  31. if (RoundBuff.Equal(-1))
  32. {
  33. return Diamond_;
  34. }
  35. else
  36. {
  37. return (int)(Diamond_ * RoundBuff * ManaSign.SignRound);
  38. }
  39. }
  40. set { Diamond_ = value; }
  41. }
  42. public int Coin_;
  43. public int Diamond_;
  44. public float RoundBuff;
  45. public bool IsLottery;
  46. public Text Lab1;
  47. public Text Lab2;
  48. public Image Icon;
  49. public Image Mark;
  50. public Vector2 OriginSize;
  51. public List<int> FlowerList = new List<int>();
  52. #endregion
  53. public Sign(int index, Transform tra, XmlAttributeCollection attribute)
  54. {
  55. Dictionary<string, Transform> dic = new Dictionary<string, Transform>();
  56. Auxiliary.CompileDic(tra, dic);
  57. Lab1 = dic["Lab1"].GetComponent<Text>();
  58. Lab2 = dic["Lab2"].GetComponent<Text>();
  59. Icon = dic["Icon1"].GetComponent<Image>();
  60. Mark = dic["Icon2"].GetComponent<Image>();
  61. OriginSize = Icon.rectTransform.sizeDelta;
  62. Lab2.text = index.ToString();
  63. Coin = Auxiliary.IntParse(attribute[4].Value, 0);
  64. IsLottery = Auxiliary.BoolParse(attribute[1].Value, false);
  65. Diamond = Auxiliary.IntParse(attribute[3].Value, 0);
  66. FlowerList = Auxiliary.IntListParse(',', attribute[2].Value, new List<int>());
  67. RoundBuff = Auxiliary.FloatParse(attribute[5].Value, -1);
  68. SetUI();
  69. }
  70. public void Get()
  71. {
  72. if (IsLottery)
  73. {
  74. Lottery.EnterAnimation(true);
  75. return;
  76. }
  77. ManaAudio.PlayClip(Clip.CurrentClip);
  78. Mark.SetActive(true);
  79. ResetSign();
  80. ManaReso.SetActive("Bb_Get", false);
  81. ManaReso.SetActive("Bb_Rotate", true);
  82. ManaReso.SetActive("Bb_Confirm", true);
  83. if (FlowerList.Valid())
  84. {
  85. for (int i = 0; i < FlowerList.Count; i++)
  86. {
  87. FlowerInfo flowerInfo = ManaGarden.FlowerInfoDic[FlowerList[i]];
  88. if (flowerInfo.Unlock == false)
  89. {
  90. ManaReso.SetText("Bb_InfoLabA", flowerInfo.Name);
  91. ManaReso.SetActive("Bb_IconA", true);
  92. ManaReso.SetSprite("Bb_IconA0", flowerInfo.Icon);
  93. ManaReso.Get<Image>("Bb_IconA0").Resize(true, 0.65f, 0.65f);
  94. flowerInfo.Unlock = true;
  95. return;
  96. }
  97. }
  98. }
  99. if (Diamond > 0)
  100. {
  101. ManaReso.SetText("Bb_InfoLabB", Diamond.ToString());
  102. ManaReso.SetSprite("Bb_IconB", ManaReso.LoadSprite("钻石", Folder.UI));
  103. ManaReso.SetActive("Bb_IconB", true);
  104. ManaCenter.AddDiamond(Diamond, StaticsManager.ItemID.获得钻石, StaticsManager.ConsumeModule.Checkin);
  105. }
  106. else if (Coin > 0)
  107. {
  108. ManaReso.SetText("Bb_InfoLabB", Coin.ToString());
  109. ManaReso.SetSprite("Bb_IconB", ManaReso.LoadSprite("金币", Folder.UI));
  110. ManaReso.SetActive("Bb_IconB", true);
  111. ManaCenter.AddCoin(Coin, StaticsManager.ItemID.获得金币, StaticsManager.ConsumeModule.Checkin);
  112. }
  113. else
  114. {
  115. throw new Exception();
  116. }
  117. }
  118. public void SetUI()
  119. {
  120. if (IsLottery)
  121. {
  122. Icon.sprite = ManaReso.LoadSprite("礼包", Folder.Atlas);
  123. Icon.Resize(true, 0.3f, 0.3f);
  124. return;
  125. }
  126. if (FlowerList.Valid())
  127. {
  128. for (int i = 0; i < FlowerList.Count; i++)
  129. {
  130. FlowerInfo flowerInfo = ManaGarden.FlowerInfoDic[FlowerList[i]];
  131. if (flowerInfo.Unlock == false)
  132. {
  133. Icon.sprite = flowerInfo.Icon;
  134. Icon.Resize(true, 0.15f, 0.15f);
  135. return;
  136. }
  137. }
  138. }
  139. if (Diamond > 0)
  140. {
  141. Icon.sprite = ManaReso.LoadSprite("钻石", Folder.UI);
  142. Icon.Resize(false, OriginSize);
  143. Lab1.text = Diamond.ToString();
  144. }
  145. else if (Coin > 0)
  146. {
  147. Icon.sprite = ManaReso.LoadSprite("金币", Folder.UI);
  148. Icon.Resize(false, OriginSize);
  149. Lab1.text = Coin.ToString();
  150. }
  151. }
  152. public static void ResetSign()
  153. {
  154. ManaSign.SignTime = ManaServer.Time;
  155. ManaSign.SignIndex++;
  156. if (ManaSign.SignIndex == 22)
  157. {
  158. ManaSign.SignIndex = 1;
  159. ManaSign.SignRound++;
  160. ManaReso.Get("B_SignIn").GetTweenCG().AddEventOnetime
  161. (
  162. EventType.BackwardFinish,
  163. () =>
  164. {
  165. foreach (var kv in ManaSign.SignDic)
  166. {
  167. kv.Value.SetUI();
  168. kv.Value.Mark.SetActive(false);
  169. }
  170. }
  171. );
  172. }
  173. }
  174. }
  175. public class Lottery
  176. {
  177. #region Var
  178. public int PosIndex;
  179. public int Type;
  180. public int Value;
  181. public Text Lab;
  182. public Image Icon1;
  183. public Image Icon2;
  184. public Button Button;
  185. public Transform BK;
  186. public Transform Item;
  187. public static bool ResetSign = false;
  188. public static List<int> TempTypeList = new List<int>();
  189. public static List<int> TempValueList = new List<int>();
  190. public static List<Lottery> TempLotteryList = new List<Lottery>();
  191. public static List<int> TypeList = new List<int>();
  192. public static List<float> RateList = new List<float>();
  193. public static List<Vector3> PosList = new List<Vector3>();
  194. public static List<List<int>> LeftBorderDList = new List<List<int>>();
  195. public static List<List<int>> RightBorderDList = new List<List<int>>();
  196. #endregion
  197. public static void Configure(List<XmlAttributeCollection> attributeList)
  198. {
  199. PosList.Add(ManaReso.Get("Bc_LotteryItem1").position);
  200. PosList.Add(ManaReso.Get("Bc_LotteryItem2").position);
  201. PosList.Add(ManaReso.Get("Bc_LotteryItem3").position);
  202. for (int i = 0; i < attributeList.Count; i++)
  203. {
  204. RateList.Add((float) Auxiliary.FmlParse(attributeList[i][2].Value));
  205. TypeList.Add((int) Auxiliary.FmlParse(attributeList[i][1].Value));
  206. List<string> leftBorderStrList = Auxiliary.StringListParse(',', attributeList[i][3].Value, null);
  207. List<string> rightBorderStrList = Auxiliary.StringListParse(',', attributeList[i][4].Value, null);
  208. List<int> leftBorderList = new List<int>();
  209. List<int> rightBorderList = new List<int>();
  210. for (int j = 0; j < leftBorderStrList.Count; j++)
  211. {
  212. leftBorderList.Add((int)Auxiliary.FmlParse(leftBorderStrList[j], "l", (ManaCenter.Level+1).ToString()));
  213. rightBorderList.Add((int)Auxiliary.FmlParse(rightBorderStrList[j], "l", (ManaCenter.Level+1).ToString()));
  214. }
  215. LeftBorderDList.Add(leftBorderList);
  216. RightBorderDList.Add(rightBorderList);
  217. }
  218. }
  219. public static Lottery CreateLottery(int type, int posIndex, Transform lotteryItem)
  220. {
  221. Lottery lottery = new Lottery();
  222. lottery.Type = type;
  223. lottery.Value = Random.Range(LeftBorderDList[0][0], RightBorderDList[0][0] + 1);
  224. if (lottery.Type == 3)
  225. {
  226. #region
  227. bool allUnlock = true;
  228. for (int j = 0; j < LeftBorderDList[type - 1].Count; j++)
  229. {
  230. for (int k = LeftBorderDList[type - 1][j]; k < RightBorderDList[type - 1][j] + 1; k++)
  231. {
  232. if (!ManaGarden.FlowerInfoDic[k].Unlock && !TempValueList.Contains(k))
  233. {
  234. allUnlock = false;
  235. goto exit;
  236. }
  237. }
  238. }
  239. exit :
  240. if (allUnlock)
  241. {
  242. int index = Random.Range(0, LeftBorderDList[type - 1].Count);
  243. lottery.Value = Random.Range(LeftBorderDList[type - 1][index], RightBorderDList[type - 1][index] + 1);
  244. FlowerInfo flowerInfo = ManaGarden.FlowerInfoDic[lottery.Value];
  245. lottery.Value = flowerInfo.UnlockAmt/5;
  246. if (flowerInfo.UnlockCur == Current.Coin)
  247. {
  248. lottery.Type = 1;
  249. }
  250. else if (flowerInfo.UnlockCur == Current.Diamond)
  251. {
  252. lottery.Type = 2;
  253. }
  254. }
  255. else
  256. {
  257. int anticrush = 0;
  258. do
  259. {
  260. if (anticrush++ > 10000)
  261. {
  262. throw new Exception();
  263. }
  264. int index = Random.Range(0, LeftBorderDList[type - 1].Count);
  265. lottery.Value = Random.Range(LeftBorderDList[type - 1][index], RightBorderDList[type - 1][index] + 1);
  266. } while (ManaGarden.FlowerInfoDic[lottery.Value].Unlock || TempValueList.Contains(lottery.Value));
  267. TempValueList.Add(lottery.Value);
  268. }
  269. #endregion
  270. }
  271. else if (lottery.Type == 4)
  272. {
  273. #region
  274. bool allBought = true;
  275. for (int j = 0; j < LeftBorderDList[type - 1].Count; j++)
  276. {
  277. for (int k = LeftBorderDList[type - 1][j]; k < RightBorderDList[type - 1][j] + 1; k++)
  278. {
  279. if (!ManaPlayer.CloseUnitDic[k].Bought && !TempValueList.Contains(k))
  280. {
  281. allBought = false;
  282. goto exit;
  283. }
  284. }
  285. }
  286. exit :
  287. if (allBought)
  288. {
  289. int index = Random.Range(0, LeftBorderDList[type - 1].Count);
  290. lottery.Value = Random.Range(LeftBorderDList[type - 1][index], RightBorderDList[type - 1][index] + 1);
  291. CloseUnit closeUnit = ManaPlayer.CloseUnitDic[lottery.Value];
  292. lottery.Value = (int) closeUnit.BuyAmt/5;
  293. if (closeUnit.BuyCurrent == Current.Coin)
  294. {
  295. lottery.Type = 1;
  296. }
  297. else if (closeUnit.BuyCurrent == Current.Diamond)
  298. {
  299. lottery.Type = 2;
  300. }
  301. }
  302. else
  303. {
  304. int anticrush = 0;
  305. do
  306. {
  307. if (anticrush++ > 10000)
  308. {
  309. throw new Exception();
  310. }
  311. int index = Random.Range(0, LeftBorderDList[type - 1].Count);
  312. lottery.Value = Random.Range(LeftBorderDList[type - 1][index], RightBorderDList[type - 1][index] + 1);
  313. } while (ManaPlayer.CloseUnitDic[lottery.Value].Bought || TempValueList.Contains(lottery.Value));
  314. TempValueList.Add(lottery.Value);
  315. }
  316. #endregion
  317. }
  318. else
  319. {
  320. int index = Random.Range(0, LeftBorderDList[type - 1].Count);
  321. lottery.Value = Random.Range(LeftBorderDList[type - 1][index], RightBorderDList[type - 1][index] + 1);
  322. }
  323. lottery.PosIndex = posIndex;
  324. lottery.Item = lotteryItem;
  325. lottery.BK = lotteryItem.GetChild(0);
  326. lottery.Icon1 = lotteryItem.GetChild(1).GetChild(0).GetComponent<Image>();
  327. lottery.Icon2 = lotteryItem.GetChild(1).GetChild(1).GetComponent<Image>();
  328. lottery.Lab = lotteryItem.GetChild(1).GetChild(2).GetComponent<Text>();
  329. lottery.Button = lotteryItem.GetChild(1).GetChild(3).GetComponent<Button>();
  330. lottery.BK.SetActive(false);
  331. if (lottery.Type == 1)
  332. {
  333. lottery.Icon1.SetActive(false);
  334. lottery.Icon2.sprite = ManaReso.LoadSprite("金币", Folder.UI);
  335. lottery.Icon2.Resize(true, 1, 1);
  336. lottery.Icon2.transform.localPosition = new Vector3(0, 7.5f, 0);
  337. lottery.Lab.SetActive(true);
  338. lottery.Lab.text = lottery.Value.ToString();
  339. }
  340. else if (lottery.Type == 2)
  341. {
  342. lottery.Icon1.SetActive(false);
  343. lottery.Icon2.sprite = ManaReso.LoadSprite("钻石", Folder.UI);
  344. lottery.Icon2.Resize(true, 1, 1);
  345. lottery.Icon2.transform.localPosition = new Vector3(0, 7.5f, 0);
  346. lottery.Lab.SetActive(true);
  347. lottery.Lab.text = lottery.Value.ToString();
  348. }
  349. else if (lottery.Type == 3)
  350. {
  351. lottery.Icon1.SetActive(false);
  352. lottery.Icon2.sprite = ManaGarden.FlowerInfoDic[lottery.Value].Icon;
  353. lottery.Icon2.Resize(true, 0.25f, 0.25f);
  354. lottery.Icon2.transform.localPosition = new Vector3();
  355. lottery.Lab.SetActive(false);
  356. }
  357. else if (lottery.Type == 4)
  358. {
  359. CloseUnit closeUnit = ManaPlayer.CloseUnitDic[lottery.Value];
  360. float newSize = closeUnit.PixelSize/closeUnit.Sprites[0].rect.width;
  361. lottery.Icon2.sprite = closeUnit.Sprites[0];
  362. lottery.Icon2.Resize(true, newSize, newSize);
  363. lottery.Icon2.transform.localPosition = new Vector2(0, closeUnit.IconOffset);
  364. lottery.Lab.SetActive(false);
  365. if (closeUnit.Sprites.Length > 1)
  366. {
  367. lottery.Icon1.SetActive(true);
  368. lottery.Icon1.sprite = closeUnit.Sprites[1];
  369. lottery.Icon1.Resize(true, newSize, newSize);
  370. lottery.Icon1.transform.localPosition = new Vector2(0, closeUnit.IconOffset) + closeUnit.IconOffset1*newSize;
  371. }
  372. else
  373. {
  374. lottery.Icon1.SetActive(false);
  375. }
  376. }
  377. lottery.Button.onClick = new Button.ButtonClickedEvent();
  378. lottery.Button.onClick.AddListener(() => { OnClick(posIndex); });
  379. return lottery;
  380. }
  381. public static void EnterAnimation(bool resetSign)
  382. {
  383. ResetSign = resetSign;
  384. ManaReso.Get("Bc_Lottery").TweenForCG();
  385. ManaReso.Get("Ba_Notice0").TweenBacCG();
  386. float random = Random.Range(0f, 1f);
  387. for (int i = 0; i < RateList.Count; i++)
  388. {
  389. if (random <= RateList.MySum(f => f, i + 1))
  390. {
  391. TempTypeList.Add(TypeList[i]);
  392. TempTypeList.AddRange(TypeList.Random(2, true, false, type => !TempTypeList.Contains(type)));
  393. break;
  394. }
  395. }
  396. TempLotteryList.Add(CreateLottery(TempTypeList[0], 0, ManaReso.Get("Bc_LotteryItem1")));
  397. TempLotteryList.Add(CreateLottery(TempTypeList[1], 1, ManaReso.Get("Bc_LotteryItem2")));
  398. TempLotteryList.Add(CreateLottery(TempTypeList[2], 2, ManaReso.Get("Bc_LotteryItem3")));
  399. List<Vector3> posList = PosList.Disturb();
  400. TempLotteryList[0].Item.position = posList[0];
  401. TempLotteryList[1].Item.position = posList[1];
  402. TempLotteryList[2].Item.position = posList[2];
  403. Button button1 = ManaReso.Get<Button>("Bc_LotteryBack1");
  404. Button button2 = ManaReso.Get<Button>("Bc_LotteryBack2");
  405. Button button3 = ManaReso.Get<Button>("Bc_LotteryBack3");
  406. button1.interactable = false;
  407. button2.interactable = false;
  408. button3.interactable = false;
  409. Auxiliary.Instance.DelayCall
  410. (
  411. () =>
  412. {
  413. ManaReso.Get("Bc_LotteryItem1").Move2D(PosList[1], 0.25f, false, Curve.EaseOutQuad);
  414. ManaReso.Get("Bc_LotteryItem2").Move2D(PosList[1], 0.25f, false, Curve.EaseOutQuad);
  415. ManaReso.Get("Bc_LotteryItem3").Move2D(PosList[1], 0.25f, false, Curve.EaseOutQuad);
  416. },
  417. 1f
  418. );
  419. Auxiliary.Instance.DelayCall
  420. (
  421. () =>
  422. {
  423. ManaReso.Get("Bc_LotteryItem1").TweenForEuler();
  424. ManaReso.Get("Bc_LotteryItem2").TweenForEuler();
  425. ManaReso.Get("Bc_LotteryItem3").TweenForEuler();
  426. },
  427. 1.5f
  428. );
  429. Auxiliary.Instance.DelayCall
  430. (
  431. () =>
  432. {
  433. button1.interactable = true;
  434. button2.interactable = true;
  435. button3.interactable = true;
  436. ManaReso.Get("Bc_LotteryItem1").Move2D(PosList[0], 0.25f, false, Curve.EaseOutQuad);
  437. ManaReso.Get("Bc_LotteryItem2").Move2D(PosList[1], 0.25f, false, Curve.EaseOutQuad);
  438. ManaReso.Get("Bc_LotteryItem3").Move2D(PosList[2], 0.25f, false, Curve.EaseOutQuad);
  439. },
  440. 2f
  441. );
  442. Auxiliary.Instance.DelayCall
  443. (
  444. () =>
  445. {
  446. ManaReso.Get("Bc_Lab").TweenForCG();
  447. ManaReso.SetText("Bc_Lab", Language.GetStr("UI", "Bc_Lab"));
  448. },
  449. 2.5f
  450. );
  451. }
  452. public static void EndAnimation()
  453. {
  454. TempTypeList = new List<int>();
  455. TempValueList = new List<int>();
  456. TempLotteryList = new List<Lottery>();
  457. ManaReso.Get("Bc_Lab").TweenBacCG();
  458. ManaReso.Get("Bc_Confirm").TweenBacCG();
  459. ManaReso.Get("Ba_Notice0").TweenForCG();
  460. ManaReso.Get("B_SignIn").TweenBacCG();
  461. ManaReso.Get("Ba_Notice").TweenBacCG();
  462. ManaReso.Get("Bb_SignIn").TweenBacCG();
  463. ManaReso.Get("Bc_Lottery").TweenBacCG();
  464. ManaAudio.PlayClip(Clip.BtnClip);
  465. }
  466. public static void OnClick(int index)
  467. {
  468. ManaAudio.PlayClip(Clip.CurrentClip);
  469. ManaReso.Get<Button>("Bc_LotteryBack1").interactable = false;
  470. ManaReso.Get<Button>("Bc_LotteryBack2").interactable = false;
  471. ManaReso.Get<Button>("Bc_LotteryBack3").interactable = false;
  472. TempLotteryList[0].Item.TweenBacEuler();
  473. TempLotteryList[0].BK.SetActive(true);
  474. TempLotteryList[0].GetAward();
  475. List<Vector3> posList = new List<Vector3>(PosList);
  476. posList.Remove(PosList[index]);
  477. posList = posList.Disturb();
  478. TempLotteryList[0].Item.position = PosList[index];
  479. TempLotteryList[1].Item.position = posList[0];
  480. TempLotteryList[2].Item.position = posList[1];
  481. Auxiliary.Instance.DelayCall
  482. (
  483. () =>
  484. {
  485. ManaReso.Get("Bc_Confirm").TweenForCG();
  486. ManaReso.Get("Bc_LotteryItem1").TweenBacEuler();
  487. ManaReso.Get("Bc_LotteryItem2").TweenBacEuler();
  488. ManaReso.Get("Bc_LotteryItem3").TweenBacEuler();
  489. },
  490. 1f
  491. );
  492. }
  493. public void GetAward()
  494. {
  495. if (ResetSign)
  496. {
  497. Sign.ResetSign();
  498. }
  499. BK.SetActive(true);
  500. if (Type == 1)
  501. {
  502. ManaCenter.AddCoin(Value, StaticsManager.ItemID.获得金币, StaticsManager.ConsumeModule.Checkin);
  503. ManaReso.SetText("Bc_Lab", Language.GetStr("UI", "Bc_Lab1") + Language.GetStr("Common", "Coin") + " " + Value);
  504. }
  505. else if (Type == 2)
  506. {
  507. ManaCenter.AddDiamond(Value, StaticsManager.ItemID.获得钻石, StaticsManager.ConsumeModule.Checkin);
  508. ManaReso.SetText("Bc_Lab", Language.GetStr("UI", "Bc_Lab1") + Language.GetStr("Common", "Diamond") + " " + Value);
  509. }
  510. else if (Type == 3)
  511. {
  512. ManaGarden.FlowerInfoDic[Value].Unlock = true;
  513. ManaReso.SetText("Bc_Lab", Language.GetStr("UI", "Bc_Lab1") + " " + ManaGarden.FlowerInfoDic[Value].Name);
  514. }
  515. else if (Type == 4)
  516. {
  517. ManaPlayer.CloseUnitDic[Value].Unlock();
  518. ManaPlayer.BoughtCloseList.UniqueAdd(Value);
  519. ManaReso.SetText("Bc_Lab", Language.GetStr("UI", "Bc_Lab1") + " " + ManaPlayer.CloseUnitDic[Value].Name);
  520. }
  521. }
  522. }
  523. public class ManaSign : Regist
  524. {
  525. #region 变量
  526. public static int SignIndex;
  527. public static int SignRound;
  528. public static DateTime SignTime;
  529. public static Dictionary<int, Sign> SignDic = new Dictionary<int, Sign>();
  530. #endregion
  531. public static bool ShowOfflineReward()
  532. {
  533. if (ManaTutorial.TutorialA)
  534. {
  535. return false;
  536. }
  537. if (ShowOfflineIncomReward())
  538. {
  539. return true;
  540. }
  541. if (ShowMailReward())
  542. {
  543. return true;
  544. }
  545. if (ShowSignReward())
  546. {
  547. return true;
  548. }
  549. if (ShowNotification())
  550. {
  551. return true;
  552. }
  553. return false;
  554. }
  555. public static bool ShowOfflineIncomReward()
  556. {
  557. if (ManaCenter.OfflineLock)
  558. {
  559. ManaReso.Get("C_Group").TweenBacCG();
  560. ManaReso.Get("B_SignIn").TweenForCG();
  561. ManaReso.Get("Ba_Notice").TweenForCG();
  562. return true;
  563. }
  564. return false;
  565. }
  566. public static bool ShowMailReward()
  567. {
  568. ManaServer.DecodeMailXml(ManaServer.MailXml);
  569. if (ManaServer.MailRewardList.Count > 0)
  570. {
  571. ManaServer.GetMailReward();
  572. ManaReso.Get("C_Group").TweenBacCG();
  573. ManaReso.Get("B_SignIn").TweenForCG();
  574. ManaReso.Get("Bd_Mail0").TweenForCG();
  575. return true;
  576. }
  577. return false;
  578. }
  579. public static bool ShowSignReward()
  580. {
  581. if (ManaData.GetPlayerBool("QuitFlag") && ManaServer.Connect)
  582. {
  583. int daySpan = ManaServer.Time.Day - ManaSign.SignTime.Day;
  584. int yearSpan = ManaServer.Time.Year - ManaSign.SignTime.Year;
  585. int monthSpan = ManaServer.Time.Month - ManaSign.SignTime.Month;
  586. if (daySpan >= 1 || yearSpan >= 1 || monthSpan >= 1)
  587. {
  588. ManaReso.Get("B_SignIn").TweenForCG();
  589. ManaReso.Get("Bb_SignIn").TweenForCG();
  590. return true;
  591. }
  592. }
  593. return false;
  594. }
  595. public static bool ShowNotification()
  596. {
  597. //Debug.Log(ManaServer.NotificationIndex + " " + ManaData.GetPlayerInt("NotificationIndex"));
  598. if (ManaServer.NotificationIndex > ManaData.GetPlayerInt("NotificationIndex") && ManaServer.NotificationReady)
  599. {
  600. ManaData.SavePlayerInt("NotificationIndex", ManaServer.NotificationIndex);
  601. ManaNotify.Show();
  602. return true;
  603. }
  604. else
  605. {
  606. //Debug.Log("Don't Show");
  607. return false;
  608. }
  609. }
  610. public static void GetSignReward()
  611. {
  612. SignDic[SignIndex].Get();
  613. ManaCenter.SignAmt++;
  614. }
  615. public override void RegistValueB()
  616. {
  617. SignTime = DateTime.Parse(ManaData.GetPlayerString("SignTime"));
  618. SignIndex = ManaData.GetPlayerInt("SignIndex");
  619. SignRound = ManaData.GetPlayerInt("SignRound");
  620. Transform par = ManaReso.Get("Bb_Grid");
  621. List<XmlAttributeCollection> attributeList = ManaData.GetSignConfig();
  622. for (int i = 0; i < attributeList.Count; i++)
  623. {
  624. Transform tra = ManaReso.Get("SignItem", Folder.UI, false, par, false, ObjType.SignItem);
  625. SignDic.Add(i + 1, new Sign(i + 1, tra, attributeList[i]));
  626. }
  627. for (int i = 1; i < SignIndex; i++)
  628. {
  629. SignDic[i].Mark.SetActive(true);
  630. }
  631. Lottery.Configure(ManaData.GetLotteryConfig());
  632. }
  633. }
  634. #region DebugList
  635. //签到的循环与存档
  636. #endregion