ManaSign.cs 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. using UnityEngine;
  2. using UnityEngine.UI;
  3. using System;
  4. using System.Xml;
  5. using System.Collections;
  6. using System.Collections.Generic;
  7. public class Sign
  8. {
  9. #region 变量
  10. public int Coin
  11. {
  12. get
  13. {
  14. if (RoundBuff.Equal(-1))
  15. {
  16. return Coin_;
  17. }
  18. else
  19. {
  20. return (int)(Coin_*RoundBuff*ManaSign.SignRound);
  21. }
  22. }
  23. set { Coin_ = value; }
  24. }
  25. public int Diamond
  26. {
  27. get
  28. {
  29. if (RoundBuff.Equal(-1))
  30. {
  31. return Diamond_;
  32. }
  33. else
  34. {
  35. return (int)(Diamond_ * RoundBuff * ManaSign.SignRound);
  36. }
  37. }
  38. set { Diamond_ = value; }
  39. }
  40. public int Coin_;
  41. public int Diamond_;
  42. public float RoundBuff;
  43. public Text Lab1;
  44. public Text Lab2;
  45. public Image Icon;
  46. public Image Mark;
  47. public Vector2 OriginSize;
  48. public List<int> FlowerList = new List<int>();
  49. #endregion
  50. public Sign(int index, Transform tra, XmlAttributeCollection attribute)
  51. {
  52. Dictionary<string, Transform> dic = new Dictionary<string, Transform>();
  53. Auxiliary.CompileDic(tra, dic);
  54. Lab1 = dic["Lab1"].GetComponent<Text>();
  55. Lab2 = dic["Lab2"].GetComponent<Text>();
  56. Icon = dic["Icon1"].GetComponent<Image>();
  57. Mark = dic["Icon2"].GetComponent<Image>();
  58. OriginSize = Icon.rectTransform.sizeDelta;
  59. Lab2.text = index.ToString();
  60. Coin = Auxiliary.IntParse(attribute[3].Value, 0);
  61. Diamond = Auxiliary.IntParse(attribute[2].Value, 0);
  62. FlowerList = Auxiliary.IntListParse(',', attribute[1].Value, new List<int>());
  63. RoundBuff = Auxiliary.FloatParse(attribute[4].Value, -1);
  64. SetUI();
  65. }
  66. public void Get()
  67. {
  68. Mark.SetActive(true);
  69. ManaSign.SignTime = ManaServer.Time;
  70. ManaSign.SignIndex++;
  71. if (ManaSign.SignIndex == 22)
  72. {
  73. ManaSign.SignIndex = 1;
  74. ManaSign.SignRound++;
  75. ManaReso.Get("B_SignIn").GetTweenCG().AddEventOnetime
  76. (
  77. EventType.BackwardFinish,
  78. () =>
  79. {
  80. foreach (var kv in ManaSign.SignDic)
  81. {
  82. kv.Value.SetUI();
  83. kv.Value.Mark.SetActive(false);
  84. }
  85. }
  86. );
  87. }
  88. if (FlowerList.Valid())
  89. {
  90. for (int i = 0; i < FlowerList.Count; i++)
  91. {
  92. FlowerInfo flowerInfo = ManaGarden.FlowerInfoDic[FlowerList[i]];
  93. if (flowerInfo.Unlock == false)
  94. {
  95. ManaReso.SetText("Bb_InfoLabA", flowerInfo.Name);
  96. ManaReso.SetActive("Bb_IconA", true);
  97. ManaReso.SetSprite("Bb_IconA0", flowerInfo.Icon);
  98. ManaReso.Get<Image>("Bb_IconA0").Resize(true, 0.65f, 0.65f);
  99. flowerInfo.Unlock = true;
  100. return;
  101. }
  102. }
  103. }
  104. if (Diamond > 0)
  105. {
  106. ManaReso.SetText("Bb_InfoLabB", Diamond.ToString());
  107. ManaReso.SetSprite("Bb_IconB", ManaReso.LoadSprite("钻石", Folder.UI));
  108. ManaReso.SetActive("Bb_IconB", true);
  109. ManaCenter.Diamond += Diamond;
  110. }
  111. else if (Coin > 0)
  112. {
  113. ManaReso.SetText("Bb_InfoLabB", Coin.ToString());
  114. ManaReso.SetSprite("Bb_IconB", ManaReso.LoadSprite("金币", Folder.UI));
  115. ManaReso.SetActive("Bb_IconB", true);
  116. ManaCenter.Coin += Coin;
  117. }
  118. else
  119. {
  120. throw new Exception();
  121. }
  122. }
  123. public void SetUI()
  124. {
  125. if (FlowerList.Valid())
  126. {
  127. for (int i = 0; i < FlowerList.Count; i++)
  128. {
  129. FlowerInfo flowerInfo = ManaGarden.FlowerInfoDic[FlowerList[i]];
  130. if (flowerInfo.Unlock == false)
  131. {
  132. Icon.sprite = flowerInfo.Icon;
  133. Icon.Resize(true, 0.2f, 0.2f);
  134. return;
  135. }
  136. }
  137. }
  138. if (Diamond > 0)
  139. {
  140. Icon.sprite = ManaReso.LoadSprite("钻石", Folder.UI);
  141. Icon.Resize(false, OriginSize);
  142. Lab1.text = Diamond.ToString();
  143. }
  144. else if (Coin > 0)
  145. {
  146. Icon.sprite = ManaReso.LoadSprite("金币", Folder.UI);
  147. Icon.Resize(false, OriginSize);
  148. Lab1.text = Coin.ToString();
  149. }
  150. }
  151. }
  152. public class ManaSign : Regist
  153. {
  154. #region 变量
  155. public static int SignIndex;
  156. public static int SignRound;
  157. public static DateTime SignTime;
  158. public static Dictionary<int, Sign> SignDic = new Dictionary<int, Sign>();
  159. #endregion
  160. public static void Get()
  161. {
  162. SignDic[SignIndex].Get();
  163. ManaCenter.SignAmt++;
  164. }
  165. public override void RegistValueB()
  166. {
  167. SignTime = DateTime.Parse(ManaData.GetPlayerString("SignTime"));
  168. SignIndex = ManaData.GetPlayerInt("SignIndex");
  169. SignRound = ManaData.GetPlayerInt("SignRound");
  170. Transform par = ManaReso.Get("Bb_Grid");
  171. List<XmlAttributeCollection> attributeList = ManaData.GetSignConfig();
  172. for (int i = 0; i < attributeList.Count; i++)
  173. {
  174. Transform tra = ManaReso.Get("SignItem", Folder.UI, false, par, false, ObjType.SignItem);
  175. SignDic.Add(i + 1, new Sign(i + 1, tra, attributeList[i]));
  176. }
  177. for (int i = 1; i < SignIndex; i++)
  178. {
  179. SignDic[i].Mark.SetActive(true);
  180. }
  181. }
  182. }
  183. #region DebugList
  184. //签到的循环与存档
  185. #endregion