123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513 |
- using UnityEngine;
- using System;
- using System.Xml;
- using System.Text;
- using System.Collections;
- using System.Collections.Generic;
- public class Pack : SkillRoot
- {
- #region 变量
- #region 配置
- public override string ID
- {
- get
- {
- return "Pack" + ID_;
- }
- }
- public override string Name
- {
- get
- {
- return Language.GetStr("SkillName", ID);
- }
- }
- public int MinUseLv;
- public int MaxUseLv;
- public float Person;
- public float SkillCD;
- public float UseAmt;
- public float CoinPerson;
- public float DiamondOnce;
- public string CoinFml;
- public float Plus;
- public float PersonBuff;
- public float SkillCdBuff;
- public string Label;
- public string Anim;
- public string Flower;
- public string[] Flowers;
- public string[] Diamonds;
- public Current BuyCur;
- #endregion
- public override int Level
- {
- get; set;
- }
- public override SkillStatus ItemStatus
- {
- get { return ItemStatus_; }
- set
- {
- ItemStatus_ = value;
- if (ItemStatus_ == SkillStatus.Buy)
- {
- ItemBtn.interactable = true;
- SkillItem.SetActive(true);
- ManaLan.Add(ItemBtnLab, new LanStr("UI", "Fe_BtnLab3"), "\n", Auxiliary.ImageParse(BuyCur), UseAmt.ToString("0"));
- }
- else if (ItemStatus_ == SkillStatus.Lock)
- {
- ItemBtn.interactable = false;
- SkillItem.SetActive(false);
- }
- }
- }
- #endregion
- public Pack(XmlAttributeCollection attribute)
- {
- #region 配置
- ID_ = int.Parse(attribute[0].Value);
- Icon_ = attribute[14].Value;
- Anim = attribute[15].Value;
- Label = attribute[16].Value;
- Flower = attribute[9].Value;
- CoinFml = attribute[7].Value;
- UseAmt = Auxiliary.FloatParse(attribute[12].Value,0);
- ItemIndex = Auxiliary.IntParse(attribute[3].Value,0);
- DiamondOnce = Auxiliary.FloatParse(attribute[8].Value,0);
-
- BuyCur = Auxiliary.CurrentParse(attribute[11].Value);
- SkillTab = SkillClassParse(attribute[2].Value);
- MinUseLv = MinLevelParse(attribute[10].Value);
- MaxUseLv = MaxLevelParse(attribute[10].Value);
- ValueBuffParse(out Person, out PersonBuff, attribute[5].Value);
- ValueBuffParse(out SkillCD, out SkillCdBuff, attribute[6].Value);
- ValueBuffParse(out CoinPerson, out Plus, attribute[4].Value);
- if (!string.IsNullOrEmpty(Flower))
- {
- Flowers = Flower.Split(' ')[0].Split(',');
- Diamonds = Flower.Split(' ')[1].Split(',');
- }
- #endregion
- SkillType = SkillType.Pack;
- }
- public override void AnnulA()
- {
- ManaCenter.SkillPlus -= Plus;
- ManaCenter.SkillPerson -= Person;
- ManaCenter.SkillPersonBuff -= PersonBuff;
- ManaCenter.SkillCoinPerson -= CoinPerson;
- if (!SkillCD.Equal(0))
- {
- for (int j = 0; j < ManaCenter.SkillList.Count; j++)
- {
- ManaCenter.SkillList[j].ReceiveCool(-SkillCD, false, false);
- }
- }
- if (!SkillCdBuff.Equal(0))
- {
- for (int j = 0; j < ManaCenter.SkillList.Count; j++)
- {
- ManaCenter.SkillList[j].ReceiveCool(-SkillCdBuff, false, true);
- }
- }
- }
- public override void Reactive()
- {
- //for (int i = 0; i < Level; i++)
- //{
- // AnnulA();
- //}
- }
- public override void RegistValue(bool firstRegist, float elapse, List<List<Skill>> useList, XmlAttributeCollection attribute)
- {
- if (!firstRegist)
- {
- return;
- }
- if (Application.platform == RuntimePlatform.IPhonePlayer) //todo 暂时关闭
- {
- if (BuyCur == Current.Cash)
- {
- return;
- }
- }
- Level = int.Parse(attribute[3].Value);
- ItemStatus_ = (SkillStatus)Enum.Parse(typeof(SkillStatus), attribute[2].Value);
- for (int i = 0; i < Level; i++)
- {
- UseA();
- }
- ItemBtn.onClick.RemoveAllListeners();
- ItemBtn.onClick.AddListener(OnClick);
- ItemLab.text = GetDescription(0);
- ManaLan.Add(ItemTit, new LanStr("SkillName", ID));
- ManaIAP.ProductDic.UniqueAdd(ID, PurchaseResult);
- ItemStatus = ItemStatus;
- }
- public override void RegistReference()
- {
- if (Application.platform == RuntimePlatform.IPhonePlayer) //todo 暂时关闭
- {
- if (BuyCur == Current.Cash)
- {
- return;
- }
- }
- base.RegistReference();
- }
- public override void UpdateStatus()
- {
- if (Application.platform == RuntimePlatform.IPhonePlayer) //todo 暂时关闭
- {
- if (BuyCur == Current.Cash)
- {
- return;
- }
- }
- if (!ManaCenter.Complete)
- {
- return;
- }
- ItemLab.text = GetDescription(0);
- if (MaxUseLv == MinUseLv)
- {
- ItemStatus = SkillStatus.Buy;
- }
- else
- {
- if (ManaCenter.Level > MaxUseLv || ManaCenter.Level < MinUseLv)
- {
- ItemStatus = SkillStatus.Lock;
- }
- else
- {
- ItemStatus = SkillStatus.Buy;
- }
- }
- }
- protected void UseB()
- {
- if (!string.IsNullOrEmpty(CoinFml))
- {
- ManaCenter.Coin += Auxiliary.FmlParse(CoinFml, "l", ManaCenter.Level.ToString(), "c", ManaCenter.CoinPerson.ToString("0.000"));
- }
- ManaCenter.Diamond += DiamondOnce;
- }
- protected void UseA()
- {
- if (!string.IsNullOrEmpty(Flower))
- {
- for (int i = 0; i < Flowers.Length; i++)
- {
- FlowerInfo flowerInfo = ManaGarden.FlowerInfoDic[int.Parse(Flowers[i])];
- if (!flowerInfo.Unlock)
- {
- flowerInfo.Unlock = true;
- }
- else
- {
- ManaCenter.Diamond += int.Parse(Diamonds[i]);
- }
- }
- }
- ManaCenter.SkillPlus += Plus;
- ManaCenter.SkillPerson += Person;
- ManaCenter.SkillPersonBuff += PersonBuff;
- ManaCenter.SkillCoinPerson += CoinPerson;
- if (!SkillCD.Equal(0))
- {
- for (int i = 0; i < ManaCenter.SkillList.Count; i++)
- {
- ManaCenter.SkillList[i].ReceiveCool(SkillCD, false, false);
- }
- }
- if (!SkillCdBuff.Equal(0))
- {
- for (int i = 0; i < ManaCenter.SkillList.Count; i++)
- {
- ManaCenter.SkillList[i].ReceiveCool(SkillCdBuff, false, true);
- }
- }
- }
- protected void OnClick()
- {
- ManaAudio.PlayClip(Clip.BtnClip);
- ManaReso.Get("Fe_Info").TweenForCG();
- ManaReso.SetText("Fe_Tit", Name);
- ManaReso.SetSprite("Fe_Icon", ItemIcon.sprite);
- if (ItemStatus == SkillStatus.Buy)
- {
- ManaReso.SetText("Fe_Lab0", "");
- ManaReso.SetText("Fe_Lab1", GetDescription(0));
- ManaReso.SetText("Fe_BtnLab", string.Format("{0}({1}{2:0})", Language.GetStr("UI", "Fe_BtnLab3"), Auxiliary.ImageParse(BuyCur), UseAmt));
- ManaReso.SetButtonEvent
- (
- "Fe_Btn",
- () =>
- {
- Purchase();
- ManaReso.Get("Fe_Info").TweenBacCG();
- }
- );
- }
- }
- protected void Purchase()
- {
- ManaAudio.PlayClip(Clip.BtnClip);
- ManaCenter.Pay(ID, UseAmt, BuyCur, PurchaseResult, StaticsManager.ItemID.购买礼包, StaticsManager.ConsumeModule.Charge);
- }
- protected void PurchaseResult()
- {
- int tempDiamond = (int) DiamondOnce;
- string tempFlower = "";
- if (!string.IsNullOrEmpty(Flower))
- {
- for (int i = 0; i < Flowers.Length; i++)
- {
- FlowerInfo flowerInfo = ManaGarden.FlowerInfoDic[int.Parse(Flowers[i])];
- if (flowerInfo.Unlock == false)
- {
- tempFlower += string.Format("{0}{1}{2} ", Language.GetStr("UI", "J_Info0"), "<(花朵)>", flowerInfo.Name);
- }
- else
- {
- tempDiamond += int.Parse(Diamonds[i]);
- }
- }
- }
- StringBuilder sb = new StringBuilder();
- if (!string.IsNullOrEmpty(CoinFml))
- {
- sb.AppendFormat("{0}{1}{2} ", Language.GetStr("UI", "J_Info0"), "<(金币)>", Auxiliary.FmlParse(CoinFml, "l", ManaCenter.Level.ToString(), "c", ManaCenter.CoinPerson.ToString("0.000")).ToString("0"));
- }
- if (!tempDiamond.Equal(0))
- {
- sb.AppendFormat("{0}{1}{2} ", Language.GetStr("UI", "J_Info0"), "<(钻石)>", tempDiamond);
- }
- if (!string.IsNullOrEmpty(tempFlower))
- {
- sb.Append(tempFlower);
- }
- string str = sb.ToString();
- if (!string.IsNullOrEmpty(str))
- {
- ManaInfo.Show(str, 10f);
- }
- Level++;
- ManaAudio.PlayClip(Clip.SkillClip);
- if (BuyCur == Current.Cash)
- {
- ManaServer.Save();
- }
- UseA();
- UseB();
- }
- #region 解读器
- protected int MinLevelParse(string str)
- {
- if (string.IsNullOrEmpty(str))
- {
- return 0;
- }
- else
- {
- return Auxiliary.IntParse(str.Split(',')[0],0);
- }
- }
- protected int MaxLevelParse(string str)
- {
- if (string.IsNullOrEmpty(str))
- {
- return 0;
- }
- else
- {
- return Auxiliary.IntParse(str.Split(',')[1],0);
- }
- }
- protected override 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 (!string.IsNullOrEmpty(CoinFml))
- {
- stringBuilder.Append(Auxiliary.FmlParse(CoinFml, "l", ManaCenter.Level.ToString(), "c", ManaCenter.CoinPerson.ToString("0.000")).ToString("0"));
- }
- #endregion
- }
- else if (strings[i].Contains("&flower&"))
- {
- #region MyRegion
- if (!string.IsNullOrEmpty(Flower))
- {
- for (int j = 0; j < Flowers.Length; j++)
- {
- stringBuilder.Append(Language.GetStr("FlowerName", "Flower" + Flowers[j]));
- if (j != Flowers.Length - 1)
- {
- stringBuilder.Append(",");
- }
- }
- }
- #endregion
- }
- else if (strings[i].Contains("&replace&"))
- {
- #region MyRegion
- if (!string.IsNullOrEmpty(Flower))
- {
- for (int j = 0; j < Diamonds.Length; j++)
- {
- stringBuilder.Append(int.Parse(Diamonds[j]));
- if (j != Diamonds.Length - 1)
- {
- stringBuilder.Append(",");
- }
- }
- }
- #endregion
- }
- else if (strings[i].Contains("&diamond&"))
- {
- #region MyRegion
- if (!DiamondOnce.Equal(0))
- {
- stringBuilder.Append(DiamondOnce.ToString("0"));
- }
- #endregion
- }
- else if (strings[i].Contains("&coin_person&"))
- {
- #region MyRegion
- if (!Plus.Equal(0))
- {
- stringBuilder.Append(string.Format("{0:0}%", Plus*100));
- }
- else if (!CoinPerson.Equal(0))
- {
- stringBuilder.Append(CoinPerson.ToString("0"));
- }
- #endregion
- }
- else
- {
- stringBuilder.Append(strings[i]);
- }
- }
-
- return stringBuilder.ToString();
- }
- #endregion
- }
|