280 lines
7.8 KiB
C#
280 lines
7.8 KiB
C#
|
//********************************************************************
|
|||
|
// 文件名: GameTitleInvestitive.cs
|
|||
|
// 描述: 称号结构
|
|||
|
// 作者: WangZhe
|
|||
|
// Modify Log:
|
|||
|
// 2014-5-28 Lijia: 客户端效率优化,把GameSystemTitleInvestitive从class改为struct
|
|||
|
// 2014-5-28 Lijia: 客户端效率优化,把GameUserDefTitleInvestitive从class改为struct
|
|||
|
//********************************************************************
|
|||
|
|
|||
|
using UnityEngine;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System;
|
|||
|
using GCGame.Table;
|
|||
|
using GCGame;
|
|||
|
using Games.GlobeDefine;
|
|||
|
|
|||
|
namespace Games.TitleInvestitive
|
|||
|
{
|
|||
|
enum TITLE_SIZE
|
|||
|
{
|
|||
|
TITLE_NAME = 22,
|
|||
|
SYSTEMTITLE_NUM = 128,//系统程序支持存储的32个
|
|||
|
USERDEF_NUM = 8, //定义称号支持存储8个
|
|||
|
USERDEF_START = SYSTEMTITLE_NUM,
|
|||
|
TITLE_TOTAL = USERDEF_START + USERDEF_NUM,
|
|||
|
};
|
|||
|
|
|||
|
enum TITLE_TYPE
|
|||
|
{
|
|||
|
TYPE_NONE = -1,
|
|||
|
TYPE_SYSTITLE,
|
|||
|
TYPE_DEFTITE,
|
|||
|
TYPE_ALL,
|
|||
|
};
|
|||
|
|
|||
|
public enum OptionType
|
|||
|
{
|
|||
|
Adorn_Title = 1, //佩戴称号
|
|||
|
Activite_Title = 2, // 激活称号
|
|||
|
Del_Title = 3, //删除称号
|
|||
|
Req_TitleList = 4, //请求称号列表
|
|||
|
Add_Title = 5, //添加称号
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 物品品质
|
|||
|
/// </summary>
|
|||
|
public enum TITLE_COLORLEVEL
|
|||
|
{
|
|||
|
COLOR_INVALID = 0,
|
|||
|
COLOR_WHITE, //白
|
|||
|
COLOR_GREEN, //绿
|
|||
|
COLOR_BLUE, //蓝
|
|||
|
COLOR_PURPLE, //紫
|
|||
|
COLOR_ORANGE, //橙
|
|||
|
COLOR_GOLD, //金
|
|||
|
}
|
|||
|
|
|||
|
// 系统称号
|
|||
|
public struct GameSystemTitleInvestitive
|
|||
|
{
|
|||
|
/// <summary>
|
|||
|
/// 称号ID
|
|||
|
/// </summary>
|
|||
|
private int m_TitleID;
|
|||
|
public int TitleID
|
|||
|
{
|
|||
|
get { return m_TitleID; }
|
|||
|
set { m_TitleID = value; }
|
|||
|
}
|
|||
|
|
|||
|
//CD时间 (-1是没有CD)
|
|||
|
private int m_ValidTime;
|
|||
|
public int ValidTime
|
|||
|
{
|
|||
|
set { m_ValidTime = value; }
|
|||
|
get { return m_ValidTime; }
|
|||
|
}
|
|||
|
|
|||
|
public GameSystemTitleInvestitive(int nTitle, int nValitTime)
|
|||
|
{
|
|||
|
m_TitleID = nTitle;
|
|||
|
m_ValidTime = nValitTime;
|
|||
|
}
|
|||
|
|
|||
|
public void Clear()
|
|||
|
{
|
|||
|
m_TitleID = -1;
|
|||
|
m_ValidTime = -1;
|
|||
|
}
|
|||
|
|
|||
|
public int GetTitleType()
|
|||
|
{
|
|||
|
Tab_TitleData title = TableManager.GetTitleDataByID(m_TitleID, 0);
|
|||
|
if (title != null)
|
|||
|
{
|
|||
|
return title.Type;
|
|||
|
}
|
|||
|
return GlobeVar.INVALID_ID;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public class GameTitleInvestitive
|
|||
|
{
|
|||
|
private List<GameSystemTitleInvestitive> m_AllTitleList = new List<GameSystemTitleInvestitive>();
|
|||
|
public List<GameSystemTitleInvestitive> AllTitleList //拥有即激活
|
|||
|
{
|
|||
|
get { return m_AllTitleList; }
|
|||
|
}
|
|||
|
|
|||
|
private string m_CurTitleName; //当前称号文字内容
|
|||
|
public string CurTitleName
|
|||
|
{
|
|||
|
set { m_CurTitleName = value; }
|
|||
|
get { return m_CurTitleName; }
|
|||
|
}
|
|||
|
|
|||
|
private int m_AdornTitldId; //当前佩戴的称号ID
|
|||
|
public int AdornTitleId
|
|||
|
{
|
|||
|
set { m_AdornTitldId = value; }
|
|||
|
get { return m_AdornTitldId; }
|
|||
|
}
|
|||
|
|
|||
|
public GameTitleInvestitive()
|
|||
|
{
|
|||
|
m_CurTitleName = "";
|
|||
|
m_AdornTitldId = -1;
|
|||
|
}
|
|||
|
|
|||
|
public GameTitleInvestitive(int id, string name)
|
|||
|
{
|
|||
|
m_CurTitleName = name;
|
|||
|
}
|
|||
|
|
|||
|
public void ReadAllTitleInvestitive(GC_UPDATE_ALL_TITLEINVESTITIVE rData) //存储拥有的称号列表
|
|||
|
{
|
|||
|
for (int index = 0; index < rData.TitleInfoCount; index++)
|
|||
|
{
|
|||
|
GameSystemTitleInvestitive title = new GameSystemTitleInvestitive(rData.GetTitleInfo(index).TitleID, rData.GetTitleInfo(index).ValidTime);
|
|||
|
for (int _Index = 0; _Index < m_AllTitleList.Count; _Index++)
|
|||
|
{
|
|||
|
if(m_AllTitleList[_Index].TitleID == title.TitleID)
|
|||
|
{
|
|||
|
m_AllTitleList.RemoveAt(_Index);
|
|||
|
}
|
|||
|
}
|
|||
|
m_AllTitleList.Add(title);
|
|||
|
}
|
|||
|
|
|||
|
RefreshTitleViewState();
|
|||
|
}
|
|||
|
|
|||
|
public void RefreshTitleViewState()
|
|||
|
{
|
|||
|
if (TitleNameViewCtr.Instace)
|
|||
|
{
|
|||
|
TitleNameViewCtr.Instace.GetAllTitleNameList();
|
|||
|
}
|
|||
|
if(TitlePropPanelCtr.Instance)
|
|||
|
{
|
|||
|
TitlePropPanelCtr.Instance.RefreshTitlePropView();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void DeleteTitle(int titltId)
|
|||
|
{
|
|||
|
for(int index = 0; index < m_AllTitleList.Count; index++)
|
|||
|
{
|
|||
|
if(m_AllTitleList[index].TitleID == titltId)
|
|||
|
{
|
|||
|
m_AllTitleList.RemoveAt(index);
|
|||
|
break;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public int GetCurrentTitleID()
|
|||
|
{
|
|||
|
return AdornTitleId; //当前佩戴的称号ID
|
|||
|
}
|
|||
|
|
|||
|
public bool IsTitleActived(int titleId)
|
|||
|
{
|
|||
|
for(int index = 0; index < m_AllTitleList.Count; index++)
|
|||
|
{
|
|||
|
if (m_AllTitleList[index].TitleID == titleId)
|
|||
|
return true;
|
|||
|
}
|
|||
|
|
|||
|
return false;
|
|||
|
}
|
|||
|
|
|||
|
public bool IsGainTitle(int titleId)
|
|||
|
{
|
|||
|
for (int index = 0; index < m_AllTitleList.Count; index++)
|
|||
|
{
|
|||
|
if (m_AllTitleList[index].TitleID == titleId)
|
|||
|
{
|
|||
|
return true;
|
|||
|
}
|
|||
|
}
|
|||
|
return false;
|
|||
|
}
|
|||
|
|
|||
|
public void SetTitleName(string name)
|
|||
|
{
|
|||
|
m_CurTitleName = name;
|
|||
|
}
|
|||
|
|
|||
|
public string GetCurrentTitle()
|
|||
|
{
|
|||
|
return m_CurTitleName; //当前佩戴的称号文字内容
|
|||
|
}
|
|||
|
|
|||
|
public void AddTitle(int titleId, int validTime) //添加称号
|
|||
|
{
|
|||
|
for(int index = 0; index < m_AllTitleList.Count; index++)
|
|||
|
{
|
|||
|
if(m_AllTitleList[index].TitleID == titleId)
|
|||
|
{
|
|||
|
break;
|
|||
|
}
|
|||
|
}
|
|||
|
GameSystemTitleInvestitive title = new GameSystemTitleInvestitive(titleId, validTime);
|
|||
|
m_AllTitleList.Add(title);
|
|||
|
}
|
|||
|
|
|||
|
public bool ChangeTitle(int nNewIndex)
|
|||
|
{
|
|||
|
//m_ActiveTitleId = nNewIndex; //更换当前的
|
|||
|
return false;
|
|||
|
}
|
|||
|
|
|||
|
//同步当前佩戴称号 激活称号 佩戴的称号名字
|
|||
|
public void HandleGainTitle(int nTitleID, string strUserDef, int nActiveTitleId)
|
|||
|
{
|
|||
|
AdornTitleId = nTitleID; //当前佩戴的称号ID
|
|||
|
CurTitleName = strUserDef; //当前佩戴的称号的文字内容
|
|||
|
|
|||
|
//刷新面板Mark标记
|
|||
|
if(TitleNameViewCtr.Instace)
|
|||
|
{
|
|||
|
TitleNameViewCtr.Instace.ShowMarkIcon();
|
|||
|
}
|
|||
|
}
|
|||
|
public void HandleUpdateDefTitle(int nTitleID, string strUserDef) //无用
|
|||
|
{
|
|||
|
//for (int nIndex = (int)TITLE_SIZE.USERDEF_START; nIndex < (int)TITLE_SIZE.TITLE_TOTAL; nIndex++)
|
|||
|
//{
|
|||
|
// if (nTitleID == m_UserDefTitle[nIndex - (int)TITLE_SIZE.USERDEF_START].TitleID)
|
|||
|
// {
|
|||
|
// m_UserDefTitle[nIndex - (int)TITLE_SIZE.USERDEF_START].StrFullTitleName = strUserDef;
|
|||
|
// }
|
|||
|
//}
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
public void ClearData()
|
|||
|
{
|
|||
|
m_AllTitleList.Clear();
|
|||
|
m_CurTitleName = "";
|
|||
|
m_AdornTitldId = -1;
|
|||
|
}
|
|||
|
|
|||
|
public bool IsHaveType(int type)
|
|||
|
{
|
|||
|
for (int index = 0; index < m_AllTitleList.Count; index++)
|
|||
|
{
|
|||
|
if (m_AllTitleList[index].GetTitleType() == type)
|
|||
|
{
|
|||
|
return true;
|
|||
|
}
|
|||
|
}
|
|||
|
return false;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|