private void Start()
 {
     _factory        = new HealthBarFactory();
     _userHealthbars = new Dictionary <int, HealthBarFacade>();
     _playerRespawn.OnClickAsObservable().Subscribe(_ =>
     {
         PlayersController.Instance.RespawnPlayer();
     }).AddTo(this);
     Initialize();
 }
Exemplo n.º 2
0
        public static PlayerHealthBar CreateFromData(dynamic jsonData,
                                                     ContentManager contentManager,
                                                     GraphicsDevice graphicsDevice,
                                                     WeaponInventory weaponInventory,
                                                     GameWorld gameWorld,
                                                     GameData gameData,
                                                     HealthBarFactory healthBarFactory,
                                                     Player player)
        {
            var hudComponentDefinition = HudComponentDefinition.Create(jsonData);
            var healthBar = healthBarFactory.Create("PlayerHealthBar", hudComponentDefinition.Width, hudComponentDefinition.Height);

            return(new PlayerHealthBar(hudComponentDefinition, player, healthBar));
        }
Exemplo n.º 3
0
        public static SelectedWeapon CreateFromData(dynamic jsonData,
                                                    ContentManager contentManager,
                                                    GraphicsDevice graphicsDevice,
                                                    WeaponInventory weaponInventory,
                                                    GameWorld gameWorld,
                                                    GameData gameData,
                                                    HealthBarFactory healthBarFactory,
                                                    Player player)
        {
            var hudComponentDefinition = HudComponentDefinition.Create(jsonData);

            var scale = float.Parse((string)jsonData["scale"]);

            return(new SelectedWeapon(hudComponentDefinition, weaponInventory, scale));
        }
Exemplo n.º 4
0
        public static PlayerHealth CreateFromData(dynamic jsonData,
                                                  ContentManager contentManager,
                                                  GraphicsDevice graphicsDevice,
                                                  WeaponInventory weaponInventory,
                                                  GameWorld gameWorld,
                                                  GameData gameData,
                                                  HealthBarFactory healthBarFactory,
                                                  Player player)
        {
            var hudComponentDefinition = HudComponentDefinition.Create(jsonData);

            var font         = FontFactory.Instance.GetFont((string)jsonData["fontName"]);
            var textTemplate = (string)jsonData["textTemplate"];

            return(new PlayerHealth(hudComponentDefinition, font, textTemplate, player));
        }
Exemplo n.º 5
0
 /// <summary>
 /// ctor
 /// </summary>
 public Hud(ContentManager contentManager,
            GraphicsDevice graphicsDevice,
            WeaponInventory weaponInventory,
            GameWorld gameWorld,
            GameData gameData,
            HealthBarFactory healthBarFactory,
            Player player)
 {
     _contentManager  = contentManager;
     _graphicsDevice  = graphicsDevice;
     _weaponInventory = weaponInventory;
     _hudComponents   = new List <HudComponent>();
     GameWorld        = gameWorld;
     GameData         = gameData;
     Player           = player;
     HealthBarFactory = healthBarFactory;
 }
Exemplo n.º 6
0
        public static Minimap CreateFromData(dynamic jsonData,
                                             ContentManager contentManager,
                                             GraphicsDevice graphicsDevice,
                                             WeaponInventory weaponInventory,
                                             GameWorld gameWorld,
                                             GameData gameData,
                                             HealthBarFactory healthBarFactory,
                                             Player player)
        {
            Texture2D backgroundTexture = null;
            var       mapWidth          = (int)jsonData["width"];
            var       mapHeight         = (int)jsonData["height"];

            backgroundTexture = new Texture2D(graphicsDevice, mapWidth + (2 * MinimapBorderThicknessPx), mapHeight + (2 * MinimapBorderThicknessPx));
            var textureData = new Color[(mapWidth + (2 * MinimapBorderThicknessPx)) * (mapHeight + (2 * MinimapBorderThicknessPx))];

            //color the top border
            for (var i = 0; i < MinimapBorderThicknessPx * mapWidth; ++i)
            {
                textureData[i] = Color.Red;
            }

            //color the bottom border
            for (var i = (mapWidth * mapHeight); i < textureData.Length; ++i)
            {
                textureData[i] = Color.Red;
            }

            for (var i = MinimapBorderThicknessPx * mapWidth; i < textureData.Length - (MinimapBorderThicknessPx * mapWidth); ++i)
            {
                var col = i % (mapWidth + 2 * MinimapBorderThicknessPx);
                if (col < MinimapBorderThicknessPx)
                {
                    textureData[i] = Color.Red;
                }
                else if (col > mapWidth)
                {
                    textureData[i] = Color.Red;
                }
                else
                {
                    textureData[i] = Color.Black;
                }
            }

            backgroundTexture.SetData(textureData);

            var width  = (int)jsonData["alienWidth"];
            var height = (int)jsonData["alienHeight"];

            Texture2D alienTexture = null;

            alienTexture = new Texture2D(graphicsDevice, width, height);
            var alienTextureData = new Color[width * height];

            for (var i = 0; i < alienTextureData.Length; ++i)
            {
                alienTextureData[i] = Color.Green;
            }

            alienTexture.SetData(alienTextureData);

            var pickupTexture     = new Texture2D(graphicsDevice, width, height);
            var pickupTextureData = new Color[width * height];

            for (var i = 0; i < pickupTextureData.Length; ++i)
            {
                pickupTextureData[i] = Color.AliceBlue;
            }

            pickupTexture.SetData(pickupTextureData);

            var playerWidth       = (int)jsonData["alienWidth"];
            var playerHeight      = (int)jsonData["alienHeight"];
            var playerTexture     = new Texture2D(graphicsDevice, playerWidth, playerHeight);
            var playerTextureData = new Color[playerWidth * playerHeight];

            for (var i = 0; i < playerTextureData.Length; ++i)
            {
                playerTextureData[i] = Color.Gray;
            }

            playerTexture.SetData(playerTextureData);

            var hudComponentDefinition = HudComponentDefinition.Create(jsonData);

            return(new Minimap(gameWorld, gameData, backgroundTexture, alienTexture, pickupTexture, playerTexture, hudComponentDefinition, player));
        }