The gamepad controller uses the gamestate to determine which controllers to use
Inheritance: Controller
Example #1
0
 public CharacterController(ScreenManager screen, GamepadController pad, Vector2 startPos, int countDown)
     : base(screen)
 {
     stats    = pad.PlayerModel.SelectedCharacter;
     model    = new CharacterModel(pad, startPos, countDown, stats);
     moves    = new MoveController(Screen, stats, pad.PlayerIndex);
     this.pad = pad;
 }
Example #2
0
        public CursorModel(ContentManager content, World world, GamepadController pad, 
            SmashBros.Controllers.GamepadController.NavigationKey navigationMethod,
           OnCollisionEventHandler col, OnSeparationEventHandler sep,bool enabled = false)
        {
            Cursor = new Sprite(content, "Cursors/Player" + pad.PlayerIndex, 70, 70, 280 * pad.PlayerIndex + 100, 680);
            Cursor.BoundRect(world, 5, 5, BodyType.Dynamic);
            Cursor.StaticPosition = true;
            Cursor.Category = Category.Cat4;
            Cursor.CollidesWith = Category.Cat5;
            Cursor.Layer = 1002;
            Cursor.Mass = 1;
            Cursor.UserData = pad.PlayerIndex;
            Cursor.BoundBox.IgnoreGravity = true;
            Cursor.Origin = new Vector2(50, 20);

            this.Pad = pad;
            this.Navigation = navigationMethod;
            this.OnCollision = col;
            this.OnSeparation = sep;
            this.Enabled = enabled;
        }
Example #3
0
        protected override void LoadContent()
        {
            ContentManager content = Game.Content;

            //Loads the gameoptions from last time
            GameOptions = Serializing.LoadGameOptions();

            ControllerViewManager = new ControllerViewManager(Game.GraphicsDevice, content);
            //Adds the sound controller
            ControllerViewManager.AddController(soundController);

            //Loads and add the fonts to the a list so controllers easily can reach this just by the name of the string
            fonts.Add("Impact", content.Load<SpriteFont>("Fonts/Impact"));
            fonts.Add("Impact.large", content.Load<SpriteFont>("Fonts/Impact.large"));

            //Loads the player controllers from file
            List<Player> players = Serializing.LoadPlayerControllers();
            // Init each player by creating a gamepadcontroller foreach player
            foreach (Player player in players)
            {
                GamepadController gamepad = new GamepadController(this, player);
                gamePads.Add(gamepad);
                ControllerViewManager.AddController(gamepad);
            }

            //Creates the controller for the cursor
            cursorsController = new CursorController(this);
            ControllerViewManager.AddController(cursorsController);

            //Adds the popupmenu to the controllers stack
            popupMenuController = new OverlayMenuController(this);
            ControllerViewManager.AddController(popupMenuController);

            //if startgameplay is true then the game goes straight in to game play
            if (Constants.StartGameplay)
            {
                //Set the right state
                gameStateManager.CurrentState = GameState.GamePlay;
                var chars = Serializing.LoadCharacters();
                var maps = Serializing.LoadMaps();
                gamePads[0].PlayerModel.SelectedCharacter = chars[1];
                gamePads[0].PlayerModel.CharacterIndex = 0;
                gamePads[1].PlayerModel.SelectedCharacter = chars[2];
                gamePads[1].PlayerModel.CharacterIndex = 2;

                GamePlayController game = new GamePlayController(this, maps[1]);
                ControllerViewManager.AddController(game);
            }
            else
            {
                gameStateManager.CurrentState = GameState.StartScreen;
                this.menu = new MenuController(this);
                ControllerViewManager.AddController(menu);
            }
        }
Example #4
0
 public CharacterController(ScreenManager screen, GamepadController pad, Vector2 startPos, int countDown)
     : base(screen)
 {
     stats = pad.PlayerModel.SelectedCharacter;
     model = new CharacterModel(pad, startPos, countDown, stats);
     moves = new MoveController(Screen, stats, pad.PlayerIndex);
     this.pad = pad;
 }
Example #5
0
 public CharacterModel(GamepadController pad, Vector2 startPos, int countDown, CharacterStats stats)
 {
     position = startPos;
     playerIndex = pad.PlayerIndex;
     resetTimeLeft = countDown * 1000;
     maxSpeed = stats.maxSpeed;
     acceleration = stats.acceleration;
     weight = stats.weight;
     JumpStartVelocity = stats.jumpStartVelocity;
 }