Beispiel #1
0
        /// <summary>
        /// Title screen constructor.
        /// </summary>
        public LoadingScreen(GameMain parent)
        {
            _font = GameContent.LoadContent <SpriteFont>("fonts/DefaultFont");

            _parent = parent;
            _text   = "Loading";
        }
Beispiel #2
0
        /// <summary>
        /// Creates title card with default values.
        /// </summary>
        public TitleCard()
        {
            _showTime     = 0;
            _fadeTime     = 0;
            _currentTitle = String.Empty;

            _font = GameContent.LoadContent <SpriteFont>("fonts/TitleFont");
        }
        /// <summary>
        /// Title screen constructor.
        /// </summary>
        public HowToPlay(GameMain parent)
        {
            _logo = GameContent.LoadContent <Texture2D>("images/controls.png");

            _parent = parent;

            _input = new Input();
        }
Beispiel #4
0
        public Entity(string spriteSheetPath, Point?frameSize)
            : this()
        {
            SpriteSheet    = new SpriteSheet(GameContent.LoadContent <Texture2D>(spriteSheetPath), frameSize);
            _framesPerLine = SpriteSheet.Texture.Width / SpriteSheet.FrameSize.X;

            Speed = SpriteSheet.FrameSize.X;
        }
Beispiel #5
0
 public Particle(string texture, Vector2 position, Vector2 direction, List <ParticleState> states)
 {
     Texture       = GameContent.LoadContent <Texture2D>(texture);
     Position      = position;
     Direction     = direction;
     States        = states;
     _currentState = 0;
 }
Beispiel #6
0
 public Label(string text)
     : base(text)
 {
     Font       = GameContent.LoadContent <SpriteFont>("fonts/DefaultFont");
     Text       = text;
     Select     = null;
     Selectable = false;
 }
        /// <summary>
        /// Creates the Component List.
        /// </summary>
        public ComponentList()
        {
            _components     = new List <Component>();
            _input          = new Input();
            ComponentHeight = null;

            _timeout = 0;

            _arrow = GameContent.LoadContent <Texture2D>("images/arrow.png");
        }
Beispiel #8
0
        public Entity(string spriteSheetPath, int columns, int lines)
            : this()
        {
            var texture = GameContent.LoadContent <Texture2D>(spriteSheetPath);

            SpriteSheet    = new SpriteSheet(texture, new Point(texture.Width / columns, texture.Height / lines));
            _framesPerLine = columns;

            Speed = SpriteSheet.FrameSize.X;
        }
Beispiel #9
0
        public GameGUI()
        {
            _background = GameContent.LoadContent <Texture2D>("images/gui/background.png");
            _arrow      = GameContent.LoadContent <Texture2D>("images/gui/arrow.png");
            _font       = GameContent.LoadContent <SpriteFont>("fonts/DefaultFont");

            _ammoLight  = GameContent.LoadContent <Texture2D>("images/sprites/ammo-light.png");
            _ammoMedium = GameContent.LoadContent <Texture2D>("images/sprites/ammo-medium.png");
            _ammoHeavy  = GameContent.LoadContent <Texture2D>("images/sprites/ammo-heavy.png");
        }
Beispiel #10
0
        public GameGUI()
        {
            _shadow      = GameContent.LoadContent <Texture2D>("gui/gui_shadow.png");
            _magic       = GameContent.LoadContent <Texture2D>("gui/gui_background.png");
            _fullHealth  = GameContent.LoadContent <Texture2D>("gui/health_full.png");
            _emptyHealth = GameContent.LoadContent <Texture2D>("gui/health_empty.png");
            _partHealth  = GameContent.LoadContent <Texture2D>("gui/health_part.png");

            _font = GameContent.LoadContent <SpriteFont>("fonts/DefaultFont");
        }
Beispiel #11
0
        /// <summary>
        /// Creates the Component List.
        /// </summary>
        public ComponentList()
        {
            _components     = new List <Component>();
            _input          = MultipleInput.GetInstance();
            ComponentHeight = null;

            _timeout = 0;

            _arrow     = GameContent.LoadContent <Texture2D>("Images/arrow");
            _selectSfx = GameContent.LoadContent <SoundEffect>("Sfx/select");
        }
Beispiel #12
0
        public Level(string background, int width, int height, int playerCount, bool useKeyboard, GameState gameType)
        {
            int diff = useKeyboard ? 0 : 1;

            if (playerCount < 2)
            {
                playerCount = 2;
            }
            if (playerCount > 4)
            {
                playerCount = 4;
            }

            _entities = new List <Entity>();
            _toRemove = new Stack <Entity>();
            _toAdd    = new Stack <Entity>();

            _bounds       = new Rectangle(0, 0, width, height);
            _background   = GameContent.LoadContent <Texture2D>(background);
            _font         = GameContent.LoadContent <SpriteFont>("Fonts/SmallFont");
            _winFont      = GameContent.LoadContent <SpriteFont>("Fonts/BigFont");
            _textOrigin   = Vector2.Zero;
            _screenCenter = new Vector2(width / 2.0f, height / 2.0f);

            _fireballSfx = GameContent.LoadContent <SoundEffect>("SFX/Fireball");

            _gameEnded   = false;
            _winnerColor = Color.Black;
            _winnerText  = String.Empty;


            if (gameType == GameState.PlayingLocal)
            {
                _connDelayTime = 0;

                for (int i = 0; i < playerCount; i++)
                {
                    _entities.Add(new Player(this, positions[i], colors[i], inputs[i + diff], names[i]));
                }
            }
            else if (gameType == GameState.PlayingHost || gameType == GameState.PlayingClient)
            {
                _connDelayTime = 5000;

                int               mod             = (gameType == GameState.PlayingHost) ? 0 : 1;
                Player            local           = new Player(this, positions[mod], colors[mod], inputs[diff], GameMain.CurrentSession.LocalGamers[0].Gamertag);
                NetPlayerBehavior localController = new NetPlayerBehavior(local);
                local.Behaviors.Add(localController);
                GameMain.Connection.CreatePlayer(local);
                NetController = localController;

                _entities.Add(local);
            }
        }
Beispiel #13
0
        public Level(Game game) : base(game)
        {
            _game = game as GameMain;
            _gui  = new GameGUI();

            _background = GameContent.LoadContent <Texture2D>("images/backgrounds/background.png");
            _clouds     = GameContent.LoadContent <Texture2D>("images/backgrounds/clouds.png");

            _cloudPosition = Vector2.Zero;
            _cloudSize     = new Vector2(_clouds.Width, _clouds.Height);
            _cloudOffset   = Vector2.UnitX * _cloudSize.X;
        }
Beispiel #14
0
        /// <summary>
        /// Title screen constructor.
        /// </summary>
        public GameOverScreen(GameMain parent)
        {
            _goimage = GameContent.LoadContent <Texture2D>("images/gameover.png");

            _font = GameContent.LoadContent <SpriteFont>("fonts/DefaultFont");

            _window = Rectangle.Empty;

            _parent = parent;

            _input = new Input();
        }
        public SaveDataButton(string name, Base.GameState state, SelectDelegate select)
            : base(name)
        {
            _shadow      = GameContent.LoadContent <Texture2D>("gui/gui_shadow.png");
            _magic       = GameContent.LoadContent <Texture2D>("gui/gui_background.png");
            _fullHealth  = GameContent.LoadContent <Texture2D>("gui/health_full.png");
            _emptyHealth = GameContent.LoadContent <Texture2D>("gui/health_empty.png");
            _partHealth  = GameContent.LoadContent <Texture2D>("gui/health_part.png");

            Font    = GameContent.LoadContent <SpriteFont>("fonts/DefaultFont");
            Data    = state;
            Select += select;
        }
Beispiel #16
0
        public Player(Level level, Vector2 position, Color color, GenericInput inputMethod, string name)
        {
            Sprite        = new Sprite("Sprites/mage", new Point(64, 64), 100);
            Sprite.Origin = new Vector2(32, 32);
            Position      = position + Origin;
            Name          = name;

            Health = 5;

            _font       = GameContent.LoadContent <SpriteFont>("Fonts/SmallFont");
            _nameSize   = (Name != null) ? _font.MeasureString(Name) / 2 : Vector2.Zero;
            _healthSize = _font.MeasureString(Health.ToString()) / 2;
            _textDiff   = Vector2.UnitY * (Size.Y / 2);

            Color = color;

            Sprite.Animations.Add(new Animation("walking_down", 2, 0, 8));
            Sprite.Animations.Add(new Animation("walking_up", 0, 0, 8));
            Sprite.Animations.Add(new Animation("walking_right", 3, 0, 8));
            Sprite.Animations.Add(new Animation("walking_left", 1, 0, 8));

            Sprite.Animations.Add(new Animation("fireball_down", 6, 0, 6));
            Sprite.Animations.Add(new Animation("fireball_up", 4, 0, 6));
            Sprite.Animations.Add(new Animation("fireball_right", 7, 0, 6));
            Sprite.Animations.Add(new Animation("fireball_left", 5, 0, 6));

            Sprite.Animations.Add(new Animation("dying", 8, 0, 5));
            Sprite.Animations.Add(new Animation("dead", 8, 5, 5));

            _currentDirection = Direction.Down;
            _level            = level;

            Dead = false;

            //Player didn't set movement speed
            if (MovementSpeed < 0.0001f)
            {
                MovementSpeed = 0.2f;
            }

            _deathSfx = GameContent.LoadContent <SoundEffect>("SFX/Death");
            _hitSfx   = GameContent.LoadContent <SoundEffect>("SFX/Explosion");

            Behaviors.Add(new ControllableBehavior(this, inputMethod));

            Sprite.ChangeAnimation(0);
        }
Beispiel #17
0
        /// <summary>
        /// Title screen constructor.
        /// </summary>
        public IntroScreen(GameMain parent)
        {
            _font = GameContent.LoadContent <SpriteFont>("fonts/DefaultFont");

            _parent = parent;

            _input = new Input();

            _credits = new List <string>();
            _credits.Add("A long time ago, an distant kingdom lived in peace");
            _credits.Add("thanks to a magic crown. The peace was kept until ");
            _credits.Add("one day, when a Evil Wizard stole the crown.");
            _credits.Add("The Prince couldn't let the worst happen,");
            _credits.Add("and saved the day, killing the villain.");
            _credits.Add("");
            _credits.Add("Two hundred years have passed since then.");
            _credits.Add("A group of cultists stole the crown and");
            _credits.Add("captured the king, so they could");
            _credits.Add("get enough power to ressurrect the wizard.");
            _credits.Add("");
            _credits.Add("Now, all of the kingdom's hopes rest on");
            _credits.Add("the shoulders of the king's bodyguard.");
            _credits.Add("He needs to get the sacred weapons to");
            _credits.Add("destroy the evil cult, saving the king,");
            _credits.Add("the kingdom and the crown.");
            _credits.Add("");
            _credits.Add("But first... he would need a sword.");

            _titleList = new ComponentList();
            _titleList.AddComponent(new Label("Diogo Muller & João Vitor present..."));
            _titleList.Position = new Rectangle(20, 20, parent.Window.ClientBounds.Width - 40, parent.Window.ClientBounds.Height - 40);

            _list = new ScrollingList();

            _list.ComponentHeight = 50;

            foreach (string st in _credits)
            {
                _list.AddComponent(new Label(st));
            }

            _list.Position = new Rectangle(20, 20, parent.Window.ClientBounds.Width - 40, parent.Window.ClientBounds.Height - 40);
            _list.ResetPosition();

            _showningTime = ShowTime;
            _fadingTime   = FadeTime;
        }
Beispiel #18
0
        /// <summary>
        /// Loads all game content.
        /// </summary>
        protected override void LoadContent()
        {
            _spriteBatch = new SpriteBatch(GraphicsDevice);
            GameContent.LoadContent(Content);

            _paddle = new Paddle();
            _ball   = new Ball();

            _gameOverText      = new Text(new Vector2(2000, 2000), "GAME OVER");
            _gameOverText.Font = GameContent.GameFont48;

            _scoreText = new Text(new Vector2(119, 24), _score.ToString());

            _gameEntities.Add(_paddle);
            _gameEntities.Add(_ball);

            for (int i = 0; i < BRICK_COLUMNS; i++)
            {
                for (int j = 0; j < BRICK_ROWS; j++)
                {
                    IGameEntity newBrick = new Brick();
                    newBrick.Location = new Vector2(15 + ((GameContent.RedBrickTexture.Width + 10) * i),
                                                    86 + (GameContent.RedBrickTexture.Height + 10) * j);
                    _gameEntities.Add(newBrick);
                }
            }

            _ball.PopulateCollidables(_gameEntities);

            for (int i = 0; i < _lives; i++)
            {
                IGameEntity newHeart = new Heart();
                newHeart.Location = new Vector2(995 + ((GameContent.HeartTexture.Width + 5) * i), 24);
                _gameEntities.Add(newHeart);
            }

            this.SetIDs();

            foreach (IGameEntity g in _gameEntities)
            {
                if (g is Brick)
                {
                    (g as Brick).SetTexture();
                }
            }
        }
Beispiel #19
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            _spriteBatch = new SpriteBatch(GraphicsDevice);
            GameContent.Initialize(Content);

            _title = new TitleScreen("Images/arena", Width, Height);

            _hostingScreen   = new MessageScreen("Images/arena", Width, Height, "Searching for Players...");
            _searchingScreen = new MessageScreen("Images/arena", Width, Height, "Searching for Games...");

            //Reset();

            _titleSong = GameContent.LoadContent <Song>("Music/Title");
            _gameSong  = GameContent.LoadContent <Song>("Music/Arena");

            MediaPlayer.Play(_titleSong);
            MediaPlayer.IsRepeating = true;
        }
        /// <summary>
        /// Title screen constructor.
        /// </summary>
        public TitleScreen(GameMain parent)
        {
            _logo = GameContent.LoadContent <Texture2D>("images/title.png");

            _list = new ComponentList();

            _list.ComponentHeight = 50;

            _list.AddComponent(new Button("New Game", () => _parent.ChangeState(GameState.NewGame)));
            _list.AddComponent(new Button("Load Game", () => _parent.ChangeState(GameState.LoadGame)));
            _list.AddComponent(new Button("Demo Mode", () => _parent.ChangeState(GameState.DemoMode)));
            _list.AddComponent(new Button("Options", () => _parent.ChangeState(GameState.Options)));
            _list.AddComponent(new Button("How to Play", () => _parent.ChangeState(GameState.HowToPlay)));
            _list.AddComponent(new Button("Credits", () => _parent.ChangeState(GameState.Credits)));
            _list.AddComponent(new Button("Quit Game", () => _parent.ChangeState(GameState.Quiting)));

            _window = Rectangle.Empty;

            _parent = parent;
        }
Beispiel #21
0
        /// <summary>
        /// Creates a tileset with the parameters.
        /// </summary>
        /// <param name="firstgid">First GID</param>
        /// <param name="name">Tileset name</param>
        /// <param name="tileSize">Tile size</param>
        /// <param name="imageSource">Image source path</param>
        /// <param name="imageSize">Image size in pixels</param>
        public Tileset(int firstgid, string name, Point tileSize, string imageSource, Point imageSize)
        {
            FirstGID = firstgid;
            Name     = name;
            TileSize = tileSize;
            Source   = imageSource;
            Size     = imageSize;

            Texture = GameContent.LoadContent <Texture2D>(Source);

            NumRows = Size.Y / TileSize.Y;
            NumCols = Size.X / TileSize.X;

            Tiles = new Tile[NumRows * NumCols];

            for (int i = 0; i < NumRows * NumCols; i++)
            {
                Tiles[i] = new Tile(i, this);
            }
        }
Beispiel #22
0
        /// <summary>
        /// Creates sprite by file, frameSize and Milisecons per frame.
        /// </summary>
        /// <param name="texturePath"></param>
        /// <param name="frameSize"></param>
        /// <param name="msPerFrame"></param>
        public Sprite(string texturePath, Point frameSize, float msPerFrame)
        {
            _texture = GameContent.LoadContent <Texture2D>(texturePath);
            if (frameSize == default(Point))
            {
                FrameSize = new Point(_texture.Width, _texture.Height);
            }
            else
            {
                FrameSize = frameSize;
            }
            MilisecondsPerFrame = msPerFrame;
            Animations          = new List <Animation>();

            _center           = new Vector2((float)FrameSize.X / 2f, (float)FrameSize.Y / 2f);
            _currentFrameTime = 0;

            _currentAnimation = -1;
            _currentFrame     = null;
            _sourceRect       = Rectangle.Empty;
        }
        public SelectionBox(string label)
            : base(label)
        {
            Font              = GameContent.LoadContent <SpriteFont>("fonts/DefaultFont");
            Label             = label;
            SelectionChanged += new SelectionChangeDelegate((value) =>
            {
                if (value < -0.8)
                {
                    SelectPrevious();
                }
                else if (value > 0.8)
                {
                    SelectNext();
                }
            });

            _options = new List <string>();
            _current = -1;

            _arrow = GameContent.LoadContent <Texture2D>("images/arrow.png");
        }
        public MessageScreen(string background, int width, int height, string message)
        {
            #region Title Screen Assets initialization

            _bounds     = new Rectangle(0, 0, width, height);
            _background = GameContent.LoadContent <Texture2D>(background);
            _logo       = GameContent.LoadContent <Texture2D>("Images/Logo");
            _font       = GameContent.LoadContent <SpriteFont>("Fonts/SmallFont");

            Vector2 bg_center     = new Vector2(_logo.Width / 2.0f, _logo.Height / 2.0f);
            Vector2 screen_center = new Vector2(width / 2.0f, height / 2.0f);
            _titlePosition = new Rectangle((int)(screen_center.X - bg_center.X),
                                           (int)(screen_center.Y * 0.5 - bg_center.Y),
                                           (int)(_logo.Width),
                                           (int)(_logo.Height));

            _message = message;
            Vector2 startSize = _font.MeasureString(_message);
            _messageOrigin   = new Vector2(startSize.X / 2, startSize.Y / 2);
            _messagePosition = new Vector2(screen_center.X, screen_center.Y * 1.7f);

            #endregion Message Screen Assets initialization
        }
        /// <summary>
        /// Title screen constructor.
        /// </summary>
        public CreditsScreen(GameMain parent)
        {
            _logo = GameContent.LoadContent <Texture2D>("images/title.png");

            _font = GameContent.LoadContent <SpriteFont>("fonts/DefaultFont");

            _window = Rectangle.Empty;

            _parent = parent;

            _input = new Input();

            _credits = new List <string>();
            _credits.Add("Students:");
            _credits.Add("    Diogo Muller de Miranda");
            _credits.Add("    João Vitor Pietsiaki Moraes");
            _credits.Add("");
            _credits.Add("Tecnicas de Implementacao de Jogos");
            _credits.Add("Teacher: Fabio Binder");
            _credits.Add("");
            _credits.Add("PROGRAMMING:");
            _credits.Add("      João Vitor Pietsiaki Moraes");
            _credits.Add("      Diogo Muller de Miranda");
            _credits.Add("");
            _credits.Add("ART:");
            _credits.Add("      Tilesets by David Gervais, licensed under Creative Commons 3.0");
            _credits.Add("      Website: http://pousse.rapiere.free.fr/tome/");
            _credits.Add("");
            _credits.Add("      Zombie and Skelleton - Reemax and artisticdude - http://opengameart.org/");
            _credits.Add("");
            _credits.Add("      Baldric (Main Character) and Mage - By Stephen 'Redshrike' Challener, ");
            _credits.Add("      design by Zi Ye - www.OpenGameArt.org");
            _credits.Add("");
            _credits.Add("      Slime and Slimeworm based on Slime by Xenoyia");
            _credits.Add("      http://gmc.yoyogames.com/index.php?showtopic=330208");
            _credits.Add("      Edited by Diogo Muller de Miranda.");
            _credits.Add("");
            _credits.Add("      Crab - Free for personal use");
            _credits.Add("      Found on: http://www.rpgmakervx.net/lofiversion/index.php/t28829.html");
            _credits.Add("");
            _credits.Add("      Bat by Diogo Muller de Miranda.");
            _credits.Add("");
            _credits.Add("      Goon (Male Orc)");
            _credits.Add("      http://opengameart.org/");
            _credits.Add("      Done by Matthew Krohn.");
            _credits.Add("      Walkcycle, Hurt, Slash, and Spellcast animations by Stephen Challener (AKA Redshrike), ");
            _credits.Add("      Shooting and Thrusting animations by Johannes Sjölund, Male and female orc heads by ");
            _credits.Add("      MadMarcel and based on Stephen Challener's Sinbad.");
            _credits.Add("      Master Goon edit based on this characted, made by Diogo Muller de Miranda.");
            _credits.Add("");
            _credits.Add("      Oldman:");
            _credits.Add("      Done by Tap, from OpenGameArt.Org");
            _credits.Add("");
            _credits.Add("      Water Dragon by Tana: ");
            _credits.Add("      http://www.rpgmakervx.net/index.php?showtopic=23956");
            _credits.Add("");
            _credits.Add("      Fire Dragon in Grayman Sprites:");
            _credits.Add("      http://kootation.com/grayman-sprites-rpg-maker-vx-community.html");
            _credits.Add("");
            _credits.Add("MUSIC:");
            _credits.Add("      All music by Kevin MacLeod");
            _credits.Add("      http://incompetech.com/");
            _credits.Add("");
            _credits.Add("      Brittle Rille");
            _credits.Add("      Call to Adventure");
            _credits.Add("      Easy Lemon");
            _credits.Add("      Five Armies");
            _credits.Add("      Heroic Age");
            _credits.Add("      Moonlight Hall");
            _credits.Add("      Rising Game");
            _credits.Add("      Suvaco do Cristo");
            _credits.Add("      Tenebrous Brothers Carnival - Act One");
            _credits.Add("      Tenebrous Brothers Carnival - Act Two");
            _credits.Add("      Brittle Rille");
            _credits.Add("");
            _credits.Add("SOUND EFFECTS:");
            _credits.Add("      Sword and Bow by Qat from http://www.freesound.org");
            _credits.Add("      All other sounds by Diogo Muller de Miranda.");
            _credits.Add("");
            _credits.Add("LEVEL DESIGN:");
            _credits.Add("      Diogo Muller de Miranda");
            _credits.Add("");
            _credits.Add("WEAPON DESIGN:");
            _credits.Add("      Diogo Muller de Miranda");
            _credits.Add("      João Vitor Pietsiaki Moraes");
            _credits.Add("");
            _credits.Add("ENEMY AND CHARACTER AI:");
            _credits.Add("      João Vitor Pietsiaki Moraes");
            _credits.Add("");
            _credits.Add("SPECIAL THANKS:");
            _credits.Add("      Enzo Augusto Marchiorato");
            _credits.Add("      Orlando Stein Junior");
            _credits.Add("      Luis Fernando Sobrejero Rigoni");
            _credits.Add("      Melanie Young Yee");
            _credits.Add("");
            _credits.Add("Made using MonoGame.");
            _credits.Add("http://www.monogame.net/");

            _list = new ScrollingList();

            _list.ComponentHeight = 50;

            foreach (string st in _credits)
            {
                _list.AddComponent(new Label(st));
            }
        }
        public TitleScreen(string background, int width, int height)
        {
            #region Title Screen Assets initialization

            _bounds     = new Rectangle(0, 0, width, height);
            _background = GameContent.LoadContent <Texture2D>(background);
            _logo       = GameContent.LoadContent <Texture2D>("Images/Logo");
            _font       = GameContent.LoadContent <SpriteFont>("Fonts/SmallFont");

            Vector2 bg_center     = new Vector2(_logo.Width / 2.0f, _logo.Height / 2.0f);
            Vector2 screen_center = new Vector2(width / 2.0f, height / 2.0f);
            _titlePosition = new Rectangle((int)(screen_center.X - bg_center.X),
                                           (int)(screen_center.Y * 0.5 - bg_center.Y),
                                           (int)(_logo.Width),
                                           (int)(_logo.Height));

            _startMessage = "Press START or ENTER to start the game";
            Vector2 startSize = _font.MeasureString(_startMessage);
            _startOrigin   = new Vector2(startSize.X / 2, startSize.Y / 2);
            _startPosition = new Vector2(screen_center.X, screen_center.Y * 1.7f);

            _transparency     = 0.9f;
            _transparencyDiff = 0.001f;

            #endregion Title Screen Assets initialization

            #region Options Initialization

            _options = new ComponentList();

            SelectionBox controller = new SelectionBox("Use Keyboard?");
            controller.AddOption("Yes");
            controller.AddOption("No");
            controller.SelectOption(GameMain.UseKeyboard ? "Yes" : "No");
            _options.AddComponent(controller);

            SelectionBox players = new SelectionBox("Players");
            players.AddOption("2");
            players.AddOption("3");
            players.AddOption("4");

            /*players.AddOption("5");
            *  players.AddOption("6");
            *  players.AddOption("7");
            *  players.AddOption("8");*/
            players.SelectOption(GameMain.PlayerCount.ToString());
            _options.AddComponent(players);

            _options.ValueChanged += () =>
            {
                string useKeyboard  = _options.GetValue("Use Keyboard?");
                string playersCount = _options.GetValue("Players");

                GameMain.UseKeyboard = (useKeyboard == "Yes");
                GameMain.PlayerCount = int.Parse(playersCount.Replace('*', '\0'));

                if (GameMain.PlayerCount > 2)
                {
                    _options.GetComponent <Button>("Search For Game").Visible = false;
                    _options.GetComponent <Button>("Host Game").Visible       = false;
                }
                else
                {
                    _options.GetComponent <Button>("Search For Game").Visible = true;
                    _options.GetComponent <Button>("Host Game").Visible       = true;
                }
            };

            _options.AddComponent(new Button("Play Local", () =>
            {
                _showOptions = false;
                GameMain.ChangeState(GameState.PlayingLocal);
            }));

            _options.AddComponent(new Button("Search For Game", () =>
            {
                // TODO: Add network logic.
                _showOptions = false;
                GameMain.ChangeState(GameState.SearchingGame);
            }));

            _options.AddComponent(new Button("Host Game", () =>
            {
                if (GameMain.CurrentState != GameState.TitleScreen)
                {
                    return;
                }

                // TODO: Add network logic.
                _showOptions = false;
                GameMain.ChangeState(GameState.CreatingHost);
            }));

            _options.Position = new Rectangle(30, 200, width - 60, height - 220);
            _showOptions      = false;
            #endregion Options Initialization

            _firstKeyUp = false;
        }
Beispiel #27
0
 public PlayerGUI(Player player)
 {
     Player = player;
     _font  = GameContent.LoadContent <SpriteFont>("fonts/DefaultFont");
 }
Beispiel #28
0
 public Button(string text, SelectDelegate select) : base(text)
 {
     Font    = GameContent.LoadContent <SpriteFont>("fonts/SmallFont");
     Text    = text;
     Select += select;
 }
Beispiel #29
0
 /// <summary>
 /// Creates component and initializes the texture with a default value.
 /// </summary>
 public Component(string name)
 {
     SelectedTexture = GameContent.LoadContent <Texture2D>("images/menuselected");
     Name            = name;
     Visible         = true;
 }