Inheritance: BaseSprite
Exemplo n.º 1
0
        /// <summary>
        /// Updates the HUD.
        /// </summary>
        /// <param name="elapsedTime">Time since the last call.</param>
        public void Update(float elapsedTime)
        {
            foreach (Player player in _playerComponent.All)
            {
                HUDSprite hud = getHUDSprite(player.PlayerIndex);
                if (hud.Show == false)
                {
                    continue;
                }

                //Update status bars.
                PlayerInfo info  = _game.PlayerInfoComponent[player.EntityID];
                Stats      stats = _game.StatsComponent[player.EntityID];

                float healthPercent = info.Health / stats.HealthBase;
                float psiPercent    = info.Psi / stats.PsiBase;
                float expPercent    = info.Experience / 100; //Need to find expbase

                hud.HealthBounds.Width = (int)(HEALTH_BAR_MAX_BOUNDS * healthPercent);
                hud.PsiBounds.Width    = (int)(PSI_BAR_MAX_BOUNDS * psiPercent);
                hud.ExpBounds.Width    = (int)(EXP_BAR_MAX_BOUNDS * expPercent);

                //Update icons

                //Update level
                hud.Level = LEVEL_PREFIX + info.Level;

                setHUDSprite(player.PlayerIndex, hud);
            }
        }
Exemplo n.º 2
0
 public void Set(HUDTransform transform)
 {
     this._transform = transform;
     player_name     = transform.GetHUDComponent <HUDText>("name");
     title           = transform.GetHUDComponent <HUDSprite>("title");
     guild_name      = transform.GetHUDComponent <HUDText>("guild_name");
     guild_icon      = transform.GetHUDComponent <HUDSprite>("guild_icon");
 }
Exemplo n.º 3
0
 public void Draw(SpriteBatch spriteBatch)
 {
     HUDSprite.Draw(spriteBatch, HUDDestinationRectangle);
     levelNumSprite.Draw(spriteBatch, levelNumDestinationRectangle);
     MinimapSprite.Draw(spriteBatch, MinimapDestinationRectangle);
     for (int index = 0; index < HeartSprites.Count; index++)
     {
         HeartSprites[index].Draw(spriteBatch, HeartDestinationRectangles[index]);
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// Creates a new HUDSystem.
        /// </summary>
        /// <param name="game">Parent game.</param>
        public HUDSystem(DungeonCrawlerGame game)
        {
            _game = game;
            _content = game.Content;
            _playerComponent = game.PlayerComponent;

            _p1 = new HUDSprite { Show = false };
            _p2 = new HUDSprite { Show = false };
            _p3 = new HUDSprite { Show = false };
            _p4 = new HUDSprite { Show = false };
        }
Exemplo n.º 5
0
        /// <summary>
        /// Creates a new HUDSystem.
        /// </summary>
        /// <param name="game">Parent game.</param>
        public HUDSystem(DungeonCrawlerGame game)
        {
            _game = game;
            _content = game.Content;
            _playerComponent = game.PlayerComponent;
            spriteBatch = new SpriteBatch(game.GraphicsDevice);

            _p1 = new HUDSprite { Show = false };
            _p2 = new HUDSprite { Show = false };
            _p3 = new HUDSprite { Show = false };
            _p4 = new HUDSprite { Show = false };
        }
Exemplo n.º 6
0
        /// <summary>
        /// Creates a new HUDSystem.
        /// </summary>
        /// <param name="game">Parent game.</param>
        public HUDSystem(DungeonCrawlerGame game)
        {
            _game            = game;
            _content         = game.Content;
            _playerComponent = game.PlayerComponent;

            _p1 = new HUDSprite {
                Show = false
            };
            _p2 = new HUDSprite {
                Show = false
            };
            _p3 = new HUDSprite {
                Show = false
            };
            _p4 = new HUDSprite {
                Show = false
            };
        }
Exemplo n.º 7
0
        /// <summary>
        /// Creates a new HUDSystem.
        /// </summary>
        /// <param name="game">Parent game.</param>
        public HUDSystem(DungeonCrawlerGame game)
        {
            _game            = game;
            _content         = game.Content;
            _playerComponent = game.PlayerComponent;
            spriteBatch      = new SpriteBatch(game.GraphicsDevice);

            _p1 = new HUDSprite {
                Show = false
            };
            _p2 = new HUDSprite {
                Show = false
            };
            _p3 = new HUDSprite {
                Show = false
            };
            _p4 = new HUDSprite {
                Show = false
            };
        }
Exemplo n.º 8
0
        private void setHUDSprite(PlayerIndex index, HUDSprite sprite)
        {
            switch (index)
            {
            case PlayerIndex.One:
                _p1 = sprite;
                break;

            case PlayerIndex.Two:
                _p2 = sprite;
                break;

            case PlayerIndex.Three:
                _p3 = sprite;
                break;

            case PlayerIndex.Four:
                _p4 = sprite;
                break;
            }
        }
Exemplo n.º 9
0
        public Boton(CustomBitmap sprite, CustomBitmap spriteSelec, string texto, int indice, Drawer2D drawer)
        {
            CustomSprite menuSprite = new CustomSprite();

            menuSprite.Bitmap = sprite;
            CustomSprite menuSpriteSelec = new CustomSprite();

            menuSpriteSelec.Bitmap = spriteSelec;

            menuItem      = new HUDSprite(HUD.AnclajeHorizontal.LEFT, HUD.AnclajeVertical.TOP, new TGCVector2(0.05f, 0.5f + (float)indice / 17), new TGCVector2(1, 1), drawer, menuSprite);
            menuItemSelec = new HUDSprite(HUD.AnclajeHorizontal.LEFT, HUD.AnclajeVertical.TOP, new TGCVector2(0.05f, 0.5f + (float)indice / 17), new TGCVector2(1, 1), drawer, menuSpriteSelec);
            menuItem.Init();
            menuItemSelec.Init();

            TgcText2D texto2D = new TgcText2D();

            texto2D.Align = TgcText2D.TextAlign.CENTER;
            texto2D.Size  = new Size((int)(menuItem.Sprite.Scaling.X * 350), 20);
            texto2D.changeFont(new System.Drawing.Font("Calibri", D3DDevice.Instance.Width / 96f, FontStyle.Italic | FontStyle.Bold));
            texto2D.Text = texto;

            this.texto = new HUDTexto(HUD.AnclajeHorizontal.LEFT, HUD.AnclajeVertical.TOP, new TGCVector2(0.1f, 0.5175f + (float)indice / 17), drawer, texto2D);
            this.texto.Init();
        }
Exemplo n.º 10
0
        /// <summary>
        /// Creates a HUD for the specific player.
        /// </summary>
        /// <param name="player">Player to create hud for.</param>
        public void LoadPlayerHUD(Player player)
        {
            HUDSprite hud = new HUDSprite { Show = true };

            //Load avatar
            switch (player.PlayerRace)
            {
                case Entities.Aggregate.CultistPlayer:
                    hud.AvatarSpriteSheet = _content.Load<Texture2D>("Spritesheets/Aggregate/Cultist");
                    break;
                case Entities.Aggregate.CyborgPlayer:
                    hud.AvatarSpriteSheet = _content.Load<Texture2D>("Spritesheets/Aggregate/cyborg");
                    break;
                case Entities.Aggregate.EarthianPlayer:
                    hud.AvatarSpriteSheet = _content.Load<Texture2D>("Spritesheets/Aggregate/Earthian2x");
                    break;
                case Entities.Aggregate.FairyPlayer:
                    hud.AvatarSpriteSheet = _content.Load<Texture2D>("Spritesheets/Aggregate/wind_fae");
                    break;
                case Entities.Aggregate.GargranianPlayer:
                    hud.AvatarSpriteSheet = _content.Load<Texture2D>("Spritesheets/Aggregate/gargranian");
                    break;
                case Entities.Aggregate.SpacePiratePlayer:
                    hud.AvatarSpriteSheet = _content.Load<Texture2D>("Spritesheets/Aggregate/SpacePBig");
                    break;
                case Entities.Aggregate.ZombiePlayer:
                    hud.AvatarSpriteSheet = _content.Load<Texture2D>("Spritesheets/Aggregate/MzombieBx2");
                    break;
                default:
                    throw new Exception("Unknown race");
            }
            hud.AvatarSpriteBounds = new Rectangle(0, 0, 64, 64);

            //Load skill icon

            //Load the rest of the spritesheets. Dont worry about position yet.
            hud.HudBgSpriteBounds = new Rectangle(0, 0, 270, 143);
            hud.HealthSpriteSheet = _content.Load<Texture2D>("Spritesheets/HUD/HealthBar");
            hud.HealthBounds = new Rectangle(0, 0, HEALTH_BAR_MAX_BOUNDS, 17);
            hud.PsiSpriteSheet = _content.Load<Texture2D>("Spritesheets/HUD/PsiBar");
            hud.PsiBounds = new Rectangle(0, 0, PSI_BAR_MAX_BOUNDS, 17);
            hud.ExpSpriteSheet = _content.Load<Texture2D>("Spritesheets/HUD/ExpBar");
            hud.ExpBounds = new Rectangle(0, 0, EXP_BAR_MAX_BOUNDS, 7);

            PlayerInfo info = _game.PlayerInfoComponent[player.EntityID];
            hud.Level = LEVEL_PREFIX + info.Level;

            //Load the right background and set all the positions based on the playerindex.
            switch (player.PlayerIndex)
            {
                case PlayerIndex.One:
                    hud.HudBgSpriteSheet = _content.Load<Texture2D>("Spritesheets/HUD/hud_one");
                    hud.HudBgPosition = new Vector2(0, 0);
                    hud.AvatarPosition = new Vector2(20, 20);
                    hud.HealthPosition = new Vector2(109, 4);
                    hud.PsiPosition = new Vector2(109, 26);
                    hud.ExpPosition = new Vector2(109, 48);
                    hud.LevelPosition = new Vector2(20, 84);

                    _p1 = hud;
                    break;
                case PlayerIndex.Two:
                    hud.HudBgSpriteSheet = _content.Load<Texture2D>("Spritesheets/HUD/hud_two");
                    hud.HudBgPosition = new Vector2(1010, 0);
                    hud.AvatarPosition = new Vector2(1195, 20);
                    hud.HealthPosition = new Vector2(1013, 4);
                    hud.PsiPosition = new Vector2(1013, 26);
                    hud.ExpPosition = new Vector2(1013, 48);
                    hud.LevelPosition = new Vector2(1195, 84);

                    _p2 = hud;
                    break;
                case PlayerIndex.Three:
                    hud.HudBgSpriteSheet = _content.Load<Texture2D>("Spritesheets/HUD/hud_three");
                    hud.HudBgPosition = new Vector2(0, 577);
                    hud.AvatarPosition = new Vector2(20, 615);
                    hud.HealthPosition = new Vector2(109, 700);
                    hud.PsiPosition = new Vector2(109, 678);
                    hud.ExpPosition = new Vector2(109, 667);
                    hud.LevelPosition = new Vector2(20, 679);

                    _p3 = hud;
                    break;
                case PlayerIndex.Four:
                    hud.HudBgSpriteSheet = _content.Load<Texture2D>("Spritesheets/HUD/hud_four");
                    hud.HudBgPosition = new Vector2(1010, 577);
                    hud.AvatarPosition = new Vector2(1195, 615);
                    hud.HealthPosition = new Vector2(1013, 700);
                    hud.PsiPosition = new Vector2(1013, 678);
                    hud.ExpPosition = new Vector2(1013, 667);
                    hud.LevelPosition = new Vector2(1195, 679);

                    _p4 = hud;
                    break;
                default:
                    throw new Exception("Invalid player index");
            }
        }
Exemplo n.º 11
0
        //Handles drawing the individual HUDs.
        private void drawHud(HUDSprite hud, float elapsedTime, SpriteBatch spriteBatch)
        {
            //Background
            spriteBatch.Draw(hud.HudBgSpriteSheet,
                             hud.HudBgPosition,
                             hud.HudBgSpriteBounds,
                             Color.White,
                             0f,                     // rotation
                             new Vector2(0),         // origin
                             1f,                     // scale
                             SpriteEffects.None,
                             0.1f);

            //Avatar
            spriteBatch.Draw(hud.AvatarSpriteSheet,
                             hud.AvatarPosition,
                             hud.AvatarSpriteBounds,
                             Color.White,
                             0f,                     // rotation
                             new Vector2(0),         // origin
                             1f,                     // scale
                             SpriteEffects.None,
                             0);

            //Health bar
            spriteBatch.Draw(hud.HealthSpriteSheet,
                             hud.HealthPosition,
                             hud.HealthBounds,
                             Color.White,
                             0,                      // rotation
                             new Vector2(0),         // origin
                             1f,                     // scale
                             SpriteEffects.None,
                             0);

            //Psi bar
            spriteBatch.Draw(hud.PsiSpriteSheet,
                             hud.PsiPosition,
                             hud.PsiBounds,
                             Color.White,
                             0,                      // rotation
                             new Vector2(0),         // origin
                             1f,                     // scale
                             SpriteEffects.None,
                             0);

            //Exp bar
            spriteBatch.Draw(hud.ExpSpriteSheet,
                             hud.ExpPosition,
                             hud.ExpBounds,
                             Color.White,
                             0,                      // rotation
                             new Vector2(0),         // origin
                             1f,                     // scale
                             SpriteEffects.None,
                             0);

            //Skill icon

            //Item icon

            //Collection icon

            //Level
            spriteBatch.DrawString(_font, hud.Level, hud.LevelPosition, Color.Black);
        }
Exemplo n.º 12
0
        public void CreateHUD(Player player)
        {
            uint entityID;
            Texture2D spriteSheet;
            Position position;
            Vector2 corner; //Which corner of the screen the Health/Psi status goes
            HUDSprite AButtonSprite,
                      BButtonSprite,
                      XButtonSprite,
                      YButtonSprite,
                      DPadSprite,
                      HeatlhPsiStatusSprite;
            HUD hud;
            #region buttons
            //Make A button
            entityID = Entity.NextEntity();
            spriteSheet = game.Content.Load<Texture2D>("ControllerTGAs/xboxControllerButtonA-BW");
            position = new Position()
            {
                EntityID = entityID,
                Center = new Vector2(960,440),
                Radius = 40f,
            };
            game.PositionComponent[entityID] = position;
            AButtonSprite = new HUDSprite()
            {
                EntityID = entityID,
                isSeen = false,
                SpriteSheet = spriteSheet,
                SpriteBounds = new Rectangle(0, 0, 80, 80),
                PlayerIndex = player.PlayerIndex,
                isStatus = false,
            };
            game.HUDSpriteComponent[entityID] = AButtonSprite;

            //Make B button
            entityID = Entity.NextEntity();
            spriteSheet = game.Content.Load<Texture2D>("ControllerTGAs/xboxControllerButtonB-BW");
            position = new Position()
            {
                EntityID = entityID,
                Center = new Vector2(1040,360),
                Radius = 40f,
            };
            game.PositionComponent[entityID] = position;

            BButtonSprite = new HUDSprite()
            {
                EntityID = entityID,
                isSeen = false,
                SpriteSheet = spriteSheet,
                SpriteBounds = new Rectangle(0, 0, 80, 80),
                PlayerIndex = player.PlayerIndex,
                isStatus = false,
            };
            game.HUDSpriteComponent[entityID] = BButtonSprite;

            //Make X Button
            entityID = Entity.NextEntity();
            spriteSheet = game.Content.Load<Texture2D>("ControllerTGAs/xboxControllerButtonX-BW");

            position = new Position()
            {
                EntityID = entityID,
                Center = new Vector2(880,360),
                Radius = 40f,
            };
            game.PositionComponent[entityID] = position;

            XButtonSprite= new HUDSprite()
            {
                EntityID = entityID,
                isSeen = false,
                SpriteSheet = spriteSheet,
                SpriteBounds = new Rectangle(0, 0, 80, 80),
                PlayerIndex = player.PlayerIndex,
                isStatus = false,
            };
            game.HUDSpriteComponent[entityID] = XButtonSprite;

            //Make Y Button
            entityID = Entity.NextEntity();
            spriteSheet = game.Content.Load<Texture2D>("ControllerTGAs/xboxControllerButtonY-BW");

            position = new Position()
            {
                EntityID = entityID,
                Center = new Vector2(960,280),
                Radius = 40f,
            };
            game.PositionComponent[entityID] = position;

            YButtonSprite = new HUDSprite()
            {
                EntityID = entityID,
                isSeen = false,
                SpriteSheet = spriteSheet,
                SpriteBounds = new Rectangle(0, 0, 80, 80),
                PlayerIndex = player.PlayerIndex,
                isStatus = false,
            };
            game.HUDSpriteComponent[entityID] = YButtonSprite;

            //Make Dpad
            entityID = Entity.NextEntity();
            spriteSheet = game.Content.Load<Texture2D>("ControllerTGAs/xboxControllerDPad");

            position = new Position()
            {
                EntityID = entityID,
                Center = new Vector2(320,360),
                Radius = 93f,
            };
            game.PositionComponent[entityID] = position;

            DPadSprite = new HUDSprite()
            {
                EntityID = entityID,
                isSeen = false,
                SpriteSheet = spriteSheet,
                SpriteBounds = new Rectangle(0, 0, 186, 186),
                PlayerIndex = player.PlayerIndex,
                isStatus = false,
            };
            game.HUDSpriteComponent[entityID] = DPadSprite;
            #endregion
            //Use a Health/Psi or Health/Fatigue Status Bar depending on the player's race
            entityID = Entity.NextEntity();
            switch(player.PlayerRace)
            {
                case Aggregate.CultistPlayer:
                case Aggregate.GargranianPlayer:
                    spriteSheet = game.Content.Load<Texture2D>("Spritesheets/HealthPsi");
                    break;
                case Aggregate.EarthianPlayer:
                case Aggregate.CyborgPlayer:
                case Aggregate.SpacePiratePlayer:
                case Aggregate.ZombiePlayer:
                    spriteSheet = game.Content.Load<Texture2D>("Spritesheets/HealthFatigue");
                break;
            }

            //Choose player corner
            switch (player.PlayerIndex)
            {
                case PlayerIndex.One:
                    corner = new Vector2(0, 0);
                    break;
                case PlayerIndex.Two:
                    corner = new Vector2(1024, 0);
                    break;
                case PlayerIndex.Three:
                    corner = new Vector2(0, 656);
                    break;
                case PlayerIndex.Four:
                    corner = new Vector2(1024, 656);
                    break;
                default:
                    corner = new Vector2(0,0);
                    break;
            }
            position = new Position()
            {
                EntityID = entityID,
                Center = corner,
                Radius = 0f,//its a rectangle, so no radius for proper drawing
            };
            game.PositionComponent[entityID] = position;
            HeatlhPsiStatusSprite = new HUDSprite()
            {
                EntityID = entityID,
                isSeen = true,
                SpriteSheet = spriteSheet,
                SpriteBounds = new Rectangle(0,0,256,64),
                PlayerIndex = player.PlayerIndex,
                isStatus = true,
            };
            game.HUDSpriteComponent[entityID] = HeatlhPsiStatusSprite;
            //Set hud
            hud = new HUD()
            {
                EntityID = player.EntityID,
                AButtonSpriteID = AButtonSprite.EntityID,
                BButtonSpriteID = BButtonSprite.EntityID,
                XButtonSpriteID = XButtonSprite.EntityID,
                YButtonSpriteID = YButtonSprite.EntityID,
                DPadSpriteID = DPadSprite.EntityID,
                HealthPsiStatusSpriteID = HeatlhPsiStatusSprite.EntityID,
            };
            game.HUDComponent[player.EntityID] = hud;
        }
Exemplo n.º 13
0
        /// <summary>
        /// Creates a HUD for the specific player.
        /// </summary>
        /// <param name="player">Player to create hud for.</param>
        public void LoadPlayerHUD(Player player)
        {
            HUDSprite hud = new HUDSprite {
                Show = true
            };

            //Load avatar
            switch (player.PlayerRace)
            {
            case Entities.Aggregate.CultistPlayer:
                hud.AvatarSpriteSheet = _content.Load <Texture2D>("Spritesheets/Aggregate/Cultist");
                break;

            case Entities.Aggregate.CyborgPlayer:
                hud.AvatarSpriteSheet = _content.Load <Texture2D>("Spritesheets/Aggregate/cyborg");
                break;

            case Entities.Aggregate.EarthianPlayer:
                hud.AvatarSpriteSheet = _content.Load <Texture2D>("Spritesheets/Aggregate/Earthian2x");
                break;

            case Entities.Aggregate.FairyPlayer:
                hud.AvatarSpriteSheet = _content.Load <Texture2D>("Spritesheets/Aggregate/wind_fae");
                break;

            case Entities.Aggregate.GargranianPlayer:
                hud.AvatarSpriteSheet = _content.Load <Texture2D>("Spritesheets/Aggregate/gargranian");
                break;

            case Entities.Aggregate.SpacePiratePlayer:
                hud.AvatarSpriteSheet = _content.Load <Texture2D>("Spritesheets/Aggregate/SpacePBig");
                break;

            case Entities.Aggregate.ZombiePlayer:
                hud.AvatarSpriteSheet = _content.Load <Texture2D>("Spritesheets/Aggregate/MzombieBx2");
                break;

            default:
                throw new Exception("Unknown race");
            }
            hud.AvatarSpriteBounds = new Rectangle(0, 0, 64, 64);

            //Load skill icon

            //Load the rest of the spritesheets. Dont worry about position yet.
            hud.HudBgSpriteBounds = new Rectangle(0, 0, 270, 143);
            hud.HealthSpriteSheet = _content.Load <Texture2D>("Spritesheets/HUD/HealthBar");
            hud.HealthBounds      = new Rectangle(0, 0, HEALTH_BAR_MAX_BOUNDS, 17);
            hud.PsiSpriteSheet    = _content.Load <Texture2D>("Spritesheets/HUD/PsiBar");
            hud.PsiBounds         = new Rectangle(0, 0, PSI_BAR_MAX_BOUNDS, 17);
            hud.ExpSpriteSheet    = _content.Load <Texture2D>("Spritesheets/HUD/ExpBar");
            hud.ExpBounds         = new Rectangle(0, 0, EXP_BAR_MAX_BOUNDS, 7);

            PlayerInfo info = _game.PlayerInfoComponent[player.EntityID];

            hud.Level = LEVEL_PREFIX + info.Level;

            //Load the right background and set all the positions based on the playerindex.
            switch (player.PlayerIndex)
            {
            case PlayerIndex.One:
                hud.HudBgSpriteSheet = _content.Load <Texture2D>("Spritesheets/HUD/hud_one");
                hud.HudBgPosition    = new Vector2(0, 0);
                hud.AvatarPosition   = new Vector2(20, 20);
                hud.HealthPosition   = new Vector2(109, 4);
                hud.PsiPosition      = new Vector2(109, 26);
                hud.ExpPosition      = new Vector2(109, 48);
                hud.LevelPosition    = new Vector2(20, 84);

                _p1 = hud;
                break;

            case PlayerIndex.Two:
                hud.HudBgSpriteSheet = _content.Load <Texture2D>("Spritesheets/HUD/hud_two");
                hud.HudBgPosition    = new Vector2(1024, 0);
                hud.AvatarPosition   = new Vector2(940, 20);
                hud.HealthPosition   = new Vector2(925 - HEALTH_BAR_MAX_BOUNDS, 4);
                hud.PsiPosition      = new Vector2(925 - PSI_BAR_MAX_BOUNDS, 26);
                hud.ExpPosition      = new Vector2(925 - EXP_BAR_MAX_BOUNDS, 48);
                hud.LevelPosition    = new Vector2(940, 84);

                _p2 = hud;
                break;

            case PlayerIndex.Three:
                hud.HudBgSpriteSheet = _content.Load <Texture2D>("Spritesheets/HUD/hud_three");
                hud.HudBgPosition    = new Vector2(0, 656);
                hud.AvatarPosition   = new Vector2(20, 572);
                hud.HealthPosition   = new Vector2(109, 635);
                hud.PsiPosition      = new Vector2(109, 613);
                hud.ExpPosition      = new Vector2(109, 591);
                hud.LevelPosition    = new Vector2(20, 508);

                _p3 = hud;
                break;

            case PlayerIndex.Four:
                hud.HudBgSpriteSheet = _content.Load <Texture2D>("Spritesheets/HUD/hud_four");
                hud.HudBgPosition    = new Vector2(1024, 656);
                hud.AvatarPosition   = new Vector2(940, 572);
                hud.HealthPosition   = new Vector2(925 - HEALTH_BAR_MAX_BOUNDS, 635);
                hud.PsiPosition      = new Vector2(925 - PSI_BAR_MAX_BOUNDS, 613);
                hud.ExpPosition      = new Vector2(109, 591);
                hud.LevelPosition    = new Vector2(940, 508);

                _p4 = hud;
                break;

            default:
                throw new Exception("Invalid player index");
            }
        }
        public void CreateHUD(Player player)
        {
            uint      entityID;
            Texture2D spriteSheet;
            Position  position;
            Vector2   corner; //Which corner of the screen the Health/Psi status goes
            HUDSprite AButtonSprite,
                      BButtonSprite,
                      XButtonSprite,
                      YButtonSprite,
                      DPadSprite,
                      HeatlhPsiStatusSprite;
            HUD hud;

            #region buttons
            //Make A button
            entityID    = Entity.NextEntity();
            spriteSheet = game.Content.Load <Texture2D>("ControllerTGAs/xboxControllerButtonA-BW");
            position    = new Position()
            {
                EntityID = entityID,
                Center   = new Vector2(960, 440),
                Radius   = 40f,
            };
            game.PositionComponent[entityID] = position;
            AButtonSprite = new HUDSprite()
            {
                EntityID     = entityID,
                isSeen       = false,
                SpriteSheet  = spriteSheet,
                SpriteBounds = new Rectangle(0, 0, 80, 80),
                PlayerIndex  = player.PlayerIndex,
                isStatus     = false,
            };
            game.HUDSpriteComponent[entityID] = AButtonSprite;

            //Make B button
            entityID    = Entity.NextEntity();
            spriteSheet = game.Content.Load <Texture2D>("ControllerTGAs/xboxControllerButtonB-BW");
            position    = new Position()
            {
                EntityID = entityID,
                Center   = new Vector2(1040, 360),
                Radius   = 40f,
            };
            game.PositionComponent[entityID] = position;

            BButtonSprite = new HUDSprite()
            {
                EntityID     = entityID,
                isSeen       = false,
                SpriteSheet  = spriteSheet,
                SpriteBounds = new Rectangle(0, 0, 80, 80),
                PlayerIndex  = player.PlayerIndex,
                isStatus     = false,
            };
            game.HUDSpriteComponent[entityID] = BButtonSprite;

            //Make X Button
            entityID    = Entity.NextEntity();
            spriteSheet = game.Content.Load <Texture2D>("ControllerTGAs/xboxControllerButtonX-BW");

            position = new Position()
            {
                EntityID = entityID,
                Center   = new Vector2(880, 360),
                Radius   = 40f,
            };
            game.PositionComponent[entityID] = position;

            XButtonSprite = new HUDSprite()
            {
                EntityID     = entityID,
                isSeen       = false,
                SpriteSheet  = spriteSheet,
                SpriteBounds = new Rectangle(0, 0, 80, 80),
                PlayerIndex  = player.PlayerIndex,
                isStatus     = false,
            };
            game.HUDSpriteComponent[entityID] = XButtonSprite;

            //Make Y Button
            entityID    = Entity.NextEntity();
            spriteSheet = game.Content.Load <Texture2D>("ControllerTGAs/xboxControllerButtonY-BW");

            position = new Position()
            {
                EntityID = entityID,
                Center   = new Vector2(960, 280),
                Radius   = 40f,
            };
            game.PositionComponent[entityID] = position;

            YButtonSprite = new HUDSprite()
            {
                EntityID     = entityID,
                isSeen       = false,
                SpriteSheet  = spriteSheet,
                SpriteBounds = new Rectangle(0, 0, 80, 80),
                PlayerIndex  = player.PlayerIndex,
                isStatus     = false,
            };
            game.HUDSpriteComponent[entityID] = YButtonSprite;

            //Make Dpad
            entityID    = Entity.NextEntity();
            spriteSheet = game.Content.Load <Texture2D>("ControllerTGAs/xboxControllerDPad");

            position = new Position()
            {
                EntityID = entityID,
                Center   = new Vector2(320, 360),
                Radius   = 93f,
            };
            game.PositionComponent[entityID] = position;

            DPadSprite = new HUDSprite()
            {
                EntityID     = entityID,
                isSeen       = false,
                SpriteSheet  = spriteSheet,
                SpriteBounds = new Rectangle(0, 0, 186, 186),
                PlayerIndex  = player.PlayerIndex,
                isStatus     = false,
            };
            game.HUDSpriteComponent[entityID] = DPadSprite;
            #endregion
            //Use a Health/Psi or Health/Fatigue Status Bar depending on the player's race
            entityID = Entity.NextEntity();
            switch (player.PlayerRace)
            {
            case Aggregate.CultistPlayer:
            case Aggregate.GargranianPlayer:
                spriteSheet = game.Content.Load <Texture2D>("Spritesheets/HealthPsi");
                break;

            case Aggregate.EarthianPlayer:
            case Aggregate.CyborgPlayer:
            case Aggregate.SpacePiratePlayer:
            case Aggregate.ZombiePlayer:
                spriteSheet = game.Content.Load <Texture2D>("Spritesheets/HealthFatigue");
                break;
            }

            //Choose player corner
            switch (player.PlayerIndex)
            {
            case PlayerIndex.One:
                corner = new Vector2(0, 0);
                break;

            case PlayerIndex.Two:
                corner = new Vector2(1024, 0);
                break;

            case PlayerIndex.Three:
                corner = new Vector2(0, 656);
                break;

            case PlayerIndex.Four:
                corner = new Vector2(1024, 656);
                break;

            default:
                corner = new Vector2(0, 0);
                break;
            }
            position = new Position()
            {
                EntityID = entityID,
                Center   = corner,
                Radius   = 0f,//its a rectangle, so no radius for proper drawing
            };
            game.PositionComponent[entityID] = position;
            HeatlhPsiStatusSprite            = new HUDSprite()
            {
                EntityID     = entityID,
                isSeen       = true,
                SpriteSheet  = spriteSheet,
                SpriteBounds = new Rectangle(0, 0, 256, 64),
                PlayerIndex  = player.PlayerIndex,
                isStatus     = true,
            };
            game.HUDSpriteComponent[entityID] = HeatlhPsiStatusSprite;
            //Set hud
            hud = new HUD()
            {
                EntityID                = player.EntityID,
                AButtonSpriteID         = AButtonSprite.EntityID,
                BButtonSpriteID         = BButtonSprite.EntityID,
                XButtonSpriteID         = XButtonSprite.EntityID,
                YButtonSpriteID         = YButtonSprite.EntityID,
                DPadSpriteID            = DPadSprite.EntityID,
                HealthPsiStatusSpriteID = HeatlhPsiStatusSprite.EntityID,
            };
            game.HUDComponent[player.EntityID] = hud;
        }
Exemplo n.º 15
0
 private void setHUDSprite(PlayerIndex index, HUDSprite sprite)
 {
     switch(index)
     {
         case PlayerIndex.One:
             _p1 = sprite;
             break;
         case PlayerIndex.Two:
             _p2 = sprite;
             break;
         case PlayerIndex.Three:
             _p3 = sprite;
             break;
         case PlayerIndex.Four:
             _p4 = sprite;
             break;
     }
 }
Exemplo n.º 16
0
        //Handles drawing the individual HUDs.
        private void drawHud(HUDSprite hud, float elapsedTime, SpriteBatch spriteBatch)
        {
            //Background
            spriteBatch.Draw(hud.HudBgSpriteSheet,
                                    hud.HudBgPosition,
                                    hud.HudBgSpriteBounds,
                                    Color.White,
                                    0f,                                             // rotation
                                    new Vector2(0),  // origin
                                    1f,                                             // scale
                                    SpriteEffects.None,
                                    0.1f);

            //Avatar
            spriteBatch.Draw(hud.AvatarSpriteSheet,
                                    hud.AvatarPosition,
                                    hud.AvatarSpriteBounds,
                                    Color.White,
                                    0f,                                             // rotation
                                    new Vector2(0),  // origin
                                    1f,                                             // scale
                                    SpriteEffects.None,
                                    0);

            //Health bar
            spriteBatch.Draw(hud.HealthSpriteSheet,
                                    hud.HealthPosition,
                                    hud.HealthBounds,
                                    Color.White,
                                    0,                                             // rotation
                                    new Vector2(0),  // origin
                                    1f,                                             // scale
                                    SpriteEffects.None,
                                    0);

            //Psi bar
            spriteBatch.Draw(hud.PsiSpriteSheet,
                                    hud.PsiPosition,
                                    hud.PsiBounds,
                                    Color.White,
                                    0,                                             // rotation
                                    new Vector2(0),  // origin
                                    1f,                                             // scale
                                    SpriteEffects.None,
                                    0);

            //Exp bar
            spriteBatch.Draw(hud.ExpSpriteSheet,
                                    hud.ExpPosition,
                                    hud.ExpBounds,
                                    Color.White,
                                    0,                                             // rotation
                                    new Vector2(0),  // origin
                                    1f,                                             // scale
                                    SpriteEffects.None,
                                    0);

            //Skill icon

            //Item icon

            //Collection icon

            //Level
            spriteBatch.DrawString(_font, hud.Level, hud.LevelPosition, Color.Black);
        }
Exemplo n.º 17
0
        public void CreateHUD(Player player)
        {
            uint entityID;
            Texture2D spriteSheet;
            Position position;
            HUDSprite AButtonSprite,
                      BButtonSprite,
                      XButtonSprite,
                      YButtonSprite,
                      DPadSprite,
                      HeatlhStatusSprite,
                      ItemStatusSprite,
                      PsiStatusSprite,
                      SkillStatusSprite;
            HUD hud;
            #region buttons
            //Make A button
            entityID = Entity.NextEntity();
            spriteSheet = game.Content.Load<Texture2D>("ControllerTGAs/xboxControllerButtonA");
            position = new Position()
            {
                EntityID = entityID,
                Center = new Vector2(960,440),
                Radius = 40f,
            };
            game.PositionComponent[entityID] = position;
            AButtonSprite = new HUDSprite()
            {
                EntityID = entityID,
                isSeen = false,
                SpriteSheet = spriteSheet,
                SpriteBounds = new Rectangle(0, 0, 80, 80),
            };
            game.HUDSpriteComponent[entityID] = AButtonSprite;

            //Make B button
            entityID = Entity.NextEntity();
            spriteSheet = game.Content.Load<Texture2D>("ControllerTGAs/xboxControllerButtonB");
            position = new Position()
            {
                EntityID = entityID,
                Center = new Vector2(1040,360),
                Radius = 40f,
            };
            game.PositionComponent[entityID] = position;

            BButtonSprite = new HUDSprite()
            {
                EntityID = entityID,
                isSeen = false,
                SpriteSheet = spriteSheet,
                SpriteBounds = new Rectangle(0, 0, 80, 80),
            };
            game.HUDSpriteComponent[entityID] = BButtonSprite;

            //Make X Button
            entityID = Entity.NextEntity();
            spriteSheet = game.Content.Load<Texture2D>("ControllerTGAs/xboxControllerButtonX");

            position = new Position()
            {
                EntityID = entityID,
                Center = new Vector2(880,360),
                Radius = 40f,
            };
            game.PositionComponent[entityID] = position;

            XButtonSprite= new HUDSprite()
            {
                EntityID = entityID,
                isSeen = false,
                SpriteSheet = spriteSheet,
                SpriteBounds = new Rectangle(0, 0, 80, 80),
            };
            game.HUDSpriteComponent[entityID] = XButtonSprite;

            //Make Y Button
            entityID = Entity.NextEntity();
            spriteSheet = game.Content.Load<Texture2D>("ControllerTGAs/xboxControllerButtonY");

            position = new Position()
            {
                EntityID = entityID,
                Center = new Vector2(960,280),
                Radius = 40f,
            };
            game.PositionComponent[entityID] = position;

            YButtonSprite = new HUDSprite()
            {
                EntityID = entityID,
                isSeen = false,
                SpriteSheet = spriteSheet,
                SpriteBounds = new Rectangle(0, 0, 80, 80),
            };
            game.HUDSpriteComponent[entityID] = YButtonSprite;

            //Make Dpad
            entityID = Entity.NextEntity();
            spriteSheet = game.Content.Load<Texture2D>("ControllerTGAs/xboxControllerDPad");

            position = new Position()
            {
                EntityID = entityID,
                Center = new Vector2(320,360),
                Radius = 93f,
            };
            game.PositionComponent[entityID] = position;

            DPadSprite = new HUDSprite()
            {
                EntityID = entityID,
                isSeen = false,
                SpriteSheet = spriteSheet,
                SpriteBounds = new Rectangle(0, 0, 186, 186),
            };
            game.HUDSpriteComponent[entityID] = DPadSprite;
            #endregion

            #region status
            //Health
            entityID = Entity.NextEntity();
            spriteSheet = game.Content.Load<Texture2D>("Spritesheets/StatusBar");
            position = new Position()
            {
                EntityID = entityID,
                Center = new Vector2(45, 40),
                Radius = 40f, //dont care really...
            };
            game.PositionComponent[entityID] = position;
            HeatlhStatusSprite = new HUDSprite()
            {
                EntityID = entityID,
                isSeen = true,
                SpriteSheet = spriteSheet,
                SpriteBounds = new Rectangle(5, 95, 346, 66),
            };
            game.HUDSpriteComponent[entityID] = HeatlhStatusSprite;
            //Item
            entityID = Entity.NextEntity();
            spriteSheet = game.Content.Load<Texture2D>("Spritesheets/StatusBar");
            position = new Position()
            {
                EntityID = entityID,
                Center = new Vector2(45, 695),
                Radius = 40f, //dont care really...
            };
            game.PositionComponent[entityID] = position;
            ItemStatusSprite = new HUDSprite()
            {
                EntityID = entityID,
                isSeen = true,
                SpriteSheet = spriteSheet,
                SpriteBounds = new Rectangle(3, 10, 346, 66),
            };
            game.HUDSpriteComponent[entityID] = ItemStatusSprite;
            //Psi
            entityID = Entity.NextEntity();
            spriteSheet = game.Content.Load<Texture2D>("Spritesheets/StatusBar");
            position = new Position()
            {
                EntityID = entityID,
                Center = new Vector2(960, 40),
                Radius = 40f, //dont care really...
            };
            game.PositionComponent[entityID] = position;
            PsiStatusSprite = new HUDSprite()
            {
                EntityID = entityID,
                isSeen = true,
                SpriteSheet = spriteSheet,
                SpriteBounds = new Rectangle(3, 258, 346, 66),
            };
            game.HUDSpriteComponent[entityID] = PsiStatusSprite;
            //Skill
            entityID = Entity.NextEntity();
            spriteSheet = game.Content.Load<Texture2D>("Spritesheets/StatusBar");
            position = new Position()
            {
                EntityID = entityID,
                Center = new Vector2(960, 695),
                Radius = 40f, //dont care really...
            };
            game.PositionComponent[entityID] = position;
            SkillStatusSprite = new HUDSprite()
            {
                EntityID = entityID,
                isSeen = true,
                SpriteSheet = spriteSheet,
                SpriteBounds = new Rectangle(3, 180, 346, 66),
            };
            game.HUDSpriteComponent[entityID] = SkillStatusSprite;
            #endregion
            hud = new HUD()
            {
                EntityID = player.EntityID,
                AButtonSpriteID = AButtonSprite.EntityID,
                BButtonSpriteID = BButtonSprite.EntityID,
                XButtonSpriteID = XButtonSprite.EntityID,
                YButtonSpriteID = YButtonSprite.EntityID,
                DPadSpriteID = DPadSprite.EntityID,
                HealthStatusSpriteID = HeatlhStatusSprite.EntityID,
                ItemStatusSpriteID = ItemStatusSprite.EntityID,
                SkillStatusSpriteID = SkillStatusSprite.EntityID,
            };
            game.HUDComponent[player.EntityID] = hud;
        }