using UnityEngine; using System.Collections; using System.Collections.Generic; using System.Linq; using TableConfig; using System; using Snxxz.UI; public class EquipmentInitialization { private int _equipIndex;//装备位置 private int _equipPartStarLV;//装备强化等级 private int _proficiency;//熟练度 public int EquipIndex { get { return _equipIndex; } set { _equipIndex = value; } } public int EquipPartStarLV { get { return _equipPartStarLV; } set { _equipPartStarLV = value; } } public int Proficiency { get { return _proficiency; } set { _proficiency = value; } } public EquipmentInitialization() { } public EquipmentInitialization(int equipIndex, int equipPartStarLV, int proficiency) { this._equipIndex = equipIndex; this._equipPartStarLV = equipPartStarLV; this._proficiency = proficiency; } } public class PlayerStrengthengDatas : Model, IBeforePlayerDataInitialize, IPlayerLoginOk { public Dictionary _EqInfo = new Dictionary();//接收服务器下发的数值 Dictionary DefineIndexDic = new Dictionary();//装备强化类型 Dictionary EquipMaxDic = new Dictionary();//装备强化最大上限强化类型 List listStrengtheningAll = new List();//用于全身装备属性 public Dictionary StrengthengRedPoint = new Dictionary();//强化部位红点 public delegate void Delegate_Ha3b3(HA3B3_tagMCEquipPartStarLVInfo info); public static event Delegate_Ha3b3 Event_Ha3b3; //事件刷新的委托 public static event Action RefreshEquipUpgradLvAct; public int MoneyMax = 0;//所需最大的钱数 public bool LevelAstrictBool = true; public int equipmentA = 0; PlayerPackModel _playerPack; PlayerPackModel playerPack { get { return _playerPack ?? (_playerPack = ModelCenter.Instance.GetModel()); } } PlayerStrengthengDatas m_StrengthengModel; PlayerStrengthengDatas strengthengmodel { get { return m_StrengthengModel ?? (m_StrengthengModel = ModelCenter.Instance.GetModel()); } } public class EquipRedDot { public int CurrentLevel;//当前等级 public int Money;//所需的钱数 } Dictionary DicEquip = new Dictionary(); public override void Init() { listStrengtheningAll = ConfigManager.Instance.GetAllKeys(); FuncConfigConfig funConfig = ConfigManager.Instance.GetTemplate("StrengthenLevelLimit"); DefineIndexDic = ConfigParse.GetDic(funConfig.Numerical2); EquipMaxDic = ConfigParse.GetDic(funConfig.Numerical1); } public override void UnInit() { } public void OnPlayerLoginOk() { playerPack.RefreshItemCountAct -= OnItemRefreshEvent; playerPack.ItemCntAddAct -= OnEquipRefreshEvent; FuncOpen.Instance.OnFuncStateChangeEvent -= OnFuncStateChange; playerPack.RefreshItemCountAct += OnItemRefreshEvent;//背包刷新 playerPack.ItemCntAddAct += OnEquipRefreshEvent;//角色装备刷新 FuncOpen.Instance.OnFuncStateChangeEvent += OnFuncStateChange; FuncConfigConfig StrengthenRedPointLevel = ConfigManager.Instance.GetTemplate("StrengthenRedPointLevel");//强化红点规则 string[] strStrengthenRedPointLevel = ConfigParse.GetMultipleStr(StrengthenRedPointLevel.Numerical1); StrengthengRedPointAdd(); ClassList.Clear(); for (int i = 0; i < strStrengthenRedPointLevel.Length; i++) { ClassList.Add(int.Parse(strStrengthenRedPointLevel[i])); } ClassList.Add(600); MoneyData(); int playerLv = PlayerDatas.Instance.baseData.LV; ulong copper = UIHelper.GetMoneyCnt(3); if (playerLv >= 150 && MoneyMax > (int)copper) { LevelAstrictBool = false; } } private void OnFuncStateChange(int obj) { if (obj == 1) { MoneyData(); } } public void OnBeforePlayerDataInitialize() { _EqInfo.Clear(); MoneyMax = 0; LevelAstrictBool = true; } private void OnEquipRefreshEvent(PackType type, int index, int id) { MoneyData(); } private void OnItemRefreshEvent(PackType type, int index, int id) { if (type == PackType.rptEquip) { MoneyData(); } } private const int RedPoint_key2 = 10601; public Redpoint redPointStre = new Redpoint(MainRedDot.RedPoint_key1, RedPoint_key2); public Redpoint StrengthRedpoint { get { return redPointStre; } } public void MoneyRequired(int EquippedWith, int EquipmentLevel)//获取最高阶所需的钱数 { int Type = GameDefineIndex(EquippedWith); ItemPlusConfig _tagItemPlue = ItemPlusConfig.GetTypeAndGrade(Type, EquipmentLevel); if (DicEquip.ContainsKey(EquippedWith)) { DicEquip[EquippedWith].CurrentLevel = EquipmentLevel; DicEquip[EquippedWith].Money = _tagItemPlue.costCount; } else { EquipRedDot _EquipRedDot = new EquipRedDot(); _EquipRedDot.CurrentLevel = EquipmentLevel; _EquipRedDot.Money = _tagItemPlue.costCount; DicEquip.Add(EquippedWith, _EquipRedDot); } MoneyData(); } public void MoneyData()//获取金钱数据 { equipmentA = 0; MoneyMax = ContrastObtain(); ulong copper = UIHelper.GetMoneyCnt(3); //redPointStre.state = RedPointState.None; foreach (int key in StrengthengRedPoint.Keys) { StrengthengRedPoint[key].state = RedPointState.None; } if (!FuncOpen.Instance.IsFuncOpen(1)) return; if (copper != 0 && MoneyMax != 0 && copper >= (ulong)MoneyMax) { // redPointStre.state = RedPointState.Simple; Lowest(); } } private int ContrastObtain() { MoneyMax = 0; SinglePackModel singlePack = playerPack.GetSinglePackModel(PackType.rptEquip); if (singlePack == null) return MoneyMax; foreach (var key in DicEquip.Keys) { ItemModel itemModel = singlePack.GetItemModelByIndex(key); if (itemModel != null) { ItemConfig _Item = ConfigManager.Instance.GetTemplate((int)itemModel.itemInfo.ItemID); ItemPlusMaxConfig _itemPM = new ItemPlusMaxConfig(); if (EquipMax(_Item.EquipPlace) != 3) { _itemPM = ItemPlusMaxConfig.GetEquipTypeAndPhaseColor(EquipMax(_Item.EquipPlace), _Item.LV, _Item.ItemColor); } else { _itemPM = ItemPlusMaxConfig.GetEquipTypeAndPhaseColor(EquipMax(_Item.EquipPlace), 0, 0); } if (_itemPM.levelMax > DicEquip[key].CurrentLevel) { if (DicEquip[key].Money > MoneyMax) { MoneyMax = DicEquip[key].Money; } } } } return MoneyMax; } public void OnEquipmentToStrengthen(HA3B3_tagMCEquipPartStarLVInfo info) { for (int i = 0; i < info.Count; i++) { if ((int)info.InfoList[i].EquipIndex > 0 && (int)info.InfoList[i].EquipIndex <= 10) { AddInfo(i, info); } } } public bool TheRatingPrompt(int ItemID)//评级提示 { ItemConfig _Item = ConfigManager.Instance.GetTemplate(ItemID); if (_EqInfo.ContainsKey(_Item.EquipPlace)) { int EqInfoLV = _EqInfo[_Item.EquipPlace].EquipPartStarLV;//装备等级 ItemPlusMaxConfig _itemPM = new ItemPlusMaxConfig(); if (EquipMax(_Item.EquipPlace) != 3) { _itemPM = ItemPlusMaxConfig.GetEquipTypeAndPhaseColor(EquipMax(_Item.EquipPlace), _Item.LV, _Item.ItemColor); } else { _itemPM = ItemPlusMaxConfig.GetEquipTypeAndPhaseColor(EquipMax(_Item.EquipPlace), 0, 0); } int MaxLV = _itemPM.levelMax; if (EqInfoLV >= MaxLV) return true; else return false; } return false; } public void AddInfo(int equipPlace, HA3B3_tagMCEquipPartStarLVInfo info)//装备位置 { int index = (int)info.InfoList[equipPlace].EquipIndex; MoneyRequired(index, (int)info.InfoList[equipPlace].EquipPartStarLV); if (_EqInfo.ContainsKey(index)) { _EqInfo[index].EquipIndex = index; bool isUpgrad = false; if ((int)info.InfoList[equipPlace].EquipPartStarLV > _EqInfo[index].EquipPartStarLV) { isUpgrad = true; } _EqInfo[index].EquipPartStarLV = (int)info.InfoList[equipPlace].EquipPartStarLV; _EqInfo[index].Proficiency = (int)info.InfoList[equipPlace].Proficiency; if (Event_Ha3b3 != null) Event_Ha3b3(info); if (isUpgrad && RefreshEquipUpgradLvAct != null) { RefreshEquipUpgradLvAct(index); } } else { EquipmentInitialization equip = new EquipmentInitialization(); equip.EquipIndex = index; equip.EquipPartStarLV = (int)info.InfoList[equipPlace].EquipPartStarLV; equip.Proficiency = (int)info.InfoList[equipPlace].Proficiency; _EqInfo.Add(index, equip); } } public int GameDefineIndex(int _location)//强化类型返回 { if (DefineIndexDic.ContainsKey(_location)) { return DefineIndexDic[_location]; } else { return 0; } } public int EquipMax(int _location)//强化最大上限返回类型 { if (EquipMaxDic.ContainsKey(_location)) { return EquipMaxDic[_location]; } else { return 0; } } public int StrengthenTheCeiling(int _equippedWith = 1)//装备位 { if (!_EqInfo.ContainsKey(_equippedWith)) { return 0; } int EquipPartStarLV = _EqInfo[_equippedWith].EquipPartStarLV; ItemModel itemModel = playerPack.GetItemModelByIndex(PackType.rptEquip, _equippedWith); ; ItemConfig _Item = ConfigManager.Instance.GetTemplate((int)itemModel.itemInfo.ItemID); ItemPlusMaxConfig _itemPM = new ItemPlusMaxConfig(); if (EquipMax(_Item.EquipPlace) != 3) { _itemPM = ItemPlusMaxConfig.GetEquipTypeAndPhaseColor(EquipMax(_Item.EquipPlace), _Item.LV, _Item.ItemColor); } else { _itemPM = ItemPlusMaxConfig.GetEquipTypeAndPhaseColor(EquipMax(_Item.EquipPlace), 0, 0); } if (_itemPM.levelMax >= EquipPartStarLV) { return EquipPartStarLV; } else { return _itemPM.levelMax; } } public Dictionary> StrengtheningAll()//全身属性 { Dictionary> _dic = new Dictionary>(); int _wholeBodyLevel = 0; foreach (int key in _EqInfo.Keys) { _wholeBodyLevel += _EqInfo[key].EquipPartStarLV; } for (int i = 0; i < listStrengtheningAll.Count; i++) { if (int.Parse(listStrengtheningAll[i]) > _wholeBodyLevel) { int _index = listStrengtheningAll.IndexOf(listStrengtheningAll[i]); _dic = GeneralProperties(_index, int.Parse(listStrengtheningAll[i])); return _dic; } } return null; } Dictionary> GeneralProperties(int _index, int key) { Dictionary> _dic = new Dictionary>(); if (_index <= 0) { Dictionary _dic1 = new Dictionary(); _dic.Add(0, _dic1); Dictionary _dic2 = new Dictionary(); var config = ConfigManager.Instance.GetTemplate(key); _dic2.Add(config.attType[0], config.attValue[0]); _dic2.Add(config.attType[1], config.attValue[1]); _dic.Add(key, _dic2); return _dic; } else { Dictionary _dic1 = new Dictionary(); var config = ConfigManager.Instance.GetTemplate(listStrengtheningAll[(_index - 1)]); _dic1.Add(config.attType[0], config.attValue[0]); _dic1.Add(config.attType[1], config.attValue[1]); _dic.Add(int.Parse(listStrengtheningAll[(_index - 1)]), _dic1); Dictionary _dic2 = new Dictionary(); config = ConfigManager.Instance.GetTemplate(key); _dic2.Add(config.attType[0], config.attValue[0]); _dic2.Add(config.attType[1], config.attValue[1]); _dic.Add(key, _dic2); return _dic; } } //==========装备红点 List StrengthList = new List(); private bool IsFairyDevice(int Index) { if (Index == 9 || Index == 10) { SinglePackModel singlePack = playerPack.GetSinglePackModel(PackType.rptEquip); if (singlePack != null && singlePack.GetPackModelIndexDict().ContainsKey(Index)) { ItemModel item = singlePack.GetItemModelByIndex(Index); ItemPlusMaxConfig _itemPM = new ItemPlusMaxConfig(); _itemPM = ItemPlusMaxConfig.GetEquipTypeAndPhaseColor(strengthengmodel.EquipMax(Index), 0, 0); if (_itemPM.levelMax > strengthengmodel._EqInfo[Index].EquipPartStarLV)//最大可升阶等级和服务端对比 { return true; } } } return false; } private int Compare(string x, string y)//数组排列 { var _index_x = int.Parse(x); var _index_y = int.Parse(y); bool havex = IsFairyDevice(_index_x); bool havey = IsFairyDevice(_index_y); if (havex.CompareTo(havey) != 0) { return -havex.CompareTo(havey); } var _sort_x = StrengthList.IndexOf(_index_x); var _sort_y = StrengthList.IndexOf(_index_y); return _sort_x.CompareTo(_sort_y); } private void StrengthengRedPointAdd() { string str = ConfigManager.Instance.GetTemplate("EquipArea").Numerical1; if (StrengthList.Count <= 0) { for (int i = 0; i < ConfigParse.GetMultipleStr(str).Length; i++) { StrengthList.Add(int.Parse(ConfigParse.GetMultipleStr(str)[i])); } } List SortList = new List(); for (int i = 0; i < ConfigParse.GetMultipleStr(str).Length; i++) { SortList.Add(ConfigParse.GetMultipleStr(str)[i]); } SortList.Sort(Compare); string[] StrengthenDisplay = SortList.ToArray(); for (int i = 0; i < StrengthenDisplay.Length; i++) { int equippedWith = int.Parse(StrengthenDisplay[i]); if (!StrengthengRedPoint.ContainsKey(equippedWith)) { int RedPoint_Strength = RedPoint_key2 * 10 + equippedWith; Redpoint redPoint = new Redpoint(RedPoint_key2, RedPoint_Strength); StrengthengRedPoint.Add(equippedWith, redPoint); } } } List ClassList = new List();//红点阶级 List equipmentRed = new List();//当前存在的装备 int LowestZbw = 0; private void Lowest()//筛选强化部位上最低阶级装备 { equipmentRed.Clear(); int LowestLV = 0; var StrengthengRedPointAllKey = StrengthengRedPoint.Keys; foreach (int key in StrengthengRedPointAllKey) { ItemModel itemModel = playerPack.GetItemModelByIndex(PackType.rptEquip, key); if (itemModel != null) { ItemConfig _Item = ConfigManager.Instance.GetTemplate((int)itemModel.itemInfo.ItemID); ItemPlusMaxConfig _itemPM = new ItemPlusMaxConfig(); if (EquipMax(_Item.EquipPlace) != 3) { _itemPM = ItemPlusMaxConfig.GetEquipTypeAndPhaseColor(EquipMax(_Item.EquipPlace), _Item.LV, _Item.ItemColor); } else { _itemPM = ItemPlusMaxConfig.GetEquipTypeAndPhaseColor(EquipMax(_Item.EquipPlace), 0, 0); } if (_itemPM.levelMax > DicEquip[key].CurrentLevel) { if (LowestLV == 0) { LowestLV = DicEquip[key].CurrentLevel; LowestZbw = key; } if (DicEquip[key].CurrentLevel < LowestLV) { LowestLV = DicEquip[key].CurrentLevel; LowestZbw = key; } equipmentRed.Add(key); } } } //DesignDebug.LogError(LowestZbw); //DesignDebug.LogError(DicEquip[LowestZbw].CurrentLevel); int Lv = ClassifyJudge(DicEquip[LowestZbw].CurrentLevel); RedPointPart(Lv); } private int ClassifyJudge(int Lv) { for (int i = 0; i < ClassList.Count; i++) { if (Lv < ClassList[i]) { return ClassList[i]; } } return 0; } private void RedPointPart(int Lv) { //DesignDebug.LogError("得到限制等级"+ Lv); for (int i = 0; i < equipmentRed.Count; i++) { if (_EqInfo.ContainsKey(equipmentRed[i]) && _EqInfo[(equipmentRed[i])].EquipPartStarLV < Lv && LevelAstrictBool) { equipmentA = equipmentRed[i]; StrengthengRedPoint[(equipmentRed[i])].state = RedPointState.Simple; // DesignDebug.LogError("得到装备位" + (equipmentRed[i])); return; } } } //===========羽翼精炼 Dictionary _DicWingRe = new Dictionary(); class WingRefineAttrModel { public int Ability1;//属性值1 public int Ability1Value;//数值1 public int Ability2;//属性值2 public int Ability2Value;//数值2 } void WingRefine()//精炼属性 { var tegWing = ConfigManager.Instance.GetAllValues(); foreach (var values in tegWing) { if (!_DicWingRe.ContainsKey(values.wingsPhase)) { WingRefineAttrModel _wingRefineAttrModel = new WingRefineAttrModel(); int[] array = ConfigParse.GetKeyValueKeys(values.attrupper); int[] intarray = ConfigParse.GetKeyValueValues(values.attrupper); _wingRefineAttrModel.Ability1 = array[0]; _wingRefineAttrModel.Ability2 = array[1]; _wingRefineAttrModel.Ability1Value = intarray[0]; _wingRefineAttrModel.Ability2Value = intarray[1]; _DicWingRe.Add(values.wingsPhase, _wingRefineAttrModel); } } } public float[] BackpackWings(int ItemID, int _Refining)//用于背包 翅膀(1.翅膀ID,2.精炼值) { WingRefine(); int _currentRefiningAll = 0;//总精炼度 ItemConfig Item = ConfigManager.Instance.GetTemplate(ItemID); var configs = ConfigManager.Instance.GetAllValues(); foreach (var values in configs) { if (Item.LV == values.wingsPhase) { _currentRefiningAll = values.EXPupper;//总精炼度 if (_Refining >= _currentRefiningAll) { _Refining = _currentRefiningAll; } } } float _RefiningRatio = (float)_Refining / _currentRefiningAll;//精炼比值 float _RefiningDegrees = _DicWingRe[Item.LV].Ability2Value * _RefiningRatio; float _life = _DicWingRe[Item.LV].Ability1Value * _RefiningRatio; float[] _floList = new float[2]; _floList[0] = _RefiningDegrees; _floList[1] = _life; return _floList; } public bool IsHint(int ID) { if (ConfigManager.Instance.GetTemplate(ID) == null) { return false; } ItemModel itemModel = playerPack.GetItemModelByIndex(PackType.rptEquip, (int)RoleEquipType.retWing); if (itemModel.GetUseDataModel((int)ItemUseDataKey.Def_IudetWingProgressValue) != null) { int currentRefining = 0; int currentReAll = 0; currentRefining = itemModel.GetUseDataModel((int)ItemUseDataKey.Def_IudetWingProgressValue)[0];//当前精炼度 var wingRefineAttrConfigs = ConfigManager.Instance.GetAllValues(); foreach (var value in wingRefineAttrConfigs) { if (itemModel.chinItemModel.LV == value.wingsPhase) { currentReAll = value.EXPupper;//总精炼度 } } if (currentReAll > currentRefining) { return true; } else { return false; } } else { return false; } } }