コード例 #1
0
ファイル: RemainingAmmo.cs プロジェクト: timgarwood/invaders
 private RemainingAmmo(HudComponentDefinition definition, Font font, string textTemplate, WeaponInventory weaponInventory) :
     base(definition)
 {
     Font            = font;
     TextTemplate    = textTemplate;
     WeaponInventory = weaponInventory;
 }
コード例 #2
0
 public PlayerHealthBar(HudComponentDefinition hudComponentDefinition,
                        Player player,
                        HealthBar healthBar) :
     base(hudComponentDefinition)
 {
     Player    = player;
     HealthBar = healthBar;
 }
コード例 #3
0
ファイル: TotalScore.cs プロジェクト: timgarwood/invaders
 public TotalScore(HudComponentDefinition definition,
                   Player player,
                   Font font,
                   string textTemplate) : base(definition)
 {
     Player       = player;
     Font         = font;
     TextTemplate = textTemplate;
 }
コード例 #4
0
 public LivesRemaining(HudComponentDefinition definition,
                       Player player,
                       Font font,
                       string textTemplate) : base(definition)
 {
     Player       = player;
     Font         = font;
     TextTemplate = textTemplate;
 }
コード例 #5
0
ファイル: HudComponent.cs プロジェクト: timgarwood/invaders
        /// <summary>
        /// ctor
        /// </summary>
        /// <param name="definition"></param>
        public HudComponent(HudComponentDefinition definition)
        {
            _hudComponentDefinition = definition;
            if (definition.Width <= 0 || definition.Height <= 0)
            {
                throw new System.Exception("HudComponent needs a width and height");
            }

            _location = new Vector2(Left, Top);
        }
コード例 #6
0
ファイル: PlayerHealth.cs プロジェクト: timgarwood/invaders
 private PlayerHealth(HudComponentDefinition hudComponentDefinition,
                      Font font,
                      string template,
                      Player player) :
     base(hudComponentDefinition)
 {
     _font         = font;
     _textTemplate = template;
     Player        = player;
 }
コード例 #7
0
        /// <summary>
        /// creates a HudComponentDefinition from the given dynamic object
        /// </summary>
        /// <param name="jsonData"></param>
        public static HudComponentDefinition Create(dynamic d)
        {
            var def = new HudComponentDefinition();

            def.HorizontalPercentage = (float)d["horizontalPercentage"];
            def.VerticalPercentage   = (float)d["verticalPercentage"];
            def.HAlign = (string)d["hAlignment"];
            def.VAlign = (string)d["vAlignment"];
            def.Width  = (int)d["width"];
            def.Height = (int)d["height"];
            def.Name   = (string)d["name"];
            return(def);
        }
コード例 #8
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));
        }
コード例 #9
0
ファイル: SelectedWeapon.cs プロジェクト: timgarwood/invaders
        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));
        }
コード例 #10
0
ファイル: PlayerHealth.cs プロジェクト: timgarwood/invaders
        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));
        }
コード例 #11
0
ファイル: Minimap.cs プロジェクト: timgarwood/invaders
 /// <summary>
 /// ctor
 /// </summary>
 /// <param name="texture"></param>
 /// <param name="definition"></param>
 private Minimap(GameWorld gameWorld,
                 GameData gameData,
                 Texture2D backgroundTexture,
                 Texture2D alienTexture,
                 Texture2D pickupTexture,
                 Texture2D playerTexture,
                 HudComponentDefinition definition,
                 Player player)
     : base(definition)
 {
     GameWorld          = gameWorld;
     GameData           = gameData;
     Player             = player;
     _backgroundTexture = backgroundTexture;
     _alienTexture      = alienTexture;
     _pickupTexture     = pickupTexture;
     _playerTexture     = playerTexture;
     _destPoint         = new Vector2();
 }
コード例 #12
0
ファイル: Minimap.cs プロジェクト: timgarwood/invaders
        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));
        }
コード例 #13
0
ファイル: SelectedWeapon.cs プロジェクト: timgarwood/invaders
 private SelectedWeapon(HudComponentDefinition definition, WeaponInventory weaponInventory, float scale) :
     base(definition)
 {
     WeaponInventory = weaponInventory;
     Scale           = new Vector2(scale, scale);
 }