Exemplo n.º 1
0
 private void EngineCheckPlayerPosition(PlayerDataEx playerData)
 {
     Engine.ValidateNewPlayerPosition(playerData, playerData.Map);
 }
Exemplo n.º 2
0
 public byte[] MiniMapGet(PlayerDataEx playerData, out ShortSize miniMapSize)
 {
     miniMapSize = playerData.Map.MiniMapSize;
     return playerData.Map.GetMiniMap();
 }
Exemplo n.º 3
0
 public bool PlayerAdd(long sessionToken, Player player)
 {
     if (!_sessionPlayers.ContainsKey(sessionToken))
     {
         PlayerDataEx playerData = new PlayerDataEx(player, _maps);
         lock (_sessionPlayers) lock (_players)
         {
             _players.Add(playerData);
             _sessionPlayers.Add(sessionToken, playerData);
             return true;
         }
     }
     return false;
 }
Exemplo n.º 4
0
        public byte[] MapWindowGet(PlayerDataEx playerData, out ShortRect mapWindow)
        {
            const float resCoef = MAP_WINDOW_RES_COEF/ConstMap.PIXEL_SIZE;

            float dStartX, dStartY;
            float dWidth = playerData.ScreenRes.Width*resCoef;
            float dHeight = playerData.ScreenRes.Height*resCoef;
            ShortPoint pos = playerData.Player.Position.ToShortPoint(ConstMap.PIXEL_SIZE);
            switch (playerData.Player.Direction)
            {
                case Direction.N:
                    dStartX = pos.X - dWidth/2;
                    dStartY = pos.Y - dHeight;
                    break;
                case Direction.S:
                    dStartX = pos.X - dWidth/2;
                    dStartY = pos.Y;
                    break;
                case Direction.W:
                    dStartX = pos.X - dWidth;
                    dStartY = pos.Y - dHeight/2;
                    break;
                case Direction.E:
                    dStartX = pos.X;
                    dStartY = pos.Y - dHeight/2;
                    break;
                case Direction.NW:
                    dStartX = pos.X - dWidth/1.1f;
                    dStartY = pos.Y - dHeight/1.1f;
                    break;
                case Direction.NE:
                    dStartX = pos.X - dWidth*0.1f;
                    dStartY = pos.Y - dHeight/1.1f;
                    break;
                case Direction.SW:
                    dStartX = pos.X - dWidth/1.1f;
                    dStartY = pos.Y - dHeight*0.1f;
                    break;
                case Direction.SE:
                    dStartX = pos.X - dWidth*0.1f;
                    dStartY = pos.Y - dHeight*0.1f;
                    break;
                default:
                    dStartX = pos.X - dWidth/2;
                    dStartY = pos.Y - dHeight/2;
                    break;
            }

            int mapWidth = playerData.Map.Width, mapHeight = playerData.Map.Height;

            ushort startX = (ushort) Math.Max(dStartX, 0);
            ushort startY = (ushort) Math.Max(dStartY, 0);
            ushort width = (ushort) Math.Floor(startX + dWidth > mapWidth
                ? dWidth - (startX + dWidth - mapWidth)
                : dWidth);
            ushort height = (ushort) Math.Floor(startY + dHeight > mapHeight
                ? dHeight - (startY + dHeight - mapHeight)
                : dHeight);

            mapWindow = new ShortRect(startX, startY, width, height);
            return playerData.Map.GetWindow(mapWindow.X, mapWindow.Y, mapWindow.Width, mapWindow.Height);
        }