using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
|
using System;
|
using Snxxz.UI;
|
|
namespace Snxxz.UI
|
{
|
[XLua.LuaCallCSharp]
|
public class RolePromoteModel : Model, IBeforePlayerDataInitialize, IAfterPlayerDataInitialize, IPlayerLoginOk
|
{
|
PackModel _playerPack;
|
PackModel playerPack
|
{
|
get { return _playerPack ?? (_playerPack = ModelCenter.Instance.GetModel<PackModel>()); }
|
}
|
|
public override void Init()
|
{
|
ParseConfig();
|
playerPack.refreshItemCountEvent += RefreshItemCountAct;
|
PlayerStoneData.OnRefreshStoneData += OnRefreshStoneData;
|
PlayerMountDatas.Event_MountHA301A += OnRefreshMountData;
|
PlayerPetDatas.Event_H0704Add += OnRefreshPetData;
|
PlayerPetDatas.Event_H0704Update += OnRefreshPetData;
|
petmodel.PlayerLoginOkData += OnRefreshPetData;
|
equipWashModel.RefreshWashModelEvent += RefreshWashModelEvent;
|
RedpointCenter.Instance.redpointValueChangeEvent += RedpointValueChangeEvent;
|
ItemLogicUtility.Instance.GetBetterEquipEvent += RefreshGetBetterEquipEvent;
|
PlayerMountDatas.PlayerLoginOKData += PlayerLoginOKData;
|
blastFurnaceModel.blastFurnacePromoteUpdate += BlastFurnacePromoteUpdate;
|
PlayerDatas.Instance.PlayerDataRefreshInfoEvent += PlayerDataRefreshInfoEvent;
|
OnBeforePlayerDataInitialize();
|
}
|
|
public override void UnInit()
|
{
|
|
}
|
|
public void OnBeforePlayerDataInitialize()
|
{
|
|
}
|
|
public void OnAfterPlayerDataInitialize()
|
{
|
|
}
|
|
public void OnPlayerLoginOk()
|
{
|
CheckPromoteDetailEffect();
|
RefreshData();
|
}
|
|
public void RefreshData()
|
{
|
GetAllStoneLv();
|
GetWashCntDic();
|
GetPetCntDic();
|
GetMountCntDic();
|
}
|
|
EquipWashModel m_EquipWashModel;
|
EquipWashModel equipWashModel
|
{
|
get
|
{
|
return m_EquipWashModel ?? (m_EquipWashModel = ModelCenter.Instance.GetModel<EquipWashModel>());
|
}
|
}
|
|
TreasureModel m_TreasureModel;
|
TreasureModel treasureModel
|
{
|
get
|
{
|
return m_TreasureModel ?? (m_TreasureModel = ModelCenter.Instance.GetModel<TreasureModel>());
|
}
|
}
|
|
MagicianModel m_MagicianModel;
|
MagicianModel magicianModel
|
{
|
get
|
{
|
return m_MagicianModel ?? (m_MagicianModel = ModelCenter.Instance.GetModel<MagicianModel>());
|
}
|
}
|
|
RuneModel m_RuneModel;
|
RuneModel runeModel
|
{
|
get
|
{
|
return m_RuneModel ?? (m_RuneModel = ModelCenter.Instance.GetModel<RuneModel>());
|
}
|
}
|
PlayerPetDatas m_petModel;
|
PlayerPetDatas petmodel
|
{
|
get
|
{
|
return m_petModel ?? (m_petModel = ModelCenter.Instance.GetModel<PlayerPetDatas>());
|
}
|
}
|
PlayerMountDatas m_HorseModel;
|
PlayerMountDatas horsemodel
|
{
|
get
|
{
|
return m_HorseModel ?? (m_HorseModel = ModelCenter.Instance.GetModel<PlayerMountDatas>());
|
}
|
}
|
PlayerStrengthengDatas m_StrengthengModel;
|
PlayerStrengthengDatas strengthengmodel
|
{
|
get
|
{
|
return m_StrengthengModel ?? (m_StrengthengModel = ModelCenter.Instance.GetModel<PlayerStrengthengDatas>());
|
}
|
}
|
|
PlayerSuitModel _suitModel;
|
PlayerSuitModel SuitModel
|
{
|
get { return _suitModel ?? (_suitModel = ModelCenter.Instance.GetModel<PlayerSuitModel>()); }
|
}
|
|
GemModel gemModel { get { return ModelCenter.Instance.GetModel<GemModel>(); } }
|
|
BlastFurnaceModel blastFurnaceModel { get { return ModelCenter.Instance.GetModel<BlastFurnaceModel>(); } }
|
|
RoleModel roleModel { get { return ModelCenter.Instance.GetModel<RoleModel>(); } }
|
|
RolePointModel rolePointModel { get { return ModelCenter.Instance.GetModel<RolePointModel>(); } }
|
|
#region 配置
|
public Dictionary<int, int> wingLv2GenerDict = new Dictionary<int, int>();
|
public Dictionary<int, List<RoleStrongerConfig>> roleStrongerDic = new Dictionary<int, List<RoleStrongerConfig>>();
|
List<int> promotePercents = new List<int>();
|
public List<int> fightPowerPercents = new List<int>();
|
void ParseConfig()
|
{
|
var dict = RoleStrongerConfig.GetValues();
|
foreach (var cfg in dict)
|
{
|
List<RoleStrongerConfig> list = null;
|
roleStrongerDic.TryGetValue(cfg.funcType, out list);
|
if (list == null)
|
{
|
list = new List<RoleStrongerConfig>();
|
roleStrongerDic.Add(cfg.funcType, list);
|
}
|
list.Add(cfg);
|
}
|
var funcConfig = FuncConfigConfig.Get("WingLV");
|
LitJson.JsonData _json = LitJson.JsonMapper.ToObject(funcConfig.Numerical1);
|
foreach (var _wingLv in _json.Keys)
|
{
|
wingLv2GenerDict.Add(int.Parse(_wingLv), int.Parse(_json[_wingLv].ToString()));
|
}
|
funcConfig = FuncConfigConfig.Get("FightpowerUp");
|
promotePercents.AddRange(ConfigParse.GetMultipleStr<int>(funcConfig.Numerical1));
|
fightPowerPercents.AddRange(ConfigParse.GetMultipleStr<int>(funcConfig.Numerical2));
|
}
|
|
public List<RoleStrongerConfig> GetStrongerConfigs(int funcType)
|
{
|
List<RoleStrongerConfig> list = null;
|
roleStrongerDic.TryGetValue(funcType, out list);
|
return list;
|
}
|
|
public int GetPromoteState(int percent)
|
{
|
for (int i = 0; i < promotePercents.Count; i++)
|
{
|
if (percent <= promotePercents[i])
|
{
|
return i;
|
}
|
}
|
return promotePercents.Count - 1;
|
}
|
#endregion
|
|
public RoleStrongerConfig GetPresentRoleStronger(int funcType)
|
{
|
List<RoleStrongerConfig> list = GetStrongerConfigs(funcType);
|
int i = 0;
|
int presentLevel = PlayerDatas.Instance.baseData.LV;
|
if (list != null && list.Count > 0)
|
{
|
for (i = 0; i < list.Count; i++)
|
{
|
if (presentLevel < list[i].LV)
|
{
|
return list[i];
|
}
|
}
|
return list[list.Count - 1];
|
}
|
return null;
|
}
|
|
#region 装备
|
private void RefreshItemCountAct(PackType packType, int itemPlace, int id)
|
{
|
if (packType == PackType.Equip || packType == PackType.Item)
|
{
|
CheckPromoteDetailEffect();
|
}
|
else if (packType == PackType.PetPack)
|
{
|
GetPetCntDic();
|
}
|
else if (packType == PackType.Horse)
|
{
|
GetMountCntDic();
|
}
|
}
|
|
public int GetEquipCnt(int _color, int _starlv, int _lv)
|
{
|
int _count = 0;
|
SinglePack packTypeModel = playerPack.GetSinglePack(PackType.Equip);
|
if (packTypeModel == null || packTypeModel.GetAllItems() == null || packTypeModel.GetAllItems().Count == 0)
|
{
|
return _count;
|
}
|
foreach (var _itemModel in packTypeModel.GetAllItems().Values)
|
{
|
var _itemCfg = ItemConfig.Get(_itemModel.itemId);
|
if (_itemCfg != null)
|
{
|
if (_itemCfg.ItemColor < _color || _itemCfg.LV < _lv)
|
{
|
continue;
|
}
|
if (_itemCfg.ItemColor > _color)
|
{
|
_count++;
|
continue;
|
}
|
if (_itemCfg.ItemColor == _color)
|
{
|
if (_itemCfg.StarLevel >= _starlv)
|
{
|
_count++;
|
}
|
}
|
}
|
}
|
return _count;
|
}
|
#endregion
|
|
#region 符印
|
public bool GetRuneCnt(int _tatalLv, out int _count)
|
{
|
int totalLv = 0;
|
var _runeHoleDatas = runeModel.GetAllRuneData();
|
foreach (var _rune in _runeHoleDatas.Values)
|
{
|
totalLv += _rune.lv;
|
}
|
_count = totalLv >= _tatalLv ? _runeHoleDatas.Count : 0;
|
return totalLv >= _tatalLv;
|
}
|
#endregion
|
|
#region 宝石
|
private void OnRefreshStoneData()
|
{
|
GetAllStoneLv();
|
}
|
private int m_AllStoneLv = 0;
|
public int allStoneLv
|
{
|
get { return m_AllStoneLv; }
|
}
|
private void GetAllStoneLv()
|
{
|
m_AllStoneLv = 0;
|
var dict = PlayerStoneData.Instance.GetAllStone();
|
foreach (uint[] array in dict.Values)
|
{
|
if (array == null || array.Length == 0) continue;
|
for (int i = 0; i < array.Length; i++)
|
{
|
if (array[i] == 0) continue;
|
ItemConfig _tagChinItemModel = ItemConfig.Get((int)array[i]);
|
if (_tagChinItemModel == null) continue;
|
m_AllStoneLv += _tagChinItemModel.EffectValueB1;
|
}
|
}
|
}
|
#endregion
|
|
#region 坐骑
|
|
private void PlayerLoginOKData()
|
{
|
GetMountCntDic();
|
}
|
|
private void OnRefreshMountData(int _HorseID)
|
{
|
GetMountCntDic();
|
}
|
private Dictionary<int, Dictionary<int, int>> mountCntDic = new Dictionary<int, Dictionary<int, int>>();
|
private void GetMountCntDic()
|
{
|
foreach (var dict in mountCntDic.Values)
|
{
|
dict.Clear();
|
}
|
var mountDict = horsemodel._DicHorse;
|
if (mountDict == null || mountDict.Count == 0) return;
|
foreach (var horseID in mountDict.Keys)
|
{
|
HorseConfig _tagHorseModel = HorseConfig.Get(horseID);
|
if (_tagHorseModel == null)
|
{
|
continue;
|
}
|
ItemConfig _tagChinItemModel = ItemConfig.Get(_tagHorseModel.ItemID);
|
Dictionary<int, int> dict = null;
|
mountCntDic.TryGetValue(_tagChinItemModel.ItemColor, out dict);
|
if (dict == null)
|
{
|
dict = new Dictionary<int, int>();
|
mountCntDic.Add(_tagChinItemModel.ItemColor, dict);
|
dict[mountDict[horseID].Lv] = 0;
|
}
|
if (!dict.ContainsKey(mountDict[horseID].Lv))
|
{
|
dict.Add(mountDict[horseID].Lv, 0);
|
}
|
dict[mountDict[horseID].Lv]++;
|
}
|
}
|
public int GetMountCnt(int _itemColor, int _lv)
|
{
|
int val = 0;
|
foreach (var itemColor in mountCntDic.Keys)
|
{
|
if (itemColor < _itemColor)
|
{
|
continue;
|
}
|
foreach (var lv in mountCntDic[itemColor].Keys)
|
{
|
if (lv < _lv)
|
{
|
continue;
|
}
|
val += mountCntDic[itemColor][lv];
|
}
|
}
|
return val;
|
}
|
public int GetMountTotallv()
|
{
|
var mountDict = horsemodel._DicHorse;
|
if (mountDict == null || mountDict.Count == 0)
|
{
|
return 0;
|
}
|
var _lv = 0;
|
foreach (var _horse in mountDict.Values)
|
{
|
_lv += _horse.Lv;
|
}
|
return _lv;
|
}
|
#endregion
|
|
#region 灵宠
|
private void OnRefreshPetData(int info)
|
{
|
GetPetCntDic();
|
}
|
private void OnRefreshPetData()
|
{
|
GetPetCntDic();
|
}
|
private Dictionary<int, int> petCntDic = new Dictionary<int, int>();
|
private void GetPetCntDic()
|
{
|
petCntDic.Clear();
|
var dict = petmodel._DicPetBack;
|
if (dict == null) return;
|
foreach (var pet in dict.Values)
|
{
|
if (!petCntDic.ContainsKey(pet.PetClass))
|
{
|
petCntDic.Add(pet.PetClass, 0);
|
}
|
petCntDic[pet.PetClass]++;
|
}
|
}
|
public int GetPetCnt(int lv)
|
{
|
int val = 0;
|
foreach (var key in petCntDic.Keys)
|
{
|
if (key >= lv)
|
{
|
val += petCntDic[key];
|
}
|
}
|
return val;
|
}
|
#endregion
|
|
#region 洗练
|
private void RefreshWashModelEvent()
|
{
|
GetWashCntDic();
|
}
|
private Dictionary<int, int> washCntDic = new Dictionary<int, int>();
|
private void GetWashCntDic()
|
{
|
washCntDic.Clear();
|
var dict = equipWashModel.GetWashInfoDict();
|
if (dict == null)
|
{
|
return;
|
}
|
foreach (var wash in dict.Values)
|
{
|
if (!washCntDic.ContainsKey(wash.XLAttrLV))
|
{
|
washCntDic.Add(wash.XLAttrLV, 1);
|
}
|
else
|
{
|
washCntDic[wash.XLAttrLV]++;
|
}
|
}
|
}
|
public int GetWashCnt(int lv)
|
{
|
int val = 0;
|
foreach (var key in washCntDic.Keys)
|
{
|
if (lv <= key)
|
{
|
val += washCntDic[key];
|
}
|
}
|
return val;
|
}
|
|
#endregion
|
|
#region 炼丹
|
public int GetBlastFurnaceDragUseCount(int _lv)
|
{
|
var list = playerPack.makeDruglist;
|
var count = 0;
|
if (list != null)
|
{
|
for (int i = 0; i < list.Count; i++)
|
{
|
var config = ItemConfig.Get(list[i].ID);
|
if (config != null && config.LV == _lv)
|
{
|
count += playerPack.GetItemTotalUsedTimes(config.ID);
|
}
|
}
|
}
|
return count;
|
}
|
#endregion
|
|
#region 主界面提升
|
PlayerMethodData methodData
|
{
|
get { return ModelCenter.Instance.GetModel<PlayerMethodData>(); }
|
}
|
|
RealmModel realmModel { get { return ModelCenter.Instance.GetModel<RealmModel>(); } }
|
|
public Redpoint m_PromoteRedpoint = new Redpoint(31);
|
|
private void RefreshGetBetterEquipEvent(string _str)
|
{
|
CheckPromoteDetailEffect();
|
}
|
|
public void CheckPromoteDetailEffect()
|
{
|
m_PromoteRedpoint.state = RedPointState.None;
|
for (int i = 0; i < (int)PromoteDetailType.RolePromote; i++)
|
{
|
if (GetPromoteDetailShow((PromoteDetailType)i))
|
{
|
m_PromoteRedpoint.state = RedPointState.Simple;
|
break;
|
}
|
}
|
}
|
|
private void BlastFurnacePromoteUpdate()
|
{
|
CheckPromoteDetailEffect();
|
}
|
|
private void PlayerDataRefreshInfoEvent(PlayerDataRefresh refreshType)
|
{
|
if (refreshType == PlayerDataRefresh.OfficialRank)
|
{
|
CheckPromoteDetailEffect();
|
}
|
}
|
|
private void RedpointValueChangeEvent(int _id)
|
{
|
if (_id == strengthengmodel.StrengthRedpoint.id ||
|
_id == MainRedDot.RedPoint_MountPackKey ||
|
_id == MainRedDot.Instance.redPonintPetFunc2.id ||
|
_id == MainRedDot.Instance.redPointWashFunc.id ||
|
_id == runeModel.runeMosaicRedpoint.id ||
|
_id == magicianModel.magicianRedpoint.id ||
|
_id == methodData.fairyHeartRedpoint.id ||
|
_id == realmModel.realmRedpoint.id ||
|
_id == gemModel.gemTagRedPoint.id ||
|
_id == rolePointModel.redpoint.id ||
|
IsTreasureRedpoint(_id))
|
{
|
CheckPromoteDetailEffect();
|
}
|
}
|
|
private bool IsTreasureRedpoint(int _id)
|
{
|
for (int k = 1; k < (int)TreasureCategory.Zerg; k++)
|
{
|
var list = treasureModel.GetTreasureCategory((TreasureCategory)k);
|
if (list == null)
|
{
|
continue;
|
}
|
for (int j = 0; j < list.Count; j++)
|
{
|
Treasure treasure;
|
if (treasureModel.TryGetTreasure(list[j], out treasure)
|
&& treasure.skillLevelUpRedpoint != null && treasure.skillLevelUpRedpoint.id == _id)
|
{
|
return true;
|
}
|
}
|
}
|
return false;
|
}
|
|
public bool GetPromoteDetailShow(PromoteDetailType _type)
|
{
|
switch (_type)
|
{
|
case PromoteDetailType.BetterEquip:
|
var dict = ItemLogicUtility.Instance.CheckBetterEquipByRealm();
|
return dict != null && dict.Count > 0;
|
case PromoteDetailType.AddPoint:
|
return rolePointModel.redpoint.state == RedPointState.Simple;
|
case PromoteDetailType.EquipStrength:
|
return strengthengmodel.StrengthRedpoint.state == RedPointState.Simple;
|
case PromoteDetailType.Mount:
|
return MainRedDot.Instance.redPointMountFunc.state == RedPointState.Simple;
|
case PromoteDetailType.Pet:
|
return MainRedDot.Instance.redPonintPetFunc2.state == RedPointState.Simple;
|
case PromoteDetailType.RuneMosaic:
|
return runeModel.runeMosaicRedpoint.state == RedPointState.Simple;
|
case PromoteDetailType.GodWeapon:
|
return magicianModel.magicianRedpoint.state == RedPointState.Simple;
|
case PromoteDetailType.TreasurePotential:
|
var list = treasureModel.GetTreasureCategory(TreasureCategory.Human);
|
for (int j = 0; j < list.Count; j++)
|
{
|
Treasure treasure;
|
if (treasureModel.TryGetTreasure(list[j], out treasure) && treasure.state == TreasureState.Collected
|
&& treasure.skillLevelUpRedpoint != null && treasure.skillLevelUpRedpoint.state == RedPointState.Simple)
|
{
|
return true;
|
}
|
}
|
break;
|
case PromoteDetailType.Gem:
|
return gemModel.gemTagRedPoint.state == RedPointState.Simple;
|
case PromoteDetailType.Wash:
|
return MainRedDot.Instance.redPointWashFunc.state == RedPointState.Simple;
|
case PromoteDetailType.RolePromote:
|
return true;
|
case PromoteDetailType.FairyHeart:
|
return ModelCenter.Instance.GetModel<PlayerMethodData>().fairyHeartRedpoint.state == RedPointState.Simple;
|
case PromoteDetailType.BlastFurnace:
|
return blastFurnaceModel.CheckUseDrugLimit();
|
case PromoteDetailType.max:
|
break;
|
}
|
return false;
|
}
|
#endregion
|
|
public enum PromoteDetailType
|
{
|
BetterEquip,
|
AddPoint,
|
EquipStrength,
|
Mount,
|
Pet,
|
RuneMosaic,
|
Gem,
|
Wash,
|
GodWeapon,
|
FairyHeart,
|
TreasurePotential,
|
BlastFurnace,//八卦炉
|
RolePromote,
|
max,
|
}
|
}
|
}
|
|