|
@@ -34,135 +34,69 @@ namespace ET.Server
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /** 玩家进场景后推的消息 **/
|
|
|
+ /// <summary>
|
|
|
+ /// 玩家进场景后推的消息
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="self"></param>
|
|
|
+ /// <param name="player"></param>
|
|
|
public static void OnReady(this MapEventComponent self, WNPlayer player)
|
|
|
{
|
|
|
}
|
|
|
|
|
|
- /** 玩家登录事件 **/
|
|
|
+ /// <summary>
|
|
|
+ /// 玩家登录事件
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="self"></param>
|
|
|
+ /// <param name="player"></param>
|
|
|
public static void OnPlayerLogin(this MapEventComponent self, WNPlayer player)
|
|
|
{
|
|
|
}
|
|
|
|
|
|
- /** 角色成功进入场景 **/
|
|
|
+ /// <summary>
|
|
|
+ /// 角色成功进入场景
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="self"></param>
|
|
|
+ /// <param name="player"></param>
|
|
|
public static void OnPlayerEntered(this MapEventComponent self, WNPlayer player)
|
|
|
{
|
|
|
}
|
|
|
|
|
|
- /** 单位死亡事件 **/
|
|
|
- public static void OnUnitDead(this MapEventComponent self, Map map, JObject msg)
|
|
|
+ /// <summary>
|
|
|
+ /// 单位死亡事件
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="self"></param>
|
|
|
+ /// <param name="msg"></param>
|
|
|
+ public static void OnUnitDead(this MapEventComponent self, JObject msg)
|
|
|
{
|
|
|
- int unitType = Convert.ToInt32(msg.SelectToken("unitType"));
|
|
|
- /*int objId = Convert.ToInt32(msg.SelectToken("objId"));
|
|
|
- int posX = Convert.ToInt32(msg.SelectToken("posX"));
|
|
|
- int posY = Convert.ToInt32(msg.SelectToken("posY"));
|
|
|
- // 攻击者
|
|
|
- long hitFinalPlayerId = msg.SelectToken("hitFinal").ToString() == ""? 0 : Convert.ToInt64(msg.SelectToken("hitFinal"));
|
|
|
- long belongPlayerId = msg.SelectToken("belongPlayerId").ToString() == ""? 0 : Convert.ToInt64(msg.SelectToken("belongPlayerId"));
|
|
|
- long[] atkAssistantList = JsonConvert.DeserializeObject<long[]>(Convert.ToString(msg.SelectToken("atkAssistantList")) ?? string.Empty);
|
|
|
- WNPlayer hitFinalPlayer = null;
|
|
|
-
|
|
|
- // 默认使用第一个摸怪玩家
|
|
|
- if (belongPlayerId > 0)
|
|
|
- {
|
|
|
- hitFinalPlayer = map.GetPlayer(belongPlayerId);
|
|
|
- }
|
|
|
-
|
|
|
- if (hitFinalPlayer == null && hitFinalPlayerId > 0)
|
|
|
- {
|
|
|
- hitFinalPlayer = map.GetPlayer(hitFinalPlayerId);
|
|
|
- }*/
|
|
|
+ }
|
|
|
|
|
|
- switch (unitType)
|
|
|
- {
|
|
|
- case 0:
|
|
|
- // 怪物死亡(玩家单位死亡, 延迟5秒复活)
|
|
|
- int unitTemplateId = Convert.ToInt32(msg.SelectToken("unitTemplateId"));
|
|
|
- // Monster monsterProp = MonsterCategory.Instance.Get(unitTemplateId);
|
|
|
- // if (monsterProp == null)
|
|
|
- // {
|
|
|
- // Log.Error($"单位死亡...找不到怪物配置 : unitTemplateId={unitTemplateId}, MapId={map.MapId}, data={msg}");
|
|
|
- // return;
|
|
|
- // }
|
|
|
-
|
|
|
- // 如果是塔
|
|
|
- // if (monsterProp.Atype == 4)
|
|
|
- // {
|
|
|
- // if (!map.DeadUnits.Contains(unitTemplateId))
|
|
|
- // {
|
|
|
- // map.DeadUnits.Add(unitTemplateId);
|
|
|
- // }
|
|
|
- // }
|
|
|
- // 如果是单位玩家
|
|
|
- /*if (map.UnitObjIds.ContainsValue(objId) && !map.IsGameOver())
|
|
|
- {
|
|
|
- Log.Debug($"单位死亡...objId={objId}, unitTemplateId={unitTemplateId}, posX={posX}, posY={posY}");
|
|
|
-
|
|
|
- string unitOpenId = null;
|
|
|
-
|
|
|
- foreach (string key in from key in map.UnitObjIds.Keys where !string.IsNullOrEmpty(key) let value = map.UnitObjIds[key] where value >= 0 && value == objId select key)
|
|
|
- {
|
|
|
- unitOpenId = key;
|
|
|
- break;
|
|
|
- }
|
|
|
-
|
|
|
- if (unitOpenId != null)
|
|
|
- {
|
|
|
- unitTemplateId = map.GetUnitTemplateId(unitOpenId);
|
|
|
-
|
|
|
- if (unitTemplateId == 0)
|
|
|
- {
|
|
|
- int[] units = new int[] { 101, 111, 121 };
|
|
|
-
|
|
|
- unitTemplateId = RandomGenerator.RandomArray(units);
|
|
|
- }
|
|
|
-
|
|
|
- map.GetComponent<MapReliveTimeComponent>().ReliveDatas.Add(new Struct.UnitPlayerReliveData(map, unitOpenId, unitTemplateId, TimeHelper.ServerNow() + 5000, posX, posY));
|
|
|
-
|
|
|
- map.UnitObjIds.Remove(unitOpenId);
|
|
|
- }
|
|
|
- }*/
|
|
|
-
|
|
|
- break;
|
|
|
- /*case 1:
|
|
|
- // 玩家死亡(主播死亡立即复活)
|
|
|
- long unitPlayerId = Convert.ToInt64(msg.SelectToken("unitPlayerId"));
|
|
|
-
|
|
|
- if (hitFinalPlayerId <= 0)
|
|
|
- {
|
|
|
- // 被boss杀死
|
|
|
- int attackerTemplateId = Convert.ToInt32(msg.SelectToken("attackerTemplateId"));
|
|
|
- Log.Debug($"玩家死亡...被boss杀死...playerId={unitPlayerId}, bossId={attackerTemplateId}");
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- // 被玩家杀死
|
|
|
- Log.Debug($"玩家死亡...被玩家杀死...playerId={unitPlayerId}, 攻击者={hitFinalPlayerId}");
|
|
|
- }
|
|
|
-
|
|
|
- WNPlayer unitPlayer = map.GetPlayer(unitPlayerId);
|
|
|
- if (unitPlayer == null)
|
|
|
- {
|
|
|
- return;
|
|
|
- }
|
|
|
- // 原地复活
|
|
|
- unitPlayer.GetXmdsManager().revivePlayer(unitPlayer.GetId().ToString(), unitPlayer.Map.ReliveData(ReliveType.NOW));
|
|
|
-
|
|
|
- break;
|
|
|
- case 2:
|
|
|
- // 宠物死亡
|
|
|
- break;*/
|
|
|
- }
|
|
|
+ /// <summary>
|
|
|
+ /// 塔死亡事件
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="self"></param>
|
|
|
+ /// <param name="msg"></param>
|
|
|
+ public static void OnDead(this MapEventComponent self, JObject msg)
|
|
|
+ {
|
|
|
+ Log.Debug($"塔死亡事件...");
|
|
|
}
|
|
|
|
|
|
- /** 副本消息 **/
|
|
|
+ /// <summary>
|
|
|
+ /// 副本消息
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="self"></param>
|
|
|
+ /// <param name="msg"></param>
|
|
|
public static void OnMessageEvent(this MapEventComponent self, JObject msg)
|
|
|
{
|
|
|
}
|
|
|
|
|
|
- /** 场景结算事件 **/
|
|
|
- public static void OnGameOver(this MapEventComponent self, Map map)
|
|
|
+ /// <summary>
|
|
|
+ /// 场景结算事件
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="self"></param>
|
|
|
+ public static void OnGameOver(this MapEventComponent self)
|
|
|
{
|
|
|
+ Map map = self.GetParent<Map>();
|
|
|
+
|
|
|
map.IsGameOver = true;
|
|
|
|
|
|
if (map?.Players is not { Count: > 0 })
|
|
@@ -185,18 +119,30 @@ namespace ET.Server
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /** 拾取道具 **/
|
|
|
+ /// <summary>
|
|
|
+ /// 拾取道具
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="self"></param>
|
|
|
+ /// <param name="msg"></param>
|
|
|
public static void OnPickItem(this MapEventComponent self, JObject msg)
|
|
|
{
|
|
|
}
|
|
|
|
|
|
- /** 击杀boss **/
|
|
|
+ /// <summary>
|
|
|
+ /// 击杀boss
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="self"></param>
|
|
|
+ /// <param name="msg"></param>
|
|
|
public static void OnKillBoss(this MapEventComponent self, JObject msg)
|
|
|
{
|
|
|
}
|
|
|
|
|
|
- /** 战斗统计 **/
|
|
|
- public static void OnBattleReport(this MapEventComponent self, Map map, JObject msg)
|
|
|
+ /// <summary>
|
|
|
+ /// 战报统计
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="self"></param>
|
|
|
+ /// <param name="msg"></param>
|
|
|
+ public static void OnBattleReport(this MapEventComponent self, JObject msg)
|
|
|
{
|
|
|
string data = Convert.ToString(msg.SelectToken("data"));
|
|
|
if (string.IsNullOrEmpty(data))
|
|
@@ -204,30 +150,23 @@ namespace ET.Server
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- List<Struct.BattleReports> list = new List<Struct.BattleReports>();
|
|
|
-
|
|
|
List<Struct.BattleReports> battleReports = JsonConvert.DeserializeObject<List<Struct.BattleReports>>(data);
|
|
|
if (battleReports is not { Count: > 0 })
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- foreach (Struct.BattleReports report in battleReports)
|
|
|
- {
|
|
|
- // 过滤一下非我方单位
|
|
|
- if (report.Force != 1)
|
|
|
- {
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
- uint ID = report.ID;
|
|
|
- long PlayerUUID = string.IsNullOrEmpty(report.PlayerUUID)? 0 : Convert.ToInt64(report.PlayerUUID);
|
|
|
- int TemplateID = report.TemplateId;
|
|
|
- int Force = report.Force;
|
|
|
- int TotalDamage = report.TotalDamage;
|
|
|
-
|
|
|
- list.Add(new Struct.BattleReports(ID, report.PlayerUUID, TemplateID, "name", Force, TotalDamage));
|
|
|
- }
|
|
|
+ Map map = self.GetParent<Map>();
|
|
|
+
|
|
|
+ List<Struct.BattleReports> list = (from report in battleReports
|
|
|
+ where report.Force == 1
|
|
|
+ let ID = report.ID
|
|
|
+ let PlayerUUID = string.IsNullOrEmpty(report.PlayerUUID)? "0" : report.PlayerUUID
|
|
|
+ let TemplateID = report.TemplateId
|
|
|
+ let Name = "玩家" + ID + "." + TemplateID
|
|
|
+ let Force = report.Force
|
|
|
+ let TotalDamage = report.TotalDamage
|
|
|
+ select new Struct.BattleReports(ID, PlayerUUID, TemplateID, Name, Force, TotalDamage)).ToList();
|
|
|
|
|
|
map.GetComponent<MapRankComponent>().UpdateRank(list, map);
|
|
|
}
|