1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- using System.Collections.Generic;
- using BattleIce;
- namespace ET.Server
- {
- [FriendOf(typeof (PlayerTempDataComponent))]
- public static class PlayerTempDataComponentSystem
- {
- public class PlayerTempDataComponentAwakeSystem: AwakeSystem<PlayerTempDataComponent>
- {
- protected override void Awake(PlayerTempDataComponent self)
- {
- Log.Info($"创建玩家临时数据组件...");
- self.MapData = new PlayerMapInfo();
- self.MapData.mapId = 10099;
- self.MapData.x = 1586;
- self.MapData.y = 1566;
- // self.MapData.direction = System.MathF.PI / 2;
- self.MapData.hp = PLAYER.initHp;
- self.MapData.mp = PLAYER.initMp;
- self.ToJson4BattleServerTempData = self.GetBattleServerTempData();
- }
- }
- public class PlayerTempDataComponentDestroySystem: DestroySystem<PlayerTempDataComponent>
- {
- protected override void Destroy(PlayerTempDataComponent self)
- {
- }
- }
- /** 同步场景出生数据 **/
- public static void SyncBornData(this PlayerTempDataComponent self, float bornX, float bornY, int bornAreaId)
- {
- self.MapData.bornX = bornX;
- self.MapData.bornY = bornY;
- self.MapData.bornMapId = bornAreaId;
- }
- /** 同步场景临时数据 **/
- public static void SyncNowData(this PlayerTempDataComponent self, int areaId, long instanceId, GetPlayerData data)
- {
- self.MapData.x = data.x;
- self.MapData.y = data.y;
- self.MapData.direction = data.direction;
- self.MapData.hp = data.hp;
- self.MapData.mp = data.mp;
- self.MapData.mapId = areaId;
- self.MapData.mapInstanceId = instanceId;
- }
- /** 同步场景历史数据 **/
- public static void SyncHistoryData(this PlayerTempDataComponent self, MapConfig prop, long instanceId, GetPlayerData data)
- {
- self.MapData.historyX = data.x;
- self.MapData.historyY = data.y;
- self.MapData.historyDirection = data.direction;
- self.MapData.historyMapId = prop.Id;
- self.MapData.historyMapInstanceId = instanceId;
- }
- /// <summary>
- /// 发送给场景服的数据
- /// </summary>
- /// <param name="self"></param>
- /// <returns></returns>
- private static Dictionary<string, object> GetBattleServerTempData(this PlayerTempDataComponent self)
- {
- Dictionary<string, object> data = new Dictionary<string, object>();
- data.Add("x", self.MapData.x);
- data.Add("y", self.MapData.y);
- data.Add("direction", self.MapData.direction);
- data.Add("hp", self.MapData.hp > 0 ? self.MapData.hp : self.GetParent<WNPlayer>().GetComponent<PlayerBtlComponent>().GetAllInflus(PlayerBtlData.MaxHP));
- data.Add("mp", self.MapData.mp);
- return data;
- }
- }
- }
|