SignManager.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815
  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 SignItemLabel
  10. {
  11. public static string Amount = "Amount";
  12. public static string Index = "Index";
  13. public static string Award = "Award";
  14. public static string Tick = "Tick";
  15. }
  16. public class SignItem
  17. {
  18. #region Config
  19. public int Coin
  20. {
  21. get
  22. {
  23. if (RoundBuff.Equal(-1))
  24. {
  25. return coin;
  26. }
  27. else
  28. {
  29. return (int)(coin*RoundBuff*SignManager.SignRound);
  30. }
  31. }
  32. set { coin = value; }
  33. }
  34. public int coin;
  35. public int Diamond
  36. {
  37. get
  38. {
  39. if (RoundBuff.Equal(-1))
  40. {
  41. return diamond;
  42. }
  43. else
  44. {
  45. return (int)(diamond * RoundBuff * SignManager.SignRound);
  46. }
  47. }
  48. set { diamond = value; }
  49. }
  50. public int diamond;
  51. public float RoundBuff; //第几轮 每签21次加一轮
  52. public bool LotteryAwardFlag;
  53. public Text AmountText;
  54. public Text IndexText;
  55. public Image Award;
  56. public Image Tick;
  57. public Vector2 OriginSpriteSize;
  58. public List<int> AwardFlowerIDs = new List<int>();
  59. public static int MaxSignIndex = 22;
  60. #endregion
  61. public SignItem(int index, Transform tra, XmlAttributeCollection attribute)
  62. {
  63. Dictionary<string, Transform> dic = new Dictionary<string, Transform>();
  64. Auxiliary.CompileDic(tra, dic);
  65. AmountText = dic[SignItemLabel.Amount].GetComponent<Text>();
  66. IndexText = dic[SignItemLabel.Index].GetComponent<Text>();
  67. Award = dic[SignItemLabel.Award].GetComponent<Image>();
  68. Tick = dic[SignItemLabel.Tick].GetComponent<Image>();
  69. OriginSpriteSize = Award.rectTransform.sizeDelta;
  70. IndexText.text = index.ToString();
  71. Coin = Auxiliary.StringToInt(attribute[4].Value, 0);
  72. LotteryAwardFlag = Auxiliary.StringToBool(attribute[1].Value, false);
  73. Diamond = Auxiliary.StringToInt(attribute[3].Value, 0);
  74. AwardFlowerIDs = Auxiliary.StringToInts(',', attribute[2].Value, new List<int>());
  75. RoundBuff = Auxiliary.StringToFloat(attribute[5].Value, -1);
  76. SetupUI();
  77. }
  78. public void Get()
  79. {
  80. if (LotteryAwardFlag)
  81. {
  82. Lottery.PlayAnimation(true);
  83. return;
  84. }
  85. AudioManager.PlayClip(AudioLabel.GetCurrent);
  86. Tick.SetActive(true);
  87. ResetSignRound();
  88. ResourceManager.SetActive(CanvasLabel.Bb_Get, false);
  89. ResourceManager.SetActive(CanvasLabel.Bb_Rotate, true);
  90. ResourceManager.SetActive(CanvasLabel.Bb_Confirm, true);
  91. if (AwardFlowerIDs.Valid())
  92. {
  93. for (int i = 0; i < AwardFlowerIDs.Count; i++)
  94. {
  95. FlowerInfo flowerInfo = GardenManager.FlowerInfoDictionary[AwardFlowerIDs[i]];
  96. if (flowerInfo.Unlock == false)
  97. {
  98. ResourceManager.SetText(CanvasLabel.Bb_InfoLabA, flowerInfo.Name);
  99. ResourceManager.SetActive(CanvasLabel.Bb_IconA, true);
  100. ResourceManager.SetSprite(CanvasLabel.Bb_IconA0, flowerInfo.Icon);
  101. ResourceManager.Get<Image>(CanvasLabel.Bb_IconA0).Resize(true, 0.8125f, 0.8125f);
  102. flowerInfo.Add();
  103. return;
  104. }
  105. }
  106. }
  107. if (Diamond > 0)
  108. {
  109. ResourceManager.SetText(CanvasLabel.Bb_InfoLabB, Diamond.ToString());
  110. ResourceManager.SetSprite(CanvasLabel.Bb_IconB, Lib.DiamondSprite);
  111. ResourceManager.SetActive(CanvasLabel.Bb_IconB, true);
  112. Manager.AddDiamond(Diamond, StaticsManager.ItemID.获得钻石, StaticsManager.ConsumeModule.Checkin);
  113. }
  114. else if (Coin > 0)
  115. {
  116. ResourceManager.SetText(CanvasLabel.Bb_InfoLabB, Coin.ToString());
  117. ResourceManager.SetSprite(CanvasLabel.Bb_IconB, Lib.GoldSprite);
  118. ResourceManager.SetActive(CanvasLabel.Bb_IconB, true);
  119. Manager.AddCoin(Coin, StaticsManager.ItemID.获得金币, StaticsManager.ConsumeModule.Checkin);
  120. }
  121. else
  122. {
  123. throw new Exception();
  124. }
  125. }
  126. public void SetupUI()
  127. {
  128. if (LotteryAwardFlag)
  129. {
  130. Award.sprite = Lib.PackSprite;
  131. Award.Resize(true, 0.3f, 0.3f);
  132. return;
  133. }
  134. if (AwardFlowerIDs.Valid())
  135. {
  136. for (int i = 0; i < AwardFlowerIDs.Count; i++)
  137. {
  138. FlowerInfo flowerInfo = GardenManager.FlowerInfoDictionary[AwardFlowerIDs[i]];
  139. if (flowerInfo.Unlock == false)
  140. {
  141. Award.sprite = flowerInfo.Icon;
  142. Award.Resize(true, 0.1875f, 0.1875f);
  143. return;
  144. }
  145. }
  146. }
  147. if (Diamond > 0)
  148. {
  149. Award.sprite = Lib.DiamondSprite;
  150. Award.Resize(false, OriginSpriteSize);
  151. AmountText.text = Diamond.ToString();
  152. }
  153. else if (Coin > 0)
  154. {
  155. Award.sprite = Lib.GoldSprite;
  156. Award.Resize(false, OriginSpriteSize);
  157. AmountText.text = Coin.ToString();
  158. }
  159. }
  160. public static void ResetSignRound()
  161. {
  162. SignManager.LastSignTime = HttpManager.CurrentDateTime;
  163. SignManager.SignIndex++;
  164. if (SignManager.SignIndex == MaxSignIndex)
  165. {
  166. SignManager.SignIndex = 1;
  167. SignManager.SignRound++;
  168. ResourceManager.Get(CanvasLabel.B_SignIn).GetTweenCG().AddEventOnetime
  169. (
  170. EventType.BackwardFinish,
  171. () =>
  172. {
  173. foreach (var kv in SignManager.SignItemDictionary)
  174. {
  175. kv.Value.SetupUI();
  176. kv.Value.Tick.SetActive(false);
  177. }
  178. }
  179. );
  180. }
  181. }
  182. }
  183. public class Lottery
  184. {
  185. private enum LotteryType
  186. {
  187. Coin=1,
  188. Diamond=2,
  189. Flower=3,
  190. Close=4,
  191. }
  192. #region Config
  193. public int Index;
  194. public int Type;
  195. public int Value;
  196. public Text DescriptionText;
  197. public Image Icon1;
  198. public Image Icon2;
  199. public Image Icon3;
  200. public Button Button;
  201. public Transform BK;
  202. public Transform Item;
  203. public static List<int> TempTypeList = new List<int>();
  204. public static List<int> TempValueList = new List<int>();
  205. public static List<Lottery> TempLotteryList = new List<Lottery>();
  206. public static List<int> TypeList = new List<int>();
  207. public static List<float> RateList = new List<float>();
  208. public static List<List<int>> LeftBorderIDList = new List<List<int>>();
  209. public static List<List<int>> RightBorderIDList = new List<List<int>>();
  210. public static List<Vector3> PosList = new List<Vector3>();
  211. public static bool ResetSignRound = false;
  212. #endregion
  213. public static void Init(List<XmlAttributeCollection> attributeList)
  214. {
  215. PosList.Add(ResourceManager.Get(CanvasLabel.Bc_LotteryItem1).position);
  216. PosList.Add(ResourceManager.Get(CanvasLabel.Bc_LotteryItem2).position);
  217. PosList.Add(ResourceManager.Get(CanvasLabel.Bc_LotteryItem3).position);
  218. for (int i = 0; i < attributeList.Count; i++)
  219. {
  220. RateList.Add((float) Auxiliary.FmlParse(attributeList[i][2].Value));
  221. TypeList.Add((int) Auxiliary.FmlParse(attributeList[i][1].Value));
  222. List<string> leftBorderStrList = Auxiliary.StringToStrings(',', attributeList[i][3].Value, null);
  223. List<string> rightBorderStrList = Auxiliary.StringToStrings(',', attributeList[i][4].Value, null);
  224. List<int> leftBorderList = new List<int>();
  225. List<int> rightBorderList = new List<int>();
  226. for (int j = 0; j < leftBorderStrList.Count; j++)
  227. {
  228. leftBorderList.Add((int)Auxiliary.FmlParse(leftBorderStrList[j], "l", (Manager.GardenLevel+1).ToString()));
  229. rightBorderList.Add((int)Auxiliary.FmlParse(rightBorderStrList[j], "l", (Manager.GardenLevel+1).ToString()));
  230. }
  231. LeftBorderIDList.Add(leftBorderList);
  232. RightBorderIDList.Add(rightBorderList);
  233. }
  234. }
  235. public static Lottery CreateLottery(int type, int posIndex, Transform lotteryItem)
  236. {
  237. Lottery lottery = new Lottery();
  238. lottery.Type = type;
  239. lottery.Value = Random.Range(LeftBorderIDList[0][0], RightBorderIDList[0][0] + 1);
  240. if (lottery.Type == LotteryType.Flower.GetHashCode())
  241. {
  242. #region
  243. List<int> flowerIDs = new List<int>();
  244. for (int j = 0; j < LeftBorderIDList[type - 1].Count; j++)
  245. {
  246. for (int k = LeftBorderIDList[type - 1][j]; k < RightBorderIDList[type - 1][j] + 1; k++)
  247. {
  248. if (!TempValueList.Contains(k))
  249. {
  250. flowerIDs.Add(k);
  251. }
  252. }
  253. }
  254. lottery.Value = MinigameAward.SelectUnlockFlowerID(flowerIDs);
  255. TempValueList.Add(lottery.Value);
  256. #endregion
  257. }
  258. else if (lottery.Type == LotteryType.Close.GetHashCode())
  259. {
  260. #region
  261. bool allBought = true;
  262. for (int j = 0; j < LeftBorderIDList[type - 1].Count; j++)
  263. {
  264. for (int k = LeftBorderIDList[type - 1][j]; k < RightBorderIDList[type - 1][j] + 1; k++)
  265. {
  266. if (!PlayerManager.CloseItemDictionary[k].IsBought && !TempValueList.Contains(k))
  267. {
  268. allBought = false;
  269. goto exit;
  270. }
  271. }
  272. }
  273. exit :
  274. if (allBought)
  275. {
  276. int index = Random.Range(0, LeftBorderIDList[type - 1].Count);
  277. lottery.Value = Random.Range(LeftBorderIDList[type - 1][index], RightBorderIDList[type - 1][index] + 1);
  278. CloseItem closeItem = PlayerManager.CloseItemDictionary[lottery.Value];
  279. lottery.Value = (int) closeItem.BuyCost/5;
  280. if (closeItem.BuyCurrent == Current.Coin)
  281. {
  282. lottery.Type = LotteryType.Coin.GetHashCode();
  283. }
  284. else if (closeItem.BuyCurrent == Current.Diamond)
  285. {
  286. lottery.Type = LotteryType.Diamond.GetHashCode();
  287. }
  288. }
  289. else
  290. {
  291. int anticrush = 0;
  292. do
  293. {
  294. if (anticrush++ > 10000)
  295. {
  296. throw new Exception();
  297. }
  298. int index = Random.Range(0, LeftBorderIDList[type - 1].Count);
  299. lottery.Value = Random.Range(LeftBorderIDList[type - 1][index], RightBorderIDList[type - 1][index] + 1);
  300. } while (PlayerManager.CloseItemDictionary[lottery.Value].IsBought || TempValueList.Contains(lottery.Value));
  301. TempValueList.Add(lottery.Value);
  302. }
  303. #endregion
  304. }
  305. else
  306. {
  307. int index = Random.Range(0, LeftBorderIDList[type - 1].Count);
  308. lottery.Value = Random.Range(LeftBorderIDList[type - 1][index], RightBorderIDList[type - 1][index] + 1);
  309. }
  310. lottery.Index = posIndex;
  311. lottery.Item = lotteryItem;
  312. lottery.BK = lotteryItem.GetChild(0);
  313. lottery.Icon1 = lotteryItem.GetChild(1).GetChild(0).GetComponent<Image>();
  314. lottery.Icon2 = lotteryItem.GetChild(1).GetChild(1).GetComponent<Image>();
  315. lottery.Icon3 = lotteryItem.GetChild(1).GetChild(2).GetComponent<Image>();
  316. lottery.DescriptionText = lotteryItem.GetChild(1).GetChild(3).GetComponent<Text>();
  317. lottery.Button = lotteryItem.GetChild(1).GetChild(4).GetComponent<Button>();
  318. lottery.BK.SetActive(false);
  319. if (lottery.Type == LotteryType.Coin.GetHashCode())
  320. {
  321. lottery.Icon1.SetActive(false);
  322. lottery.Icon2.SetActive(true);
  323. lottery.Icon3.SetActive(false);
  324. lottery.Icon2.sprite = Lib.GoldSprite;
  325. lottery.Icon2.Resize(true, 1, 1);
  326. lottery.Icon2.transform.localPosition = new Vector3(0, 7.5f, 0);
  327. lottery.DescriptionText.SetActive(true);
  328. lottery.DescriptionText.text = lottery.Value.ToString();
  329. }
  330. else if (lottery.Type == LotteryType.Diamond.GetHashCode())
  331. {
  332. lottery.Icon1.SetActive(false);
  333. lottery.Icon2.SetActive(true);
  334. lottery.Icon3.SetActive(false);
  335. lottery.Icon2.sprite = Lib.DiamondSprite;
  336. lottery.Icon2.Resize(true, 1, 1);
  337. lottery.Icon2.transform.localPosition = new Vector3(0, 7.5f, 0);
  338. lottery.DescriptionText.SetActive(true);
  339. lottery.DescriptionText.text = lottery.Value.ToString();
  340. }
  341. else if (lottery.Type == LotteryType.Flower.GetHashCode())
  342. {
  343. lottery.Icon1.SetActive(false);
  344. lottery.Icon2.SetActive(true);
  345. lottery.Icon3.SetActive(false);
  346. lottery.Icon2.sprite = GardenManager.FlowerInfoDictionary[lottery.Value].Icon;
  347. lottery.Icon2.Resize(true, 0.3125f, 0.3125f);
  348. lottery.Icon2.transform.localPosition = new Vector3();
  349. lottery.DescriptionText.SetActive(false);
  350. }
  351. else if (lottery.Type == LotteryType.Close.GetHashCode())
  352. {
  353. CloseItem closeItem = PlayerManager.CloseItemDictionary[lottery.Value];
  354. float newSize = closeItem.PixelSize/closeItem.Sprites[0].rect.width;
  355. closeItem.SetupUI(newSize, new Vector2(), lottery.Icon1, lottery.Icon3, lottery.Icon2);
  356. lottery.DescriptionText.SetActive(false);
  357. }
  358. lottery.Button.onClick = new Button.ButtonClickedEvent();
  359. lottery.Button.onClick.AddListener(() => { OnClick(posIndex); });
  360. return lottery;
  361. }
  362. public static void PlayAnimation(bool resetSign)
  363. {
  364. ResetSignRound = resetSign;
  365. ResourceManager.Get(CanvasLabel.Bc_Lottery).TweenForCG();
  366. ResourceManager.Get(CanvasLabel.Ba_Notice0).TweenBacCG();
  367. float random = Random.Range(0f, 1f);
  368. for (int i = 0; i < RateList.Count; i++)
  369. {
  370. if (random <= RateList.MySum(f => f, i + 1))
  371. {
  372. TempTypeList.Add(TypeList[i]);
  373. TempTypeList.AddRange(TypeList.Random(2, true, false, type => !TempTypeList.Contains(type)));
  374. break;
  375. }
  376. }
  377. TempLotteryList.Add(CreateLottery(TempTypeList[0], 0, ResourceManager.Get(CanvasLabel.Bc_LotteryItem1)));
  378. TempLotteryList.Add(CreateLottery(TempTypeList[1], 1, ResourceManager.Get(CanvasLabel.Bc_LotteryItem2)));
  379. TempLotteryList.Add(CreateLottery(TempTypeList[2], 2, ResourceManager.Get(CanvasLabel.Bc_LotteryItem3)));
  380. List<Vector3> posList = PosList.Disturb();
  381. TempLotteryList[0].Item.position = posList[0];
  382. TempLotteryList[1].Item.position = posList[1];
  383. TempLotteryList[2].Item.position = posList[2];
  384. Button button1 = ResourceManager.Get<Button>(CanvasLabel.Bc_LotteryBack1);
  385. Button button2 = ResourceManager.Get<Button>(CanvasLabel.Bc_LotteryBack2);
  386. Button button3 = ResourceManager.Get<Button>(CanvasLabel.Bc_LotteryBack3);
  387. button1.interactable = false;
  388. button2.interactable = false;
  389. button3.interactable = false;
  390. Auxiliary.Instance.DelayCall
  391. (
  392. () =>
  393. {
  394. ResourceManager.Get(CanvasLabel.Bc_LotteryItem1).Move2D(PosList[1], 0.25f, false, Curve.EaseOutQuad);
  395. ResourceManager.Get(CanvasLabel.Bc_LotteryItem2).Move2D(PosList[1], 0.25f, false, Curve.EaseOutQuad);
  396. ResourceManager.Get(CanvasLabel.Bc_LotteryItem3).Move2D(PosList[1], 0.25f, false, Curve.EaseOutQuad);
  397. },
  398. 1f
  399. );
  400. Auxiliary.Instance.DelayCall
  401. (
  402. () =>
  403. {
  404. ResourceManager.Get(CanvasLabel.Bc_LotteryItem1).TweenForEuler();
  405. ResourceManager.Get(CanvasLabel.Bc_LotteryItem2).TweenForEuler();
  406. ResourceManager.Get(CanvasLabel.Bc_LotteryItem3).TweenForEuler();
  407. },
  408. 1.5f
  409. );
  410. Auxiliary.Instance.DelayCall
  411. (
  412. () =>
  413. {
  414. button1.interactable = true;
  415. button2.interactable = true;
  416. button3.interactable = true;
  417. ResourceManager.Get(CanvasLabel.Bc_LotteryItem1).Move2D(PosList[0], 0.25f, false, Curve.EaseOutQuad);
  418. ResourceManager.Get(CanvasLabel.Bc_LotteryItem2).Move2D(PosList[1], 0.25f, false, Curve.EaseOutQuad);
  419. ResourceManager.Get(CanvasLabel.Bc_LotteryItem3).Move2D(PosList[2], 0.25f, false, Curve.EaseOutQuad);
  420. },
  421. 2f
  422. );
  423. Auxiliary.Instance.DelayCall
  424. (
  425. () =>
  426. {
  427. ResourceManager.Get(CanvasLabel.Bc_Lab).TweenForCG();
  428. ResourceManager.SetText(CanvasLabel.Bc_Lab, Language.GetStr(LanguageLabel.UI__Bc_Lab));
  429. },
  430. 2.5f
  431. );
  432. }
  433. public static void EndAnimation()
  434. {
  435. TempTypeList = new List<int>();
  436. TempValueList = new List<int>();
  437. TempLotteryList = new List<Lottery>();
  438. ResourceManager.Get(CanvasLabel.Bc_Lab).TweenBacCG();
  439. ResourceManager.Get(CanvasLabel.Bc_Confirm).TweenBacCG();
  440. ResourceManager.Get(CanvasLabel.Ba_Notice0).TweenForCG();
  441. ResourceManager.Get(CanvasLabel.B_SignIn).TweenBacCG();
  442. ResourceManager.Get(CanvasLabel.Ba_Notice).TweenBacCG();
  443. ResourceManager.Get(CanvasLabel.Bb_SignIn).TweenBacCG();
  444. ResourceManager.Get(CanvasLabel.Bc_Lottery).TweenBacCG();
  445. AudioManager.PlayClip(AudioLabel.ClickButton);
  446. }
  447. public static void OnClick(int index)
  448. {
  449. AudioManager.PlayClip(AudioLabel.GetCurrent);
  450. ResourceManager.Get<Button>(CanvasLabel.Bc_LotteryBack1).interactable = false;
  451. ResourceManager.Get<Button>(CanvasLabel.Bc_LotteryBack2).interactable = false;
  452. ResourceManager.Get<Button>(CanvasLabel.Bc_LotteryBack3).interactable = false;
  453. TempLotteryList[0].Item.TweenBacEuler();
  454. TempLotteryList[0].BK.SetActive(true);
  455. TempLotteryList[0].GetAward();
  456. List<Vector3> posList = new List<Vector3>(PosList);
  457. posList.Remove(PosList[index]);
  458. posList = posList.Disturb();
  459. TempLotteryList[0].Item.position = PosList[index];
  460. TempLotteryList[1].Item.position = posList[0];
  461. TempLotteryList[2].Item.position = posList[1];
  462. Auxiliary.Instance.DelayCall
  463. (
  464. () =>
  465. {
  466. ResourceManager.Get(CanvasLabel.Bc_Confirm).TweenForCG();
  467. ResourceManager.Get(CanvasLabel.Bc_LotteryItem1).TweenBacEuler();
  468. ResourceManager.Get(CanvasLabel.Bc_LotteryItem2).TweenBacEuler();
  469. ResourceManager.Get(CanvasLabel.Bc_LotteryItem3).TweenBacEuler();
  470. },
  471. 1f
  472. );
  473. }
  474. public void GetAward()
  475. {
  476. if (ResetSignRound)
  477. {
  478. SignItem.ResetSignRound();
  479. }
  480. BK.SetActive(true);
  481. if (Type == LotteryType.Coin.GetHashCode())
  482. {
  483. Manager.AddCoin(Value, StaticsManager.ItemID.获得金币, StaticsManager.ConsumeModule.Checkin);
  484. ResourceManager.SetText(CanvasLabel.Bc_Lab, Language.GetStr(LanguageLabel.UI__Bc_Lab1) + Language.GetStr(LanguageLabel.Common__Coin) + " " + Value);
  485. }
  486. else if (Type == LotteryType.Diamond.GetHashCode())
  487. {
  488. Manager.AddDiamond(Value, StaticsManager.ItemID.获得钻石, StaticsManager.ConsumeModule.Checkin);
  489. ResourceManager.SetText(CanvasLabel.Bc_Lab, Language.GetStr(LanguageLabel.UI__Bc_Lab1) + Language.GetStr(LanguageLabel.Common__Diamond) + " " + Value);
  490. }
  491. else if (Type == LotteryType.Flower.GetHashCode())
  492. {
  493. GardenManager.FlowerInfoDictionary[Value].Add();
  494. ResourceManager.SetText(CanvasLabel.Bc_Lab, Language.GetStr(LanguageLabel.UI__Bc_Lab1) + " " + GardenManager.FlowerInfoDictionary[Value].Name);
  495. }
  496. else if (Type == LotteryType.Close.GetHashCode())
  497. {
  498. PlayerManager.CloseItemDictionary[Value].Unlock();
  499. PlayerManager.BoughtCloseIDs.UniqueAdd(Value);
  500. ResourceManager.SetText(CanvasLabel.Bc_Lab, Language.GetStr(LanguageLabel.UI__Bc_Lab1) + " " + PlayerManager.CloseItemDictionary[Value].Name);
  501. }
  502. }
  503. }
  504. public class SignManager : Regist
  505. {
  506. #region Config
  507. public static int SignIndex;
  508. public static int SignRound;
  509. public static DateTime LastSignTime;
  510. public static Dictionary<int, SignItem> SignItemDictionary = new Dictionary<int, SignItem>();
  511. #endregion
  512. public static bool ShowPanels()
  513. {
  514. if (TutorialManager.NewplayerTutorial)
  515. {
  516. return false;
  517. }
  518. if (ShowOfflineIncomPanel())
  519. {
  520. return true;
  521. }
  522. if (ShowMailRewardPanel())
  523. {
  524. return true;
  525. }
  526. if (ShowSignPanel())
  527. {
  528. return true;
  529. }
  530. if (ShowAnnouncePanel())
  531. {
  532. return true;
  533. }
  534. if (NickNameManager.ShowNickNameSettingPanelFirstTime())
  535. {
  536. return false;
  537. }
  538. return false;
  539. }
  540. public static bool ShowOfflineIncomPanel()
  541. {
  542. if (Manager.OfflineFlag)
  543. {
  544. ResourceManager.Get(CanvasLabel.C_Group).TweenBacCG();
  545. ResourceManager.Get(CanvasLabel.B_SignIn).TweenForCG();
  546. ResourceManager.Get(CanvasLabel.Ba_Notice).TweenForCG();
  547. return true;
  548. }
  549. return false;
  550. }
  551. public static bool ShowMailRewardPanel()
  552. {
  553. HttpManager.DecodeMailXmlStr(HttpManager.MailXmlStr);
  554. if (HttpManager.MailRewardList.Count > 0)
  555. {
  556. HttpManager.GetAllMailReward();
  557. ResourceManager.Get(CanvasLabel.C_Group).TweenBacCG();
  558. ResourceManager.Get(CanvasLabel.B_SignIn).TweenForCG();
  559. ResourceManager.Get(CanvasLabel.Bd_Mail0).TweenForCG();
  560. return true;
  561. }
  562. return false;
  563. }
  564. public static bool ShowSignPanel()
  565. {
  566. if (ConfigManager.GetBoolFormConfig(PlayerConfigLabel.QuitFlag) && HttpManager.IsConnect)
  567. {
  568. int daySpan = HttpManager.CurrentDateTime.Day - LastSignTime.Day;
  569. int yearSpan = HttpManager.CurrentDateTime.Year - LastSignTime.Year;
  570. int monthSpan = HttpManager.CurrentDateTime.Month - LastSignTime.Month;
  571. if (daySpan >= 1 || yearSpan >= 1 || monthSpan >= 1)
  572. {
  573. ResourceManager.Get(CanvasLabel.B_SignIn).TweenForCG();
  574. ResourceManager.Get(CanvasLabel.Bb_SignIn).TweenForCG();
  575. return true;
  576. }
  577. }
  578. return false;
  579. }
  580. public static bool ShowAnnouncePanel()
  581. {
  582. //ConfigManager.SaveIntToConfig(PlayerConfigLabel.NotificationIndex, -1);
  583. if (HttpManager.AnnounceIndex > ConfigManager.GetIntFormConfig(PlayerConfigLabel.NotificationIndex) && HttpManager.IsAnnounceReady)
  584. {
  585. ResourceManager.Get(CanvasLabel.B_SignIn).TweenBacCG();
  586. ConfigManager.SaveIntToConfig(PlayerConfigLabel.NotificationIndex, HttpManager.AnnounceIndex);
  587. AnnounceManager.ShowAnnouncePanel();
  588. return true;
  589. }
  590. else
  591. {
  592. return false;
  593. }
  594. }
  595. public static void GetSignAward()
  596. {
  597. SignItemDictionary[SignIndex].Get();
  598. Manager.SignAmt++;
  599. }
  600. public override void SecondInit()
  601. {
  602. LastSignTime = DateTime.Parse(ConfigManager.GetStringFormConfig(PlayerConfigLabel.SignTime));
  603. SignIndex = ConfigManager.GetIntFormConfig(PlayerConfigLabel.SignIndex);
  604. SignRound = ConfigManager.GetIntFormConfig(PlayerConfigLabel.SignRound);
  605. Transform par = ResourceManager.Get(CanvasLabel.Bb_Grid);
  606. List<XmlAttributeCollection> attributeList = ConfigManager.GetSignConfig();
  607. for (int i = 0; i < attributeList.Count; i++)
  608. {
  609. Transform tra = ResourceManager.Get(ResourceLabel.SignItem, Folder.UI, false, par, false, ObjType.SignItem);
  610. SignItemDictionary.Add(i + 1, new SignItem(i + 1, tra, attributeList[i]));
  611. }
  612. for (int i = 1; i < SignIndex; i++)
  613. {
  614. SignItemDictionary[i].Tick.SetActive(true);
  615. }
  616. Lottery.Init(ConfigManager.GetLotteryConfig());
  617. }
  618. }