123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390 |
- using UnityEngine;
- using System;
- using System.Xml;
- using System.Text;
- using System.Collections;
- using System.Collections.Generic;
- public class Pack : SkillRoot
- {
- #region 变量
- #region 配置
- protected int Flower;
- protected int MinUseLv;
- protected int MaxUseLv;
- protected float Person;
- protected float SkillCD;
- protected float UseAmt;
- protected float CoinOnce;
- protected float CoinPerson;
- protected float DiamondOnce;
- protected float Plus;
- protected float PersonBuff;
- protected float SkillCdBuff;
- protected string Desc;
- protected string Label;
- protected string Anim;
- protected Current UseCur;
- #endregion
- public SkillStatus _ItemStatus;
- public SkillStatus ItemStatus
- {
- get { return _ItemStatus; }
- set
- {
- _ItemStatus = value;
- if (_ItemStatus == SkillStatus.Buy)
- {
- ItemBtn.interactable = true;
- ItemBtnLab.text = string.Format("购买\n{0}{1}", UseCur, UseAmt);
- }
- else if (_ItemStatus == SkillStatus.Lock)
- {
- ItemBtn.interactable = false;
- ItemBtnLab.text = string.Format("无法使用\n等级{0}-{1}", MinUseLv, MaxUseLv);
- }
- else
- {
- throw new Exception(_ItemStatus.ToString());
- }
- }
- }
- #endregion
- public Pack(XmlAttributeCollection attributes)
- {
- #region 配置
- Icon = attributes[14].Value;
- Desc = attributes[13].Value;
- Anim = attributes[15].Value;
- Label = attributes[16].Value;
- Name = attributes[1].Value;
- Flower = IntParse(attributes[9].Value);
- ClassID = IntParse(attributes[3].Value);
- UseAmt = FloatParse(attributes[12].Value);
- CoinOnce = FloatParse(attributes[7].Value);
- DiamondOnce = FloatParse(attributes[8].Value);
-
- Tab = SkillClassParse(attributes[2].Value);
- UseCur = CurrentParse(attributes[11].Value);
- MinUseLv = MinLevelParse(attributes[10].Value);
- MaxUseLv = MaxLevelParse(attributes[10].Value);
- ValueBuffParse(out Person, out PersonBuff, attributes[5].Value);
- ValueBuffParse(out SkillCD, out SkillCdBuff, attributes[6].Value);
- ValueBuffParse(out CoinPerson, out Plus, attributes[4].Value);
- #endregion
- SkillType = SkillType.Pack;
- }
- public override void RegistValue(double elapse, List<List<SkillRoot>> collectList)
- {
- ItemTit.text = Name;
- ItemLab.text = GetDescription(0);
- ItemBtn.onClick.AddListener(OnClick);
- for (int i = 0; i < Level; i++)
- {
- ManaLog.Log(string.Format("初始化<color=red>{0}</color> 等级 : {1}", Name, Level));
- Effect();
- }
- }
- public override void ReceiveCool(float amt, bool isCurrent, bool isBuff)
- {
-
- }
- public override void OnLevelChange()
- {
- if (MaxUseLv == MinUseLv)
- {
- ItemStatus = SkillStatus.Buy;
- }
- else
- {
- if (ManaData.Level > MaxUseLv || ManaData.Level < MinUseLv) //无法使用
- {
- ItemStatus = SkillStatus.Lock;
- }
- else
- {
- ItemStatus = SkillStatus.Buy;
- }
- }
- }
- protected void OnClick()
- {
- if (ManaData.Connect == false)
- {
- ManaReso.Get("Fg_Reconnect").TweenForCG();
- return;
- }
- ManaReso.Get("Fe_Info").TweenForCG();
- ManaReso.SetText("Fe_Tit", Name);
- if (MinUseLv != MaxUseLv) //有等级限制
- {
- ManaReso.SetText("Fe_Lab0", string.Format("{0}-{1}级可用", MinUseLv, MaxUseLv));
- ManaReso.SetActive("Fe_Lab0", true);
- }
- else
- {
- ManaReso.SetActive("Fe_Lab0", false);
- }
- if (ItemStatus == SkillStatus.Buy)
- {
- ManaReso.SetText("Fe_Lab1", GetDescription(0));
- ManaReso.SetText("Fe_BtnLab", string.Format("购买({0}{1})", UseCur, UseAmt));
- ManaReso.SetButtonEvent
- (
- "Fe_Btn",
- () =>
- {
- Use();
- ManaReso.Get("Fe_Info").TweenBacCG();
- }
- );
- }
- else
- {
- throw new Exception();
- }
- }
- protected virtual void Use()
- {
- if (ManaData.Pay(UseAmt, UseCur))
- {
- Effect();
- EffectOnce();
- Level++;
- #region 调试输出
- StringBuilder strb = new StringBuilder();
- strb.AppendFormat("使用技能 : <color=red>{0}</color>", Name);
- if (Math.Abs(Plus) > 0.0005f)
- {
- strb.AppendFormat(" 收入加成<color=red>+{0}%</color>", Plus * 100);
- }
- if (Math.Abs(Person) > 0.0005f)
- {
- strb.AppendFormat(" 参观人次<color=red>+{0}</color>", Person);
- }
- if (Math.Abs(PersonBuff) > 0.0005f)
- {
- strb.AppendFormat(" 参观人次<color=red>+{0}%</color>", PersonBuff * 100);
- }
- if (Math.Abs(CoinPerson) > 0.0005f)
- {
- strb.AppendFormat(" 每次金币<color=red>+{0}</color>", CoinPerson);
- }
- if (Math.Abs(SkillCD) > 0.0005f)
- {
- strb.AppendFormat(" 减少冷却上限<color=red>{0}</color>", SkillCD);
- }
- if (Math.Abs(SkillCdBuff) > 0.0005f)
- {
- strb.AppendFormat(" 减少冷却上限<color=red>{0}%</color>", SkillCdBuff * 100);
- }
- if (Math.Abs(CoinOnce) > 0.0005f)
- {
- strb.AppendFormat(" 获得金币<color=red>{0}</color>", CoinOnce);
- }
- if (Math.Abs(DiamondOnce) > 0.0005f)
- {
- strb.AppendFormat(" 获得钻石<color=red>{0}</color>", DiamondOnce);
- }
- strb.Append(" <color=red>永久有效</color>");
- ManaLog.Log(strb.ToString());
- #endregion
- }
- }
- public override bool DoUse()
- {
- return true;
- }
- protected void Effect()
- {
- ManaData.SkillPlus += Plus;
- ManaData.SkillPerson += Person;
- ManaData.SkillPersonBuff += PersonBuff;
- ManaData.SkillCoinPerson += CoinPerson;
- if (Math.Abs(SkillCD) > 0.0005f)
- {
- for (int i = 0; i < ManaData.SkillList.Count; i++)
- {
- ManaData.SkillList[i].ReceiveCool(SkillCD, false, false);
- }
- }
- if (Math.Abs(SkillCdBuff) > 0.0005f)
- {
- for (int i = 0; i < ManaData.SkillList.Count; i++)
- {
- ManaData.SkillList[i].ReceiveCool(SkillCdBuff, false, true);
- }
- }
- }
- protected void EffectOnce()
- {
- ManaData.Coin += CoinOnce;
- ManaData.Diamond += DiamondOnce;
- }
- #region 解读器
- private int MinLevelParse(string str)
- {
- if (string.IsNullOrEmpty(str))
- {
- return 0;
- }
- else
- {
- return IntParse(str.Split(',')[0]);
- }
- }
- private int MaxLevelParse(string str)
- {
- if (string.IsNullOrEmpty(str))
- {
- return 0;
- }
- else
- {
- return IntParse(str.Split(',')[1]);
- }
- }
- protected string GetDescription(int offset)
- {
- string[] strings = Desc.Split('[', ']');
- StringBuilder stringBuilder = new StringBuilder();
- for (int i = 0; i < strings.Length; i++)
- {
- if (strings[i].Contains("lv"))
- {
- }
- else if (strings[i].Contains("&coin&"))
- {
- #region MyRegion
- if (Math.Abs(CoinOnce) > 0.0005f)
- {
- stringBuilder.Append(CoinOnce);
- }
- else
- {
- }
- #endregion
- }
- else if (strings[i].Contains("&flower&"))
- {
- #region MyRegion
- if (Math.Abs(Flower) > 0.0005f)
- {
- stringBuilder.Append(Flower);
- }
- else
- {
- }
- #endregion
- }
- else if (strings[i].Contains("&diamond&"))
- {
- #region MyRegion
- if (Math.Abs(DiamondOnce) > 0.0005f)
- {
- stringBuilder.Append(DiamondOnce);
- }
- else
- {
- }
- #endregion
- }
- else if (strings[i].Contains("&coin_person&"))
- {
- #region MyRegion
- if (Math.Abs(Plus) > 0.0005f)
- {
- stringBuilder.Append(string.Format("{0}%", Plus*100));
- }
- else if (Math.Abs(CoinPerson) > 0.0005f)
- {
- stringBuilder.Append(CoinPerson);
- }
- else
- {
- }
- #endregion
- }
- else
- {
- stringBuilder.Append(strings[i]);
- }
- }
- return stringBuilder.ToString();
- } //得到说明
- #endregion
- }
|