123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245 |
- using UnityEngine;
- using UnityEngine.UI;
- using System;
- using System.Xml;
- using System.Collections;
- using System.Collections.Generic;
- public class Sign
- {
- #region 变量
- public int Coin
- {
- get
- {
- if (RoundBuff.Equal(-1))
- {
- return Coin_;
- }
- else
- {
- return (int)(Coin_*RoundBuff*ManaSign.SignRound);
- }
- }
- set { Coin_ = value; }
- }
- public int Diamond
- {
- get
- {
- if (RoundBuff.Equal(-1))
- {
- return Diamond_;
- }
- else
- {
- return (int)(Diamond_ * RoundBuff * ManaSign.SignRound);
- }
- }
- set { Diamond_ = value; }
- }
- public int Coin_;
- public int Diamond_;
- public float RoundBuff;
- public Text Lab1;
- public Text Lab2;
- public Image Icon;
- public Image Mark;
- public Vector2 OriginSize;
- public List<int> FlowerList = new List<int>();
- #endregion
- public Sign(int index, Transform tra, XmlAttributeCollection attribute)
- {
- Dictionary<string, Transform> dic = new Dictionary<string, Transform>();
- Auxiliary.CompileDic(tra, dic);
- Lab1 = dic["Lab1"].GetComponent<Text>();
- Lab2 = dic["Lab2"].GetComponent<Text>();
- Icon = dic["Icon1"].GetComponent<Image>();
- Mark = dic["Icon2"].GetComponent<Image>();
- OriginSize = Icon.rectTransform.sizeDelta;
- Lab2.text = index.ToString();
- Coin = Auxiliary.IntParse(attribute[3].Value, 0);
- Diamond = Auxiliary.IntParse(attribute[2].Value, 0);
- FlowerList = Auxiliary.IntListParse(',', attribute[1].Value, new List<int>());
- RoundBuff = Auxiliary.FloatParse(attribute[4].Value, -1);
- SetUI();
- }
- public void Get()
- {
- Mark.SetActive(true);
- ManaSign.SignTime = ManaServer.Time;
- ManaSign.SignIndex++;
- if (ManaSign.SignIndex == 22)
- {
- ManaSign.SignIndex = 1;
- ManaSign.SignRound++;
- ManaReso.Get("B_SignIn").GetTweenCG().AddEventOnetime
- (
- EventType.BackwardFinish,
- () =>
- {
- foreach (var kv in ManaSign.SignDic)
- {
- kv.Value.SetUI();
- kv.Value.Mark.SetActive(false);
- }
- }
- );
- }
- if (FlowerList.Valid())
- {
- for (int i = 0; i < FlowerList.Count; i++)
- {
- FlowerInfo flowerInfo = ManaGarden.FlowerInfoDic[FlowerList[i]];
- if (flowerInfo.Unlock == false)
- {
- ManaReso.SetText("Bb_InfoLabA", flowerInfo.Name);
- ManaReso.SetActive("Bb_IconA", true);
- ManaReso.SetSprite("Bb_IconA0", flowerInfo.Icon);
-
- ManaReso.Get<Image>("Bb_IconA0").Resize(true, 0.65f, 0.65f);
- flowerInfo.Unlock = true;
- return;
- }
- }
- }
- if (Diamond > 0)
- {
- ManaReso.SetText("Bb_InfoLabB", Diamond.ToString());
- ManaReso.SetSprite("Bb_IconB", ManaReso.LoadSprite("钻石", Folder.UI));
- ManaReso.SetActive("Bb_IconB", true);
- ManaCenter.Diamond += Diamond;
- }
- else if (Coin > 0)
- {
- ManaReso.SetText("Bb_InfoLabB", Coin.ToString());
- ManaReso.SetSprite("Bb_IconB", ManaReso.LoadSprite("金币", Folder.UI));
- ManaReso.SetActive("Bb_IconB", true);
- ManaCenter.Coin += Coin;
- }
- else
- {
- throw new Exception();
- }
- }
- public void SetUI()
- {
- if (FlowerList.Valid())
- {
- for (int i = 0; i < FlowerList.Count; i++)
- {
- FlowerInfo flowerInfo = ManaGarden.FlowerInfoDic[FlowerList[i]];
- if (flowerInfo.Unlock == false)
- {
- Icon.sprite = flowerInfo.Icon;
- Icon.Resize(true, 0.2f, 0.2f);
- return;
- }
- }
- }
-
- if (Diamond > 0)
- {
- Icon.sprite = ManaReso.LoadSprite("钻石", Folder.UI);
- Icon.Resize(false, OriginSize);
- Lab1.text = Diamond.ToString();
- }
- else if (Coin > 0)
- {
- Icon.sprite = ManaReso.LoadSprite("金币", Folder.UI);
- Icon.Resize(false, OriginSize);
- Lab1.text = Coin.ToString();
- }
- }
- }
- public class ManaSign : Regist
- {
- #region 变量
- public static int SignIndex;
- public static int SignRound;
- public static DateTime SignTime;
- public static Dictionary<int, Sign> SignDic = new Dictionary<int, Sign>();
- #endregion
- public static void Get()
- {
- SignDic[SignIndex].Get();
- ManaCenter.SignAmt++;
- }
- public override void RegistValueB()
- {
- SignTime = DateTime.Parse(ManaData.GetPlayerString("SignTime"));
- SignIndex = ManaData.GetPlayerInt("SignIndex");
- SignRound = ManaData.GetPlayerInt("SignRound");
-
- Transform par = ManaReso.Get("Bb_Grid");
- List<XmlAttributeCollection> attributeList = ManaData.GetSignConfig();
- for (int i = 0; i < attributeList.Count; i++)
- {
- Transform tra = ManaReso.Get("SignItem", Folder.UI, false, par, false, ObjType.SignItem);
- SignDic.Add(i + 1, new Sign(i + 1, tra, attributeList[i]));
- }
- for (int i = 1; i < SignIndex; i++)
- {
- SignDic[i].Mark.SetActive(true);
- }
- }
- }
- #region DebugList
- //签到的循环与存档
- #endregion
|