123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using Newtonsoft.Json;
- using Newtonsoft.Json.Linq;
- namespace ET.Server
- {
- [FriendOf(typeof (MapEventComponent))]
- [FriendOfAttribute(typeof (Map))]
- public static class MapEventComponentSystem
- {
- public class MapEventComponentAwakeSystem: AwakeSystem<MapEventComponent>
- {
-
-
-
-
- protected override void Awake(MapEventComponent self)
- {
- Log.Info($"创建事件组件...");
- }
- }
- public class MapEventComponentDestroySystem: DestroySystem<MapEventComponent>
- {
-
-
-
-
- protected override void Destroy(MapEventComponent self)
- {
- Log.Info($"销毁事件组件...");
- }
- }
-
- public static void OnReady(this MapEventComponent self, WNPlayer player)
- {
- }
-
- public static void OnPlayerLogin(this MapEventComponent self, WNPlayer player)
- {
- }
-
- public static void OnPlayerEntered(this MapEventComponent self, WNPlayer player)
- {
- }
-
- public static void OnUnitDead(this MapEventComponent self, Map map, JObject msg)
- {
- int unitType = Convert.ToInt32(msg.SelectToken("unitType"));
-
- switch (unitType)
- {
- case 0:
-
- 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);
- }
- }
-
-
- break;
-
- }
- }
-
- public static void OnMessageEvent(this MapEventComponent self, JObject msg)
- {
- }
-
- public static void OnGameOver(this MapEventComponent self, Map map)
- {
- map.IsGameOver = true;
- if (map?.Players is not { Count: > 0 })
- {
- return;
- }
- foreach (WNPlayer player in map.Players.Values.Where(player => player != null))
- {
-
- map.SyncPlayerHistoryData(player);
-
- map.PlayerLeaveRequest(player, false);
-
- map.RemovePlayer(player, false);
-
- map.GetZoneManager().destroyZoneRequest(map.Id.ToString());
- player.Map = null;
- }
- }
-
- public static void OnPickItem(this MapEventComponent self, JObject msg)
- {
- }
-
- public static void OnKillBoss(this MapEventComponent self, JObject msg)
- {
- }
-
- public static void OnBattleReport(this MapEventComponent self, Map map, JObject msg)
- {
- string data = Convert.ToString(msg.SelectToken("data"));
- if (string.IsNullOrEmpty(data))
- {
- 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;
- string name = "";
- if (PlayerUUID > 0)
- {
- name = "玩家-" + TemplateID;
- }
- else
- {
- if (TemplateID > 0)
- {
- Monster prop = MonsterCategory.Instance.Get(TemplateID);
- if (prop != null)
- {
- name = prop.Name;
- }
- }
- }
- list.Add(new Struct.BattleReports(ID, report.PlayerUUID, TemplateID, name, Force, TotalDamage));
- }
- map.GetComponent<MapRankComponent>().UpdateRank(list, map);
- }
- }
- }
|