| New file |
| | |
| | | using System.Collections; |
| | | using System.Collections.Generic; |
| | | using UnityEngine; |
| | | |
| | | |
| | | namespace Snxxz.UI |
| | | { |
| | | |
| | | public class EquipFightPower : Singleton<EquipFightPower> |
| | | { |
| | | |
| | | PackModel packModel { get { return ModelCenter.Instance.GetModel<PackModel>(); } } |
| | | EquipModel equipModel { get { return ModelCenter.Instance.GetModel<EquipModel>(); } } |
| | | EquipStarModel starModel { get { return ModelCenter.Instance.GetModel<EquipStarModel>(); } } |
| | | EquipTrainModel trainModel { get { return ModelCenter.Instance.GetModel<EquipTrainModel>(); } } |
| | | EquipStrengthModel strengthenModel { get { return ModelCenter.Instance.GetModel<EquipStrengthModel>(); } } |
| | | EquipGemModel gemModel { get { return ModelCenter.Instance.GetModel<EquipGemModel>(); } } |
| | | |
| | | string scoreFormula; |
| | | string propertyFormula; |
| | | |
| | | public EquipFightPower() |
| | | { |
| | | var config = FuncConfigConfig.Get("FightpowerFormula"); |
| | | propertyFormula = config.Numerical1; |
| | | scoreFormula = config.Numerical2; |
| | | } |
| | | |
| | | public int CalculatePower(int level) |
| | | { |
| | | Equation.Instance.Clear(); |
| | | Equation.Instance.AddKeyValue("equipScoreTotal", CountEquipScore(level)); |
| | | var power = 0; |
| | | power = Equation.Instance.Eval<int>(scoreFormula); |
| | | |
| | | var propertyContainer = new Properties(); |
| | | CountProperties(level, ref propertyContainer); |
| | | |
| | | Equation.Instance.Clear(); |
| | | var keys = propertyContainer.keys; |
| | | for (int i = 0; i < keys.Count; i++) |
| | | { |
| | | var id = keys[i]; |
| | | var value = propertyContainer[id]; |
| | | var config = PlayerPropertyConfig.Get(id); |
| | | Equation.Instance.AddKeyValue(config.Parameter, value); |
| | | } |
| | | |
| | | power += Equation.Instance.Eval<int>(propertyFormula); |
| | | |
| | | var skillIds = CountEightSuitSkills(level); |
| | | if (!skillIds.IsNullOrEmpty()) |
| | | { |
| | | foreach (var skillId in skillIds) |
| | | { |
| | | var config = SkillConfig.Get(skillId); |
| | | power += config.FightPower; |
| | | } |
| | | } |
| | | |
| | | return power; |
| | | } |
| | | |
| | | private int CountEquipScore(int level) |
| | | { |
| | | var score = 0; |
| | | for (int i = 1; i <= 12; i++) |
| | | { |
| | | var equipPosition = new Int2(level, i); |
| | | var guid = equipModel.GetEquip(equipPosition); |
| | | if (string.IsNullOrEmpty(guid)) |
| | | { |
| | | continue; |
| | | } |
| | | |
| | | var equip = packModel.GetItemByGuid(guid); |
| | | if (equip == null) |
| | | { |
| | | continue; |
| | | } |
| | | |
| | | score += equip.score; |
| | | } |
| | | |
| | | return score; |
| | | } |
| | | |
| | | private List<int> CountEightSuitSkills(int level) |
| | | { |
| | | var skills = new List<int>(); |
| | | |
| | | var eightSuitLevel = equipModel.GetSuitLevel(level, EquipSuitType.EightSuit); |
| | | List<EquipSuitConfig> eightConfigs = null; |
| | | if (eightSuitLevel >= 0) |
| | | { |
| | | eightConfigs = EquipSuitConfig.GetConfigs(PlayerDatas.Instance.baseData.Job, level, EquipSuitType.EightSuit); |
| | | } |
| | | |
| | | for (int i = 9; i >= 0; i--) |
| | | { |
| | | if (i % 3 != 0) |
| | | { |
| | | continue; |
| | | } |
| | | |
| | | if (eightSuitLevel >= i) |
| | | { |
| | | var config = eightConfigs.Find(x => { return x.star == i; }); |
| | | if (config.skillID > 0) |
| | | { |
| | | skills.Add(config.skillID); |
| | | } |
| | | } |
| | | } |
| | | |
| | | return skills; |
| | | } |
| | | |
| | | private void CountProperties(int level, ref Properties container) |
| | | { |
| | | CountSuitProperties(level, ref container); |
| | | CountStrengthenProperties(level, ref container); |
| | | CountStarProperties(level, ref container); |
| | | CountGemProperties(level, ref container); |
| | | CountTrainProperties(level, ref container); |
| | | } |
| | | |
| | | private void CountSuitProperties(int level, ref Properties container) |
| | | { |
| | | var twoSuitLevel = equipModel.GetSuitLevel(level, EquipSuitType.TwoSuit); |
| | | var fiveSuitLevel = equipModel.GetSuitLevel(level, EquipSuitType.FiveSuit); |
| | | var eightSuitLevel = equipModel.GetSuitLevel(level, EquipSuitType.EightSuit); |
| | | |
| | | List<EquipSuitConfig> twoConfigs = null; |
| | | if (twoSuitLevel >= 0) |
| | | { |
| | | twoConfigs = EquipSuitConfig.GetConfigs(PlayerDatas.Instance.baseData.Job, level, EquipSuitType.TwoSuit); |
| | | } |
| | | |
| | | List<EquipSuitConfig> fiveConfigs = null; |
| | | if (fiveSuitLevel >= 0) |
| | | { |
| | | fiveConfigs = EquipSuitConfig.GetConfigs(PlayerDatas.Instance.baseData.Job, level, EquipSuitType.FiveSuit); |
| | | } |
| | | |
| | | List<EquipSuitConfig> eightConfigs = null; |
| | | if (eightSuitLevel >= 0) |
| | | { |
| | | eightConfigs = EquipSuitConfig.GetConfigs(PlayerDatas.Instance.baseData.Job, level, EquipSuitType.EightSuit); |
| | | } |
| | | |
| | | for (int i = 9; i >= 0; i--) |
| | | { |
| | | if (i % 3 != 0) |
| | | { |
| | | continue; |
| | | } |
| | | |
| | | if (twoSuitLevel >= i) |
| | | { |
| | | var config = twoConfigs.Find(x => { return x.star == i; }); |
| | | foreach (var property in config.attr) |
| | | { |
| | | container.Add(property.x, property.y); |
| | | } |
| | | } |
| | | |
| | | if (fiveSuitLevel >= i) |
| | | { |
| | | var config = fiveConfigs.Find(x => { return x.star == i; }); |
| | | foreach (var property in config.attr) |
| | | { |
| | | container.Add(property.x, property.y); |
| | | } |
| | | } |
| | | |
| | | if (eightSuitLevel >= i) |
| | | { |
| | | var config = eightConfigs.Find(x => { return x.star == i; }); |
| | | foreach (var property in config.attr) |
| | | { |
| | | container.Add(property.x, property.y); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | private void CountStrengthenProperties(int level, ref Properties container) |
| | | { |
| | | for (int i = 1; i <= 12; i++) |
| | | { |
| | | var equipPosition = new Int2(level, i); |
| | | var equip = equipModel.GetEquip(equipPosition); |
| | | if (string.IsNullOrEmpty(equip)) |
| | | { |
| | | continue; |
| | | } |
| | | |
| | | var values = strengthenModel.GetEquipValueList(level, i); |
| | | foreach (var item in values) |
| | | { |
| | | container.Add(item.AttType, item.AttValue); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private void CountStarProperties(int level, ref Properties container) |
| | | { |
| | | for (int i = 1; i <= 12; i++) |
| | | { |
| | | var equipPosition = new Int2(level, i); |
| | | var equip = equipModel.GetEquip(equipPosition); |
| | | if (string.IsNullOrEmpty(equip)) |
| | | { |
| | | continue; |
| | | } |
| | | |
| | | var star = starModel.GetEquipStarLevel(equipPosition); |
| | | var config = EquipStarConfig.Get(equipPosition.x, equipPosition.y, star); |
| | | if (config == null) |
| | | { |
| | | continue; |
| | | } |
| | | |
| | | foreach (var property in config.BaseAttrInfo) |
| | | { |
| | | container.Add(property.x, property.y); |
| | | } |
| | | |
| | | foreach (var property in config.StarAttrInfo) |
| | | { |
| | | container.Add(property.x, property.y); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | private void CountGemProperties(int level, ref Properties container) |
| | | { |
| | | for (int i = 1; i <= 12; i++) |
| | | { |
| | | var equipPosition = new Int2(level, i); |
| | | var equip = equipModel.GetEquip(equipPosition); |
| | | if (string.IsNullOrEmpty(equip)) |
| | | { |
| | | continue; |
| | | } |
| | | |
| | | for (int holeIndex = 0; holeIndex < 4; holeIndex++) |
| | | { |
| | | if (gemModel.IsEquipGemHoleOpen(equipPosition.x, equipPosition.y, holeIndex)) |
| | | { |
| | | continue; |
| | | } |
| | | |
| | | var gem = 0; |
| | | if (!gemModel.TryGetEquipGem(equipPosition.x, equipPosition.y, holeIndex, out gem)) |
| | | { |
| | | continue; |
| | | } |
| | | |
| | | var itemConfig = ItemConfig.Get(gem); |
| | | if (itemConfig.Effect2 > 0) |
| | | { |
| | | container.Add(itemConfig.Effect2, itemConfig.EffectValueA2); |
| | | } |
| | | |
| | | if (itemConfig.Effect3 > 0) |
| | | { |
| | | container.Add(itemConfig.Effect3, itemConfig.EffectValueA3); |
| | | } |
| | | |
| | | if (itemConfig.Effect4 > 0) |
| | | { |
| | | container.Add(itemConfig.Effect4, itemConfig.EffectValueA4); |
| | | } |
| | | |
| | | if (itemConfig.Effect5 > 0) |
| | | { |
| | | container.Add(itemConfig.Effect5, itemConfig.EffectValueA5); |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | private void CountTrainProperties(int level, ref Properties container) |
| | | { |
| | | for (int i = 1; i <= 12; i++) |
| | | { |
| | | var equipPosition = new Int2(level, i); |
| | | var equip = equipModel.GetEquip(equipPosition); |
| | | if (string.IsNullOrEmpty(equip)) |
| | | { |
| | | continue; |
| | | } |
| | | |
| | | var trainLevel = trainModel.GetTrainLevel(equipPosition); |
| | | if (trainLevel <= 0) |
| | | { |
| | | continue; |
| | | } |
| | | |
| | | var type = EquipTrainModel.GetTrainType(equipPosition.y); |
| | | var data = EquipWashConfig.Get(type, trainLevel); |
| | | if (data == null) |
| | | { |
| | | continue; |
| | | } |
| | | |
| | | var trainedProperties = trainModel.GetTrainedProperties(equipPosition); |
| | | container.Add(data.config.attType1, Mathf.Min(data.config.attMax1, trainedProperties.x)); |
| | | container.Add(data.config.attType2, Mathf.Min(data.config.attMax2, trainedProperties.y)); |
| | | container.Add(data.config.attType3, Mathf.Min(data.config.attMax3, trainedProperties.z)); |
| | | } |
| | | |
| | | } |
| | | |
| | | class Properties |
| | | { |
| | | Dictionary<int, int> tables = new Dictionary<int, int>(); |
| | | |
| | | public List<int> keys { get { return new List<int>(tables.Keys); } } |
| | | |
| | | public int this[int id] { get { return tables[id]; } } |
| | | |
| | | public void Add(int id, int value) |
| | | { |
| | | if (id == 7) |
| | | { |
| | | Add(65, value); |
| | | Add(66, value); |
| | | } |
| | | else |
| | | { |
| | | if (tables.ContainsKey(id)) |
| | | { |
| | | tables[id] = tables[id] + value; |
| | | } |
| | | else |
| | | { |
| | | tables[id] = value; |
| | | } |
| | | } |
| | | } |
| | | |
| | | public void AddRange(List<int> ids, List<int> values) |
| | | { |
| | | if (ids.IsNullOrEmpty() || values.IsNullOrEmpty()) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | var count = Mathf.Min(ids.Count, values.Count); |
| | | for (int i = 0; i < count; i++) |
| | | { |
| | | Add(ids[i], values[i]); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | | |