//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Wednesday, May 30, 2018
|
//--------------------------------------------------------
|
using UnityEngine;
|
using System.Collections;
|
using UnityEngine.UI;
|
|
using System;
|
using System.Collections.Generic;
|
|
namespace vnxbqy.UI
|
{
|
|
|
public class RidingAndPetActivationModel : Model, IBeforePlayerDataInitialize, IPlayerLoginOk
|
{
|
|
public RidingAndPetActivation RidingAndPetActivation1;
|
public int ActivateID1 = 0;
|
public int SkillID1 = 0;
|
public int Lv = 1;
|
|
PetModel m_petModel;
|
PetModel petmodel { get { return m_petModel ?? (m_petModel = ModelCenter.Instance.GetModel<PetModel>()); } }
|
|
MountModel m_MountModel;
|
MountModel mountModel { get { return m_MountModel ?? (m_MountModel = ModelCenter.Instance.GetModel<MountModel>()); } }
|
//==============坐骑属性弹框
|
public PropertyTip property;
|
public int RidingId;
|
List<int> PetAndMountExpList = new List<int>();
|
List<int> PetAndMountNumList = new List<int>();
|
public override void Init()
|
{
|
|
}
|
|
public void OnBeforePlayerDataInitialize()
|
{
|
|
}
|
|
public void OnPlayerLoginOk()
|
{
|
var funconfig = FuncConfigConfig.Get("MountPetDan");
|
int[] expList = ConfigParse.GetMultipleStr<int>(funconfig.Numerical1);
|
int[] numList = ConfigParse.GetMultipleStr<int>(funconfig.Numerical2);
|
PetAndMountExpList.Clear();
|
PetAndMountNumList.Clear();
|
for (int i = 0; i < expList.Length; i++)
|
{
|
PetAndMountExpList.Add(expList[i]);
|
}
|
for (int i = 0; i < numList.Length; i++)
|
{
|
PetAndMountNumList.Add(numList[i]);
|
}
|
}
|
|
public override void UnInit()
|
{
|
|
}
|
|
|
public void RidingAndPetActivationSet(RidingAndPetActivation ridingAndPetActivation, int ActivateID, int SkillID = 0, int lv = 1)
|
{
|
RidingAndPetActivation1 = ridingAndPetActivation;
|
ActivateID1 = ActivateID;
|
SkillID1 = SkillID;
|
Lv = lv;
|
WindowCenter.Instance.Open<RidingAndPetActivationWin>();
|
}
|
|
public enum RidingAndPetProperty
|
{
|
PetAttack = 508,//灵宠攻击
|
PetLife = 509,//人物生命(灵宠赋予角色的)
|
MountProperty1 = 510,//坐骑属性效果1
|
MountProperty2 = 511,//坐骑属性效果2
|
//后续IL开发添加预设
|
default1,
|
default2,
|
default3,
|
default4,
|
default5,
|
default6,
|
default7,
|
default8,
|
default9,
|
default10,
|
}
|
//-------------关于灵宠的攻击加成
|
public float GetPetSkillAddAttack(int PetSkill)//用来获取单个技能增加的的攻击值
|
{
|
SkillConfig skillconfig = SkillConfig.Get(PetSkill);
|
if (skillconfig == null)
|
{
|
return 0f;
|
}
|
if (skillconfig.Effect1 == (int)RidingAndPetProperty.PetAttack)
|
{
|
return GetPetAttack(skillconfig.EffectValue11, skillconfig.EffectValue12);
|
}
|
else if (skillconfig.Effect2 == (int)RidingAndPetProperty.PetAttack)
|
{
|
return GetPetAttack(skillconfig.EffectValue21, skillconfig.EffectValue22);
|
}
|
else if (skillconfig.Effect3 == (int)RidingAndPetProperty.PetAttack)
|
{
|
return GetPetAttack(skillconfig.EffectValue31, skillconfig.EffectValue32);
|
}
|
else if (skillconfig.Effect4 == (int)RidingAndPetProperty.PetAttack)
|
{
|
return GetPetAttack(skillconfig.EffectValue41, skillconfig.EffectValue42);
|
}
|
else if (skillconfig.Effect5 == (int)RidingAndPetProperty.PetAttack)
|
{
|
return GetPetAttack(skillconfig.EffectValue51, skillconfig.EffectValue52);
|
}
|
else if (skillconfig.Effect6 == (int)RidingAndPetProperty.PetAttack)
|
{
|
return GetPetAttack(skillconfig.EffectValue61, skillconfig.EffectValue62);
|
}
|
return 0f;
|
}
|
private float GetPetAttack(int Quality, int Value)
|
{
|
float Number = 0;
|
var petInfo = PetInfoConfig.GetValues();
|
foreach (var value in petInfo)
|
{
|
if (petmodel._DicPetBack.ContainsKey(value.ID) && value.Quality == Quality)
|
{
|
PetClassCostConfig PetClassCost = PetClassCostConfig.GetPetIdAndRank(value.ID, petmodel._DicPetBack[value.ID].PetClass);
|
Number += PetClassCost.AtkAdd;
|
}
|
|
}
|
float specificValue = (float)Value / 10000;
|
|
return (float)(Number * specificValue);
|
}
|
public float GetOnePetAddAttack(int PetID)//获得单只宠物的攻击加成
|
{
|
|
if (petmodel._DicPetBack.ContainsKey(PetID))
|
{
|
PetInfoConfig petInfo = PetInfoConfig.Get(PetID);
|
int[] ids = petInfo.SkillID;
|
int[] unlocks = petInfo.SkillUnLock;
|
float attackAdd = 0f;
|
for (int i = 0; i < unlocks.Length; i++)
|
{
|
if (petmodel._DicPetBack[PetID].PetClass >= unlocks[i])
|
{
|
attackAdd += GetPetSkillAddAttack(ids[i]);
|
}
|
}
|
return attackAdd;
|
}
|
return 0f;
|
}
|
public float GetAllPetAddAttack()//获取所有灵宠的攻击加成
|
{
|
if (petmodel._DicPetBack.Count <= 0)
|
{
|
return 0f;
|
}
|
float attackAllAdd = 0f;
|
foreach (var key in petmodel._DicPetBack.Keys)
|
{
|
attackAllAdd += GetOnePetAddAttack(key);
|
}
|
return attackAllAdd;
|
}
|
//-------------关于灵宠给予人物的生命加成
|
public float GetPetSkillAddLife(int PetSkill)//用来获取单个技能增加的的生命值
|
{
|
SkillConfig skillconfig = SkillConfig.Get(PetSkill);
|
if (skillconfig == null)
|
{
|
return 0f;
|
}
|
if (skillconfig.Effect1 == (int)RidingAndPetProperty.PetLife)
|
{
|
return GetPetAttack(skillconfig.EffectValue11, skillconfig.EffectValue12);
|
}
|
else if (skillconfig.Effect2 == (int)RidingAndPetProperty.PetLife)
|
{
|
return GetPetAttack(skillconfig.EffectValue21, skillconfig.EffectValue22);
|
}
|
else if (skillconfig.Effect3 == (int)RidingAndPetProperty.PetLife)
|
{
|
return GetPetAttack(skillconfig.EffectValue31, skillconfig.EffectValue32);
|
}
|
else if (skillconfig.Effect4 == (int)RidingAndPetProperty.PetLife)
|
{
|
return GetPetAttack(skillconfig.EffectValue41, skillconfig.EffectValue42);
|
}
|
else if (skillconfig.Effect5 == (int)RidingAndPetProperty.PetLife)
|
{
|
return GetPetAttack(skillconfig.EffectValue51, skillconfig.EffectValue52);
|
}
|
else if (skillconfig.Effect6 == (int)RidingAndPetProperty.PetLife)
|
{
|
return GetPetAttack(skillconfig.EffectValue61, skillconfig.EffectValue62);
|
}
|
return 0f;
|
}
|
public float GetOnePetAddLife(int PetID)//获得单只宠物的给予人物的生命加成
|
{
|
if (petmodel._DicPetBack.ContainsKey(PetID))
|
{
|
PetInfoConfig petInfo = PetInfoConfig.Get(PetID);
|
int[] ids = petInfo.SkillID;
|
int[] unlocks = petInfo.SkillUnLock;
|
float LifeAdd = 0f;
|
for (int i = 0; i < unlocks.Length; i++)
|
{
|
if (petmodel._DicPetBack[PetID].PetClass >= unlocks[i])
|
{
|
LifeAdd += GetPetSkillAddLife(ids[i]);
|
}
|
}
|
return LifeAdd;
|
}
|
return 0f;
|
}
|
public float GetAllPetAddLife()//获得所有宠物给予人物的生命加成
|
{
|
if (petmodel._DicPetBack.Count <= 0)
|
{
|
return 0f;
|
}
|
float lifeAllAdd = 0f;
|
foreach (var key in petmodel._DicPetBack.Keys)
|
{
|
lifeAllAdd += GetOnePetAddLife(key);
|
}
|
return lifeAllAdd;
|
}
|
//------------关于坐骑技能给予单只坐骑增加的属性值
|
List<HorseSkillClass> MountSkills = new List<HorseSkillClass>();
|
public Dictionary<int, float> GetMountSkillAddProperty(int MountSkill)
|
{
|
Dictionary<int, float> DicSkill = new Dictionary<int, float>();
|
DicSkill.Add(6, 0f);
|
DicSkill.Add(7, 0f);
|
SkillConfig skillconfig = SkillConfig.Get(MountSkill);
|
if (skillconfig == null)
|
{
|
return DicSkill;
|
}
|
if (skillconfig.Effect1 == (int)RidingAndPetProperty.MountProperty1)
|
{
|
DicSkill.Clear();
|
DicSkill = GetMountProperty(skillconfig.EffectValue11, skillconfig.EffectValue12, skillconfig.EffectValue13);
|
return DicSkill;
|
}
|
else if (skillconfig.Effect2 == (int)RidingAndPetProperty.MountProperty1)
|
{
|
DicSkill.Clear();
|
DicSkill = GetMountProperty(skillconfig.EffectValue11, skillconfig.EffectValue12, skillconfig.EffectValue13);
|
return DicSkill;
|
}
|
else if (skillconfig.Effect3 == (int)RidingAndPetProperty.MountProperty1)
|
{
|
DicSkill.Clear();
|
DicSkill = GetMountProperty(skillconfig.EffectValue11, skillconfig.EffectValue12, skillconfig.EffectValue13);
|
return DicSkill;
|
}
|
else if (skillconfig.Effect4 == (int)RidingAndPetProperty.MountProperty1)
|
{
|
DicSkill.Clear();
|
DicSkill = GetMountProperty(skillconfig.EffectValue11, skillconfig.EffectValue12, skillconfig.EffectValue13);
|
return DicSkill;
|
}
|
else if (skillconfig.Effect5 == (int)RidingAndPetProperty.MountProperty1)
|
{
|
DicSkill.Clear();
|
DicSkill = GetMountProperty(skillconfig.EffectValue11, skillconfig.EffectValue12, skillconfig.EffectValue13);
|
return DicSkill;
|
}
|
else if (skillconfig.Effect6 == (int)RidingAndPetProperty.MountProperty1)
|
{
|
DicSkill.Clear();
|
DicSkill = GetMountProperty(skillconfig.EffectValue11, skillconfig.EffectValue12, skillconfig.EffectValue13);
|
return DicSkill;
|
}
|
return DicSkill;
|
}
|
private Dictionary<int, float> GetMountProperty(int mountID, int ValueKey, int Value)
|
{
|
Dictionary<int, float> DicSkill = new Dictionary<int, float>();
|
return DicSkill;
|
}
|
public Dictionary<int, float> GetOneMountProperty(int MountID)//获取单只坐骑的技能属性加成
|
{
|
MountSkills.Clear();
|
foreach (var key in mountModel.GetMountSkillAndItem.Keys)
|
{
|
if (mountModel.GetMountSkillAndItem[key].HorseID == MountID)
|
{
|
MountSkills.Add(mountModel.GetMountSkillAndItem[key]);
|
}
|
}
|
Dictionary<int, float> DicSkill = new Dictionary<int, float>();
|
DicSkill.Add(6, 0f);
|
DicSkill.Add(7, 0f);
|
if (mountModel._DicHorse.ContainsKey(MountID))
|
{
|
for (int i = 0; i < MountSkills.Count; i++)
|
{
|
if (mountModel._DicHorse[MountID].Lv >= MountSkills[i].HorseLV)
|
{
|
DicSkill[6] += GetMountSkillAddProperty(MountSkills[i].SkillID)[6];
|
DicSkill[7] += GetMountSkillAddProperty(MountSkills[i].SkillID)[7];
|
}
|
|
}
|
return DicSkill;
|
}
|
return DicSkill;
|
}
|
public Dictionary<int, float> GetAllMountProperty()//获取所有坐骑技能的属性加成
|
{
|
Dictionary<int, float> DicSkill = new Dictionary<int, float>();
|
DicSkill.Add(6, 0f);
|
DicSkill.Add(7, 0f);
|
if (mountModel._DicHorse.Count > 0)
|
{
|
foreach (var key in mountModel._DicHorse.Keys)
|
{
|
DicSkill[6] += GetOneMountProperty(key)[6];
|
DicSkill[7] += GetOneMountProperty(key)[7];
|
}
|
|
return DicSkill;
|
}
|
return DicSkill;
|
}
|
//------关于增加坐骑品质的某个属性值
|
public Dictionary<int, float> GetMountSkillAddPropertyQuality(int MountSkill,int value)
|
{
|
Dictionary<int, float> DicSkill = new Dictionary<int, float>();
|
DicSkill.Add(6, 0f);
|
DicSkill.Add(7, 0f);
|
SkillConfig skillconfig = SkillConfig.Get(MountSkill);
|
if (skillconfig == null)
|
{
|
return DicSkill;
|
}
|
if (skillconfig.Effect1 == (int)RidingAndPetProperty.MountProperty2 && skillconfig.EffectValue12== value)
|
{
|
DicSkill.Clear();
|
DicSkill = GetMountPropertyQuality(skillconfig.EffectValue11, skillconfig.EffectValue12, skillconfig.EffectValue13);
|
return DicSkill;
|
}
|
else if (skillconfig.Effect2 == (int)RidingAndPetProperty.MountProperty2 && skillconfig.EffectValue22 == value)
|
{
|
DicSkill.Clear();
|
DicSkill = GetMountPropertyQuality(skillconfig.EffectValue21, skillconfig.EffectValue22, skillconfig.EffectValue23);
|
return DicSkill;
|
}
|
else if (skillconfig.Effect3 == (int)RidingAndPetProperty.MountProperty2 && skillconfig.EffectValue32 == value)
|
{
|
DicSkill.Clear();
|
DicSkill = GetMountPropertyQuality(skillconfig.EffectValue31, skillconfig.EffectValue32, skillconfig.EffectValue33);
|
return DicSkill;
|
}
|
else if (skillconfig.Effect4 == (int)RidingAndPetProperty.MountProperty2 && skillconfig.EffectValue42 == value)
|
{
|
DicSkill.Clear();
|
DicSkill = GetMountPropertyQuality(skillconfig.EffectValue41, skillconfig.EffectValue42, skillconfig.EffectValue43);
|
return DicSkill;
|
}
|
else if (skillconfig.Effect5 == (int)RidingAndPetProperty.MountProperty2 && skillconfig.EffectValue52 == value)
|
{
|
DicSkill.Clear();
|
DicSkill = GetMountPropertyQuality(skillconfig.EffectValue51, skillconfig.EffectValue52, skillconfig.EffectValue53);
|
return DicSkill;
|
}
|
else if (skillconfig.Effect6 == (int)RidingAndPetProperty.MountProperty2 && skillconfig.EffectValue62 == value)
|
{
|
DicSkill.Clear();
|
DicSkill = GetMountPropertyQuality(skillconfig.EffectValue61, skillconfig.EffectValue62, skillconfig.EffectValue63);
|
return DicSkill;
|
}
|
return DicSkill;
|
}
|
private Dictionary<int, float> GetMountPropertyQuality(int Quality, int ValueKey, int Value)
|
{
|
Dictionary<int, float> DicSkill = new Dictionary<int, float>();
|
|
return DicSkill;
|
}
|
public Dictionary<int, float> GetOneMountPropertyQuality(int MountID)//根据品质获取单只坐骑的技能属性加成
|
{
|
MountSkills.Clear();
|
foreach (var key in mountModel.GetMountSkillAndItem.Keys)
|
{
|
if (mountModel.GetMountSkillAndItem[key].HorseID == MountID)
|
{
|
MountSkills.Add(mountModel.GetMountSkillAndItem[key]);
|
}
|
}
|
Dictionary<int, float> DicSkill = new Dictionary<int, float>();
|
DicSkill.Add(6, 0f);
|
DicSkill.Add(7, 0f);
|
if (mountModel._DicHorse.ContainsKey(MountID))
|
{
|
for (int i = 0; i < MountSkills.Count; i++)
|
{
|
if (mountModel._DicHorse[MountID].Lv >= MountSkills[i].HorseLV)
|
{
|
DicSkill[6] += GetMountSkillAddPropertyQuality(MountSkills[i].SkillID, 6)[6];
|
DicSkill[7] += GetMountSkillAddPropertyQuality(MountSkills[i].SkillID,7)[7];
|
}
|
|
}
|
return DicSkill;
|
}
|
return DicSkill;
|
}
|
public Dictionary<int, float> GetAllMountPropertyQuality()//根据品质获取所有坐骑技能的属性加成
|
{
|
Dictionary<int, float> DicSkill = new Dictionary<int, float>();
|
DicSkill.Add(6, 0f);
|
DicSkill.Add(7, 0f);
|
if (mountModel._DicHorse.Count > 0)
|
{
|
foreach (var key in mountModel._DicHorse.Keys)
|
{
|
DicSkill[6] += GetOneMountPropertyQuality(key)[6];
|
DicSkill[7] += GetOneMountPropertyQuality(key)[7];
|
}
|
return DicSkill;
|
}
|
return DicSkill;
|
}
|
|
|
|
public int PetAndHorseNeedDanNum(int exp)//骑宠需要的吃培养的颗数
|
{
|
int _type = 0;
|
bool _bool = true;
|
int needNum = 1;
|
for (int i = 0; i < PetAndMountExpList.Count; i++)
|
{
|
if (exp < PetAndMountExpList[i] && _bool)
|
{
|
_type = i;
|
_bool = false;
|
}
|
}
|
|
if (_type - 1 < 0)
|
{
|
_type = 0;
|
}
|
if (_type + 1 <= PetAndMountNumList.Count)
|
{
|
needNum = PetAndMountNumList[_type];
|
}
|
return needNum;
|
}
|
}
|
|
}
|
|
|
|