916 lines
29 KiB
C#
916 lines
29 KiB
C#
/********************************************************************************
|
||
* 文件名: Guild.cs
|
||
* 全路径: \Script\Player\Guild\Guild.cs
|
||
* 创建人: 李嘉
|
||
* 创建时间:2014-04-22
|
||
*
|
||
* 功能说明:帮会基础数据
|
||
* 修改记录:
|
||
*********************************************************************************/
|
||
using UnityEngine;
|
||
using System.Collections;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using Games.GlobeDefine;
|
||
|
||
public class Guild
|
||
{
|
||
public enum BuildType
|
||
{
|
||
None = -2,
|
||
guildInfo = -1,
|
||
house,
|
||
coin,
|
||
library,
|
||
}
|
||
|
||
public static Dictionary<int, string> GuildJobName = new Dictionary<int, string>()
|
||
{
|
||
{(int)GameDefine_Globe.GUILD_JOB.CHIEF,"#{25004}" },
|
||
{(int)GameDefine_Globe.GUILD_JOB.VICE_CHIEF,"#{25005}" },
|
||
{(int)GameDefine_Globe.GUILD_JOB.TANGZHU,"#{25006}" },
|
||
{(int)GameDefine_Globe.GUILD_JOB.XIANGZHU,"#{25007}" },
|
||
{(int)GameDefine_Globe.GUILD_JOB.ELITE,"#{25008}" },
|
||
{(int)GameDefine_Globe.GUILD_JOB.MEMBER,"#{25009}" },
|
||
{(int)GameDefine_Globe.GUILD_JOB.RESERVE,"#{25010}" },
|
||
{(int)GameDefine_Globe.GUILD_JOB.PRERESERVE,"#{25011}" },
|
||
};
|
||
|
||
public Guild()
|
||
{
|
||
CleanUp();
|
||
}
|
||
|
||
public void CleanUp()
|
||
{
|
||
m_GuildGuid = GlobeVar.INVALID_GUID;
|
||
m_GuildName = "";
|
||
m_GuildLevel = 0;
|
||
m_GuildChiefGuid = GlobeVar.INVALID_GUID;
|
||
m_nPSCanAcceptTimes = 0;
|
||
buildLevels.Clear();
|
||
buildCooldown.Clear();
|
||
if (null == m_GuildMemberList)
|
||
{
|
||
m_GuildMemberList = new Dictionary<UInt64, GuildMember>();
|
||
}
|
||
if(null == m_GuildApplyList)
|
||
{
|
||
m_GuildApplyList = new Dictionary<ulong, GuildMember>();
|
||
}
|
||
m_GuildMemberList.Clear();
|
||
m_GuildApplyList.Clear();
|
||
if(Singleton<ObjManager>.Instance.MainPlayer!=null)
|
||
{
|
||
Singleton<ObjManager>.Instance.MainPlayer.ChangePaoShangState("");
|
||
}
|
||
GuildRedShow();
|
||
}
|
||
|
||
private UInt64 m_GuildGuid; //帮会GUID
|
||
public System.UInt64 GuildGuid
|
||
{
|
||
get { return m_GuildGuid; }
|
||
set { m_GuildGuid = value; }
|
||
}
|
||
|
||
private string m_GuildName; //帮会GUID
|
||
public string GuildName
|
||
{
|
||
get { return m_GuildName; }
|
||
set { m_GuildName = value; }
|
||
}
|
||
|
||
private int m_GuildLevel; //帮会等级
|
||
public int GuildLevel
|
||
{
|
||
get { return m_GuildLevel; }
|
||
set { m_GuildLevel = value; }
|
||
}
|
||
|
||
private int m_GuildJob; //自己在帮会的职位
|
||
public int GuildJob
|
||
{
|
||
get { return m_GuildJob; }
|
||
set { m_GuildJob = value; }
|
||
}
|
||
|
||
private int m_GuildLevelCoolDown; //帮会等级冷却时间
|
||
public int GuildLevelCoolDown
|
||
{
|
||
get { return m_GuildLevelCoolDown; }
|
||
set { m_GuildLevelCoolDown = value; }
|
||
}
|
||
|
||
private UInt64 m_GuildChiefGuid; //帮主Guid
|
||
public System.UInt64 GuildChiefGuid
|
||
{
|
||
get { return m_GuildChiefGuid; }
|
||
set { m_GuildChiefGuid = value; }
|
||
}
|
||
|
||
private string m_GuildChiefName; //帮主名字
|
||
public string GuildChiefName
|
||
{
|
||
get { return m_GuildChiefName; }
|
||
set { m_GuildChiefName = value; }
|
||
}
|
||
|
||
private string m_GuildCreatorName; //帮主名字
|
||
public string GuildCreatorName
|
||
{
|
||
get { return m_GuildCreatorName; }
|
||
set { m_GuildCreatorName = value; }
|
||
}
|
||
|
||
private int m_GuildExp; //帮会活跃度
|
||
public int GuildExp
|
||
{
|
||
get { return m_GuildExp; }
|
||
set { m_GuildExp = value; }
|
||
}
|
||
|
||
private int m_GuildCurMem; //帮会当前人数
|
||
public int GuildCurMem
|
||
{
|
||
get { return m_GuildCurMem; }
|
||
set { m_GuildCurMem = value; }
|
||
}
|
||
|
||
private int m_GuildMaxMem; //帮会最大人数
|
||
public int GuildMaxMem
|
||
{
|
||
get { return m_GuildMaxMem; }
|
||
set { m_GuildMaxMem = value; }
|
||
}
|
||
|
||
private int m_GuildPay; //帮会维护费用
|
||
public int GuildPay
|
||
{
|
||
get { return m_GuildPay; }
|
||
set { m_GuildPay = value; }
|
||
}
|
||
|
||
private long m_GuildMoney; //帮会资金
|
||
public long GuildMoney
|
||
{
|
||
get { return m_GuildMoney; }
|
||
set { m_GuildMoney = value; }
|
||
}
|
||
|
||
private int m_GuildContribute; //帮会贡献
|
||
public int GuildContribute
|
||
{
|
||
get { return m_GuildContribute; }
|
||
set { m_GuildContribute = value;
|
||
Games.Events.EventDispatcher.Instance.SendMessage(Games.Events.EventId.FRESHSAMEUSETIP);
|
||
XiulianRedPoint();
|
||
}
|
||
}
|
||
|
||
private int m_GuildTotleCombat; //帮会总战力
|
||
public int GuildTotleCombat
|
||
{
|
||
get { return m_GuildTotleCombat; }
|
||
set { m_GuildTotleCombat = value; }
|
||
}
|
||
|
||
private int m_GuildMatchCamp; //帮会总战力
|
||
public int GuildMatchCam
|
||
{
|
||
get { return m_GuildMatchCamp; }
|
||
set { m_GuildMatchCamp = value; }
|
||
}
|
||
|
||
private int m_lastChangeNameTime; //上次改名时间戳
|
||
public int LastChangeNameTime
|
||
{
|
||
get { return m_lastChangeNameTime; }
|
||
set { m_lastChangeNameTime = value; }
|
||
}
|
||
|
||
private string m_GuildNotice; //帮会公告
|
||
public string GuildNotice
|
||
{
|
||
get { return m_GuildNotice; }
|
||
set { m_GuildNotice = value; }
|
||
}
|
||
|
||
private int m_AutoApproveState; //自动同意申请状态
|
||
public int AutoApproveState
|
||
{
|
||
get { return m_AutoApproveState; }
|
||
set { m_AutoApproveState = value; }
|
||
}
|
||
|
||
private int m_AutoApproveLevel; //自动同意申请限制等级
|
||
public int AutoApproveLevel
|
||
{
|
||
get { return m_AutoApproveLevel; }
|
||
set { m_AutoApproveLevel = value; }
|
||
}
|
||
|
||
private Dictionary<int, int> buildCooldown = new Dictionary<int, int>();
|
||
private Dictionary<int, int> buildLevels = new Dictionary<int, int>();
|
||
|
||
|
||
private Dictionary<UInt64, GuildMember> m_GuildMemberList = null; //帮会成员列表
|
||
public Dictionary<UInt64, GuildMember> GuildMemberList
|
||
{
|
||
get { return m_GuildMemberList; }
|
||
}
|
||
|
||
private Dictionary<UInt64, GuildMember> m_GuildApplyList = null; //帮会申请列表
|
||
public Dictionary<UInt64, GuildMember> GuildApplyList
|
||
{
|
||
get { return m_GuildApplyList; }
|
||
}
|
||
|
||
private int _GuildWineCollectState = 1; //行酒令采集任务状态
|
||
public int GuildWineCollectState
|
||
{
|
||
get { return _GuildWineCollectState; }
|
||
set { _GuildWineCollectState = value;Games.Events.EventDispatcher.Instance.Dispatch(Games.Events.EventId.GuildWine); }
|
||
}
|
||
|
||
private int _GuildWarState = 0; //帮战状态
|
||
public int GuildWarState
|
||
{
|
||
get { return _GuildWarState; }
|
||
set {
|
||
_GuildWarState = value;
|
||
ActivityDataManager.Instance.SyncActivityLeaveBoss((int)ActivityDataManager.Activity_Type.ACTIVITY_TYPE_GUILD_UNION_MATCH, _GuildWarState == 0 ? 0 : -1);
|
||
if (ActiveBtns.Instance() != null)
|
||
ActiveBtns.Instance().RefreshBtns((int)ActivityDataManager.Activity_Type.ACTIVITY_TYPE_GUILD_UNION_MATCH);
|
||
}
|
||
}
|
||
|
||
private int _FeastState = 0;
|
||
public int FeastState
|
||
{
|
||
get { return _FeastState; }
|
||
set { _FeastState = value; }
|
||
}
|
||
|
||
private int _GuildWineDrinkState = 1; //行酒令喝酒任务状态
|
||
public int GuildWineDrinkState
|
||
{
|
||
get { return _GuildWineDrinkState; }
|
||
set { _GuildWineDrinkState = value; Games.Events.EventDispatcher.Instance.Dispatch(Games.Events.EventId.GuildWine); }
|
||
}
|
||
|
||
|
||
// private UInt64 m_PreserveGuildGuid; //玩家当前加入的待审批帮会Guid,在申请帮会列表的时候同步
|
||
// public System.UInt64 PreserveGuildGuid
|
||
// {
|
||
// get { return m_PreserveGuildGuid; }
|
||
// set { m_PreserveGuildGuid = value; }
|
||
// }
|
||
|
||
private int m_nPSCanAcceptTimes;
|
||
public int PSCanAcceptTimes
|
||
{
|
||
get { return m_nPSCanAcceptTimes; }
|
||
set { m_nPSCanAcceptTimes = value; }
|
||
}
|
||
|
||
public void UpdateData(GC_GUILD_RET_INFO info)
|
||
{
|
||
//清空之前的数据
|
||
//CleanUp();
|
||
|
||
if(info!=null)
|
||
GuildContribute = info.Contribute;
|
||
|
||
//判断消息包数据合法性
|
||
if (null == info || info.GuildGuid == GlobeVar.INVALID_GUID)
|
||
{
|
||
return;
|
||
}
|
||
|
||
//填充数据
|
||
GuildGuid = info.GuildGuid;
|
||
GuildLevel = info.GuildLevel;
|
||
GuildName = info.GuildName;
|
||
GuildChiefGuid = info.GuildChiefGuid;
|
||
GuildChiefName = info.GuildChiefName;
|
||
GuildCreatorName = info.CreatorName;
|
||
GuildExp = info.GuildExp;
|
||
GuildNotice = info.Notice;
|
||
GuildCurMem = info.CurMemberNum;
|
||
GuildMaxMem = info.MaxMemberNum;
|
||
GuildTotleCombat = info.TotalCombat;
|
||
GuildPay = info.DayCost;
|
||
GuildMoney = info.Wealth;
|
||
GuildJob = info.Guildjob;
|
||
GuildContribute = info.Contribute;
|
||
buildLevels[(int)BuildType.house] = info.HouseLevel;
|
||
buildLevels[(int)BuildType.library] = info.CollegeLevel;
|
||
buildLevels[(int)BuildType.coin] = info.GoldOreLevel;
|
||
LastChangeNameTime = (int)info.LastChangeNameTime;
|
||
m_GuildMatchCamp = info.UnionMatchCamp;
|
||
if (info.HasPscanacpttimes)
|
||
{
|
||
PSCanAcceptTimes = info.Pscanacpttimes;
|
||
}
|
||
|
||
if (info.Type == (int)CG_GUILD_REQ_INFO.REQ_TYPE.REQ_TYPE_MEMBET_LIST)
|
||
{
|
||
GuildMemberList.Clear();
|
||
}
|
||
if (info.Type == (int)CG_GUILD_REQ_INFO.REQ_TYPE.REQ_TYPE_APPLY_LIST)
|
||
{
|
||
m_GuildApplyList.Clear();
|
||
}
|
||
AttrWithBuildLevel();
|
||
XiulianRedPoint();
|
||
for (int i = 0; i < info.memberInfoCount; ++i )
|
||
{
|
||
MemberBaseInfo memberInfo = info.GetMemberInfo(i);
|
||
if (memberInfo.Guid == GlobeVar.INVALID_GUID)
|
||
continue;
|
||
GuildMember member = new GuildMember();
|
||
member.Guid = memberInfo.Guid;
|
||
member.MemberName = memberInfo.Name;
|
||
member.Profession = memberInfo.Prof;
|
||
member.Level = memberInfo.Level;
|
||
member.ComBatVal = memberInfo.Combat;
|
||
member.Job = memberInfo.Job;
|
||
member.Repair = memberInfo.Repair;
|
||
member.Practice = memberInfo.Practice;
|
||
member.CurrWeekContribute = memberInfo.Weekcontribute;
|
||
member.HistoryContribute = memberInfo.Historycontribute;
|
||
member.Contribute = memberInfo.Nowcontribute;
|
||
member.WarTimes = memberInfo.Guildwarcout;
|
||
member.State = memberInfo.OnlineState;
|
||
member.LastLogout = memberInfo.Lastlogouttm;
|
||
if (info.Type == (int)CG_GUILD_REQ_INFO.REQ_TYPE.REQ_TYPE_MEMBET_LIST)
|
||
{
|
||
GuildMemberList[memberInfo.Guid] = member;
|
||
if (m_GuildApplyList.ContainsKey(memberInfo.Guid))
|
||
m_GuildApplyList.Remove(memberInfo.Guid);
|
||
}
|
||
if (info.Type == (int)CG_GUILD_REQ_INFO.REQ_TYPE.REQ_TYPE_APPLY_LIST)
|
||
{
|
||
m_GuildApplyList[memberInfo.Guid] = member;
|
||
}
|
||
|
||
|
||
}
|
||
GuildRedShow();
|
||
//按照VIP等级排序
|
||
//SortMemberListByVIP(m_GuildMemberList);
|
||
//按照等级排序
|
||
//SortMemberListByLevel(m_GuildMemberList);
|
||
//按照在线状态进行排序
|
||
//SortMemberListByOnLine(m_GuildMemberList);
|
||
//按照职位排序
|
||
//SortMemberListByJob(m_GuildMemberList);
|
||
|
||
// 玩家自己永远第一位,帮主第二位,然后按照官职排,最后按照等级排列
|
||
SortMemberListByJob(m_GuildMemberList);
|
||
}
|
||
|
||
public void GuildRedShow()
|
||
{
|
||
// 职位是否可以接收红点
|
||
if (GuildJob == (int)GameDefine_Globe.GUILD_JOB.CHIEF
|
||
|| GuildJob == (int)GameDefine_Globe.GUILD_JOB.VICE_CHIEF
|
||
|| GuildJob == (int)GameDefine_Globe.GUILD_JOB.TANGZHU
|
||
|| GuildJob == (int)GameDefine_Globe.GUILD_JOB.XIANGZHU)
|
||
{
|
||
if (m_GuildApplyList.Count > 0)
|
||
{
|
||
RedTipPoint.RedPointStateChange(RedTipPoint.PointType.GuildApply, true);
|
||
return;
|
||
}
|
||
}
|
||
RedTipPoint.RedPointStateChange(RedTipPoint.PointType.GuildApply, false);
|
||
}
|
||
|
||
public int GetBuildLevel(BuildType type)
|
||
{
|
||
if(buildLevels.ContainsKey((int)type))
|
||
{
|
||
return buildLevels[(int)type];
|
||
}
|
||
return -1;
|
||
}
|
||
|
||
public int GetBuildCoolDown(BuildType type)
|
||
{
|
||
if (buildCooldown.ContainsKey((int)type))
|
||
{
|
||
return buildCooldown[(int)type];
|
||
}
|
||
return -1;
|
||
}
|
||
|
||
public void SetBuildInfo(GC_GUILD_BUILDING_INFO packet)
|
||
{
|
||
for(int i=0;i<packet.typeCount;i++)
|
||
{
|
||
if(packet.GetType(i) == (int)BuildType.guildInfo)
|
||
{
|
||
m_GuildLevel = packet.GetLevel(i);
|
||
int cooldown = packet.GetCooldown(i);
|
||
m_GuildLevelCoolDown = cooldown > 0 ? (int)Time.realtimeSinceStartup + packet.GetCooldown(i) : 0;
|
||
}
|
||
else
|
||
{
|
||
Module.Log.LogModule.ErrorLog("Build Level : " + packet.GetLevel(i));
|
||
|
||
buildLevels[packet.GetType(i)] = packet.GetLevel(i);
|
||
int cooldown = packet.GetCooldown(i);
|
||
buildCooldown[packet.GetType(i)] = cooldown > 0 ? (int)Time.realtimeSinceStartup + packet.GetCooldown(i) : 0;
|
||
}
|
||
}
|
||
if(packet.HasGuildwealth)
|
||
m_GuildMoney = packet.Guildwealth;
|
||
}
|
||
|
||
public int GetGuildFormalMemberCount()
|
||
{
|
||
int nNum = 0;
|
||
foreach (KeyValuePair<ulong, GuildMember> member in m_GuildMemberList)
|
||
{
|
||
if (member.Value.IsValid() && member.Value.Job != (int)GameDefine_Globe.GUILD_JOB.RESERVE)
|
||
{
|
||
nNum++;
|
||
}
|
||
}
|
||
|
||
return nNum;
|
||
}
|
||
|
||
public int GetGuildReserveMemberCount()
|
||
{
|
||
int nNum = 0;
|
||
foreach (KeyValuePair<ulong, GuildMember> member in m_GuildMemberList)
|
||
{
|
||
if (member.Value.IsValid() && member.Value.Job == (int)GameDefine_Globe.GUILD_JOB.RESERVE)
|
||
{
|
||
nNum++;
|
||
}
|
||
}
|
||
|
||
return nNum;
|
||
}
|
||
|
||
//设置成员的职位
|
||
public void SetMemberJob(UInt64 memberGuid,int job)
|
||
{
|
||
if (m_GuildMemberList == null)
|
||
return;
|
||
|
||
foreach (KeyValuePair<ulong, GuildMember> member in m_GuildMemberList)
|
||
{
|
||
GuildMember mem = member.Value;
|
||
if (mem.IsValid() && mem.Guid == memberGuid)
|
||
{
|
||
mem.Job = job;
|
||
m_GuildMemberList[mem.Guid] = mem;
|
||
break;
|
||
}
|
||
}
|
||
GuildMember MainPlayer = GetMainPlayerGuildInfo();
|
||
if(job == (int)GameDefine_Globe.GUILD_JOB.CHIEF)
|
||
{
|
||
if (MainPlayer != null && MainPlayer.Job == (int)GameDefine_Globe.GUILD_JOB.CHIEF)
|
||
{
|
||
MainPlayer.Job = (int)GameDefine_Globe.GUILD_JOB.MEMBER;
|
||
m_GuildMemberList[MainPlayer.Guid] = MainPlayer;
|
||
}
|
||
GuildChiefGuid = memberGuid;
|
||
}
|
||
if (Singleton<ObjManager>.Instance.MainPlayer != null && Singleton<ObjManager>.Instance.MainPlayer.GUID == memberGuid)
|
||
{
|
||
GuildJob = job;
|
||
GuildRedShow();
|
||
}
|
||
SortMemberListByJob(m_GuildMemberList);
|
||
Games.Events.EventDispatcher.Instance.SendMessage(Games.Events.EventId.OperatorResult, null);
|
||
}
|
||
|
||
public GCGame.Table.Tab_GuildJurisdiction GetMemberJurisdic(ulong memberGuid)
|
||
{
|
||
int job = (int)GameDefine_Globe.GUILD_JOB.INVALID;
|
||
if (Singleton<ObjManager>.Instance.MainPlayer!=null && Singleton<ObjManager>.Instance.MainPlayer.GUID == memberGuid)
|
||
{
|
||
job = GuildJob;
|
||
}
|
||
else
|
||
{
|
||
foreach (KeyValuePair<ulong, GuildMember> member in m_GuildMemberList)
|
||
{
|
||
if (member.Value.IsValid() && member.Value.Guid == memberGuid)
|
||
{
|
||
job = member.Value.Job;
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
GCGame.Table.Tab_GuildJurisdiction table = GCGame.Table.TableManager.GetGuildJurisdictionByID(job, 0);
|
||
if (table != null)
|
||
return table;
|
||
return null;
|
||
}
|
||
|
||
public GuildMember GetVICE_CHIEF()
|
||
{
|
||
foreach (KeyValuePair<ulong, GuildMember> member in m_GuildMemberList)
|
||
{
|
||
if (member.Value.IsValid() && member.Value.Job == (int)GameDefine_Globe.GUILD_JOB.VICE_CHIEF)
|
||
{
|
||
return member.Value;
|
||
}
|
||
}
|
||
return null;
|
||
}
|
||
|
||
public int GetMemberCountJob(int job)
|
||
{
|
||
int count = 0;
|
||
foreach (KeyValuePair<ulong, GuildMember> member in m_GuildMemberList)
|
||
{
|
||
if (member.Value.IsValid() && member.Value.Job == job)
|
||
{
|
||
count++;
|
||
}
|
||
}
|
||
return count;
|
||
}
|
||
|
||
//根据会员Guid获得其职位
|
||
public int GetMemberJob(UInt64 memberGuid)
|
||
{
|
||
if (memberGuid == GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Guid)
|
||
return GuildJob;
|
||
|
||
int nJob = (int)GameDefine_Globe.GUILD_JOB.INVALID;
|
||
foreach (KeyValuePair<ulong, GuildMember> member in m_GuildMemberList)
|
||
{
|
||
if (member.Value.IsValid() && member.Value.Guid == memberGuid)
|
||
{
|
||
nJob = member.Value.Job;
|
||
break;
|
||
}
|
||
}
|
||
|
||
return nJob;
|
||
}
|
||
|
||
//根据会员Guid获得其等级
|
||
public int GetMemberLevel(UInt64 memberGuid)
|
||
{
|
||
int nLevel = (int)GameDefine_Globe.GUILD_JOB.INVALID;
|
||
foreach (KeyValuePair<ulong, GuildMember> member in m_GuildMemberList)
|
||
{
|
||
if (member.Value.IsValid() && member.Value.Guid == memberGuid)
|
||
{
|
||
nLevel = member.Value.Level;
|
||
break;
|
||
}
|
||
}
|
||
|
||
return nLevel;
|
||
}
|
||
|
||
//根据会员Guid获得其贡献度
|
||
public int GetMemberContribute(UInt64 memberGuid)
|
||
{
|
||
int nContribute = (int)GameDefine_Globe.GUILD_JOB.INVALID;
|
||
foreach (KeyValuePair<ulong, GuildMember> member in m_GuildMemberList)
|
||
{
|
||
if (member.Value.IsValid() && member.Value.Guid == memberGuid)
|
||
{
|
||
nContribute = member.Value.Contribute;
|
||
break;
|
||
}
|
||
}
|
||
|
||
return nContribute;
|
||
}
|
||
|
||
//获得MainPlayer的帮会信息
|
||
public GuildMember GetMainPlayerGuildInfo()
|
||
{
|
||
GuildMember mainPlayerGuildInfo;
|
||
if (null != Singleton<ObjManager>.GetInstance().MainPlayer &&
|
||
GuildMemberList.TryGetValue(GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Guid, out mainPlayerGuildInfo))
|
||
{
|
||
return mainPlayerGuildInfo;
|
||
}
|
||
|
||
return null;
|
||
}
|
||
|
||
protected Dictionary<UInt64, GuildMember> SortMemberListByJob(Dictionary<UInt64, GuildMember> dic)
|
||
{
|
||
List<KeyValuePair<UInt64, GuildMember>> myList = new List<KeyValuePair<UInt64, GuildMember>>(dic);
|
||
myList.Sort(delegate(KeyValuePair<UInt64, GuildMember> s1, KeyValuePair<UInt64, GuildMember> s2)
|
||
{
|
||
if(s1.Value.State != s2.Value.State)
|
||
{
|
||
return s2.Value.State.CompareTo(s1.Value.State);
|
||
}
|
||
else
|
||
{
|
||
if(s1.Value.Job != s2.Value.Job)
|
||
{
|
||
return s1.Value.Job.CompareTo(s2.Value.Job);
|
||
}
|
||
else
|
||
{
|
||
if(s1.Value.Level!=s2.Value.Level)
|
||
{
|
||
return s2.Value.Level.CompareTo(s1.Value.Level);
|
||
}
|
||
}
|
||
}
|
||
|
||
return s2.Value.LastLogout.CompareTo(s1.Value.LastLogout);
|
||
});
|
||
|
||
dic.Clear();
|
||
foreach (KeyValuePair<UInt64, GuildMember> pair in myList)
|
||
{
|
||
dic.Add(pair.Key, pair.Value);
|
||
}
|
||
return dic;
|
||
}
|
||
|
||
protected Dictionary<UInt64, GuildMember> SortMemberListByOnLine(Dictionary<UInt64, GuildMember> dic)
|
||
{
|
||
List<KeyValuePair<UInt64, GuildMember>> myList = new List<KeyValuePair<UInt64, GuildMember>>(dic);
|
||
myList.Sort(delegate(KeyValuePair<UInt64, GuildMember> s1, KeyValuePair<UInt64, GuildMember> s2)
|
||
{
|
||
return s2.Value.State.CompareTo(s1.Value.State);
|
||
});
|
||
|
||
dic.Clear();
|
||
foreach (KeyValuePair<UInt64, GuildMember> pair in myList)
|
||
{
|
||
dic.Add(pair.Key, pair.Value);
|
||
}
|
||
return dic;
|
||
}
|
||
|
||
protected Dictionary<UInt64, GuildMember> SortMemberListByVIP(Dictionary<UInt64, GuildMember> dic)
|
||
{
|
||
List<KeyValuePair<UInt64, GuildMember>> myList = new List<KeyValuePair<UInt64, GuildMember>>(dic);
|
||
myList.Sort(delegate(KeyValuePair<UInt64, GuildMember> s1, KeyValuePair<UInt64, GuildMember> s2)
|
||
{
|
||
return s2.Value.VIP.CompareTo(s1.Value.VIP);
|
||
});
|
||
|
||
dic.Clear();
|
||
foreach (KeyValuePair<UInt64, GuildMember> pair in myList)
|
||
{
|
||
dic.Add(pair.Key, pair.Value);
|
||
}
|
||
return dic;
|
||
}
|
||
|
||
protected Dictionary<UInt64, GuildMember> SortMemberListByLevel(Dictionary<UInt64, GuildMember> dic)
|
||
{
|
||
List<KeyValuePair<UInt64, GuildMember>> myList = new List<KeyValuePair<UInt64, GuildMember>>(dic);
|
||
myList.Sort(delegate(KeyValuePair<UInt64, GuildMember> s1, KeyValuePair<UInt64, GuildMember> s2)
|
||
{
|
||
return s2.Value.Level.CompareTo(s1.Value.Level);
|
||
});
|
||
|
||
dic.Clear();
|
||
foreach (KeyValuePair<UInt64, GuildMember> pair in myList)
|
||
{
|
||
dic.Add(pair.Key, pair.Value);
|
||
}
|
||
return dic;
|
||
}
|
||
|
||
protected void SortByNewRule()
|
||
{
|
||
// 先按照帮主第一玩家第二的规则排
|
||
Dictionary<UInt64, GuildMember> tempList = new Dictionary<ulong, GuildMember> ();
|
||
foreach (KeyValuePair<ulong, GuildMember> member in m_GuildMemberList)// 会长
|
||
{
|
||
if (member.Value.IsValid() && member.Value.Job == (int)GameDefine_Globe.GUILD_JOB.CHIEF)
|
||
{
|
||
tempList.Add(member.Key,member.Value);
|
||
break;
|
||
}
|
||
}
|
||
|
||
foreach (KeyValuePair<ulong, GuildMember> member in m_GuildMemberList)// 玩家自己
|
||
{
|
||
if (tempList.ContainsKey(member.Key))
|
||
{
|
||
break;
|
||
}
|
||
if (member.Value.IsValid() && member.Key == GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Guid)
|
||
{
|
||
tempList.Add(member.Key,member.Value);
|
||
break;
|
||
}
|
||
}
|
||
|
||
foreach (KeyValuePair<ulong, GuildMember> member in m_GuildMemberList)// 副帮主
|
||
{
|
||
if (tempList.ContainsKey(member.Key))
|
||
{
|
||
continue;
|
||
}
|
||
if (member.Value.IsValid() && member.Value.Job == (int)GameDefine_Globe.GUILD_JOB.VICE_CHIEF)
|
||
{
|
||
tempList.Add(member.Key,member.Value);
|
||
continue;
|
||
}
|
||
}
|
||
|
||
SortedDictionary<uint,GuildMember> levelTempList = new SortedDictionary<uint, GuildMember> (new MySortU());
|
||
|
||
|
||
foreach (KeyValuePair<ulong, GuildMember> member in m_GuildMemberList)// 按照等级排序,需要排除键值相同的情况所以指定SortedDictionary中的compare方法
|
||
{
|
||
if (tempList.ContainsKey(member.Key)) // 已经排过的不处理
|
||
{
|
||
continue;
|
||
}
|
||
levelTempList.Add((uint)(200 - member.Value.Level), member.Value); // 按照等级降序排列
|
||
}
|
||
|
||
foreach(var levelItem in levelTempList)
|
||
{
|
||
tempList.Add(levelItem.Value.Guid,levelItem.Value);
|
||
}
|
||
|
||
|
||
m_GuildMemberList.Clear ();
|
||
m_GuildMemberList = tempList;
|
||
}
|
||
|
||
#region
|
||
public Dictionary<int, GuildXiulianWnd.AttrInfo> m_AttrInfos = new Dictionary<int, GuildXiulianWnd.AttrInfo>();
|
||
public Dictionary<int, string> m_AttrTypes = new Dictionary<int, string>();
|
||
//帮会修炼信息
|
||
public void FreshNewInfo(GC_PERSON_PRACTICE_INFO infos)
|
||
{
|
||
if (infos == null)
|
||
return;
|
||
if (m_AttrInfos.Count <= 0 && m_AttrTypes.Count <= 0)
|
||
{
|
||
var table = GCGame.Table.TableManager.GetGuildAttrPractice().Values;
|
||
foreach (var attrInfo in table)
|
||
{
|
||
GuildXiulianWnd.AttrInfo attr = new GuildXiulianWnd.AttrInfo();
|
||
attr.attrID = attrInfo.Id;
|
||
attr.attrTab = attrInfo;
|
||
m_AttrInfos[attr.attrID] = attr;
|
||
m_AttrTypes[attrInfo.TypeId] = attrInfo.TypeName;
|
||
}
|
||
}
|
||
|
||
int libraryLevel = GameManager.gameManager.PlayerDataPool.GuildInfo.GetBuildLevel(Guild.BuildType.library);
|
||
for (int i = 0; i < infos.practiceidCount; i++)
|
||
{
|
||
if (infos.practiceexpCount <= i)
|
||
break;
|
||
if (infos.practicelevelCount <= i)
|
||
break;
|
||
GuildXiulianWnd.AttrInfo newInfo = new GuildXiulianWnd.AttrInfo();
|
||
if (m_AttrInfos.TryGetValue(infos.GetPracticeid(i), out newInfo))
|
||
{
|
||
newInfo.attrExp = infos.GetPracticeexp(i);
|
||
int level = infos.GetPracticelevel(i);
|
||
if (level == 0 && libraryLevel < newInfo.attrTab.GuildCollegeLevel)
|
||
newInfo.attrLevel = -1;
|
||
else
|
||
newInfo.attrLevel = infos.GetPracticelevel(i);
|
||
}
|
||
}
|
||
XiulianRedPoint();
|
||
}
|
||
|
||
public void AttrWithBuildLevel()
|
||
{
|
||
if (m_AttrInfos.Count <= 0 && m_AttrTypes.Count <= 0)
|
||
{
|
||
var table = GCGame.Table.TableManager.GetGuildAttrPractice().Values;
|
||
foreach (var attrInfo in table)
|
||
{
|
||
GuildXiulianWnd.AttrInfo attr = new GuildXiulianWnd.AttrInfo();
|
||
attr.attrID = attrInfo.Id;
|
||
attr.attrTab = attrInfo;
|
||
m_AttrInfos[attr.attrID] = attr;
|
||
m_AttrTypes[attrInfo.TypeId] = attrInfo.TypeName;
|
||
}
|
||
}
|
||
int libraryLevel = GameManager.gameManager.PlayerDataPool.GuildInfo.GetBuildLevel(Guild.BuildType.library);
|
||
List<int> keys = new List<int>();
|
||
for(int i=0;i<keys.Count;i++)
|
||
{
|
||
GuildXiulianWnd.AttrInfo newInfo = new GuildXiulianWnd.AttrInfo();
|
||
if (m_AttrInfos.TryGetValue(keys[i], out newInfo))
|
||
{
|
||
if (newInfo.attrTab == null || libraryLevel < newInfo.attrTab.GuildCollegeLevel)
|
||
newInfo.attrLevel = -1;
|
||
else if (newInfo.attrLevel < 0)
|
||
newInfo.attrLevel = 0;
|
||
}
|
||
}
|
||
}
|
||
|
||
public void AttrInfoSet(GC_GUILD_PRACTICE_INFO packet)
|
||
{
|
||
if (packet == null)
|
||
return;
|
||
for (int i = 0; i < packet.practiceidCount; i++)
|
||
{
|
||
GuildXiulianWnd.AttrInfo newInfo = new GuildXiulianWnd.AttrInfo();
|
||
if (GameManager.gameManager.PlayerDataPool.GuildInfo.m_AttrInfos.TryGetValue(packet.GetPracticeid(i), out newInfo))
|
||
{
|
||
if (newInfo.attrLevel < 0)
|
||
newInfo.attrLevel = 0;
|
||
}
|
||
}
|
||
XiulianRedPoint();
|
||
}
|
||
|
||
public void XiulianRedPoint()
|
||
{
|
||
int libraryLevel = 0;
|
||
if(buildLevels.ContainsKey((int)BuildType.library))
|
||
libraryLevel = buildLevels[(int)BuildType.library];
|
||
foreach (var attrInfo in m_AttrInfos)
|
||
{
|
||
if((attrInfo.Value.attrLevel>=0 || attrInfo.Value.attrTab.GuildCollegeLevel <= libraryLevel) && attrInfo.Value.attrLevel < attrInfo.Value.attrTab.getLevelCount() && attrInfo.Value.attrTab.GetNeedLevelbyIndex(attrInfo.Value.attrLevel) <= GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Level)
|
||
{
|
||
long haveCost = GameManager.gameManager.PlayerDataPool.Money.GetMoneyByType((MONEYTYPE)attrInfo.Value.attrTab.MoneyType);
|
||
int costMoney = attrInfo.Value.attrTab.MoneyNum;
|
||
|
||
int CostContribute = attrInfo.Value.attrTab.ContributeNum;
|
||
int haveContribute = GameManager.gameManager.PlayerDataPool.GuildInfo.GuildContribute;
|
||
if(haveCost >= costMoney && haveContribute >= CostContribute)
|
||
{
|
||
RedTipPoint.RedPointStateChange(RedTipPoint.PointType.GuildXiulian, true);
|
||
return;
|
||
}
|
||
}
|
||
}
|
||
RedTipPoint.RedPointStateChange(RedTipPoint.PointType.GuildXiulian, false);
|
||
}
|
||
|
||
public void AskXiulianInfo()
|
||
{
|
||
CG_REQ_GUILD_PRACTICE send = (CG_REQ_GUILD_PRACTICE)PacketDistributed.CreatePacket(MessageID.PACKET_CG_REQ_GUILD_PRACTICE);
|
||
send.SetOptiontype((int)CG_REQ_GUILD_PRACTICE.OPTION_TYPE.PERSON_PRACTICE);
|
||
send.AddPracticeid(0);
|
||
send.IsAllowWithSilver = 0;
|
||
send.SendPacket();
|
||
}
|
||
|
||
#endregion
|
||
}
|
||
|
||
public class MySort : IComparer<int>
|
||
{
|
||
#region IComparer 成员
|
||
public int Compare(int x, int y)
|
||
{
|
||
//排序
|
||
int iResult = x - y;
|
||
if(iResult == 0) iResult = -1; // 排除重复
|
||
return iResult;
|
||
}
|
||
#endregion
|
||
}
|
||
|
||
public class MySortU : IComparer<uint>
|
||
{
|
||
#region IComparer 成员
|
||
public int Compare(uint x, uint y)
|
||
{
|
||
//排序
|
||
int iResult = (int)x - (int)y;
|
||
if(iResult == 0) iResult = -1; // 排除重复
|
||
return iResult;
|
||
}
|
||
#endregion
|
||
}
|
||
|
||
//反序排序,数字大的在前前
|
||
public class MySortURverse : IComparer<uint>
|
||
{
|
||
#region IComparer 成员
|
||
public int Compare(uint x, uint y)
|
||
{
|
||
//排序
|
||
int iResult = (int)x - (int)y;
|
||
if (iResult == 0) iResult = -1; // 排除重复
|
||
return -iResult;
|
||
}
|
||
#endregion
|
||
}
|
||
|
||
|