105 lines
3.5 KiB
C#
105 lines
3.5 KiB
C#
|
using Thousandto.Code.Center;
|
|||
|
using Thousandto.Code.Global;
|
|||
|
using System.Collections.Generic;
|
|||
|
|
|||
|
namespace Thousandto.Code.Logic
|
|||
|
{
|
|||
|
//掉落归属系统
|
|||
|
public class DropAscriptionSystem
|
|||
|
{
|
|||
|
#region//私有变量
|
|||
|
private Dictionary<ulong, Dictionary<ulong, int>> _playerDropMonsters = new Dictionary<ulong, Dictionary<ulong, int>>();
|
|||
|
private Dictionary<ulong, ulong> _monsterTopRankPlayer = new Dictionary<ulong, ulong>();
|
|||
|
#endregion
|
|||
|
|
|||
|
#region//函数
|
|||
|
//改变消息
|
|||
|
public void UpdateMonsterDropOwners(ulong monsterID, List<long> owners)
|
|||
|
{
|
|||
|
if(owners == null || owners.Count <= 0)
|
|||
|
{
|
|||
|
_monsterTopRankPlayer.Remove(monsterID);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
_monsterTopRankPlayer[monsterID] = (ulong)owners[0];
|
|||
|
}
|
|||
|
//先移除这个monster的所有数据
|
|||
|
var removeList = new List<ulong>(_playerDropMonsters.Count);
|
|||
|
var iterPlayer = _playerDropMonsters.GetEnumerator();
|
|||
|
while (iterPlayer.MoveNext())
|
|||
|
{
|
|||
|
var valueDic = iterPlayer.Current.Value;
|
|||
|
if (valueDic.ContainsKey(monsterID))
|
|||
|
{
|
|||
|
valueDic.Remove(monsterID);
|
|||
|
}
|
|||
|
|
|||
|
if (valueDic.Count <= 0)
|
|||
|
{
|
|||
|
//此玩家已经不在任何列表了,移除他
|
|||
|
removeList.Add(iterPlayer.Current.Key);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
for (int i = 0; i < removeList.Count; ++i)
|
|||
|
{
|
|||
|
_playerDropMonsters.Remove(removeList[i]);
|
|||
|
}
|
|||
|
|
|||
|
if (owners != null && owners.Count > 0)
|
|||
|
{
|
|||
|
//重新设置这个monster的所有数据,只需要前三个目标数据
|
|||
|
for (int i = 0; i < owners.Count && i < 3; ++i)
|
|||
|
{
|
|||
|
Dictionary<ulong, int> curMonsterDic = null;
|
|||
|
if(!_playerDropMonsters.TryGetValue((ulong)owners[i], out curMonsterDic))
|
|||
|
{
|
|||
|
curMonsterDic = new Dictionary<ulong, int>();
|
|||
|
_playerDropMonsters.Add((ulong)owners[i], curMonsterDic);
|
|||
|
}
|
|||
|
curMonsterDic[monsterID] = i;
|
|||
|
}
|
|||
|
}
|
|||
|
GameCenter.PushFixEvent(LogicEventDefine.EID_EVENT_HUD_UPDATE_DROPINFO);
|
|||
|
}
|
|||
|
|
|||
|
//获取玩家最高排名
|
|||
|
public int GetPlayerMaxRank(ulong roleID, out ulong monsterId)
|
|||
|
{
|
|||
|
int result = int.MaxValue;
|
|||
|
monsterId = 0;
|
|||
|
Dictionary<ulong, int> curMonsterDic = null;
|
|||
|
if(_playerDropMonsters.TryGetValue(roleID, out curMonsterDic))
|
|||
|
{
|
|||
|
var iter = curMonsterDic.GetEnumerator();
|
|||
|
try
|
|||
|
{
|
|||
|
while(iter.MoveNext())
|
|||
|
{
|
|||
|
if(iter.Current.Value < result)
|
|||
|
{
|
|||
|
monsterId = iter.Current.Key;
|
|||
|
result = iter.Current.Value;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
finally
|
|||
|
{
|
|||
|
iter.Dispose();
|
|||
|
}
|
|||
|
}
|
|||
|
return result;
|
|||
|
}
|
|||
|
|
|||
|
//获取第一名的玩家id
|
|||
|
public ulong GetRankTopPlayerID(ulong monsterID)
|
|||
|
{
|
|||
|
ulong result = 0;
|
|||
|
_monsterTopRankPlayer.TryGetValue(monsterID, out result);
|
|||
|
return result;
|
|||
|
}
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|