Example #1
0
        public State(TopDownShooter game, GraphicsDevice graphicDevice, ContentManager content)
        {
            this.game = game;

            this.content = content;

            this.graphicDevice = graphicDevice;
        }
Example #2
0
        public MenuState(TopDownShooter game, GraphicsDevice graphicDevice, ContentManager content) : base(game, graphicDevice, content)
        {
            // create new buttons and load icons from resource then add to list to display on screen
            game.IsMouseVisible = true;

            var buttonTexture = content.Load <Texture2D>("button");
            var buttonFont    = content.Load <SpriteFont>("Font");

            var pos = new Vector2(550, graphicDevice.Viewport.Height / 2);

            var newGameButton = new Button(buttonTexture, buttonFont)
            {
                Position = pos,
                Text     = "New Game"
            };

            newGameButton.Click += NewGameButton_Click;

            var loadGameButton = new Button(buttonTexture, buttonFont)
            {
                Position = pos + new Vector2(0, 70),
                Text     = "Shop"
            };

            loadGameButton.Click += LoadGameButton_Click;

            var quitGameButton = new Button(buttonTexture, buttonFont)
            {
                Position = pos + new Vector2(0, 140),
                Text     = "Quit"
            };

            //create list of component of type buttons
            quitGameButton.Click += QuitGameButton_Click;

            SoundManager.LoopSound(content.Load <Song>("Music/background_music"));

            components = new List <Component>()
            {
                newGameButton,
                loadGameButton,
                quitGameButton
            };
        }
Example #3
0
        public GameState(TopDownShooter game, GraphicsDevice graphicDevice, ContentManager content, Fighter fighter) : base(game, graphicDevice, content)
        {
            game.IsMouseVisible = false;

            player = new Player(content, GAME_WIDTH, GAME_HEIGHT, fighter, 8f, new Vector2(0.45f, 0.45f));

            gameManager = new GameManager(content, player, GAME_WIDTH, GAME_HEIGHT, new Room(content, game, graphicDevice));

            player.shootSignal += gameManager.ShootZombies;
            player.punchSignal += gameManager.PunchZombies;

            font = content.Load <SpriteFont>("Font");

            resetBtn = new Button(content.Load <Texture2D>("button"), font, 100, 200)
            {
                Position = new Vector2(GAME_WIDTH / 2 - 100, GAME_HEIGHT / 2),
                Text     = "Reset"
            };
            resetBtn.Click += (sender, e) => Reset_Game(sender, e);
        }
        public ShopState(TopDownShooter game, GraphicsDevice graphicDevice, ContentManager content) : base(game, graphicDevice, content)
        {
            points = Data.GetScore();

            font = content.Load <SpriteFont>("Font");

            items = new Dictionary <string, int>();
            items.Add("Gun", 50);
            items.Add("Rifle", 150);
            items.Add("Shotgun", 200);

            shop = new List <Button>();
            var    buttonTexture = content.Load <Texture2D>("button");
            Button btn;

            int i = 0;

            foreach (var item in items.Keys)
            {
                btn = new Button(buttonTexture, font, 100, 200)
                {
                    Position = new Vector2(50 + (i) * 220, 450),
                    Text     = items[item].ToString()
                };


                btn.Click += (sender, e) => Buy_Item(sender, e, item);
                shop.Add(btn);
                i++;
            }

            btn = new Button(buttonTexture, font, 100, 200)
            {
                Position = new Vector2(100, 100),
                Text     = "Back"
            };

            btn.Click += (sender, e) => Return(sender, e);
            shop.Add(btn);
        }
 static void Main()
 {
     using (var game = new TopDownShooter())
         game.Run();
 }
Example #6
0
        public LevelMenu(TopDownShooter game, GraphicsDevice graphicDevice, ContentManager content) : base(game, graphicDevice, content)
        {
            fighters = Data.ReadObject("fighters.json");
            fighter  = fighters[0];

            string[] maps = new string[] { "wood", "desert", "grass" }; // resources names

            // create new list then add components of type button
            components = new List <Component>();

            var buttonFont = content.Load <SpriteFont>("Font");

            for (int i = 0; i < maps.Length; i++)
            {
                var text = maps[i];
                if (i != 0)
                {
                    text += "_locked"; // lock the closed levels
                }
                var bt = content.Load <Texture2D>(text);

                var button = new Button(bt, buttonFont, 250, 400)
                {
                    Position = new Vector2(20 + (i) * 420, 250)      // set the button to take on third of the screen width
                };

                if (i == 0)
                {
                    button.Click += (sender, e) => Button_Click(sender, e); // costumize the click event to the button text to load different level
                }
                components.Add(button);
            }

            var buttonTexture = content.Load <Texture2D>("button");

            for (int i = 0; i < fighters.Count; i++)
            {
                if (fighters[i].canUse)
                {
                    var txt = fighters[i].weapontype;
                    var btn = new Button(buttonTexture, content.Load <SpriteFont>("Font"), 50, 100)
                    {
                        Position = new Vector2(50 + (i) * 220, 600),
                        Text     = txt
                    };

                    btn.Click += (sender, e) => Select_Weapon(sender, e, txt);

                    components.Add(btn);
                }
            }

            Button backBtn = new Button(buttonTexture, buttonFont)
            {
                Position = new Vector2(100, 100),
                Text     = "Back"
            };

            backBtn.Click += (sender, e) => Return(sender, e);
            components.Add(backBtn);
        }