Esempio n. 1
0
        public void Respawn(Player player)
        {
            SendPlayersTo(player);

            var mapNpcs = new SpMapNpcData(this);

            mapNpcs.Send(player.Connection);
        }
        public void Warp(MapInstance map, int x, int y)
        {
            if (x > map.MaxX)
            {
                x = map.MaxX;
            }

            if (y > map.MaxY)
            {
                y = map.MaxY;
            }

            if (x < 0)
            {
                x = 0;
            }

            if (y < 0)
            {
                y = 0;
            }

            SpPlayerXY coordinates = null;

            // Se o jogador está tentando teleportar para o mesmo mapa.
            // Apenas envia as coordenadas.
            if (Player.MapId == map.Id)
            {
                coordinates = new SpPlayerXY(Player.Index, Player.X, Player.Y, Player.Direction);
                coordinates.SendToMap(Player.MapId);
            }

            // Remove o jogador do mapa antigo.
            if (Player.MapId != map.Id)
            {
                var oldMap = Player.GetMap();
                oldMap.RemovePlayer(Player);
            }

            var loadMap = new SpLoadMap(map.Id);

            loadMap.Send(Player.Connection);

            if (Player.Target > 0)
            {
                var target = new PlayerTarget()
                {
                    Player = Player
                };

                target.ClearTarget();
            }

            Player.MapId = map.Id;
            Player.X     = x;
            Player.Y     = y;

            coordinates = new SpPlayerXY(Player.Index, Player.X, Player.Y, Player.Direction);
            coordinates.Send(Player.Connection);

            map.AddPlayer(Player);
            map.SendPlayersTo(Player);

            var mapNpcs = new SpMapNpcData(map);

            mapNpcs.Send(Player.Connection);
        }