using Snxxz.UI; using System; using System.Collections.Generic; using TableConfig; public class WashProModel : Model { EquipWashModel _equipWashModel; public EquipWashModel equipWashModel { get { return _equipWashModel ?? (_equipWashModel = ModelCenter.Instance.GetModel()); } } private Dictionary washAttrModelDict = new Dictionary(); public override void Init() { } public override void UnInit() { } public void SetUIModel(EquipWashConfig washModel, WashProCount washPro,WashAttrType type) { SingleWashAttrModel washAttrModel = new SingleWashAttrModel(); washAttrModel.SetModel(washModel, washPro, type); if (!washAttrModelDict.ContainsKey(type)) { washAttrModelDict.Add(type,washAttrModel); } else { washAttrModelDict[type] = washAttrModel; } } public SingleWashAttrModel GetSingleWashAttrModel(WashAttrType type) { SingleWashAttrModel washAttrModel = null; washAttrModelDict.TryGetValue(type,out washAttrModel); return washAttrModel; } } public class SingleWashAttrModel { public WashAttrType attrType { get; private set;} public EquipWashConfig tagWashModel { get; private set; } public WashProCount washPro { get; private set; } public bool isPerfect { get; private set; } public PlayerPropertyConfig playerProModel { get; private set; } private float _minValue = 0; public float minValue { get; private set;} public float maxValue { get; private set; } public float XLAttrValue { get; private set; } public float XLAttrChange { get; private set; } public float addAttrValue { get; private set; } public WashState washState { get; private set; } public string preViewStr { get; private set; } public string attrName { get; private set; } private EquipWashConfig _preTagWashModel; public int preWashAttrMax { get; private set; } public void SetModel(EquipWashConfig washModel, WashProCount washPro,WashAttrType attrType) { this.attrType = attrType; this.tagWashModel = washModel; this.washPro = washPro; this.isPerfect = false; this.preViewStr = ""; this._preTagWashModel = EquipWashConfig.GetCurrentWashEquipModel(washModel.type, washPro.XLAttrLV -1); switch (attrType) { case WashAttrType.attack: this.maxValue = tagWashModel.attMax1; this.XLAttrValue = washPro.proValuelist[0].XLAttrValue; this.XLAttrChange = washPro.proValuelist[0].XLAttrChange; this.addAttrValue = washPro.proValuelist[0].addAttrValue; this.playerProModel = Config.Instance.Get(washModel.attType1); this.preViewStr = GetAddProRange(tagWashModel.attCostMoneyMin1, tagWashModel.attCostMoneyMax1); this.washState = washPro.proValuelist[0].washState; if (this._preTagWashModel == null) preWashAttrMax = 0; else preWashAttrMax = this._preTagWashModel.attMax1; this.minValue = preWashAttrMax; if (washPro.proValuelist[0].XLAttrValue >= tagWashModel.attMax1) this.isPerfect = true; break; case WashAttrType.life: this.maxValue = tagWashModel.attMax2; this.XLAttrValue = washPro.proValuelist[1].XLAttrValue; this.XLAttrChange = washPro.proValuelist[1].XLAttrChange; this.addAttrValue = washPro.proValuelist[1].addAttrValue; this.washState = washPro.proValuelist[1].washState; this.playerProModel = Config.Instance.Get(washModel.attType2); this.preViewStr = GetAddProRange(tagWashModel.attCostMoneyMin2, tagWashModel.attCostMoneyMax2); if (this._preTagWashModel == null) preWashAttrMax = 0; else preWashAttrMax = this._preTagWashModel.attMax2; this.minValue = preWashAttrMax; if (washPro.proValuelist[1].XLAttrValue >= tagWashModel.attMax2) this.isPerfect = true; break; case WashAttrType.ignoredefence: this.maxValue = tagWashModel.attMax3; this.XLAttrValue = washPro.proValuelist[2].XLAttrValue; this.XLAttrChange = washPro.proValuelist[2].XLAttrChange; this.addAttrValue = washPro.proValuelist[2].addAttrValue; this.washState = washPro.proValuelist[2].washState; this.playerProModel = Config.Instance.Get(washModel.attType3); this.preViewStr = GetAddProRange(tagWashModel.attCostMoneyMin3, tagWashModel.attCostMoneyMax3); if (this._preTagWashModel == null) preWashAttrMax = 0; else preWashAttrMax = this._preTagWashModel.attMax3; this.minValue = preWashAttrMax; if (washPro.proValuelist[2].XLAttrValue >= tagWashModel.attMax3) this.isPerfect = true; break; } this.attrName = GetAttrNameStr(); } private string GetAddProRange(int minValue, int maxValue) { string strRange = ""; if(maxValue != minValue) { strRange = StringUtility.Contact("+", GetProValueTypeStr(minValue), "~", GetProValueTypeStr(maxValue)); } else { strRange = StringUtility.Contact("+", GetProValueTypeStr(minValue)); } return strRange; } private string GetProValueTypeStr(float value) { string s = ""; if (playerProModel.ISPercentage == 0) { s = value.ToString(); } else if (playerProModel.ISPercentage == 1) { s = (float)Math.Round(value / 100f, 1) + "%"; } else if (playerProModel.ISPercentage == 2) { s = ((float)Math.Round(value / 100f, 1)).ToString(); } return s; } private string GetAttrNameStr() { string proName = ""; if (playerProModel.Name.Length == 2) { for (int i = 0; i < playerProModel.Name.Length; i++) { if (i < playerProModel.Name.Length - 1) { proName += playerProModel.Name[i] + " "; } else { proName += playerProModel.Name[i] + ":"; } } } else if (playerProModel.Name.Length == 4) { proName = playerProModel.Name + ":"; } return proName; } } public enum WashAttrType { attack = 0, life = 1, ignoredefence = 2, }