//******************************************************************** // 文件名: Fellow.cs // 描述: 伙伴 // 作者: TangYi // 创建时间: 2014-2-18 // // 修改历史: //******************************************************************** using UnityEngine; using System.Collections.Generic; using System; using GCGame.Table; using Games.GlobeDefine; using Games.SkillModle; using UnityEngine.UI; namespace Games.Fellow { public enum FELLOWCLASS { ANIMAL = 1, //动物型 HUNMAN = 2, //人型 } enum FELLOWATTACK { PHYSCIS = 1, //物理攻击 MAGIC = 2, //魔法攻击 } public enum FELLOWQUALITY { WHITE = 1, //白色品质 GREEN = 2, //绿色品质 BLUE = 3, //蓝色品质 PURPLE = 4, //紫色品质 RED = 5, //红色品质 ORANGE = 6, //金色品质 } public partial class Fellow { public Dictionary PropType = new Dictionary() { { 0, "#{20125}" }, { 1, "#{20126}" }, { 2, "#{20127}" }, { 3, "#{20128}" }, }; public Dictionary CharacterType = new Dictionary() { { 1, "#{20134}" }, { 2, "#{20135}" }, { 3, "#{20136}" }, { 4, "#{20137}" }, { 5, "#{20138}" }, }; /// /// 构造函数 /// /// public Fellow() { CleanUp(); } /// /// 清空 /// public void CleanUp() { m_nGuid = GlobeVar.INVALID_GUID; m_nDataId = -1; m_szName = ""; m_nExp = -1; m_nLevel = -1; m_nStarLevel = -1; m_nZzPoint = -1; m_bLocked = false; m_bCalled = false; m_OwnSkillId.Clear(); m_bHelped = false; m_GY_skillid = -1; m_MW_skillid = -1; LockSkillIds.Clear(); m_CombatAttr_Critical = 0; m_CombatAttr_Guard = 0; ownSkillDatas = new OwnSkillData[(int)SKILLDEFINE.MAX_PET_SKILLNUM]; for (int i = 0; i < (int)SKILLDEFINE.MAX_PET_SKILLNUM; i++) { ownSkillDatas[i] = new OwnSkillData(); ownSkillDatas[i].CleanUp(); } } public void SetGodPetSign(Image Sign) { if (m_nDataId >= 0) { Tab_FellowBase fellowBase = TableManager.GetFellowBaseByID(m_nDataId, 0); if (fellowBase != null) { string iconPath = ""; switch (fellowBase.Type) { case 1: iconPath = "fellowType1"; break; case 2: iconPath = "fellowType2"; break; case 3: iconPath = "fellowType3"; break; } if (string.IsNullOrEmpty(iconPath)) Sign.gameObject.SetActive(false); else { Sign.gameObject.SetActive(true); LoadAssetBundle.Instance.SetImageSprite(Sign, iconPath, null); } } } } /// /// IsValid /// /// public bool IsValid() { if (m_nDataId >= 0) { Tab_FellowBase fellowBase = TableManager.GetFellowBaseByID(m_nDataId, 0); if (fellowBase != null) { return true; } } return false; } /// /// 伙伴Guid /// /// private UInt64 m_nGuid; public System.UInt64 Guid { get { return m_nGuid; } set { m_nGuid = value; } } /// /// 伙伴ID 对应FellowAttr.txt里面的ID /// -1 为非法,-2为用于待解锁槽 /// /// private int m_nDataId; public int DataId { get { return m_nDataId; } set { m_nDataId = value; } } /// /// 名称 /// /// private string m_szName; public string Name { get { return m_szName; } set { m_szName = value; } } /// /// 经验值 /// /// private long m_nExp; public long Exp { get { return m_nExp; } set { m_nExp = value; } } /// /// 级别 /// /// private int m_nLevel; public int Level { get { return m_nLevel; } set { m_nLevel = value; } } /// /// 星级 /// /// private int m_nStarLevel; public int StarLevel { get { return m_nStarLevel; } set { m_nStarLevel = value; } } /// /// 资质点 /// private int m_nZzPoint; public int ZzPoint { get { return m_nZzPoint; } set { m_nZzPoint = value; } } public float CalculateAptitude(float atitude1, float atitude2, float atitude3, float atitude4, float atitude5) { float rateBone = 0.0f; float rateForce = 0.0f; float ratePower = 0.0f; float rateSmart = 0.0f; float rateAgile = 0.0f; Tab_FellowBase fellowBase = TableManager.GetFellowBaseByID(m_nDataId, 0); if (fellowBase == null) return 0; Tab_FellowApitute tabApitute = null; var apitutes = TableManager.GetFellowApitute().Values; foreach(var apitute in apitutes) { if(apitute.Type == fellowBase.Type && apitute.PropType == fellowBase.PropType) { tabApitute = apitute; break; } } if (tabApitute == null) return 0; rateBone = (atitude1 - tabApitute.ConstituMin) / (tabApitute.ConstituMax - tabApitute.ConstituMin); rateForce = (atitude2 - tabApitute.MorfibMin) / (tabApitute.MorfibMax - tabApitute.MorfibMin); ratePower = (atitude3 - tabApitute.StrengthMin) / (tabApitute.StrengthMax - tabApitute.StrengthMin); rateSmart = (atitude4 - tabApitute.IntellengMin) / (tabApitute.IntellengMax - tabApitute.IntellengMin); rateAgile = (atitude5 - tabApitute.AgileMin) / (tabApitute.AgilenMax - tabApitute.AgileMin); float rate = (rateBone + rateForce + ratePower + rateSmart + rateAgile) / 5; if (rate <= 0) return 0; return rate; } public void CalculateAptitudeTotle() { //AptitudeTotle = CalculateAptitude(Boneatitude,Forceatitude,Poweratitude,Smartatitude,Agileatitude); //NewAptitudeTotle = CalculateAptitude(newConstituAptitude, newMorfiAptitude, newStrengthAptitude, newIntellengAptitude, newAgileAptitude); } /// /// 品质 /// public int Quality; /// /// 加锁 /// private bool m_bLocked; public bool Locked { get { return m_bLocked; } set { m_bLocked = value; } } /// /// 实际出战宠物 /// private bool m_bRealFight; public bool RealFight { get { return m_bRealFight; } set { m_bRealFight = value; } } /// /// 出战 /// private bool m_bCalled; public bool Called { get { return m_bCalled; } set { m_bCalled = value; } } //附加 public bool Attached { get { Tab_FellowAttached attachTab = TableManager.GetFellowAttachedByID(attachId, 0); return attachTab != null; } } /// /// 助战 /// private bool m_bHelped; public bool Helped { get { return m_bHelped; } set { m_bHelped = value; } } /// /// 暴击 /// private int m_CombatAttr_Critical; public int CombatAttr_Critical { get { return m_CombatAttr_Critical; } set { m_CombatAttr_Critical = value; } } /// /// 守护 /// private int m_CombatAttr_Guard; public int CombatAttr_Guard { get { return m_CombatAttr_Guard; } set { m_CombatAttr_Guard = value; } } /// /// 加持 /// private int m_CombatAttr_Bless; public int CombatAttr_Bless { get { return m_CombatAttr_Bless; } set { m_CombatAttr_Bless = value; } } //锁住的技能 private List LockSkillIds = new List(); public void AddLockSkill(List ids) { LockSkillIds.Clear(); LockSkillIds.AddRange(ids); } public string GetCharacterStr //性格描述 { get { if(CharacterType.ContainsKey(character)) return CharacterType[character]; return ""; } } public string GetNature { get { Tab_FellowBase fellowBase = TableManager.GetFellowBaseByID(m_nDataId, 0); if (fellowBase == null) return ""; if (CharacterType.ContainsKey(character)==false) return ""; return StrDictionary.GetClientDictionaryString(CharacterType[character]); } } public string GetStyle { get { Tab_FellowBase fellowBase = TableManager.GetFellowBaseByID(m_nDataId, 0); if (fellowBase == null) return ""; return StrDictionary.GetClientDictionaryString(PropType[fellowBase.PropType]) + StrDictionary.GetClientDictionaryString("#{20130}"); } } public string Summ //总评语 { get { Tab_FellowBase fellowBase = TableManager.GetFellowBaseByID(m_nDataId, 0); if (fellowBase == null) return ""; //return StrDictionary.GetClientDictionaryString(GetCharacterStr) +" "+ StrDictionary.GetClientDictionaryString(PropType[fellowBase.PropType]) + StrDictionary.GetClientDictionaryString("#{20130}"); return StrDictionary.GetClientDictionaryString(PropType[fellowBase.PropType]) + StrDictionary.GetClientDictionaryString("#{20130}"); } } public int GetlockNum() { return LockSkillIds.Count; } public bool isSkillLocked(int id) { for(int i=0;i /// 伙伴拥有的技能 /// public const int FELLOW_MAXOWNSKILL = 8; //伙伴最大拥有技能数量 private List m_OwnSkillId = new List(); private OwnSkillData[] ownSkillDatas; private int m_GY_skillid = -1; public int GY_skillid { get { return m_GY_skillid; } } private int m_MW_skillid = -1; public int MW_skillid { get { return m_MW_skillid; } } public int GetOwnSkillId(int index) { if (index >= 0 && index < m_OwnSkillId.Count) { return m_OwnSkillId[index]; } return -1; } public int GetOwnTotleCount() { int count = GetOwnSkillCount(); Tab_FellowSkill skill = TableManager.GetFellowSkillByID(m_MW_skillid, 0); if (skill != null) count++; Tab_FellowSkill skill1 = TableManager.GetFellowSkillByID(m_GY_skillid, 0); if (skill1 != null) count++; return count; } public int GetOwnSkillCount() { int count = 0; for(int i=0;i index) ownSkill = ownSkillDatas[index]; return ownSkill; } public void UpdateSkillCD() { for (int i = 0; i < (int)SKILLDEFINE.MAX_PET_SKILLNUM; i++) { ownSkillDatas[i].UpdateCooldown(); } } public bool SkillCD(int skillID,float CD) { if (m_MW_skillid == skillID) { if (CD < 0) ownSkillDatas[0].ResetCooldown(); else ownSkillDatas[0].SetCooldown(CD); return true; } if(m_GY_skillid == skillID) { if(CD < 0) ownSkillDatas[1].ResetCooldown(); else ownSkillDatas[1].SetCooldown(CD); return true; } return false; } public bool IsHaveSkillId(int skillId) { for (int index = 0; index < m_OwnSkillId.Count; index++) { if (m_OwnSkillId[index] == skillId) { return true; } } if (skillId == MW_skillid) return true; if (skillId == GY_skillid) return true; return false; } public bool IsSkillMax(int skillId) { Tab_FellowSkill skillinfo = TableManager.GetFellowSkillByID(skillId + 1, 0); return skillinfo == null; } public int IsSkillBookUsed(int skillID) { Tab_FellowSkill skillinfo = TableManager.GetFellowSkillByID(MW_skillid, 0); if (skillinfo != null) { if (skillinfo.BaseSkillId == skillID) return MW_skillid; } skillinfo = TableManager.GetFellowSkillByID(GY_skillid, 0); if (skillinfo != null) { if (skillinfo.BaseSkillId == skillID) return GY_skillid; } for (int index = 0; index < m_OwnSkillId.Count; index++) { skillinfo = TableManager.GetFellowSkillByID(m_OwnSkillId[index],0); if(skillinfo!=null) { if (skillinfo.BaseSkillId == skillID) return skillinfo.Id; } } return 0; } public void ConstPay(int skillBaseID,out Tab_CommonItem commonItem,out int needCount) { commonItem = null; needCount = 0; int skillID = IsSkillBookUsed(skillBaseID); if (skillID > 0) { Tab_FellowSkill skillInfo = TableManager.GetFellowSkillByID(skillID, 0); if (skillInfo == null || skillInfo.Type == -1) { return; } for (int i = 0; i < skillInfo.getLevelupConsumeTypeCount(); i++) { if (skillInfo.GetLevelupConsumeTypebyIndex(i) == (int)CONSUM_TYPE.ITEM) { commonItem = TableManager.GetCommonItemByID(skillInfo.GetLevelupConsumeSubTypebyIndex(i), 0); if (commonItem != null) { needCount = skillInfo.GetLevelupConsumeNumbyIndex(i); return; } } } } else { skillID = skillBaseID; Tab_FellowLearnSkillCost skillBookInfo = TableManager.GetFellowLearnSkillCostByID(skillID, 0); if (skillBookInfo == null) { return; } for (int i = 0; i < skillBookInfo.getConsumeTypeCount(); i++) { if (skillBookInfo.GetConsumeTypebyIndex(i) == (int)CONSUM_TYPE.ITEM) { commonItem = TableManager.GetCommonItemByID(skillBookInfo.GetConsumeSubTypebyIndex(i), 0); if (commonItem != null) { needCount = skillBookInfo.GetConsumeNumbyIndex(i); } } } } } public Tab_CharModel CharModel(int dataID = -1) { Tab_FellowBase line = TableManager.GetFellowBaseByID(dataID == -1 ? m_nDataId : dataID, 0); if (line != null) { Tab_CharModel charModel = TableManager.GetCharModelByID(line.ModelId, 0); if(charModel!=null) { return charModel; } } return null; } /// /// 头像 /// /// public string GetIcon() { Tab_FellowBase line = TableManager.GetFellowBaseByID(m_nDataId, 0); if (line != null) { return line.Icon; } return null; } //static public string GetTypeString(int DataId) //{ // string retString = ""; // Tab_FellowAttr line = TableManager.GetFellowAttrByID(DataId, 0); // if (line != null) // { // if (line.ClassId == (int)FELLOWCLASS.ANIMAL) // { // retString += StrDictionary.GetClientDictionaryString("#{2902}"); // } // else if (line.ClassId == (int)FELLOWCLASS.HUNMAN) // { // retString += StrDictionary.GetClientDictionaryString("#{2903}"); // } // retString += "-"; // if (line.AttackType == (int)FELLOWATTACK.PHYSCIS) // { // retString += StrDictionary.GetClientDictionaryString("#{2904}"); // } // else if (line.AttackType == (int)FELLOWATTACK.MAGIC) // { // retString += StrDictionary.GetClientDictionaryString("#{2905}"); // } // } // return retString; //} ///// ///// 伙伴分类ID 1动物 2人形 ///// ///// //public int GetClassId() //{ // Tab_FellowAttr line = TableManager.GetFellowAttrByID(m_nDataId, 0); // if (line != null) // { // return line.ClassId; // } // return 0; //} private double m_CombatValue = 0; public double CombatValue { get { return m_CombatValue; } set { m_CombatValue = value; } } } }