123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text.RegularExpressions;
- using Newtonsoft.Json;
- using Newtonsoft.Json.Linq;
- namespace ET.Server
- {
- [FriendOf(typeof (MapEventComponent))]
- [FriendOf(typeof (Map))]
- public static class MapEventComponentSystem
- {
- public class MapEventComponentAwakeSystem: AwakeSystem<MapEventComponent>
- {
- /// <summary>
- /// 场景事件组件创建
- /// </summary>
- /// <param name="self"></param>
- protected override void Awake(MapEventComponent self)
- {
- Log.Info($"创建战斗服事件组件...");
- }
- }
- public class MapEventComponentDestroySystem: DestroySystem<MapEventComponent>
- {
- /// <summary>
- /// 场景事件组件销毁
- /// </summary>
- /// <param name="self"></param>
- protected override void Destroy(MapEventComponent self)
- {
- Log.Info($"销毁战斗服事件组件...");
- }
- }
- /// <summary>
- /// 副本消息
- /// </summary>
- /// <param name="self"></param>
- /// <param name="msg"></param>
- public static void OnMessage(this MapEventComponent self, JObject msg)
- {
- string str = Convert.ToString(msg.SelectToken("msg"));
- string[] parames = str.Split(":");
- switch (parames[0])
- {
- case "Dead":
- {
- if ("Tower1".Equals(parames[1]))
- {
- Log.Debug($"塔1死亡事件...");
- Map map = self.GetParent<Map>();
- map.CurBattleIndex = 1;
- map.TransferUnitsToNewTower();
- }
- else if ("Tower2".Equals(parames[1]))
- {
- Log.Debug($"塔2死亡事件...");
- Map map = self.GetParent<Map>();
- map.CurBattleIndex = 2;
- map.TransferUnitsToNewTower();
- }
- else if ("Tower3".Equals(parames[1]))
- {
- Log.Debug($"塔3死亡事件...");
- }
- else
- {
- int objId = int.Parse(parames[1]);
- if (objId > 0 && objId != 1 && objId != 2 && objId != 3)
- {
- Map map = self.GetParent<Map>();
- Struct.UnitPlayerData unitPlayerData = map.GetUnitPlayerByObjId(objId);
- if (unitPlayerData != null)
- {
- unitPlayerData.DeadState = 1;
- if (!map.DeadUnitPlayer.Exists(o => o == unitPlayerData.ObjId))
- {
- map.DeadUnitPlayer.Add(unitPlayerData.ObjId);
- }
- }
- }
- }
- break;
- }
- case "Revive":
- {
- int objId = int.Parse(parames[1]);
- if (objId > 0)
- {
- Map map = self.GetParent<Map>();
- Struct.UnitPlayerData unitPlayerData = map.GetUnitPlayerByObjId(objId);
- if (unitPlayerData != null)
- {
- unitPlayerData.DeadState = 0;
- if (map.DeadUnitPlayer.Exists(o => o == unitPlayerData.ObjId))
- {
- map.DeadUnitPlayer.Remove(unitPlayerData.ObjId);
- }
- }
- }
- break;
- }
- }
- }
- /// <summary>
- /// 场景结算事件
- /// </summary>
- /// <param name="self"></param>
- public static void OnGameOver(this MapEventComponent self)
- {
- Map map = self.GetParent<Map>();
- map.IsGameOver = true;
- if (map.Player == null)
- {
- return;
- }
- // 场景结束排行榜逻辑
- map.GetComponent<MapRankComponent>().OnGameOver();
- // 玩家离开
- map.Player.GetComponent<PlayerTempDataComponent>().MapData.ready = false;
- // 记录玩家历史
- map.SyncPlayerHistoryData(map.Player);
- // 战斗服场景玩家离开
- map.PlayerLeaveRequest(map.Player, false);
- // 本地场景移除玩家
- map.RemovePlayer(map.Player, false);
- // 移除本地玩家数据
- // self.DomainScene().GetComponent<GamePlayerComponent>().Remove(map.Player.GetId());
- // 战斗服结束场景
- map.DestroyZoneRequest();
- // 移除本地场景数据
- map.DomainScene().GetComponent<GameMapComponent>().Remove(map.Id, map.RoomId);
- map.Player.Map = null;
- map.Dispose();
- }
- /// <summary>
- /// 拾取道具
- /// </summary>
- /// <param name="self"></param>
- /// <param name="msg"></param>
- public static void OnPickItem(this MapEventComponent self, JObject msg)
- {
- }
- /// <summary>
- /// 击杀boss
- /// </summary>
- /// <param name="self"></param>
- /// <param name="msg"></param>
- public static void OnKillBoss(this MapEventComponent self, JObject msg)
- {
- }
- /// <summary>
- /// 战报统计
- /// </summary>
- /// <param name="self"></param>
- /// <param name="msg"></param>
- public static void OnBattleReport(this MapEventComponent self, JObject msg)
- {
- }
- }
- }
|