using vnxbqy.UI;
|
using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using System.Text.RegularExpressions;
|
using LitJson;
|
using UnityEngine;
|
//用于坐骑
|
|
public class HorseClass
|
{
|
public int Lv;//坐骑等级
|
public int Exp;//经验
|
|
}
|
public enum HorseEnum
|
{
|
HorseDan = 0,//坐骑丹
|
HorseDebris = 1,//坐骑碎片
|
HorseStone = 2,//坐骑魂石
|
//后续IL开发添加预设
|
default1,
|
default2,
|
default3,
|
default4,
|
default5,
|
}
|
|
public class HorseSkillClass
|
{
|
public int SkillID;//技能ID
|
public int SkillItem;//升级技能所需道具
|
public int HorseID;//坐骑ID
|
public int HorseLV;//所需等级
|
}
|
|
|
public class MountModel : Model, IBeforePlayerDataInitialize, IPlayerLoginOk
|
{
|
public string _HorseIDNow = string.Empty;//获取当前的坐骑ID
|
public int HorseIDNow = 0;
|
public delegate void MountHA301Update(int _HorseID);
|
public static event MountHA301Update Event_MountHA301U;//坐骑的更新
|
public delegate void MountHA301Add(int _HorseID);
|
public static event MountHA301Add Event_MountHA301A;//坐骑的添加
|
public delegate void MountHA339Update(HA339_tagMCAttrFruitEatCntList info);
|
public static event MountHA339Update Event_MountHA339U;//坐骑魂石的刷新
|
|
public Dictionary<int, HorseSkillClass> GetMountSkillAndItem = new Dictionary<int, HorseSkillClass>();//1技能TypeID,所需的消耗物品ID
|
public delegate void OnMountAlteration();//当前坐骑变更
|
public static event OnMountAlteration Event_MountAlteration;
|
public static event Action OnMountUieffectUpLv;//关于坐骑升级时特效播放时的调用
|
public Dictionary<int, HorseClass> _DicHorse = new Dictionary<int, HorseClass>();//当前的坐骑字典
|
public Dictionary<int, int> _DicMountItem = new Dictionary<int, int>();//坐骑魂石的字典
|
public Dictionary<int, Redpoint> DeblockingRedPoint = new Dictionary<int, Redpoint>();//坐骑皮肤激活按钮红点
|
public Dictionary<int, int> MountSkinActive = new Dictionary<int, int>();//坐骑皮肤ID激活情况
|
public Dictionary<int, int> mountSkin = new Dictionary<int, int>(); //horseid 对应坐骑皮肤id
|
public int MountStoneItemId = 0;
|
public bool IsOk = false;
|
public List<int> ListEffectSkill = new List<int>();
|
private int autoActiveHorseId = 0;
|
private bool hasSendAutoActive = false;
|
public int horseUpItemId { get; private set; }
|
public int HorseDanExp = 0;//坐骑丹经验
|
//public int[][] horseDanAttr;
|
public int[] HorseAttrSort; //坐骑属性面板排序,属性和添加属性为0则不显示
|
public int HorseTrainMoreCnt;
|
public int horseUpItemCost = 10;
|
PackModel _playerPack;
|
PackModel playerPack {
|
get { return _playerPack ?? (_playerPack = ModelCenter.Instance.GetModel<PackModel>()); }
|
}
|
public bool HorseRidingBool = false;//用来判断玩家是都在骑马
|
public bool Wait = true;//等待回包(使用坐骑丹)
|
public static Action<int, bool> MultipleEvent;
|
public static event Action PlayerLoginOKData;
|
|
private Dictionary<int, int> DicDefaultMount = new Dictionary<int, int>();
|
|
Dictionary<SkillEffectGroup, int> integrationSkills = new Dictionary<SkillEffectGroup, int>();
|
Dictionary<SkillEffectGroup, List<int>> integrationHorseSkills = new Dictionary<SkillEffectGroup, List<int>>();
|
Dictionary<int, SkillEffectGroup> horseSkillEffectValues = new Dictionary<int, SkillEffectGroup>();
|
Dictionary<int, int> horseSkills = new Dictionary<int, int>();
|
public Dictionary<int, int> horseStarDict = new Dictionary<int, int>(); //坐骑幻化升星
|
|
Dictionary<int, int> unLockSkinItems = new Dictionary<int, int>();
|
|
public override void Init()
|
{
|
GetRankHorseIDs();
|
playerPack.refreshItemCountEvent += OnItemRefreshEvent;
|
//FuncOpen.Instance.OnFuncStateChangeEvent += OnFuncStateChangeEvent;
|
//MountSkillAndItem();
|
MountNumberPreservation();
|
string str = FuncConfigConfig.Get("MountSkillEffect").Numerical1;
|
int[] listeffect = ConfigParse.GetMultipleStr<int>(str);
|
ListEffectSkill.Clear();
|
for (int i = 0; i < listeffect.Length; i++)
|
{
|
ListEffectSkill.Add(listeffect[i]);
|
}
|
string MountRedDotstr = FuncConfigConfig.Get("MountPetRedDot").Numerical1;
|
DicDefaultMount = ConfigParse.GetDic<int, int>(MountRedDotstr);
|
var funcConfig = FuncConfigConfig.Get("HorseUpItem");
|
horseUpItemId = int.Parse(funcConfig.Numerical1);
|
HorseDanExp = int.Parse(funcConfig.Numerical2);
|
//horseDanAttr = JsonMapper.ToObject<int[][]>(funcConfig.Numerical3);
|
HorseAttrSort = JsonMapper.ToObject<int[]>(funcConfig.Numerical4); //坐骑面板属性排序
|
HorseTrainMoreCnt = int.Parse(funcConfig.Numerical5);
|
|
var shopConfig = StoreConfig.GetStoreCfg(horseUpItemId, 1, 1);
|
if (shopConfig != null)
|
{
|
horseUpItemCost = shopConfig.MoneyNumber;
|
}
|
|
funcConfig = FuncConfigConfig.Get("PetHorseSkillIntegration");
|
var intArray = ConfigParse.GetMultipleStr<int>(funcConfig.Numerical2);
|
for (int i = 0; i < intArray.Length; i++)
|
{
|
var skillConfig = SkillConfig.Get(intArray[i]);
|
if (skillConfig != null)
|
{
|
var effectValue = SkillConfig.GetSkillEffectValue(skillConfig);
|
integrationSkills.Add(effectValue, intArray[i]);
|
}
|
}
|
|
funcConfig = FuncConfigConfig.Get("AutoActivePetHorse");
|
autoActiveHorseId = int.Parse(funcConfig.Numerical2);
|
|
//var _horseSkills = GetMountSkillAndItem.Keys;
|
//foreach (var skillId in _horseSkills)
|
//{
|
// var skillConfig = SkillConfig.Get(skillId);
|
// var effectValue = SkillConfig.GetSkillEffectValue(skillConfig);
|
|
// if (integrationSkills.ContainsKey(effectValue))
|
// {
|
// List<int> skills = null;
|
// if (!integrationHorseSkills.TryGetValue(effectValue, out skills))
|
// {
|
// skills = new List<int>();
|
// integrationHorseSkills.Add(effectValue, skills);
|
// }
|
// skills.Add(skillId);
|
// }
|
|
// horseSkills.Add(skillId, GetMountSkillAndItem[skillId].HorseID);
|
// horseSkillEffectValues.Add(skillId, effectValue);
|
//}
|
|
mountSkin.Clear();
|
MountSkinActive.Clear();
|
foreach (var config in HorseSkinPlusConfig.GetValues())
|
{
|
mountSkin[config.HorseID] = config.ID;
|
MountSkinActive[config.ID] = 0;
|
}
|
unLockSkinItems.Clear();
|
foreach (var config in HorseConfig.GetValues())
|
{
|
if (mountSkin.ContainsKey(config.HorseID))
|
{
|
unLockSkinItems[config.UnlockItemID] = mountSkin[config.HorseID];
|
}
|
}
|
}
|
|
public override void UnInit()
|
{
|
playerPack.refreshItemCountEvent -= OnItemRefreshEvent;
|
//FuncOpen.Instance.OnFuncStateChangeEvent -= OnFuncStateChangeEvent;
|
}
|
|
|
|
public void OnBeforePlayerDataInitialize()
|
{
|
IsOk = false;
|
hasSendAutoActive = false;
|
_HorseIDNow = string.Empty;
|
HorseIDNow = 0;
|
_DicHorse.Clear();
|
HorseRidingBool = false;
|
Wait = true;
|
MountHA301MorePack = false;
|
horseStarDict.Clear();
|
}
|
|
public void OnPlayerLoginOk()
|
{
|
GlobalTimeEvent.Instance.secondEvent -= secondEvent;
|
GlobalTimeEvent.Instance.secondEvent += secondEvent;
|
IsOk = true;
|
|
RefreshCurrentMount(playerPack.GetItemByIndex(PackType.Equip, EquipPlaceMapConfig.GetServerPlace(0, (int)RoleEquipType.Mount)));
|
MountStoneRed();
|
MountDanRed();
|
var singPack = playerPack.GetSinglePack(PackType.Item);
|
if (singPack != null)
|
{
|
foreach (var index in singPack.GetAllItems().Keys)
|
{
|
OnItemRefreshEventLogin(singPack.type, index, singPack.GetAllItems()[index].itemId);
|
}
|
}
|
if (PlayerLoginOKData != null)
|
{
|
PlayerLoginOKData();
|
}
|
}
|
|
private DateTime dateTimeA;
|
private void secondEvent()
|
{
|
if (!Wait)
|
{
|
TimeSpan timeS = DateTime.Now - dateTimeA;
|
if (timeS.Seconds >= 2f)
|
{
|
Wait = true;
|
}
|
}
|
else
|
{
|
dateTimeA = DateTime.Now;
|
}
|
}
|
|
List<HorseConfig> Hconfigs = new List<HorseConfig>();
|
|
public int RedPoint_HuaxingID = MainRedDot.RedPoint_MountPackKey * 10; //化形红点
|
int RedPoint_DanID = MainRedDot.RedPoint_MountPackKey * 10 + 1; //可用坐骑丹红点
|
Redpoint RedPoint_Dan;
|
private void MountNumberPreservation()//用来对坐骑个数的保存
|
{
|
Redpoint RedPoint_Huaxing = new Redpoint(MainRedDot.RedPoint_MountPackKey, RedPoint_HuaxingID);
|
RedPoint_Dan = new Redpoint(MainRedDot.RedPoint_MountPackKey, RedPoint_DanID);
|
DeblockingRedPoint.Clear();
|
var skinConfigs = HorseSkinPlusConfig.GetValues();
|
foreach (var config in skinConfigs)
|
{
|
|
int RedPoint_Mountkey1 = RedPoint_HuaxingID * 1000 + config.ID;
|
Redpoint redPointMountStare1 = new Redpoint(RedPoint_HuaxingID, RedPoint_Mountkey1);
|
DeblockingRedPoint.Add(config.ID, redPointMountStare1);
|
}
|
|
}
|
|
private const int Redpoint_key2 = MainRedDot.RedPoint_MountPackKey * 10 + 2;
|
public Redpoint redPointStre2 = new Redpoint(MainRedDot.RedPoint_MountPackKey, Redpoint_key2);//坐骑兽魂
|
|
private const int Redpoint_key3 = MainRedDot.RedPoint_MountPackKey * 10 + 3;
|
public Redpoint redPointStre3 = new Redpoint(MainRedDot.RedPoint_MountPackKey, Redpoint_key3);//坐骑培养
|
|
public event Action HorseExpItemRefresh;
|
private void OnItemRefreshEvent(PackType type, int index, int id)
|
{
|
if (type == PackType.Equip)
|
{
|
RefreshCurrentMount(playerPack.GetItemByIndex(type, index));
|
}
|
|
if (type == PackType.Item)
|
{
|
if (id == horseUpItemId)
|
{
|
MountDanRed();
|
if (HorseExpItemRefresh != null)
|
HorseExpItemRefresh();
|
}
|
|
if (unLockSkinItems.ContainsKey(id))
|
{
|
int activeID = unLockSkinItems[id];
|
if (MountSkinActive[activeID] == 0)
|
{
|
DeblockingRedPoint[activeID].state = RedPointState.Simple;
|
}
|
else
|
{
|
RefreshStarRedpoint(id);
|
}
|
|
}
|
ForsterHorseRed(id);
|
|
|
//var config = HorseConfig.Get(autoActiveHorseId);
|
//if (config != null && id == config.UnlockItemID)
|
//{
|
// TryAutoActiveHorse();
|
//}
|
}
|
}
|
|
private void OnItemRefreshEventLogin(PackType type, int index, int id)
|
{
|
|
if (type == PackType.Item)
|
{
|
if (unLockSkinItems.ContainsKey(id))
|
{
|
int activeID = unLockSkinItems[id];
|
if (MountSkinActive[activeID] == 0)
|
{
|
DeblockingRedPoint[activeID].state = RedPointState.Simple;
|
}
|
else
|
{
|
RefreshStarRedpoint(id);
|
}
|
}
|
ForsterHorseRed(id);
|
|
}
|
}
|
|
//升星和解锁共用红点
|
void RefreshStarRedpoint(int itemID)
|
{
|
int activeID = unLockSkinItems[itemID];
|
int horseID = HorseConfig.GetItemUnLockHorse(itemID);
|
if (!HorseStarUpConfig.horseIDToIDs.ContainsKey(horseID))
|
return;
|
if (!isMountSkinActive(horseID))
|
return;
|
|
DeblockingRedPoint[activeID].state = RedPointState.None;
|
|
int star = 0;
|
horseStarDict.TryGetValue(horseID, out star);
|
//满星
|
if (star == HorseStarUpConfig.horseIDToIDs[horseID].Count)
|
return;
|
|
var id = HorseStarUpConfig.horseIDToIDs[horseID][star];
|
var nextStarConfig = HorseStarUpConfig.Get(id);
|
var awards = nextStarConfig.StarUpNeedItemList;
|
for (int i = 0; i < awards.Length; i++)
|
{
|
if (playerPack.GetItemCountByID(PackType.Item, awards[i][0]) < awards[i][1])
|
return;
|
}
|
DeblockingRedPoint[activeID].state = RedPointState.Simple;
|
}
|
|
//private void OnFuncStateChangeEvent(int funcId)
|
//{
|
// if (funcId == (int)FuncOpenEnum.Mounts)
|
// {
|
// TryAutoActiveHorse();
|
// }
|
//}
|
|
//private void TryAutoActiveHorse()
|
//{
|
// if (IsOk && FuncOpen.Instance.IsFuncOpen((int)FuncOpenEnum.Mounts)
|
// && !_DicHorse.ContainsKey(autoActiveHorseId) && !hasSendAutoActive)
|
// {
|
// var horseConfig = HorseConfig.Get(autoActiveHorseId);
|
// if (horseConfig != null)
|
// {
|
// var itemCount = playerPack.GetItemCountByID(PackType.Item, horseConfig.UnlockItemID);
|
// if (itemCount >= horseConfig.UnlockItemCnt)
|
// {
|
// hasSendAutoActive = true;
|
// var pak = new CA501_tagPlayerActivateHorse();
|
// pak.HorseID = (uint)autoActiveHorseId;
|
// GameNetSystem.Instance.SendInfo(pak);
|
// }
|
// }
|
// }
|
//}
|
//培养石头
|
public void ForsterHorseRed(int id)//培养石头红点
|
{
|
for (int i = 0; i < GeneralDefine.HorseTrainIDList.Length; i++)
|
{
|
if (GeneralDefine.HorseTrainIDList[i] == id)
|
{
|
redPointStre3.state = RedPointState.None;
|
if (FosterModel.Instance.GetHorseRedPointUpdate(i, id))
|
{
|
redPointStre3.state = RedPointState.Simple;
|
}
|
return;
|
}
|
}
|
|
}
|
public void MountStoneRed()//坐骑魂石红点
|
{
|
redPointStre2.state = RedPointState.None;
|
if (!FuncOpen.Instance.IsFuncOpen(8))
|
return;
|
int type = 0;
|
foreach (var key in _DicMountItem.Keys)
|
{
|
var AttrFruit = AttrFruitConfig.Get(key);
|
if (AttrFruit == null)
|
{
|
continue;
|
}
|
if (_DicMountItem[key] >= AttrFruit.basicUseLimit)
|
{
|
continue;
|
}
|
type += playerPack.GetItemCountByID(PackType.Item, key);
|
}
|
if (type > 0)
|
{
|
redPointStre2.state = RedPointState.Simple;
|
return;
|
}
|
}
|
|
private void MountDanRed()//关于坐骑丹红点
|
{
|
RedPoint_Dan.state = RedPointState.None;
|
if (!FuncOpen.Instance.IsFuncOpen(8))
|
{
|
return;
|
}
|
List<int> IntList = new List<int>();
|
int number = playerPack.GetItemCountByID(PackType.Item, horseUpItemId);
|
var trainCnt = GetTrainCount();
|
RedPoint_Dan.state = (trainCnt == 0 || number < trainCnt) ? RedPointState.None : RedPointState.Simple;
|
|
}
|
|
|
private int GetSkillLvDis(int MountId)//获取离升级最近的技能等级
|
{
|
int SkillLv = 0;
|
|
foreach (var key in GetMountSkillAndItem.Keys)
|
{
|
if (_DicHorse.ContainsKey(MountId) && GetMountSkillAndItem[key].HorseID == MountId)
|
{
|
if (GetMountSkillAndItem[key].HorseLV > _DicHorse[MountId].Lv)
|
{
|
SkillLv = GetMountSkillAndItem[key].HorseLV;
|
return SkillLv;
|
}
|
}
|
}
|
return SkillLv;
|
}
|
|
public int GetMountSkillMaxLV(int MountId)//获取坐骑最大技能等级
|
{
|
int SkillLv = 0;
|
foreach (var key in GetMountSkillAndItem.Keys)
|
{
|
if (GetMountSkillAndItem[key].HorseID == MountId)
|
{
|
if (GetMountSkillAndItem[key].HorseLV > SkillLv)
|
{
|
SkillLv = GetMountSkillAndItem[key].HorseLV;
|
}
|
|
}
|
}
|
return SkillLv;
|
}
|
|
void RefreshCurrentMount(ItemModel info)//获取当前的坐骑
|
{
|
if (info == null)
|
{
|
return;
|
}
|
|
if (info.config.EquipPlace == (byte)RoleEquipType.Mount)//坐骑位置19
|
{
|
if (Hconfigs.Count <= 0)
|
{
|
Hconfigs = HorseConfig.GetValues();
|
}
|
|
foreach (var config in Hconfigs)
|
{
|
if (config.ItemID == info.itemId)
|
{
|
HorseIDNow = config.HorseID;
|
_HorseIDNow = config.HorseID.ToString();
|
if (Event_MountAlteration != null && IsOk)
|
{
|
Event_MountAlteration();
|
}
|
}
|
}
|
}
|
|
|
}
|
|
public int HorseLV = 1;
|
public int HorseEatCount = 0; //乘以每个丹的经验就是当前经验
|
//public uint SkinPlusState = 0;
|
public uint[] horseSkinArray; //坐骑幻化激活支持超过31
|
public event Action onHorseInfoUpdate;
|
public event Action onHorseLVUP;
|
public event Action onMountSkinActive;
|
public int NextTrainCount = 0;
|
public bool MountHA301MorePack = false;
|
|
public void CallMountAlteration()
|
{
|
if (Event_MountAlteration != null)
|
Event_MountAlteration();
|
}
|
|
public void MountHA301(HA301_tagTrainHorseData info)//已拥有的坐骑(获得与刷新)
|
{
|
bool islvup = false;
|
bool isSkinActive = false;
|
if (MountHA301MorePack && info.LV > HorseLV)
|
{
|
islvup = true;
|
|
}
|
|
if (MountHA301MorePack && info.SkinPlusStateList != horseSkinArray)
|
{
|
isSkinActive = true;
|
}
|
HorseLV = info.LV;
|
if (islvup)
|
{
|
MountDanRed();
|
}
|
HorseEatCount = (int)info.EatItemCount;
|
horseSkinArray = info.SkinPlusStateList;
|
|
RefreshHorseAllAttr();
|
|
if (onHorseInfoUpdate != null)
|
onHorseInfoUpdate();
|
|
if (islvup && onHorseLVUP != null)
|
onHorseLVUP();
|
|
if (isSkinActive && onMountSkinActive != null)
|
{
|
CalcMountSkinActive();
|
onMountSkinActive();
|
}
|
if (!MountHA301MorePack)
|
{
|
CalcMountSkinActive();
|
}
|
MountHA301MorePack = true;
|
}
|
|
private void CalcMountSkinActive()
|
{
|
MountSkinActive.Clear();
|
foreach (var config in HorseSkinPlusConfig.GetValues())
|
{
|
MountSkinActive[config.ID] = isMountSkinActiveByID(config.ID) ? 1 : 0;
|
}
|
|
foreach (var redpoint in DeblockingRedPoint)
|
{
|
if (isMountSkinActiveByID(redpoint.Key))
|
{
|
redpoint.Value.state = RedPointState.None;
|
}
|
}
|
|
}
|
|
public void MountHA339(HA339_tagMCAttrFruitEatCntList info)//坐骑魂石
|
{
|
for (int i = 0; i < info.count; i++)
|
{
|
var configItem = ItemConfig.Get((int)info.EatCntList[i].ItemID);
|
if (configItem == null)
|
{
|
continue;
|
}
|
|
if (_DicMountItem.ContainsKey((int)info.EatCntList[i].ItemID))
|
{
|
_DicMountItem[(int)info.EatCntList[i].ItemID] = (int)info.EatCntList[i].EatCnt;
|
if (Event_MountHA339U != null)
|
Event_MountHA339U(info);//坐骑魂石的刷新
|
}
|
else
|
{
|
if (configItem.Type == 22)
|
{
|
_DicMountItem.Add((int)info.EatCntList[i].ItemID, (int)info.EatCntList[i].EatCnt);
|
}
|
}
|
}
|
MountStoneRed();
|
}
|
public int GetAllMountAttack()//得到所有坐骑的攻击
|
{
|
Dictionary<int, int> dicStone = Bonuses();
|
if (_DicHorse.Count == 0)
|
{
|
return dicStone[7];
|
}
|
else
|
{
|
int _AttT = 0;//攻击
|
|
return _AttT + dicStone[7];
|
}
|
}
|
Dictionary<int, int> Bonuses()//属性加成
|
{
|
Dictionary<int, int> dic = new Dictionary<int, int>();
|
dic.Clear();
|
dic.Add(6, 0);//生命
|
dic.Add(7, 0);//攻击
|
dic.Add(8, 0);//防御
|
foreach (int key in _DicMountItem.Keys)
|
{
|
if (_DicMountItem[key] != 0)
|
{
|
ItemConfig itemModel = ItemConfig.Get(key);
|
if (dic.ContainsKey(itemModel.Effect1))
|
{
|
dic[itemModel.Effect1] += itemModel.EffectValueA1 * _DicMountItem[key];
|
}
|
if (dic.ContainsKey(itemModel.Effect2))
|
{
|
dic[itemModel.Effect2] += itemModel.EffectValueA2 * _DicMountItem[key];
|
}
|
if (dic.ContainsKey(itemModel.Effect3))
|
{
|
dic[itemModel.Effect3] += itemModel.EffectValueA3 * _DicMountItem[key];
|
}
|
if (dic.ContainsKey(itemModel.Effect4))
|
{
|
dic[itemModel.Effect4] += itemModel.EffectValueA4 * _DicMountItem[key];
|
}
|
if (dic.ContainsKey(itemModel.Effect5))
|
{
|
dic[itemModel.Effect5] += itemModel.EffectValueA5 * _DicMountItem[key];
|
}
|
}
|
}
|
return dic;
|
}
|
|
public bool IsHint(HorseEnum horseEnum, int id = 0)//True提示,False不提示
|
{
|
bool iSHint = false;
|
switch (horseEnum)
|
{
|
case HorseEnum.HorseDan:
|
foreach (var key in _DicHorse.Keys)
|
{
|
HorseConfig horseConfig = HorseConfig.Get(key);
|
if (horseConfig.MaxLV > _DicHorse[key].Lv)
|
{
|
iSHint = true;
|
}
|
}
|
return iSHint;
|
case HorseEnum.HorseDebris:
|
if (Hconfigs.Count <= 0)
|
{
|
Hconfigs = HorseConfig.GetValues();
|
}
|
foreach (var value in Hconfigs)
|
{
|
if (value.UnlockItemID == id)
|
{
|
if (!_DicHorse.ContainsKey(value.HorseID))
|
{
|
iSHint = true;
|
}
|
}
|
}
|
return iSHint;
|
case HorseEnum.HorseStone:
|
int _maxuse = AttrFruitConfig.Get(id).basicUseLimit;
|
if (_DicMountItem.ContainsKey(id))
|
{
|
if (_maxuse > _DicMountItem[id])
|
{
|
iSHint = true;
|
}
|
}
|
return iSHint;
|
default:
|
return true;
|
}
|
}
|
//ChooseType; // 1-按等阶,2-按幻化
|
//LVID; // 阶等级或幻化ID
|
public void AppearanceSwitch(byte lvID, byte ChooseType)//坐骑外观切换
|
{
|
CA502_tagPlayerChooseHorse _tagCA502 = new CA502_tagPlayerChooseHorse();
|
_tagCA502.LVID = lvID;
|
_tagCA502.ChooseType = ChooseType;
|
GameNetSystem.Instance.SendInfo(_tagCA502);
|
}
|
|
|
public void MountDanUse(int Number, bool IsAutoBuy = false)//是否自动购买
|
{
|
LimitedTimeLuxuryGiftModel.Instance.IsItemIdShow(7, horseUpItemId, GetTrainCount(), 1, 0);
|
CA527_tagCMHorseUp _tagC527 = new CA527_tagCMHorseUp();//向服务端发包坐骑经验单
|
_tagC527.UseItemCnt = (ushort)Number;
|
if (IsAutoBuy)
|
{
|
_tagC527.IsAutoBuy = 1;
|
}
|
GameNetSystem.Instance.SendInfo(_tagC527);
|
}
|
|
public int IsHorsePanelState()
|
{
|
int Type = 0;
|
foreach (var value in DeblockingRedPoint.Values)
|
{
|
if (value.state == RedPointState.Simple)
|
{
|
Type = 2;
|
return Type;
|
}
|
}
|
if (MainRedDot.Instance.redPointMountFunc.state == RedPointState.Simple)
|
{
|
Type = 1;
|
return Type;
|
}
|
return Type;
|
}
|
|
#region 预览坐骑碎片属性
|
// 坐骑皮肤属性
|
public Dictionary<int, int> GetMountAttrAddDict(int mountCode)
|
{
|
var mountAttrDict = new Dictionary<int, int>();
|
mountAttrDict.Clear();
|
var config = HorseSkinPlusConfig.Get(mountSkin[mountCode]);
|
int showIndex = 0;
|
foreach (var attrID in config.AttrType)
|
{
|
mountAttrDict[attrID] = config.AttrValue[showIndex];
|
showIndex++;
|
}
|
|
return mountAttrDict;
|
}
|
|
// 坐骑皮肤战力
|
public int GetMountSkinFightPower(int mountCode)
|
{
|
var config = HorseSkinPlusConfig.Get(mountSkin[mountCode]);
|
return (UIHelper.GetFightPower(GetMountAttrAddDict(mountCode)) + config.InitFightPower);
|
}
|
|
#endregion
|
|
#region 技能整合
|
public bool TryGetIntegrationSkill(SkillEffectGroup effect, out int skillId)
|
{
|
return integrationSkills.TryGetValue(effect, out skillId);
|
}
|
|
public bool TryGetHorseSkills(SkillEffectGroup effect, out List<int> skills)
|
{
|
return integrationHorseSkills.TryGetValue(effect, out skills);
|
}
|
|
public SkillEffectGroup GetSkillEffectGroup(int skillId)
|
{
|
if (horseSkillEffectValues.ContainsKey(skillId))
|
{
|
return horseSkillEffectValues[skillId];
|
}
|
return default(SkillEffectGroup);
|
}
|
|
public bool IsSkillUnlock(int skillId)
|
{
|
var config = SkillConfig.Get(skillId);
|
if (config == null)
|
{
|
return false;
|
}
|
var effect = SkillConfig.GetSkillEffectValue(config);
|
|
if (integrationHorseSkills.ContainsKey(effect)
|
&& !integrationHorseSkills[effect].Contains(skillId))
|
{
|
var skills = integrationHorseSkills[effect];
|
foreach (var id in skills)
|
{
|
if (IsSkillUnlock(id))
|
{
|
return true;
|
}
|
}
|
}
|
else
|
{
|
if (GetMountSkillAndItem.ContainsKey(skillId))
|
{
|
var horseId = GetMountSkillAndItem[skillId].HorseID;
|
if (_DicHorse.ContainsKey(horseId))
|
{
|
var horseInfo = _DicHorse[horseId];
|
if (horseInfo.Lv >= GetSkillUnlockLevel(skillId))
|
{
|
return true;
|
}
|
}
|
}
|
}
|
return false;
|
}
|
|
public int GetSkillUnlockLevel(int skillId)
|
{
|
if (GetMountSkillAndItem.ContainsKey(skillId))
|
{
|
return GetMountSkillAndItem[skillId].HorseLV;
|
}
|
return 0;
|
}
|
#endregion
|
|
public bool IsHorseMaxLevel(int horseId)
|
{
|
if (_DicHorse.ContainsKey(horseId))
|
{
|
var horseConfig = HorseConfig.Get(horseId);
|
return _DicHorse[horseId].Lv >= horseConfig.MaxLV;
|
}
|
else
|
{
|
return false;
|
}
|
}
|
|
public bool IsHorseUnlock(int horseId)
|
{
|
return _DicHorse.ContainsKey(horseId);
|
}
|
|
private Dictionary<int, int> HorseAllAttr = new Dictionary<int, int>();
|
private int activeAllSkinAddPower = 0; //额外增加的坐骑皮肤战力
|
//坐骑属性:丹经验属性,升阶属性,皮肤属性
|
public Dictionary<int, int> RefreshHorseAllAttr()
|
{
|
HorseAllAttr.Clear();
|
activeAllSkinAddPower = 0;
|
|
//丹经验属性
|
for (int i = 1; i <= HorseLV; i++)
|
{
|
var config = HorseLVUpConfig.Get(i);
|
var eatCnt = 0;
|
if (config.useCnt == 0)
|
{
|
//最高级不计算
|
continue;
|
}
|
else if (i == HorseLV)
|
{
|
|
//当前等级取封包数量
|
eatCnt = HorseEatCount / config.useCnt;
|
}
|
else
|
{
|
eatCnt = config.NeedEatCount / config.useCnt;
|
}
|
|
for (int j = 0; j < config.UpItemAttrType.Length; j++)
|
{
|
var upKey = config.UpItemAttrType[j];
|
if (!HorseAllAttr.ContainsKey(upKey))
|
{
|
HorseAllAttr[upKey] = 0;
|
}
|
|
HorseAllAttr[upKey] = HorseAllAttr[upKey] + eatCnt * config.UpItemAttrValue[j];
|
}
|
}
|
|
//升阶属性
|
for (int k = 1; k <= HorseLV; k++)
|
{
|
var horseLVConfig = HorseLVUpConfig.Get(k);
|
for (int i = 0; i < horseLVConfig.LVAttrType.Length; i++)
|
{
|
if (!HorseAllAttr.ContainsKey(horseLVConfig.LVAttrType[i]))
|
{
|
HorseAllAttr[horseLVConfig.LVAttrType[i]] = 0;
|
}
|
|
HorseAllAttr[horseLVConfig.LVAttrType[i]] = HorseAllAttr[horseLVConfig.LVAttrType[i]] + horseLVConfig.LVAttrValue[i];
|
}
|
}
|
//皮肤属性
|
foreach (var byteID in HorseSkinPlusConfig.GetKeys())
|
{
|
if (!isMountSkinActiveByID(int.Parse(byteID)))
|
//未激活皮肤
|
continue;
|
|
var config = HorseSkinPlusConfig.Get(byteID);
|
for (int i = 0; i < config.AttrType.Length; i++)
|
{
|
if (!HorseAllAttr.ContainsKey(config.AttrType[i]))
|
{
|
HorseAllAttr[config.AttrType[i]] = 0;
|
}
|
HorseAllAttr[config.AttrType[i]] = HorseAllAttr[config.AttrType[i]] + config.AttrValue[i];
|
}
|
activeAllSkinAddPower += config.InitFightPower;
|
}
|
|
return HorseAllAttr;
|
}
|
|
public bool isMountSkinActive(int horseID)
|
{
|
if (!mountSkin.ContainsKey(horseID))
|
{
|
return false;
|
}
|
|
return isMountSkinActiveByID(mountSkin[horseID]);
|
}
|
|
public bool isMountSkinActiveByID(int ID)
|
{
|
if (horseSkinArray == null || horseSkinArray.Length == 0)
|
return false;
|
|
int index = ID / 31;
|
int value = ID % 31;
|
if (((int)Math.Pow(2, value) & horseSkinArray[index]) <= 0)
|
//未激活皮肤
|
return false;
|
|
return true;
|
}
|
|
//额外增加战力
|
public int GetMountSkinAddFightPower()
|
{
|
int fightPower = 0;
|
foreach (var config in HorseSkinPlusConfig.GetValues())
|
{
|
if (isMountSkinActiveByID(config.ID))
|
{
|
fightPower += config.InitFightPower;
|
}
|
}
|
|
return fightPower;
|
}
|
|
|
public Dictionary<int, int> GetHorseAllAttr()
|
{
|
if (HorseAllAttr.Keys.Count == 0)
|
RefreshHorseAllAttr();
|
return HorseAllAttr;
|
}
|
//UIHelper.GetFightPower(FightDic)
|
|
public int GetHorseFightPower()
|
{
|
var allAttrDict = GetHorseAllAttr();
|
return UIHelper.GetFightPower(allAttrDict) + activeAllSkinAddPower;
|
}
|
//默认驯养一颗,当数量大于X 全部驯养(不超过2阶)
|
public int GetTrainCount()
|
{
|
var config = HorseLVUpConfig.Get(HorseLV);
|
if (config.NeedEatCount == 0)
|
{
|
//已满级
|
return 0;
|
}
|
|
//int number = playerPack.GetItemCountByID(PackType.Item, horseUpItemId);
|
|
//if (number > HorseTrainMoreCnt)
|
//{
|
// trainCount = number;
|
// if (HorseEatCount + number >= config.NeedEatCount)
|
// {
|
// //有升阶的情况,最多一阶
|
// var Nextconfig = HorseLVUpConfig.Get(HorseLV + 1);
|
// if (Nextconfig.NeedEatCount == 0)
|
// {
|
// //升级后满级
|
// trainCount = config.NeedEatCount - HorseEatCount;
|
// }
|
// else if (number >= (config.NeedEatCount - HorseEatCount + Nextconfig.NeedEatCount))
|
// {
|
// //超过2阶的情况
|
// trainCount = config.NeedEatCount - HorseEatCount + Nextconfig.NeedEatCount - 1;
|
// }
|
// }
|
//}
|
|
var nextConfig = HorseLVUpConfig.Get(HorseLV + 1);
|
if (nextConfig.NeedEatCount == 0)
|
{
|
// 下一阶满级,只扣剩余所需不超过单次的材料数量
|
if (config.NeedEatCount - HorseEatCount < config.useCnt)
|
{
|
return config.NeedEatCount - HorseEatCount;
|
}
|
}
|
|
return config.useCnt;
|
}
|
|
public Dictionary<int, int> GetNextTrainAttr()
|
{
|
Dictionary<int, int> nextTrainAttr = new Dictionary<int, int>();
|
var NextTrainCount = GetTrainCount();
|
if (NextTrainCount == 0)
|
{
|
return nextTrainAttr;
|
}
|
|
var config = HorseLVUpConfig.Get(HorseLV);
|
for (int i = 0; i < config.UpItemAttrType.Length; i++)
|
{
|
nextTrainAttr[config.UpItemAttrType[i]] = config.UpItemAttrValue[i];
|
}
|
|
if (HorseEatCount + NextTrainCount >= config.NeedEatCount)
|
{
|
//有升阶的情况
|
var Nextconfig = HorseLVUpConfig.Get(HorseLV + 1);
|
|
for (int i = 0; i < Nextconfig.LVAttrType.Length; i++)
|
{
|
if (!nextTrainAttr.ContainsKey(Nextconfig.LVAttrType[i]))
|
{
|
nextTrainAttr[Nextconfig.LVAttrType[i]] = 0;
|
}
|
nextTrainAttr[Nextconfig.LVAttrType[i]] = nextTrainAttr[Nextconfig.LVAttrType[i]] + Nextconfig.LVAttrValue[i];
|
}
|
}
|
|
return nextTrainAttr;
|
}
|
//获取升阶的所有坐骑ID
|
public List<int> RankHorseIDList = new List<int>();
|
private void GetRankHorseIDs()
|
{
|
RankHorseIDList.Clear();
|
foreach (var horseConfig in HorseLVUpConfig.GetValues())
|
{
|
RankHorseIDList.Add(horseConfig.HorseID);
|
}
|
}
|
|
//坐骑幻化升星
|
public void UpdateHorseStarInfo(HA3CD_tagMCHorseStarInfo netPack)
|
{
|
for (int i = 0; i < netPack.HorseStarList.Length; i++)
|
{
|
horseStarDict[(int)netPack.HorseStarList[i].HorseID] = netPack.HorseStarList[i].Star;
|
}
|
onMountSkinActive?.Invoke();
|
|
foreach (var id in unLockSkinItems.Keys)
|
{
|
RefreshStarRedpoint(id);
|
}
|
}
|
|
//坐骑幻化物品是否可用于觉醒
|
public bool IsHorseSkinCanAwake(int horseID)
|
{
|
if (!isMountSkinActive(horseID))
|
{
|
return false;
|
}
|
|
if (!HorseStarUpConfig.horseIDToIDs.ContainsKey(horseID))
|
return true;
|
|
int star = 0;
|
horseStarDict.TryGetValue(horseID, out star);
|
//满星
|
if (star != HorseStarUpConfig.horseIDToIDs[horseID].Count)
|
return false;
|
|
return true;
|
}
|
}
|