SignManager.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808
  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 Lab1 = "Lab1";
  12. public static string Lab2 = "Lab2";
  13. public static string Icon1 = "Icon1";
  14. public static string Icon2 = "Icon2";
  15. }
  16. public class Sign
  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 Diamond
  35. {
  36. get
  37. {
  38. if (RoundBuff.Equal(-1))
  39. {
  40. return Diamond_;
  41. }
  42. else
  43. {
  44. return (int)(Diamond_ * RoundBuff * SignManager.SignRound);
  45. }
  46. }
  47. set { Diamond_ = value; }
  48. }
  49. public int Coin_;
  50. public int Diamond_;
  51. public float RoundBuff;
  52. public bool IsLottery;
  53. public Text Lab1;
  54. public Text Lab2;
  55. public Image Icon;
  56. public Image Mark;
  57. public Vector2 OriginSize;
  58. public List<int> FlowerList = new List<int>();
  59. #endregion
  60. public Sign(int index, Transform tra, XmlAttributeCollection attribute)
  61. {
  62. Dictionary<string, Transform> dic = new Dictionary<string, Transform>();
  63. Auxiliary.CompileDic(tra, dic);
  64. Lab1 = dic[SignItemLabel.Lab1].GetComponent<Text>();
  65. Lab2 = dic[SignItemLabel.Lab2].GetComponent<Text>();
  66. Icon = dic[SignItemLabel.Icon1].GetComponent<Image>();
  67. Mark = dic[SignItemLabel.Icon2].GetComponent<Image>();
  68. OriginSize = Icon.rectTransform.sizeDelta;
  69. Lab2.text = index.ToString();
  70. Coin = Auxiliary.StringToInt(attribute[4].Value, 0);
  71. IsLottery = Auxiliary.StringToBool(attribute[1].Value, false);
  72. Diamond = Auxiliary.StringToInt(attribute[3].Value, 0);
  73. FlowerList = Auxiliary.StringToInts(',', attribute[2].Value, new List<int>());
  74. RoundBuff = Auxiliary.StringToFloat(attribute[5].Value, -1);
  75. SetUI();
  76. }
  77. public void Get()
  78. {
  79. if (IsLottery)
  80. {
  81. Lottery.EnterAnimation(true);
  82. return;
  83. }
  84. AudioManager.PlayClip(AudioLabel.GetCurrent);
  85. Mark.SetActive(true);
  86. ResetSign();
  87. ResourceManager.SetActive(ObjectLabel.Bb_Get, false);
  88. ResourceManager.SetActive(ObjectLabel.Bb_Rotate, true);
  89. ResourceManager.SetActive(ObjectLabel.Bb_Confirm, true);
  90. if (FlowerList.Valid())
  91. {
  92. for (int i = 0; i < FlowerList.Count; i++)
  93. {
  94. FlowerInfo flowerInfo = GardenManager.FlowerInfoDic[FlowerList[i]];
  95. if (flowerInfo.Unlock == false)
  96. {
  97. ResourceManager.SetText(ObjectLabel.Bb_InfoLabA, flowerInfo.Name);
  98. ResourceManager.SetActive(ObjectLabel.Bb_IconA, true);
  99. ResourceManager.SetSprite(ObjectLabel.Bb_IconA0, flowerInfo.Icon);
  100. ResourceManager.Get<Image>(ObjectLabel.Bb_IconA0).Resize(true, 0.8125f, 0.8125f);
  101. flowerInfo.Add();
  102. return;
  103. }
  104. }
  105. }
  106. if (Diamond > 0)
  107. {
  108. ResourceManager.SetText(ObjectLabel.Bb_InfoLabB, Diamond.ToString());
  109. ResourceManager.SetSprite(ObjectLabel.Bb_IconB, Lib.DiamondSprite);
  110. ResourceManager.SetActive(ObjectLabel.Bb_IconB, true);
  111. Manager.AddDiamond(Diamond, StaticsManager.ItemID.获得钻石, StaticsManager.ConsumeModule.Checkin);
  112. }
  113. else if (Coin > 0)
  114. {
  115. ResourceManager.SetText(ObjectLabel.Bb_InfoLabB, Coin.ToString());
  116. ResourceManager.SetSprite(ObjectLabel.Bb_IconB, Lib.GoldSprite);
  117. ResourceManager.SetActive(ObjectLabel.Bb_IconB, true);
  118. Manager.AddCoin(Coin, StaticsManager.ItemID.获得金币, StaticsManager.ConsumeModule.Checkin);
  119. }
  120. else
  121. {
  122. throw new Exception();
  123. }
  124. }
  125. public void SetUI()
  126. {
  127. if (IsLottery)
  128. {
  129. Icon.sprite = Lib.PackSprite;
  130. Icon.Resize(true, 0.3f, 0.3f);
  131. return;
  132. }
  133. if (FlowerList.Valid())
  134. {
  135. for (int i = 0; i < FlowerList.Count; i++)
  136. {
  137. FlowerInfo flowerInfo = GardenManager.FlowerInfoDic[FlowerList[i]];
  138. if (flowerInfo.Unlock == false)
  139. {
  140. Icon.sprite = flowerInfo.Icon;
  141. Icon.Resize(true, 0.1875f, 0.1875f);
  142. return;
  143. }
  144. }
  145. }
  146. if (Diamond > 0)
  147. {
  148. Icon.sprite = Lib.DiamondSprite;
  149. Icon.Resize(false, OriginSize);
  150. Lab1.text = Diamond.ToString();
  151. }
  152. else if (Coin > 0)
  153. {
  154. Icon.sprite = Lib.GoldSprite;
  155. Icon.Resize(false, OriginSize);
  156. Lab1.text = Coin.ToString();
  157. }
  158. }
  159. private static int MaxSignIndex = 22;
  160. public static void ResetSign()
  161. {
  162. SignManager.SignTime = HttpManager.Time;
  163. SignManager.SignIndex++;
  164. if (SignManager.SignIndex == MaxSignIndex)
  165. {
  166. SignManager.SignIndex = 1;
  167. SignManager.SignRound++;
  168. ResourceManager.Get(ObjectLabel.B_SignIn).GetTweenCG().AddEventOnetime
  169. (
  170. EventType.BackwardFinish,
  171. () =>
  172. {
  173. foreach (var kv in SignManager.SignDic)
  174. {
  175. kv.Value.SetUI();
  176. kv.Value.Mark.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 PosIndex;
  194. public int Type;
  195. public int Value;
  196. public Text Lab;
  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 bool ResetSign = false;
  204. public static List<int> TempTypeList = new List<int>();
  205. public static List<int> TempValueList = new List<int>();
  206. public static List<Lottery> TempLotteryList = new List<Lottery>();
  207. public static List<int> TypeList = new List<int>();
  208. public static List<float> RateList = new List<float>();
  209. public static List<Vector3> PosList = new List<Vector3>();
  210. public static List<List<int>> LeftBorderDList = new List<List<int>>();
  211. public static List<List<int>> RightBorderDList = new List<List<int>>();
  212. #endregion
  213. public static void Configure(List<XmlAttributeCollection> attributeList)
  214. {
  215. PosList.Add(ResourceManager.Get(ObjectLabel.Bc_LotteryItem1).position);
  216. PosList.Add(ResourceManager.Get(ObjectLabel.Bc_LotteryItem2).position);
  217. PosList.Add(ResourceManager.Get(ObjectLabel.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.Level+1).ToString()));
  229. rightBorderList.Add((int)Auxiliary.FmlParse(rightBorderStrList[j], "l", (Manager.Level+1).ToString()));
  230. }
  231. LeftBorderDList.Add(leftBorderList);
  232. RightBorderDList.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(LeftBorderDList[0][0], RightBorderDList[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 < LeftBorderDList[type - 1].Count; j++)
  245. {
  246. for (int k = LeftBorderDList[type - 1][j]; k < RightBorderDList[type - 1][j] + 1; k++)
  247. {
  248. if (!TempValueList.Contains(k))
  249. {
  250. flowerIDs.Add(k);
  251. }
  252. }
  253. }
  254. lottery.Value = Award.SelectAwardFlowerID(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 < LeftBorderDList[type - 1].Count; j++)
  263. {
  264. for (int k = LeftBorderDList[type - 1][j]; k < RightBorderDList[type - 1][j] + 1; k++)
  265. {
  266. if (!PlayerManager.CloseItemDic[k].Possess && !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, LeftBorderDList[type - 1].Count);
  277. lottery.Value = Random.Range(LeftBorderDList[type - 1][index], RightBorderDList[type - 1][index] + 1);
  278. CloseItem closeItem = PlayerManager.CloseItemDic[lottery.Value];
  279. lottery.Value = (int) closeItem.BuyAmt/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, LeftBorderDList[type - 1].Count);
  299. lottery.Value = Random.Range(LeftBorderDList[type - 1][index], RightBorderDList[type - 1][index] + 1);
  300. } while (PlayerManager.CloseItemDic[lottery.Value].Possess || TempValueList.Contains(lottery.Value));
  301. TempValueList.Add(lottery.Value);
  302. }
  303. #endregion
  304. }
  305. else
  306. {
  307. int index = Random.Range(0, LeftBorderDList[type - 1].Count);
  308. lottery.Value = Random.Range(LeftBorderDList[type - 1][index], RightBorderDList[type - 1][index] + 1);
  309. }
  310. lottery.PosIndex = 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.Lab = 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.Lab.SetActive(true);
  327. lottery.Lab.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.Lab.SetActive(true);
  337. lottery.Lab.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.FlowerInfoDic[lottery.Value].Icon;
  344. lottery.Icon2.Resize(true, 0.3125f, 0.3125f);
  345. lottery.Icon2.transform.localPosition = new Vector3();
  346. lottery.Lab.SetActive(false);
  347. }
  348. else if (lottery.Type == LotteryType.Close.GetHashCode())
  349. {
  350. CloseItem closeItem = PlayerManager.CloseItemDic[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.Lab.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 EnterAnimation(bool resetSign)
  360. {
  361. ResetSign = resetSign;
  362. ResourceManager.Get(ObjectLabel.Bc_Lottery).TweenForCG();
  363. ResourceManager.Get(ObjectLabel.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(ObjectLabel.Bc_LotteryItem1)));
  375. TempLotteryList.Add(CreateLottery(TempTypeList[1], 1, ResourceManager.Get(ObjectLabel.Bc_LotteryItem2)));
  376. TempLotteryList.Add(CreateLottery(TempTypeList[2], 2, ResourceManager.Get(ObjectLabel.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>(ObjectLabel.Bc_LotteryBack1);
  382. Button button2 = ResourceManager.Get<Button>(ObjectLabel.Bc_LotteryBack2);
  383. Button button3 = ResourceManager.Get<Button>(ObjectLabel.Bc_LotteryBack3);
  384. button1.interactable = false;
  385. button2.interactable = false;
  386. button3.interactable = false;
  387. Auxiliary.Instance.DelayCall
  388. (
  389. () =>
  390. {
  391. ResourceManager.Get(ObjectLabel.Bc_LotteryItem1).Move2D(PosList[1], 0.25f, false, Curve.EaseOutQuad);
  392. ResourceManager.Get(ObjectLabel.Bc_LotteryItem2).Move2D(PosList[1], 0.25f, false, Curve.EaseOutQuad);
  393. ResourceManager.Get(ObjectLabel.Bc_LotteryItem3).Move2D(PosList[1], 0.25f, false, Curve.EaseOutQuad);
  394. },
  395. 1f
  396. );
  397. Auxiliary.Instance.DelayCall
  398. (
  399. () =>
  400. {
  401. ResourceManager.Get(ObjectLabel.Bc_LotteryItem1).TweenForEuler();
  402. ResourceManager.Get(ObjectLabel.Bc_LotteryItem2).TweenForEuler();
  403. ResourceManager.Get(ObjectLabel.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(ObjectLabel.Bc_LotteryItem1).Move2D(PosList[0], 0.25f, false, Curve.EaseOutQuad);
  415. ResourceManager.Get(ObjectLabel.Bc_LotteryItem2).Move2D(PosList[1], 0.25f, false, Curve.EaseOutQuad);
  416. ResourceManager.Get(ObjectLabel.Bc_LotteryItem3).Move2D(PosList[2], 0.25f, false, Curve.EaseOutQuad);
  417. },
  418. 2f
  419. );
  420. Auxiliary.Instance.DelayCall
  421. (
  422. () =>
  423. {
  424. ResourceManager.Get(ObjectLabel.Bc_Lab).TweenForCG();
  425. ResourceManager.SetText(ObjectLabel.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(ObjectLabel.Bc_Lab).TweenBacCG();
  436. ResourceManager.Get(ObjectLabel.Bc_Confirm).TweenBacCG();
  437. ResourceManager.Get(ObjectLabel.Ba_Notice0).TweenForCG();
  438. ResourceManager.Get(ObjectLabel.B_SignIn).TweenBacCG();
  439. ResourceManager.Get(ObjectLabel.Ba_Notice).TweenBacCG();
  440. ResourceManager.Get(ObjectLabel.Bb_SignIn).TweenBacCG();
  441. ResourceManager.Get(ObjectLabel.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>(ObjectLabel.Bc_LotteryBack1).interactable = false;
  448. ResourceManager.Get<Button>(ObjectLabel.Bc_LotteryBack2).interactable = false;
  449. ResourceManager.Get<Button>(ObjectLabel.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(ObjectLabel.Bc_Confirm).TweenForCG();
  464. ResourceManager.Get(ObjectLabel.Bc_LotteryItem1).TweenBacEuler();
  465. ResourceManager.Get(ObjectLabel.Bc_LotteryItem2).TweenBacEuler();
  466. ResourceManager.Get(ObjectLabel.Bc_LotteryItem3).TweenBacEuler();
  467. },
  468. 1f
  469. );
  470. }
  471. public void GetAward()
  472. {
  473. if (ResetSign)
  474. {
  475. Sign.ResetSign();
  476. }
  477. BK.SetActive(true);
  478. if (Type == LotteryType.Coin.GetHashCode())
  479. {
  480. Manager.AddCoin(Value, StaticsManager.ItemID.获得金币, StaticsManager.ConsumeModule.Checkin);
  481. ResourceManager.SetText(ObjectLabel.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(ObjectLabel.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.FlowerInfoDic[Value].Add();
  491. ResourceManager.SetText(ObjectLabel.Bc_Lab, Language.GetStr(LanguageLabel.UI__Bc_Lab1) + " " + GardenManager.FlowerInfoDic[Value].Name);
  492. }
  493. else if (Type == LotteryType.Close.GetHashCode())
  494. {
  495. PlayerManager.CloseItemDic[Value].Unlock();
  496. PlayerManager.BoughtCloseList.UniqueAdd(Value);
  497. ResourceManager.SetText(ObjectLabel.Bc_Lab, Language.GetStr(LanguageLabel.UI__Bc_Lab1) + " " + PlayerManager.CloseItemDic[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 SignTime;
  507. public static Dictionary<int, Sign> SignDic = new Dictionary<int, Sign>();
  508. #endregion
  509. public static bool ShowOfflinePanel()
  510. {
  511. if (TutorialManager.NewplayerTutorial)
  512. {
  513. return false;
  514. }
  515. if (ShowOfflineIncomReward())
  516. {
  517. return true;
  518. }
  519. if (ShowMailReward())
  520. {
  521. return true;
  522. }
  523. if (ShowSignReward())
  524. {
  525. return true;
  526. }
  527. //if (ShowNotification())
  528. //{
  529. // return true;
  530. //}
  531. if (NickNameManager.ShowNickNameSettingPanelFirstTime())
  532. {
  533. return false;
  534. }
  535. return false;
  536. }
  537. public static bool ShowOfflineIncomReward()
  538. {
  539. if (Manager.OfflineLock)
  540. {
  541. ResourceManager.Get(ObjectLabel.C_Group).TweenBacCG();
  542. ResourceManager.Get(ObjectLabel.B_SignIn).TweenForCG();
  543. ResourceManager.Get(ObjectLabel.Ba_Notice).TweenForCG();
  544. return true;
  545. }
  546. return false;
  547. }
  548. public static bool ShowMailReward()
  549. {
  550. HttpManager.DecodeMailXml(HttpManager.MailXml);
  551. if (HttpManager.MailRewardList.Count > 0)
  552. {
  553. HttpManager.GetMailReward();
  554. ResourceManager.Get(ObjectLabel.C_Group).TweenBacCG();
  555. ResourceManager.Get(ObjectLabel.B_SignIn).TweenForCG();
  556. ResourceManager.Get(ObjectLabel.Bd_Mail0).TweenForCG();
  557. return true;
  558. }
  559. return false;
  560. }
  561. public static bool ShowSignReward()
  562. {
  563. if (ConfigManager.GetBoolFormConfig(PlayerConfigLabel.QuitFlag) && HttpManager.Connect)
  564. {
  565. int daySpan = HttpManager.Time.Day - SignTime.Day;
  566. int yearSpan = HttpManager.Time.Year - SignTime.Year;
  567. int monthSpan = HttpManager.Time.Month - SignTime.Month;
  568. if (daySpan >= 1 || yearSpan >= 1 || monthSpan >= 1)
  569. {
  570. ResourceManager.Get(ObjectLabel.B_SignIn).TweenForCG();
  571. ResourceManager.Get(ObjectLabel.Bb_SignIn).TweenForCG();
  572. return true;
  573. }
  574. }
  575. return false;
  576. }
  577. public static bool ShowNotification()
  578. {
  579. if (HttpManager.NotificationIndex > ConfigManager.GetIntFormConfig(PlayerConfigLabel.NotificationIndex) && HttpManager.NotificationReady)
  580. {
  581. ResourceManager.Get(ObjectLabel.B_SignIn).TweenBacCG();
  582. ConfigManager.SaveIntToConfig(PlayerConfigLabel.NotificationIndex, HttpManager.NotificationIndex);
  583. AnnounceManager.ShowAnnouncePanel();
  584. return true;
  585. }
  586. else
  587. {
  588. return false;
  589. }
  590. }
  591. public static void GetSignReward()
  592. {
  593. SignDic[SignIndex].Get();
  594. Manager.SignAmt++;
  595. }
  596. public override void SecondInit()
  597. {
  598. SignTime = DateTime.Parse(ConfigManager.GetStringFormConfig(PlayerConfigLabel.SignTime));
  599. SignIndex = ConfigManager.GetIntFormConfig(PlayerConfigLabel.SignIndex);
  600. SignRound = ConfigManager.GetIntFormConfig(PlayerConfigLabel.SignRound);
  601. Transform par = ResourceManager.Get(ObjectLabel.Bb_Grid);
  602. List<XmlAttributeCollection> attributeList = ConfigManager.GetSignConfig();
  603. for (int i = 0; i < attributeList.Count; i++)
  604. {
  605. Transform tra = ResourceManager.Get(ResourceLabel.SignItem, Folder.UI, false, par, false, ObjType.SignItem);
  606. SignDic.Add(i + 1, new Sign(i + 1, tra, attributeList[i]));
  607. }
  608. for (int i = 1; i < SignIndex; i++)
  609. {
  610. SignDic[i].Mark.SetActive(true);
  611. }
  612. Lottery.Configure(ConfigManager.GetLotteryConfig());
  613. }
  614. }