123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510 |
- using UnityEngine;
- using System;
- using System.Xml;
- using System.Text;
- using System.Collections;
- using System.Collections.Generic;
- public class Pack : SkillRoot
- {
- #region Config
- #region 配置
- public override string FullID
- {
- get
- {
- return PackFullIDPrefix + ID;
- }
- }
- public override string Name
- {
- get
- {
- return Language.GetStr(LanguageLabel.CombineLanguageLabel(LanguageLabel.SkillName, FullID));
- }
- }
- public int MinUseLv;
- public int MaxUseLv;
- public float Person;
- public float SkillCD;
- public float UseAmt;
- public float CoinPerson;
- public float DiamondOnce;
- public bool Lock;
- 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 Current BuyCur;
- #endregion
- public override int Level
- {
- get; set;
- }
- public override SkillStatus ItemStatus
- {
- get { return itemStatus; }
- set
- {
- itemStatus = value;
- if (itemStatus == SkillStatus.Buy)
- {
- button.interactable = true;
- SkillItem.SetActive(true);
- if (!string.IsNullOrEmpty(Label))
- {
- LanguageManager.Add(ButtonTitle, new MulLanStr(LanguageLabel.CombineLanguageLabel(LanguageLabel.UI, Label)), "\n", Auxiliary.ImageParse(BuyCur), UseAmt.ToString("0"));
- }
- else
- {
- LanguageManager.Add(ButtonTitle, new MulLanStr(LanguageLabel.UI__Fe_BtnLab3), "\n", Auxiliary.ImageParse(BuyCur), UseAmt.ToString("0"));
- }
- }
- else if (itemStatus == SkillStatus.Lock)
- {
- button.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;
- Lock = Auxiliary.StringToBool(attribute[17].Value, false);
- UseAmt = Auxiliary.StringToFloat(attribute[12].Value,0);
- ItemIndex = Auxiliary.StringToInt(attribute[3].Value,0);
- DiamondOnce = Auxiliary.StringToFloat(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(',');
- }
- #endregion
- SkillType = SkillType.Pack;
- }
- public override void AnnulEffect()
- {
- Manager.SkillPlus -= Plus;
- Manager.SkillPerson -= Person;
- Manager.SkillPersonBuff -= PersonBuff;
- Manager.SkillCoinPerson -= CoinPerson;
- if (!SkillCD.Equal(0))
- {
- for (int j = 0; j < Manager.SkillList.Count; j++)
- {
- Manager.SkillList[j].Cool(-SkillCD, false, false);
- }
- }
- if (!SkillCdBuff.Equal(0))
- {
- for (int j = 0; j < Manager.SkillList.Count; j++)
- {
- Manager.SkillList[j].Cool(-SkillCdBuff, false, true);
- }
- }
- }
- public override void Reactive()
- {
- //for (int i = 0; i < Level; i++)
- //{
- // AnnulA();
- //}
- }
- public override void Init(bool firstInit, float elapse, List<List<Skill>> useList, XmlAttributeCollection attribute)
- {
- if (!firstInit)
- {
- return;
- }
- Level = int.Parse(attribute[3].Value);
- itemStatus = (SkillStatus)Enum.Parse(typeof(SkillStatus), attribute[2].Value);
- for (int i = 0; i < Level; i++)
- {
- GetBuff();
- }
- button.onClick.RemoveAllListeners();
- button.onClick.AddListener(OnClick);
- //if (!string.IsNullOrEmpty(Label))
- //{
- // ItemIcon1.SetActive(true);
- // ManaLan.Add(IconLab1, new LanStr("UI", Label));
- //}
- DescriptionText.text = GetDescription(0);
- LanguageManager.Add(TitleText, new MulLanStr(LanguageLabel.CombineLanguageLabel(LanguageLabel.SkillName, FullID)));
- IAPManager.BuyProductCallbackDictionary.UniqueAdd(FullID, ()=>OnBuySucceed());
- ItemStatus = ItemStatus;
- SetActive();
- }
- public override void UpdateStatus()
- {
- if (!Manager.Inited)
- {
- return;
- }
- if (Lock && HttpManager.BuyPackLimitFlag && Level >= 1)
- {
- return;
- }
- DescriptionText.text = GetDescription(0);
- if (MaxUseLv == MinUseLv)
- {
- ItemStatus = SkillStatus.Buy;
- }
- else
- {
- if (Manager.GardenLevel > MaxUseLv || Manager.GardenLevel < MinUseLv)
- {
- ItemStatus = SkillStatus.Lock;
- }
- else
- {
- ItemStatus = SkillStatus.Buy;
- }
- }
- }
- protected void GetBuff()
- {
- Manager.SkillPlus += Plus;
- Manager.SkillPerson += Person;
- Manager.SkillPersonBuff += PersonBuff;
- Manager.SkillCoinPerson += CoinPerson;
- if (!SkillCD.Equal(0))
- {
- for (int i = 0; i < Manager.SkillList.Count; i++)
- {
- Manager.SkillList[i].Cool(SkillCD, false, false);
- }
- }
- if (!SkillCdBuff.Equal(0))
- {
- for (int i = 0; i < Manager.SkillList.Count; i++)
- {
- Manager.SkillList[i].Cool(SkillCdBuff, false, true);
- }
- }
- }
- public void SetActive()
- {
- bool active = !(Lock && HttpManager.BuyPackLimitFlag);
- if (active)
- {
- button.interactable = true;
- ItemStatus = ItemStatus;
- }
- else
- {
- if (Level > 0)
- {
- button.interactable = false;
- LanguageManager.Add(ButtonTitle, Language.GetStr(LanguageLabel.UI__Fe_BtnLab9));
- }
- }
- }
- protected void OnClick()
- {
- AudioManager.PlayClip(AudioLabel.ClickButton);
- ResourceManager.Get(CanvasLabel.Fe_Info).TweenForCG();
- ResourceManager.SetText(CanvasLabel.Fe_Tit, Name);
- ResourceManager.SetSprite(CanvasLabel.Fe_Icon, SkillIcon.sprite);
- if (ItemStatus == SkillStatus.Buy)
- {
- ResourceManager.SetText(CanvasLabel.Fe_Lab0, "");
- ResourceManager.SetText(CanvasLabel.Fe_Lab1, GetDescription(0));
- ResourceManager.SetText(CanvasLabel.Fe_BtnLab, string.Format("{0}({1}{2:0})", Language.GetStr(LanguageLabel.UI__Fe_BtnLab3), Auxiliary.ImageParse(BuyCur), UseAmt));
- ResourceManager.SetButtonEvent
- (
- CanvasLabel.Fe_Btn,
- () =>
- {
- OnBuy();
- ResourceManager.Get(CanvasLabel.Fe_Info).TweenBacCG();
- }
- );
- }
- }
- protected void OnBuy()
- {
- AudioManager.PlayClip(AudioLabel.ClickButton);
- Manager.Pay(FullID, UseAmt, BuyCur, ()=> OnBuySucceed(), StaticsManager.ItemID.购买礼包, StaticsManager.ConsumeModule.Charge);
- }
- public void OnBuySucceed(bool getGift = true)
- {
- int tempCoin = 0;
- int tempDiamond = (int) DiamondOnce;
- Manager.AddDiamond(DiamondOnce, StaticsManager.ItemID.获得钻石, StaticsManager.ConsumeModule.Charge);
- string tempFlower = "";
- if (!string.IsNullOrEmpty(Flower))
- {
- for (int i = 0; i < Flowers.Length; i++)
- {
- FlowerInfo flowerInfo = GardenManager.FlowerInfoDictionary[int.Parse(Flowers[i])];
- flowerInfo.Add();
- tempFlower += string.Format("{0}{1}{2} ", Language.GetStr(LanguageLabel.UI__J_Info0), TransferLabel.FlowerSprite, flowerInfo.Name);
- }
- }
- StringBuilder sb = new StringBuilder();
- if (!string.IsNullOrEmpty(CoinFml))
- {
- int coin = (int) Auxiliary.FmlParse(CoinFml, "l", Manager.GardenLevel.ToString(), "c", Manager.CoinPerson.ToString("0.000"));
- Manager.AddCoin(coin, StaticsManager.ItemID.获得金币, StaticsManager.ConsumeModule.Shop);
- tempCoin += coin;
- }
- if (!tempCoin.Equal(0))
- {
- sb.AppendFormat("{0}{1}{2} ", Language.GetStr(LanguageLabel.UI__J_Info0), TransferLabel.CoinSprite, Auxiliary.ShrinkNumberStr(tempCoin));
- }
- if (!tempDiamond.Equal(0))
- {
- sb.AppendFormat("{0}{1}{2} ", Language.GetStr(LanguageLabel.UI__J_Info0), TransferLabel.DiamondSprite, Auxiliary.ShrinkNumberStr(tempDiamond));
- }
- if (!string.IsNullOrEmpty(tempFlower))
- {
- sb.Append(tempFlower);
- }
- string str = sb.ToString();
- if (!string.IsNullOrEmpty(str))
- {
- InfoBoxManager.GardenInfoBox.Display(str, 10f, Color.white, ResourceManager.LoadSprite("Atlas", Folder.Atlas));
- }
- Level++;
- AudioManager.PlayClip(AudioLabel.UseSkill);
- //if (BuyCur == Current.Cash)
- //{
- // HttpManager.UploadConfig();
- //}
- GetBuff();
- SetActive();
- if (getGift)
- {
- RechargeGiftManager.GetAllRechargeGiftAward(ID);
- }
- }
- protected int MinLevelParse(string str)
- {
- if (string.IsNullOrEmpty(str))
- {
- return 0;
- }
- else
- {
- return Auxiliary.StringToInt(str.Split(',')[0],0);
- }
- }
- protected int MaxLevelParse(string str)
- {
- if (string.IsNullOrEmpty(str))
- {
- return 0;
- }
- else
- {
- return Auxiliary.StringToInt(str.Split(',')[1],0);
- }
- }
- protected override string GetDescription(int offset)
- {
- string[] strings = Desc.Split(TransferLabel.OpenChar, TransferLabel.CloseChar);
-
- StringBuilder stringBuilder = new StringBuilder();
- for (int i = 0; i < strings.Length; i++)
- {
- if (strings[i].Contains(TransferLabel.Level))
- {
- }
- else if (strings[i].Contains(TransferLabel.Coin))
- {
- #region MyRegion
- if (!string.IsNullOrEmpty(CoinFml))
- {
- stringBuilder.Append(Auxiliary.FmlParse(CoinFml, "l", Manager.GardenLevel.ToString(), "c", Manager.CoinPerson.ToString("0.000")).ToString("0"));
- }
- #endregion
- }
- else if (strings[i].Contains(TransferLabel.Flower))
- {
- #region MyRegion
- if (!string.IsNullOrEmpty(Flower))
- {
- for (int j = 0; j < Flowers.Length; j++)
- {
- FlowerInfo flowerInfo = GardenManager.FlowerInfoDictionary[int.Parse(Flowers[j])];
- stringBuilder.Append(Language.GetStr(LanguageLabel.CombineLanguageLabel(LanguageLabel.FlowerName, flowerInfo.FullID)));
- if (j != Flowers.Length - 1)
- {
- stringBuilder.Append(",");
- }
- }
- }
- #endregion
- }
- else if (strings[i].Contains(TransferLabel.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(TransferLabel.Diamond))
- {
- #region MyRegion
- if (!DiamondOnce.Equal(0))
- {
- stringBuilder.Append(DiamondOnce.ToString("0"));
- }
- #endregion
- }
- else if (strings[i].Contains(TransferLabel.CoinPerson))
- {
- #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();
- }
- }
|