Ejemplo n.º 1
0
        public void SetCamera(Camera2D camera)
        {
            var localPlayer = _netManager.CurrentRoom.Players.FirstOrDefault(x => x.Username == _netManager.Username);

            if (localPlayer == null)
            {
                return;
            }

            var tempPos = new Vector2(localPlayer.X, localPlayer.Y) - _halfScreen;

            tempPos.X = UsefulMethods.Clamp(tempPos.X,
                                            0,
                                            (float)_netManager.CurrentRoom.Map.MapSize * Map.TileSize - _halfScreen.X * 2);

            tempPos.Y = UsefulMethods.Clamp(tempPos.Y,
                                            0,
                                            (float)_netManager.CurrentRoom.Map.MapSize * Map.TileSize - _halfScreen.Y * 2);

            _camera.Position = tempPos;
        }