SignManager.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812
  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.Icon3.SetActive(false);
  323. lottery.Icon2.sprite = Lib.GoldSprite;
  324. lottery.Icon2.Resize(true, 1, 1);
  325. lottery.Icon2.transform.localPosition = new Vector3(0, 7.5f, 0);
  326. lottery.DescriptionText.SetActive(true);
  327. lottery.DescriptionText.text = lottery.Value.ToString();
  328. }
  329. else if (lottery.Type == LotteryType.Diamond.GetHashCode())
  330. {
  331. lottery.Icon1.SetActive(false);
  332. lottery.Icon3.SetActive(false);
  333. lottery.Icon2.sprite = Lib.DiamondSprite;
  334. lottery.Icon2.Resize(true, 1, 1);
  335. lottery.Icon2.transform.localPosition = new Vector3(0, 7.5f, 0);
  336. lottery.DescriptionText.SetActive(true);
  337. lottery.DescriptionText.text = lottery.Value.ToString();
  338. }
  339. else if (lottery.Type == LotteryType.Flower.GetHashCode())
  340. {
  341. lottery.Icon1.SetActive(false);
  342. lottery.Icon3.SetActive(false);
  343. lottery.Icon2.sprite = GardenManager.FlowerInfoDictionary[lottery.Value].Icon;
  344. lottery.Icon2.Resize(true, 0.3125f, 0.3125f);
  345. lottery.Icon2.transform.localPosition = new Vector3();
  346. lottery.DescriptionText.SetActive(false);
  347. }
  348. else if (lottery.Type == LotteryType.Close.GetHashCode())
  349. {
  350. CloseItem closeItem = PlayerManager.CloseItemDictionary[lottery.Value];
  351. float newSize = closeItem.PixelSize/closeItem.Sprites[0].rect.width;
  352. closeItem.SetupUI(newSize, new Vector2(), lottery.Icon1, lottery.Icon3, lottery.Icon2);
  353. lottery.DescriptionText.SetActive(false);
  354. }
  355. lottery.Button.onClick = new Button.ButtonClickedEvent();
  356. lottery.Button.onClick.AddListener(() => { OnClick(posIndex); });
  357. return lottery;
  358. }
  359. public static void PlayAnimation(bool resetSign)
  360. {
  361. ResetSignRound = resetSign;
  362. ResourceManager.Get(CanvasLabel.Bc_Lottery).TweenForCG();
  363. ResourceManager.Get(CanvasLabel.Ba_Notice0).TweenBacCG();
  364. float random = Random.Range(0f, 1f);
  365. for (int i = 0; i < RateList.Count; i++)
  366. {
  367. if (random <= RateList.MySum(f => f, i + 1))
  368. {
  369. TempTypeList.Add(TypeList[i]);
  370. TempTypeList.AddRange(TypeList.Random(2, true, false, type => !TempTypeList.Contains(type)));
  371. break;
  372. }
  373. }
  374. TempLotteryList.Add(CreateLottery(TempTypeList[0], 0, ResourceManager.Get(CanvasLabel.Bc_LotteryItem1)));
  375. TempLotteryList.Add(CreateLottery(TempTypeList[1], 1, ResourceManager.Get(CanvasLabel.Bc_LotteryItem2)));
  376. TempLotteryList.Add(CreateLottery(TempTypeList[2], 2, ResourceManager.Get(CanvasLabel.Bc_LotteryItem3)));
  377. List<Vector3> posList = PosList.Disturb();
  378. TempLotteryList[0].Item.position = posList[0];
  379. TempLotteryList[1].Item.position = posList[1];
  380. TempLotteryList[2].Item.position = posList[2];
  381. Button button1 = ResourceManager.Get<Button>(CanvasLabel.Bc_LotteryBack1);
  382. Button button2 = ResourceManager.Get<Button>(CanvasLabel.Bc_LotteryBack2);
  383. Button button3 = ResourceManager.Get<Button>(CanvasLabel.Bc_LotteryBack3);
  384. button1.interactable = false;
  385. button2.interactable = false;
  386. button3.interactable = false;
  387. Auxiliary.Instance.DelayCall
  388. (
  389. () =>
  390. {
  391. ResourceManager.Get(CanvasLabel.Bc_LotteryItem1).Move2D(PosList[1], 0.25f, false, Curve.EaseOutQuad);
  392. ResourceManager.Get(CanvasLabel.Bc_LotteryItem2).Move2D(PosList[1], 0.25f, false, Curve.EaseOutQuad);
  393. ResourceManager.Get(CanvasLabel.Bc_LotteryItem3).Move2D(PosList[1], 0.25f, false, Curve.EaseOutQuad);
  394. },
  395. 1f
  396. );
  397. Auxiliary.Instance.DelayCall
  398. (
  399. () =>
  400. {
  401. ResourceManager.Get(CanvasLabel.Bc_LotteryItem1).TweenForEuler();
  402. ResourceManager.Get(CanvasLabel.Bc_LotteryItem2).TweenForEuler();
  403. ResourceManager.Get(CanvasLabel.Bc_LotteryItem3).TweenForEuler();
  404. },
  405. 1.5f
  406. );
  407. Auxiliary.Instance.DelayCall
  408. (
  409. () =>
  410. {
  411. button1.interactable = true;
  412. button2.interactable = true;
  413. button3.interactable = true;
  414. ResourceManager.Get(CanvasLabel.Bc_LotteryItem1).Move2D(PosList[0], 0.25f, false, Curve.EaseOutQuad);
  415. ResourceManager.Get(CanvasLabel.Bc_LotteryItem2).Move2D(PosList[1], 0.25f, false, Curve.EaseOutQuad);
  416. ResourceManager.Get(CanvasLabel.Bc_LotteryItem3).Move2D(PosList[2], 0.25f, false, Curve.EaseOutQuad);
  417. },
  418. 2f
  419. );
  420. Auxiliary.Instance.DelayCall
  421. (
  422. () =>
  423. {
  424. ResourceManager.Get(CanvasLabel.Bc_Lab).TweenForCG();
  425. ResourceManager.SetText(CanvasLabel.Bc_Lab, Language.GetStr(LanguageLabel.UI__Bc_Lab));
  426. },
  427. 2.5f
  428. );
  429. }
  430. public static void EndAnimation()
  431. {
  432. TempTypeList = new List<int>();
  433. TempValueList = new List<int>();
  434. TempLotteryList = new List<Lottery>();
  435. ResourceManager.Get(CanvasLabel.Bc_Lab).TweenBacCG();
  436. ResourceManager.Get(CanvasLabel.Bc_Confirm).TweenBacCG();
  437. ResourceManager.Get(CanvasLabel.Ba_Notice0).TweenForCG();
  438. ResourceManager.Get(CanvasLabel.B_SignIn).TweenBacCG();
  439. ResourceManager.Get(CanvasLabel.Ba_Notice).TweenBacCG();
  440. ResourceManager.Get(CanvasLabel.Bb_SignIn).TweenBacCG();
  441. ResourceManager.Get(CanvasLabel.Bc_Lottery).TweenBacCG();
  442. AudioManager.PlayClip(AudioLabel.ClickButton);
  443. }
  444. public static void OnClick(int index)
  445. {
  446. AudioManager.PlayClip(AudioLabel.GetCurrent);
  447. ResourceManager.Get<Button>(CanvasLabel.Bc_LotteryBack1).interactable = false;
  448. ResourceManager.Get<Button>(CanvasLabel.Bc_LotteryBack2).interactable = false;
  449. ResourceManager.Get<Button>(CanvasLabel.Bc_LotteryBack3).interactable = false;
  450. TempLotteryList[0].Item.TweenBacEuler();
  451. TempLotteryList[0].BK.SetActive(true);
  452. TempLotteryList[0].GetAward();
  453. List<Vector3> posList = new List<Vector3>(PosList);
  454. posList.Remove(PosList[index]);
  455. posList = posList.Disturb();
  456. TempLotteryList[0].Item.position = PosList[index];
  457. TempLotteryList[1].Item.position = posList[0];
  458. TempLotteryList[2].Item.position = posList[1];
  459. Auxiliary.Instance.DelayCall
  460. (
  461. () =>
  462. {
  463. ResourceManager.Get(CanvasLabel.Bc_Confirm).TweenForCG();
  464. ResourceManager.Get(CanvasLabel.Bc_LotteryItem1).TweenBacEuler();
  465. ResourceManager.Get(CanvasLabel.Bc_LotteryItem2).TweenBacEuler();
  466. ResourceManager.Get(CanvasLabel.Bc_LotteryItem3).TweenBacEuler();
  467. },
  468. 1f
  469. );
  470. }
  471. public void GetAward()
  472. {
  473. if (ResetSignRound)
  474. {
  475. SignItem.ResetSignRound();
  476. }
  477. BK.SetActive(true);
  478. if (Type == LotteryType.Coin.GetHashCode())
  479. {
  480. Manager.AddCoin(Value, StaticsManager.ItemID.获得金币, StaticsManager.ConsumeModule.Checkin);
  481. ResourceManager.SetText(CanvasLabel.Bc_Lab, Language.GetStr(LanguageLabel.UI__Bc_Lab1) + Language.GetStr(LanguageLabel.Common__Coin) + " " + Value);
  482. }
  483. else if (Type == LotteryType.Diamond.GetHashCode())
  484. {
  485. Manager.AddDiamond(Value, StaticsManager.ItemID.获得钻石, StaticsManager.ConsumeModule.Checkin);
  486. ResourceManager.SetText(CanvasLabel.Bc_Lab, Language.GetStr(LanguageLabel.UI__Bc_Lab1) + Language.GetStr(LanguageLabel.Common__Diamond) + " " + Value);
  487. }
  488. else if (Type == LotteryType.Flower.GetHashCode())
  489. {
  490. GardenManager.FlowerInfoDictionary[Value].Add();
  491. ResourceManager.SetText(CanvasLabel.Bc_Lab, Language.GetStr(LanguageLabel.UI__Bc_Lab1) + " " + GardenManager.FlowerInfoDictionary[Value].Name);
  492. }
  493. else if (Type == LotteryType.Close.GetHashCode())
  494. {
  495. PlayerManager.CloseItemDictionary[Value].Unlock();
  496. PlayerManager.BoughtCloseIDs.UniqueAdd(Value);
  497. ResourceManager.SetText(CanvasLabel.Bc_Lab, Language.GetStr(LanguageLabel.UI__Bc_Lab1) + " " + PlayerManager.CloseItemDictionary[Value].Name);
  498. }
  499. }
  500. }
  501. public class SignManager : Regist
  502. {
  503. #region Config
  504. public static int SignIndex;
  505. public static int SignRound;
  506. public static DateTime LastSignTime;
  507. public static Dictionary<int, SignItem> SignItemDictionary = new Dictionary<int, SignItem>();
  508. #endregion
  509. public static bool ShowPanels()
  510. {
  511. if (TutorialManager.NewplayerTutorial)
  512. {
  513. return false;
  514. }
  515. if (ShowOfflineIncomPanel())
  516. {
  517. return true;
  518. }
  519. if (ShowMailRewardPanel())
  520. {
  521. return true;
  522. }
  523. if (ShowSignPanel())
  524. {
  525. return true;
  526. }
  527. if (ShowAnnouncePanel())
  528. {
  529. return true;
  530. }
  531. if (NickNameManager.ShowNickNameSettingPanelFirstTime())
  532. {
  533. return false;
  534. }
  535. return false;
  536. }
  537. public static bool ShowOfflineIncomPanel()
  538. {
  539. if (Manager.OfflineFlag)
  540. {
  541. ResourceManager.Get(CanvasLabel.C_Group).TweenBacCG();
  542. ResourceManager.Get(CanvasLabel.B_SignIn).TweenForCG();
  543. ResourceManager.Get(CanvasLabel.Ba_Notice).TweenForCG();
  544. return true;
  545. }
  546. return false;
  547. }
  548. public static bool ShowMailRewardPanel()
  549. {
  550. HttpManager.DecodeMailXmlStr(HttpManager.MailXmlStr);
  551. if (HttpManager.MailRewardList.Count > 0)
  552. {
  553. HttpManager.GetAllMailReward();
  554. ResourceManager.Get(CanvasLabel.C_Group).TweenBacCG();
  555. ResourceManager.Get(CanvasLabel.B_SignIn).TweenForCG();
  556. ResourceManager.Get(CanvasLabel.Bd_Mail0).TweenForCG();
  557. return true;
  558. }
  559. return false;
  560. }
  561. public static bool ShowSignPanel()
  562. {
  563. if (ConfigManager.GetBoolFormConfig(PlayerConfigLabel.QuitFlag) && HttpManager.IsConnect)
  564. {
  565. int daySpan = HttpManager.CurrentDateTime.Day - LastSignTime.Day;
  566. int yearSpan = HttpManager.CurrentDateTime.Year - LastSignTime.Year;
  567. int monthSpan = HttpManager.CurrentDateTime.Month - LastSignTime.Month;
  568. if (daySpan >= 1 || yearSpan >= 1 || monthSpan >= 1)
  569. {
  570. ResourceManager.Get(CanvasLabel.B_SignIn).TweenForCG();
  571. ResourceManager.Get(CanvasLabel.Bb_SignIn).TweenForCG();
  572. return true;
  573. }
  574. }
  575. return false;
  576. }
  577. public static bool ShowAnnouncePanel()
  578. {
  579. //ConfigManager.SaveIntToConfig(PlayerConfigLabel.NotificationIndex, -1);
  580. if (HttpManager.AnnounceIndex > ConfigManager.GetIntFormConfig(PlayerConfigLabel.NotificationIndex) && HttpManager.IsAnnounceReady)
  581. {
  582. ResourceManager.Get(CanvasLabel.B_SignIn).TweenBacCG();
  583. ConfigManager.SaveIntToConfig(PlayerConfigLabel.NotificationIndex, HttpManager.AnnounceIndex);
  584. AnnounceManager.ShowAnnouncePanel();
  585. return true;
  586. }
  587. else
  588. {
  589. return false;
  590. }
  591. }
  592. public static void GetSignAward()
  593. {
  594. SignItemDictionary[SignIndex].Get();
  595. Manager.SignAmt++;
  596. }
  597. public override void SecondInit()
  598. {
  599. LastSignTime = DateTime.Parse(ConfigManager.GetStringFormConfig(PlayerConfigLabel.SignTime));
  600. SignIndex = ConfigManager.GetIntFormConfig(PlayerConfigLabel.SignIndex);
  601. SignRound = ConfigManager.GetIntFormConfig(PlayerConfigLabel.SignRound);
  602. Transform par = ResourceManager.Get(CanvasLabel.Bb_Grid);
  603. List<XmlAttributeCollection> attributeList = ConfigManager.GetSignConfig();
  604. for (int i = 0; i < attributeList.Count; i++)
  605. {
  606. Transform tra = ResourceManager.Get(ResourceLabel.SignItem, Folder.UI, false, par, false, ObjType.SignItem);
  607. SignItemDictionary.Add(i + 1, new SignItem(i + 1, tra, attributeList[i]));
  608. }
  609. for (int i = 1; i < SignIndex; i++)
  610. {
  611. SignItemDictionary[i].Tick.SetActive(true);
  612. }
  613. Lottery.Init(ConfigManager.GetLotteryConfig());
  614. }
  615. }