using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
|
using System;
|
using vnxbqy.UI;
|
|
namespace vnxbqy.UI
|
{
|
|
public class RolePromoteModel : Model, IBeforePlayerDataInitialize, IAfterPlayerDataInitialize, IPlayerLoginOk
|
{
|
PackModel _playerPack;
|
PackModel playerPack
|
{
|
get { return _playerPack ?? (_playerPack = ModelCenter.Instance.GetModel<PackModel>()); }
|
}
|
|
EquipGemModel equipGemModel { get { return ModelCenter.Instance.GetModel<EquipGemModel>(); } }
|
|
public override void Init()
|
{
|
//ParseConfig();
|
//playerPack.refreshItemCountEvent += RefreshItemCountAct;
|
//MountModel.Event_MountHA301A += OnRefreshMountData;
|
//PetModel.Event_H0704Add += OnRefreshPetData;
|
//PetModel.Event_H0704Update += OnRefreshPetData;
|
//petmodel.PlayerLoginOkData += OnRefreshPetData;
|
//RedpointCenter.Instance.redpointValueChangeEvent += RedpointValueChangeEvent;
|
//ItemLogicUtility.Instance.GetBetterEquipEvent += RefreshGetBetterEquipEvent;
|
//MountModel.PlayerLoginOKData += PlayerLoginOKData;
|
//PlayerDatas.Instance.playerDataRefreshEvent += PlayerDataRefreshInfoEvent;
|
//OnBeforePlayerDataInitialize();
|
}
|
|
public override void UnInit()
|
{
|
|
}
|
|
public void OnBeforePlayerDataInitialize()
|
{
|
|
}
|
|
public void OnAfterPlayerDataInitialize()
|
{
|
|
}
|
|
public void OnPlayerLoginOk()
|
{
|
//CheckPromoteDetailEffect();
|
//RefreshData();
|
}
|
|
public void RefreshData()
|
{
|
GetPetCntDic();
|
GetMountCntDic();
|
}
|
|
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 runeModel
|
{
|
get
|
{
|
return ModelCenter.Instance.GetModel<RuneModel>();
|
}
|
}
|
PetModel m_petModel;
|
PetModel petmodel
|
{
|
get
|
{
|
return m_petModel ?? (m_petModel = ModelCenter.Instance.GetModel<PetModel>());
|
}
|
}
|
MountModel m_HorseModel;
|
MountModel horsemodel
|
{
|
get
|
{
|
return m_HorseModel ?? (m_HorseModel = ModelCenter.Instance.GetModel<MountModel>());
|
}
|
}
|
StrengthenModel m_StrengthengModel;
|
StrengthenModel strengthengmodel
|
{
|
get
|
{
|
return m_StrengthengModel ?? (m_StrengthengModel = ModelCenter.Instance.GetModel<StrengthenModel>());
|
}
|
}
|
|
|
AlchemyModel alchemyModel { get { return ModelCenter.Instance.GetModel<AlchemyModel>(); } }
|
|
RoleModel roleModel { get { return ModelCenter.Instance.GetModel<RoleModel>(); } }
|
|
ReikiRootModel reikiRootModel { get { return ModelCenter.Instance.GetModel<ReikiRootModel>(); } }
|
|
#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 坐骑
|
|
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 洗炼
|
|
#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(PlayerDataType refreshType)
|
{
|
if (refreshType == PlayerDataType.RealmLevel)
|
{
|
CheckPromoteDetailEffect();
|
}
|
}
|
|
private void RedpointValueChangeEvent(int _id)
|
{
|
if (_id == 999999 /*strengthengmodel.StrengthRedpoint.id*/ ||
|
_id == MainRedDot.RedPoint_MountPackKey ||
|
_id == MainRedDot.Instance.redPonintPetFunc2.id ||
|
_id == MainRedDot.Instance.redPointWashFunc.id ||
|
_id == runeModel.redpoint.id ||
|
_id == magicianModel.magicianRedpoint.id ||
|
_id == methodData.fairyHeartRedpoint.id ||
|
_id == realmModel.levelUpRedpoint.id ||
|
_id == equipGemModel.redpoint.id ||
|
_id == reikiRootModel.redpoint.id ||
|
_id == alchemyModel.alchemyDrugRedpoint3.id ||
|
_id == alchemyModel.alchemyDrugRedpoint4.id)
|
{
|
CheckPromoteDetailEffect();
|
}
|
}
|
|
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 reikiRootModel.redpoint.state == RedPointState.Simple;
|
case PromoteDetailType.EquipStrength:
|
return false;
|
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.redpoint.state == RedPointState.Simple;
|
case PromoteDetailType.GodWeapon:
|
return magicianModel.magicianRedpoint.state == RedPointState.Simple;
|
case PromoteDetailType.TreasurePotential:
|
return false;
|
case PromoteDetailType.Gem:
|
return equipGemModel.redpoint.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 alchemyModel.alchemyDrugRedpoint3.state == RedPointState.Simple
|
|| alchemyModel.alchemyDrugRedpoint4.state == RedPointState.Simple;
|
case PromoteDetailType.max:
|
break;
|
}
|
return false;
|
}
|
#endregion
|
|
public enum PromoteDetailType
|
{
|
BetterEquip,
|
AddPoint,
|
EquipStrength,
|
Mount,
|
Pet,
|
RuneMosaic,
|
Gem,
|
Wash,
|
GodWeapon,
|
FairyHeart,
|
TreasurePotential,
|
BlastFurnace,//八卦炉
|
RolePromote,
|
//后续IL开发添加预设
|
default1,
|
default2,
|
default3,
|
default4,
|
default5,
|
default6,
|
default7,
|
default8,
|
default9,
|
default10,
|
max,
|
}
|
}
|
}
|
|