using Snxxz.UI;
|
using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using System.Text.RegularExpressions;
|
|
using UnityEngine;
|
//用于坐骑
|
[XLua.LuaCallCSharp]
|
public class HorseClass
|
{
|
public int Lv;//坐骑等级
|
public int Exp;//经验
|
|
}
|
public enum HorseEnum
|
{
|
HorseDan = 0,//坐骑丹
|
HorseDebris = 1,//坐骑碎片
|
HorseStone = 2,//坐骑魂石
|
}
|
|
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(string NowMount);//当前坐骑变更
|
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> mountRedpoint = new Dictionary<int, Redpoint>();//坐骑外观切换红点
|
public Dictionary<int, Redpoint> DeblockingRedPoint = new Dictionary<int, Redpoint>();//激活按钮红点
|
public Dictionary<int, Redpoint> ASingleFeedRedPoint = new Dictionary<int, Redpoint>();//单次喂养红点
|
private List<HorseConfig> SortMount = new List<HorseConfig>();//用于红点排序
|
public int MountStoneItemId = 0;
|
public bool IsOk = false;
|
public List<int> ListEffectSkill = new List<int>();
|
private int HorseDanExp = 0;//坐骑丹经验
|
private int autoActiveHorseId = 0;
|
private bool hasSendAutoActive = false;
|
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 override void Init()
|
{
|
ToAddSorting();
|
playerPack.refreshItemCountEvent += OnItemRefreshEvent;
|
MountWin.RedPointMountDan += RedPointMountDan;
|
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);
|
string HorseUpItem = FuncConfigConfig.Get("HorseUpItem").Numerical2;
|
HorseDanExp = int.Parse(HorseUpItem);
|
|
var 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);
|
}
|
}
|
|
public override void UnInit()
|
{
|
MountWin.RedPointMountDan -= RedPointMountDan;
|
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;
|
}
|
|
public void OnPlayerLoginOk()
|
{
|
GlobalTimeEvent.Instance.secondEvent -= secondEvent;
|
GlobalTimeEvent.Instance.secondEvent += secondEvent;
|
IsOk = true;
|
SinglePack singPack = playerPack.GetSinglePack(PackType.Equip);
|
if (singPack == null) return;
|
foreach (var index in singPack.GetAllItems().Keys)
|
{
|
OnItemRefreshEvent(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>();
|
List<HorseUpConfig> Uconfigs = new List<HorseUpConfig>();
|
private void MountNumberPreservation()//用来对坐骑个数的保存
|
{
|
if (mountRedpoint.Count != 0)
|
return;
|
|
// var configs = HorseConfig.GetValues();
|
if (Hconfigs.Count <= 0)
|
{
|
Hconfigs = HorseConfig.GetValues();
|
}
|
int type = 0;
|
foreach (var config in Hconfigs)
|
{
|
if (!mountRedpoint.ContainsKey(config.HorseID))
|
{
|
type += 1;
|
int mountID = config.HorseID;
|
int RedPoint_Mountkey = MainRedDot.RedPoint_MountPackKey * 10 + mountID;
|
Redpoint redPointMountStare = new Redpoint(Redpoint_key1, RedPoint_Mountkey);
|
mountRedpoint.Add(mountID, redPointMountStare);
|
|
int RedPoint_Mountkey1 = RedPoint_Mountkey * 10 + type;
|
Redpoint redPointMountStare1 = new Redpoint(RedPoint_Mountkey, RedPoint_Mountkey1);
|
DeblockingRedPoint.Add(mountID, redPointMountStare1);
|
|
int RedPoint_Mountkey2 = RedPoint_Mountkey1 * 10 + type;
|
Redpoint redPointMountStare2 = new Redpoint(RedPoint_Mountkey, RedPoint_Mountkey2);
|
ASingleFeedRedPoint.Add(mountID, redPointMountStare2);
|
}
|
|
}
|
|
}
|
private void MountChangeRedPoint()//坐骑激活红点
|
{
|
foreach (var key in DeblockingRedPoint.Keys)
|
{
|
DeblockingRedPoint[key].state = RedPointState.None;
|
}
|
if (!FuncOpen.Instance.IsFuncOpen(8))
|
{
|
return;
|
}
|
if (Hconfigs.Count <= 0)
|
{
|
Hconfigs = HorseConfig.GetValues();
|
}
|
// var configs = HorseConfig.GetValues();
|
foreach (var config in Hconfigs)
|
{
|
int unlockItemID = config.UnlockItemID;
|
int itemCount = playerPack.GetItemCountByID(PackType.Item, unlockItemID);
|
int unlockItemCnt = config.UnlockItemCnt;
|
if (itemCount >= unlockItemCnt && !_DicHorse.ContainsKey(config.HorseID))
|
{
|
DeblockingRedPoint[config.HorseID].state = RedPointState.Simple;
|
}
|
}
|
}
|
|
void MountSkillAndItem()//获取坐骑技能
|
{
|
if (GetMountSkillAndItem.Count != 0)
|
return;
|
if (Uconfigs.Count <= 0)
|
{
|
Uconfigs = HorseUpConfig.GetValues();
|
}
|
//var configs = HorseUpConfig.GetValues();
|
foreach (var config in Uconfigs)
|
{
|
if (!HorseConfig.Has(config.HorseID))
|
{
|
continue;
|
}
|
|
for (int i = 0; i < config.SkillID.Length; i++)
|
{
|
int skillID = config.SkillID[i];
|
if (skillID != 0 && !GetMountSkillAndItem.ContainsKey(skillID))
|
{
|
SkillConfig _skillModel = SkillConfig.Get(skillID);
|
if (_skillModel == null)
|
{
|
Debug.Log(skillID);
|
}
|
|
HorseSkillClass horseSkillClass = new HorseSkillClass();
|
horseSkillClass.SkillID = skillID;
|
horseSkillClass.SkillItem = _skillModel.ExAttr4;
|
horseSkillClass.HorseID = config.HorseID;
|
horseSkillClass.HorseLV = config.LV;
|
GetMountSkillAndItem.Add(skillID, horseSkillClass);
|
}
|
}
|
}
|
}
|
private const int Redpoint_key1 = 1050101;
|
public Redpoint redPointStre1 = new Redpoint(MainRedDot.RedPoint_MountPackKey, Redpoint_key1);//坐骑外观
|
private const int Redpoint_key2 = 1050102;
|
public Redpoint redPointStre2 = new Redpoint(MainRedDot.RedPoint_MountPackKey, Redpoint_key2);//坐骑兽魂
|
private void OnItemRefreshEvent(PackType type, int index, int id)
|
{
|
if (type == PackType.Equip)
|
{
|
RefreshCurrentMount(playerPack.GetItemByIndex(type, index));
|
}
|
|
if (type == PackType.Item)
|
{
|
if (_DicMountItem.ContainsKey(id))
|
{
|
MountStoneRed();
|
}
|
MountChangeRedPoint();
|
MountDanRed();
|
|
var config = HorseConfig.Get(autoActiveHorseId);
|
if (config != null && id == config.UnlockItemID)
|
{
|
TryAutoActiveHorse();
|
}
|
}
|
}
|
|
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);
|
}
|
}
|
}
|
}
|
|
private 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 RedPointMountDan()
|
{
|
MountDanRed();
|
}
|
|
private void ToAddSorting()
|
{
|
SortMount.Clear();
|
if (Hconfigs.Count <= 0)
|
{
|
Hconfigs = HorseConfig.GetValues();
|
}
|
SortMount = Hconfigs;
|
SortMount.Sort(Compare);
|
}
|
int Compare(HorseConfig x, HorseConfig y)//数组排列
|
{
|
if (x.Sort.CompareTo(y.Sort) != 0)
|
{
|
return x.Sort.CompareTo(y.Sort);
|
}
|
return 1;
|
}
|
private void MountDanRed()//关于坐骑丹红点
|
{
|
foreach (var key in ASingleFeedRedPoint.Keys)
|
{
|
ASingleFeedRedPoint[key].state = RedPointState.None;
|
}
|
if (!FuncOpen.Instance.IsFuncOpen(8) || _DicHorse.Count == 0)
|
{
|
return;
|
}
|
List<int> IntList = new List<int>();
|
FuncConfigConfig _tagfun = FuncConfigConfig.Get("HorseUpItem");
|
ItemConfig _tagchine = ItemConfig.Get(int.Parse(_tagfun.Numerical1));
|
int number = playerPack.GetItemCountByID(PackType.Item, _tagchine.ID);
|
for (int i = 0; i < SortMount.Count; i++)
|
{
|
int horseID = SortMount[i].HorseID;
|
int MaxLv = HorseConfig.Get(horseID).MaxLV;
|
if (_DicHorse.ContainsKey(horseID) && _DicHorse[horseID].Lv < MaxLv)
|
{
|
int _NeedExp = HorseUpConfig.GetHorseIDAndLV(horseID, (_DicHorse[horseID].Lv)).NeedExp;
|
int NeedExp = _NeedExp - _DicHorse[horseID].Exp;
|
int NeedNumber = Mathf.CeilToInt((float)NeedExp / HorseDanExp);
|
if (number >= NeedNumber)
|
{
|
IntList.Add(horseID);
|
}
|
}
|
}
|
|
foreach (var key in _DicHorse.Keys)//因为有成就任务限制所有 第一只坐骑红点逻辑特殊写
|
{
|
if (DicDefaultMount.ContainsKey(key) && DicDefaultMount[key] > _DicHorse[key].Lv
|
&& number > 0 && ASingleFeedRedPoint.ContainsKey(key))
|
{
|
ASingleFeedRedPoint[key].state = RedPointState.Simple;
|
return;
|
}
|
}
|
int GetMinLV = 100;
|
int GetMountID = 0;
|
List<int> IntListSkill = new List<int>();
|
for (int j = 0; j < SortMount.Count; j++)//选取出可升级坐骑等级最低且有未激活技能的坐骑切经验最少
|
{
|
int Id = SortMount[j].HorseID;
|
int GetHorseMaxLv = GetMountSkillMaxLV(Id);
|
if (IntList.Contains(Id) && _DicHorse.ContainsKey(Id))
|
{
|
if (_DicHorse[Id].Lv < GetHorseMaxLv)
|
{
|
IntListSkill.Add(Id);
|
}
|
}
|
}
|
int SkillHorseId = GetRedPointMountID(IntListSkill);
|
if (SkillHorseId != 0 && ASingleFeedRedPoint.ContainsKey(SkillHorseId))
|
{
|
ASingleFeedRedPoint[SkillHorseId].state = RedPointState.Simple;
|
return;
|
}
|
|
|
for (int j = 0; j < SortMount.Count; j++)//选取出可升级坐骑等级最低
|
{
|
int Id = SortMount[j].HorseID;
|
if (IntList.Contains(Id) && _DicHorse.ContainsKey(Id))
|
{
|
if (_DicHorse[Id].Lv < GetMinLV)
|
{
|
GetMinLV = _DicHorse[Id].Lv;
|
GetMountID = Id;
|
}
|
}
|
}
|
if (GetMountID != 0 && ASingleFeedRedPoint.ContainsKey(GetMountID))
|
{
|
ASingleFeedRedPoint[GetMountID].state = RedPointState.Simple;
|
return;
|
}
|
}
|
|
public int GetMinExpMount()
|
{
|
foreach (var key in ASingleFeedRedPoint.Keys)//当存在驯养红点时选中当有红点的那只
|
{
|
if (ASingleFeedRedPoint[key].state == RedPointState.Simple)
|
{
|
return key;
|
}
|
}
|
int GetMountID = 0;
|
int MountLV = 999;
|
List<int> IntListSkill = new List<int>();
|
foreach (var key in _DicHorse.Keys)
|
{
|
var mountConfig = HorseConfig.Get(key);
|
if (_DicHorse[key].Lv < mountConfig.MaxLV)
|
{
|
IntListSkill.Add(key);
|
}
|
}
|
int SkillHorseId = GetRedPointMountID(IntListSkill);
|
if (SkillHorseId != 0)
|
{
|
GetMountID = SkillHorseId;
|
return GetMountID;
|
}
|
foreach (var key in _DicHorse.Keys)//无红点时跳转选中最低阶数且未满级
|
{
|
var mountConfig = HorseConfig.Get(key);
|
if (_DicHorse[key].Lv < MountLV && _DicHorse[key].Lv < mountConfig.MaxLV)
|
{
|
GetMountID = key;
|
MountLV = _DicHorse[key].Lv;
|
}
|
}
|
return GetMountID;
|
}
|
|
private int GetRedPointMountID(List<int> MountList)
|
{
|
int GetSkillMinLv = 999;
|
for (int i = 0; i < MountList.Count; i++)
|
{
|
int SkillminLv = GetSkillLvDis(MountList[i]);
|
if (SkillminLv < GetSkillMinLv && SkillminLv != 0)
|
{
|
GetSkillMinLv = SkillminLv;
|
}
|
}
|
|
int mountId = 0;
|
int ExpNumber = 999999999;
|
for (int i = 0; i < MountList.Count; i++)
|
{
|
int SkillLv = GetSkillLvDis(MountList[i]);
|
if (SkillLv > GetSkillMinLv || SkillLv == 0)
|
{
|
continue;
|
}
|
var Hor1 = HorseUpConfig.GetHorseIDAndLV(MountList[i], SkillLv);
|
var Hor2 = HorseUpConfig.GetHorseIDAndLV(MountList[i], _DicHorse[(MountList[i])].Lv);
|
int Exp = Hor1.NeedExpTotal - Hor2.NeedExpTotal - _DicHorse[(MountList[i])].Exp;
|
if (Exp < ExpNumber)
|
{
|
ExpNumber = Exp;
|
mountId = MountList[i];
|
}
|
}
|
return mountId;
|
}
|
|
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(_HorseIDNow);
|
}
|
}
|
}
|
}
|
|
MountDanRed();
|
MountStoneRed();
|
}
|
|
public void MountHA301(HA301_tagTrainHorseData info)//已拥有的坐骑(获得与刷新)
|
{
|
for (int i = 0; i < info.Num; i++)
|
{
|
|
if (_DicHorse.ContainsKey((int)info.InfoList[i].HorseID))
|
{
|
if ((int)info.InfoList[i].LV > _DicHorse[(int)info.InfoList[i].HorseID].Lv)
|
{
|
if (OnMountUieffectUpLv != null && IsOk)
|
{
|
OnMountUieffectUpLv();
|
}
|
}
|
_DicHorse[(int)info.InfoList[i].HorseID].Lv = (int)info.InfoList[i].LV;//坐骑等级
|
_DicHorse[(int)info.InfoList[i].HorseID].Exp = (int)info.InfoList[i].Exp;//坐骑经验
|
if (Event_MountHA301U != null && IsOk)
|
{
|
Event_MountHA301U((int)info.InfoList[i].HorseID);
|
}
|
|
}
|
else
|
{
|
HorseClass _horseClass = new HorseClass();
|
_horseClass.Lv = (int)info.InfoList[i].LV;//坐骑等级
|
_horseClass.Exp = (int)info.InfoList[i].Exp;//坐骑经验
|
|
_DicHorse.Add((int)info.InfoList[i].HorseID, _horseClass);
|
if (Event_MountHA301A != null && IsOk)
|
{
|
Event_MountHA301A((int)info.InfoList[i].HorseID);
|
}
|
|
|
if (IsOk && (int)info.InfoList[i].HorseID == autoActiveHorseId)
|
{
|
var config = HorseConfig.Get(autoActiveHorseId);
|
if (_horseClass.Lv >= config.UseNeedRank)
|
{
|
AppearanceSwitch(autoActiveHorseId);
|
DTC0428_tagPlayerRideHorse.Send_tagPlayerRideHorse(true);
|
}
|
}
|
}
|
}
|
MountStoneRed();
|
MountChangeRedPoint();
|
MountDanRed();
|
}
|
|
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;//攻击
|
foreach (int key in _DicHorse.Keys)
|
{
|
HorseUpConfig tagMode = HorseUpConfig.GetHorseIDAndLV(key, _DicHorse[key].Lv);
|
int[] intAttrValue = tagMode.AttrValue;
|
if (intAttrValue.Length != 0)
|
{
|
_AttT += intAttrValue[1];
|
}
|
}
|
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;
|
}
|
}
|
|
public void AppearanceSwitch(int HorseID)//坐骑外观切换
|
{
|
CA502_tagPlayerChooseHorse _tagCA502 = new CA502_tagPlayerChooseHorse();
|
_tagCA502.Index = (uint)HorseID;
|
GameNetSystem.Instance.SendInfo(_tagCA502);
|
}
|
|
public void MountDanUse(int HorseID, int Number, bool IsAutoBuy = false)//是否自动购买
|
{
|
CA527_tagCMHorseUp _tagC527 = new CA527_tagCMHorseUp();//向服务端发包坐骑经验单
|
_tagC527.HorseID = (uint)HorseID;
|
_tagC527.UseItemCnt = (byte)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>();
|
HorseConfig horseConfig = HorseConfig.Get(mountCode);
|
mountAttrDict.Clear();
|
if (horseConfig == null) return mountAttrDict;
|
|
int maxRank = horseConfig.MaxLV;
|
HorseUpConfig cost = HorseUpConfig.GetHorseIDAndLV(mountCode, maxRank);
|
if (cost != null)
|
{
|
int[] attrIds = cost.AttrType;
|
int[] attrValues = cost.AttrValue;
|
if (attrIds != null)
|
{
|
for (int j = 0; j < attrIds.Length; j++)
|
{
|
if (!mountAttrDict.ContainsKey(attrIds[j]))
|
{
|
mountAttrDict.Add(attrIds[j], attrValues[j]);
|
}
|
else
|
{
|
mountAttrDict[attrIds[j]] += attrValues[j];
|
}
|
}
|
}
|
}
|
return mountAttrDict;
|
}
|
|
#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
|
}
|