224 lines
7.6 KiB
C#
224 lines
7.6 KiB
C#
using System.Collections.Generic;
|
|
using GCGame.Table;
|
|
|
|
namespace Games.Fellow
|
|
{
|
|
public class PetsHoldBookInfo
|
|
{
|
|
public int PetID;
|
|
public string Name;
|
|
public string headIcon;
|
|
public int Quility;
|
|
public int BookLevel;
|
|
public bool MaxLevel;
|
|
public int Exp;
|
|
public int Type;
|
|
|
|
public Tab_FellowBase FellowBase()
|
|
{
|
|
return TableManager.GetFellowBaseByID(PetID, 0);
|
|
}
|
|
}
|
|
|
|
|
|
public class FellowBookData
|
|
{
|
|
Dictionary<int, PetsHoldBookInfo> m_PetBookInfos = new Dictionary<int, PetsHoldBookInfo>();
|
|
private int _PetBook_TotlePower = 0;
|
|
int m_FightPetBook;//幻化战斗宠物ID
|
|
public int FightPetBook
|
|
{
|
|
get { return m_FightPetBook; }
|
|
}
|
|
|
|
int m_HelpFightPetBook;//幻化助战宠物ID
|
|
public int HelpFightPetBook
|
|
{
|
|
get { return m_HelpFightPetBook; }
|
|
}
|
|
|
|
public int PetBookTotlePower
|
|
{
|
|
get { return _PetBook_TotlePower; }
|
|
}
|
|
|
|
public FellowBookData()
|
|
{
|
|
Clear();
|
|
}
|
|
|
|
public void AskFellowBookInfo()
|
|
{
|
|
ReqHandbookFellowList cmd = new ReqHandbookFellowList();
|
|
cmd.SendMsg();
|
|
}
|
|
|
|
private void Clear()
|
|
{
|
|
_PetBook_TotlePower = 0;
|
|
m_FightPetBook = -1;
|
|
m_HelpFightPetBook = -1;
|
|
m_PetBookInfos.Clear();
|
|
}
|
|
|
|
//1幻化战斗 2幻化助战 3助战战斗
|
|
public int FightType(int fellowID)
|
|
{
|
|
int TurnToType = 0;
|
|
if (FightPetBook == fellowID)
|
|
TurnToType |= 1;
|
|
if (HelpFightPetBook == fellowID)
|
|
TurnToType |= 2;
|
|
return TurnToType;
|
|
}
|
|
|
|
public List<int> GetPetBooksId()
|
|
{
|
|
List<int> bookIds = new List<int>(m_PetBookInfos.Keys);
|
|
return bookIds;
|
|
}
|
|
|
|
public PetsHoldBookInfo GetPetBookInfo(int PetId)
|
|
{
|
|
PetsHoldBookInfo book = null;
|
|
if (m_PetBookInfos.TryGetValue(PetId, out book)==false)
|
|
return null;
|
|
return book;
|
|
}
|
|
|
|
private void InitBooks()
|
|
{
|
|
m_PetBookInfos.Clear();
|
|
Dictionary<int, Tab_FellowBase> tabs = TableManager.GetFellowBase();
|
|
List<int> keys = new List<int>(tabs.Keys);
|
|
for (int i = 0; i < keys.Count; i++)
|
|
{
|
|
Tab_FellowHandBook handBook = TableManager.GetFellowHandBookByID(tabs[keys[i]].Id * 100 + 1, 0);
|
|
if (handBook == null)
|
|
continue;
|
|
PetsHoldBookInfo book = new PetsHoldBookInfo();
|
|
book.BookLevel = 0;
|
|
book.MaxLevel = false;
|
|
book.PetID = tabs[keys[i]].Id;
|
|
book.Quility = tabs[keys[i]].Quility;
|
|
book.headIcon = tabs[keys[i]].Icon;
|
|
book.Name = tabs[keys[i]].Name;
|
|
book.Type = tabs[keys[i]].Type;
|
|
m_PetBookInfos[book.PetID] = book;
|
|
}
|
|
}
|
|
|
|
private void LevelData(RespHandbookFellowList bookinfos)
|
|
{
|
|
if (bookinfos.HandbookList == null || bookinfos.HandbookList.Count <= 0)
|
|
return;
|
|
_PetBook_TotlePower = 0;
|
|
for (int j = 0; j < bookinfos.HandbookList.Count; j++)
|
|
{
|
|
PetsHoldBookInfo book = null;
|
|
if (m_PetBookInfos.TryGetValue(bookinfos.HandbookList[j].FellowId, out book))
|
|
{
|
|
book.BookLevel = bookinfos.HandbookList[j].Level;
|
|
Tab_FellowHandBook handBook = TableManager.GetFellowHandBookByID(book.PetID * 100 + book.BookLevel, 0);
|
|
Tab_FellowHandBook handBookNext = TableManager.GetFellowHandBookByID(book.PetID * 100 + book.BookLevel + 1, 0);
|
|
book.MaxLevel = (handBookNext == null);
|
|
book.Exp = bookinfos.HandbookList[j].Exp;
|
|
if (handBook != null && book.BookLevel > 0 )
|
|
{
|
|
_PetBook_TotlePower += handBook.Power;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public int CostCout(PetsHoldBookInfo bookInfo, int Type) //Type=0 满级 Type=1 消耗多少 Type=2 消耗满足 Type=3 消耗拥有
|
|
{
|
|
int hasCount = 0;
|
|
int Level = (bookInfo.BookLevel > 0 ? bookInfo.BookLevel : 1);
|
|
Tab_FellowHandBook handBook = TableManager.GetFellowHandBookByID(bookInfo.PetID * 100 + Level, 0);
|
|
Tab_FellowHandBook handBookNext = TableManager.GetFellowHandBookByID(bookInfo.PetID * 100 + Level + 1, 0);
|
|
if (handBook == null)
|
|
handBook = handBookNext;
|
|
if (handBook == null)
|
|
return -1;
|
|
bookInfo.MaxLevel = (handBookNext == null);
|
|
if (Type == 0)
|
|
return (handBookNext == null) ? 1 : 0;
|
|
if (handBook != null)
|
|
hasCount = GameManager.gameManager.PlayerDataPool.BackPack.GetItemCountByDataId(handBook.ConstPetSoulID);
|
|
if (Type == 1)
|
|
return handBook.ConstNum;
|
|
if (Type == 2)
|
|
return (handBook.ConstNum <= hasCount) ? 1 : 0;
|
|
if (Type == 3)
|
|
return hasCount;
|
|
return -1;
|
|
}
|
|
|
|
public int GetCanSelectPetID()
|
|
{
|
|
int NotMaxID = -1;
|
|
int CanupID = -1;
|
|
List<int> petIDs = new List<int>(m_PetBookInfos.Keys);
|
|
if (petIDs.Count <= 0)
|
|
return -1;
|
|
for (int i = 0; i < petIDs.Count; i++)
|
|
{
|
|
PetsHoldBookInfo book = null;
|
|
if (m_PetBookInfos.TryGetValue(petIDs[i], out book))
|
|
{
|
|
Tab_FellowBase tab_FellowBase = book.FellowBase();
|
|
if (tab_FellowBase == null || tab_FellowBase.Quility > 3)
|
|
continue;
|
|
int hasCount = CostCout(book, 3);
|
|
if (NotMaxID == -1 && book.MaxLevel == false)
|
|
NotMaxID = book.PetID;
|
|
if (CanupID == -1 && book.MaxLevel == false && hasCount > 0)
|
|
CanupID = book.PetID;
|
|
}
|
|
}
|
|
|
|
if (CanupID == -1)
|
|
CanupID = NotMaxID;
|
|
if (CanupID == -1)
|
|
CanupID = petIDs[0];
|
|
return CanupID;
|
|
}
|
|
|
|
public void RespHandBookInfos(RespHandbookFellowList bookinfos)
|
|
{
|
|
if (m_PetBookInfos.Count <= 0)
|
|
{
|
|
InitBooks();
|
|
}
|
|
m_FightPetBook = bookinfos.FellowIdMain;//幻化战斗宠物ID
|
|
m_HelpFightPetBook = bookinfos.FellowIdHelp;//幻化助战宠物ID
|
|
LevelData(bookinfos);
|
|
IsHaveCanUsePetItem();
|
|
}
|
|
|
|
public bool IsHaveCanUsePetItem()
|
|
{
|
|
if (m_PetBookInfos.Count <= 0)
|
|
{
|
|
InitBooks();
|
|
}
|
|
bool have = false;
|
|
bool haveQuility = false;
|
|
List<int> petIDs = new List<int>(m_PetBookInfos.Keys);
|
|
for (int i = 0; i < petIDs.Count; i++)
|
|
{
|
|
int Type = CostCout(m_PetBookInfos[petIDs[i]], 2);
|
|
if(Type==1 && m_PetBookInfos[petIDs[i]].MaxLevel == false)
|
|
{
|
|
if (m_PetBookInfos[petIDs[i]].Quility <= 3)
|
|
haveQuility = true;
|
|
have = true;
|
|
}
|
|
}
|
|
RedTipPoint.RedPointStateChange(RedTipPoint.PointType.PetBook, haveQuility);
|
|
return have;
|
|
}
|
|
}
|
|
|
|
} |