using UnityEngine;
|
using System.Collections;
|
using System.Collections.Generic;
|
using System.Linq;
|
|
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<int, EquipmentInitialization> _EqInfo = new Dictionary<int, EquipmentInitialization>();//接收服务器下发的数值
|
Dictionary<int, int> DefineIndexDic = new Dictionary<int, int>();//装备强化类型
|
Dictionary<int, int> EquipMaxDic = new Dictionary<int, int>();//装备强化最大上限强化类型
|
List<string> listStrengtheningAll = new List<string>();//用于全身装备属性
|
public Dictionary<int, Redpoint> StrengthengRedPoint = new Dictionary<int, Redpoint>();//强化部位红点
|
public delegate void Delegate_Ha3b3(HA3B3_tagMCEquipPartStarLVInfo info);
|
public static event Delegate_Ha3b3 Event_Ha3b3; //事件刷新的委托
|
public static event Action<int> RefreshEquipUpgradLvAct;
|
public int MoneyMax = 0;//所需最大的钱数
|
|
|
public bool LevelAstrictBool = true;
|
public int equipmentA = 0;
|
PackModel _playerPack;
|
PackModel playerPack
|
{
|
get { return _playerPack ?? (_playerPack = ModelCenter.Instance.GetModel<PackModel>()); }
|
}
|
PlayerStrengthengDatas m_StrengthengModel;
|
PlayerStrengthengDatas strengthengmodel { get { return m_StrengthengModel ?? (m_StrengthengModel = ModelCenter.Instance.GetModel<PlayerStrengthengDatas>()); } }
|
public class EquipRedDot
|
{
|
public int CurrentLevel;//当前等级
|
public int Money;//所需的钱数
|
}
|
Dictionary<int, EquipRedDot> DicEquip = new Dictionary<int, EquipRedDot>();
|
public override void Init()
|
{
|
listStrengtheningAll = ItemPlusSumAttrConfig.GetKeys();
|
FuncConfigConfig funConfig = FuncConfigConfig.Get("StrengthenLevelLimit");
|
|
DefineIndexDic = ConfigParse.GetDic<int, int>(funConfig.Numerical2);
|
EquipMaxDic = ConfigParse.GetDic<int, int>(funConfig.Numerical1);
|
|
|
|
}
|
|
public override void UnInit()
|
{
|
|
}
|
|
public void OnPlayerLoginOk()
|
{
|
|
playerPack.refreshItemCountEvent -= OnItemRefreshEvent;
|
playerPack.itemCntAddEvent -= OnEquipRefreshEvent;
|
FuncOpen.Instance.OnFuncStateChangeEvent -= OnFuncStateChange;
|
|
playerPack.refreshItemCountEvent += OnItemRefreshEvent;//背包刷新
|
playerPack.itemCntAddEvent += OnEquipRefreshEvent;//角色装备刷新
|
FuncOpen.Instance.OnFuncStateChangeEvent += OnFuncStateChange;
|
|
FuncConfigConfig StrengthenRedPointLevel = FuncConfigConfig.Get("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.Equip)
|
{
|
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;
|
SinglePack singlePack = playerPack.GetSinglePack(PackType.Equip);
|
if (singlePack == null)
|
return MoneyMax;
|
|
foreach (var key in DicEquip.Keys)
|
{
|
ItemModel itemModel = singlePack.GetItemByIndex(key);
|
if (itemModel != null)
|
{
|
ItemConfig _Item = ItemConfig.Get((int)itemModel.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 = ItemConfig.Get(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.GetItemByIndex(PackType.Equip, _equippedWith);
|
;
|
ItemConfig _Item = ItemConfig.Get((int)itemModel.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<int, Dictionary<int, int>> StrengtheningAll()//全身属性
|
{
|
Dictionary<int, Dictionary<int, int>> _dic = new Dictionary<int, Dictionary<int, int>>();
|
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<int, Dictionary<int, int>> GeneralProperties(int _index, int key)
|
{
|
Dictionary<int, Dictionary<int, int>> _dic = new Dictionary<int, Dictionary<int, int>>();
|
if (_index <= 0)
|
{
|
Dictionary<int, int> _dic1 = new Dictionary<int, int>();
|
_dic.Add(0, _dic1);
|
Dictionary<int, int> _dic2 = new Dictionary<int, int>();
|
var config = ItemPlusSumAttrConfig.Get(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<int, int> _dic1 = new Dictionary<int, int>();
|
|
var config = ItemPlusSumAttrConfig.Get(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<int, int> _dic2 = new Dictionary<int, int>();
|
config = ItemPlusSumAttrConfig.Get(key);
|
_dic2.Add(config.attType[0], config.attValue[0]);
|
_dic2.Add(config.attType[1], config.attValue[1]);
|
_dic.Add(key, _dic2);
|
return _dic;
|
}
|
}
|
//==========装备红点
|
List<int> StrengthList = new List<int>();
|
private bool IsFairyDevice(int Index)
|
{
|
if (Index == 9 || Index == 10)
|
{
|
SinglePack singlePack = playerPack.GetSinglePack(PackType.Equip);
|
if (singlePack != null && singlePack.GetAllItems().ContainsKey(Index))
|
{
|
ItemModel item = singlePack.GetItemByIndex(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 = FuncConfigConfig.Get("EquipArea").Numerical1;
|
int[] intList = ConfigParse.GetMultipleStr<int>(str);
|
if (StrengthList.Count <= 0)
|
{
|
for (int i = 0; i < intList.Length; i++)
|
{
|
StrengthList.Add(intList[i]);
|
}
|
}
|
List<string> SortList = new List<string>();
|
for (int i = 0; i < intList.Length; i++)
|
{
|
SortList.Add((intList[i]).ToString());
|
}
|
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<int> ClassList = new List<int>();//红点阶级
|
List<int> equipmentRed = new List<int>();//当前存在的装备
|
int LowestZbw = 0;
|
private void Lowest()//筛选强化部位上最低阶级装备
|
{
|
equipmentRed.Clear();
|
int LowestLV = 0;
|
var StrengthengRedPointAllKey = StrengthengRedPoint.Keys;
|
foreach (int key in StrengthengRedPointAllKey)
|
{
|
ItemModel itemModel = playerPack.GetItemByIndex(PackType.Equip, key);
|
if (itemModel != null)
|
{
|
ItemConfig _Item = ItemConfig.Get((int)itemModel.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);
|
if (!DicEquip.ContainsKey(LowestZbw))
|
{
|
return;
|
}
|
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<int, WingRefineAttrModel> _DicWingRe = new Dictionary<int, WingRefineAttrModel>();
|
class WingRefineAttrModel
|
{
|
public int Ability1;//属性值1
|
public int Ability1Value;//数值1
|
public int Ability2;//属性值2
|
public int Ability2Value;//数值2
|
|
}
|
private List<WingRefineAttrConfig> tegWing = new List<WingRefineAttrConfig>();
|
void WingRefine()//精炼属性
|
{
|
if (tegWing.Count <= 0)
|
{
|
tegWing= WingRefineAttrConfig.GetValues();
|
}
|
//var tegWing = WingRefineAttrConfig.GetValues();
|
foreach (var values in tegWing)
|
{
|
if (!_DicWingRe.ContainsKey(values.wingsPhase))
|
{
|
WingRefineAttrModel _wingRefineAttrModel = new WingRefineAttrModel();
|
int[] array = ConfigParse.GetKeyValueKeys<int>(values.attrupper);
|
int[] intarray = ConfigParse.GetKeyValueValues<int>(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 = ItemConfig.Get(ItemID);
|
if (tegWing.Count <= 0)
|
{
|
tegWing = WingRefineAttrConfig.GetValues();
|
}
|
// var configs = WingRefineAttrConfig.GetValues();
|
foreach (var values in tegWing)
|
{
|
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 (WingRefineAttrConfig.Get(ID) == null)
|
{
|
return false;
|
}
|
ItemModel itemModel = playerPack.GetItemByIndex(PackType.Equip, (int)RoleEquipType.Wing);
|
if (itemModel.GetUseDataModel((int)ItemUseDataKey.wingProgressValue) != null)
|
{
|
int currentRefining = 0;
|
int currentReAll = 0;
|
currentRefining = itemModel.GetUseDataModel((int)ItemUseDataKey.wingProgressValue)[0];//当前精炼度
|
if (tegWing.Count <= 0)
|
{
|
tegWing = WingRefineAttrConfig.GetValues();
|
}
|
// var wingRefineAttrConfigs = WingRefineAttrConfig.GetValues();
|
foreach (var value in tegWing)
|
{
|
if (itemModel.config.LV == value.wingsPhase)
|
{
|
currentReAll = value.EXPupper;//总精炼度
|
}
|
}
|
if (currentReAll > currentRefining)
|
{
|
return true;
|
}
|
else
|
{
|
return false;
|
}
|
}
|
else
|
{
|
return false;
|
}
|
}
|
}
|
|