Exemple #1
0
 public Boolean Equals(MenuState b)
 {
     if (this.getName().Equals(b.getName()))
     {
         return true;
     }
     return false;
 }
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            controllerInput = new GamePadState[GameConfig.MAX_PLAYERS];
            prevInput = new GamePadState[GameConfig.MAX_PLAYERS];
            players = new Entity[GameConfig.MAX_PLAYERS];
            time = new float[GameConfig.MAX_PLAYERS];
            pressShoot = new bool[GameConfig.MAX_PLAYERS];

            // TODO: Add your initialization logic here
            players[0] = new KTYD.Model.Character(500, 100, 0, EntityType.PLAYER, GameConfig.IMG_BASE_BLUE, Weapon.createPistol());
            players[1] = new KTYD.Model.Character(600,200,0, EntityType.PLAYER, GameConfig.IMG_BASE_RED, Weapon.createPistol());
            //players[2] = new Entity(700,200,0, EntityType.PLAYER, GameConfig.IMG_BASE_ORANGE, KTYD.Model.BulletType.PISTOL);
            //players[3] = new Entity(800,400,0, EntityType.PLAYER, GameConfig.IMG_BASE_GREEN, KTYD.Model.BulletType.PISTOL);

            item1 = new KTYD.Model.Item(100, 100, Model.ItemType.M16_WEAPON);

            item2 = new KTYD.Model.Item(100, 100, Model.ItemType.FLAME_WEAPON);

            /* Load VIEW */
            gameView = new View.View();
            gameView.setCameraDimension(GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height);

            GameConfig.SCREEN_RES_X = GraphicsDevice.Viewport.Width;
            GameConfig.SCREEN_RES_Y = GraphicsDevice.Viewport.Height;
            gameView.loadViewPort(GraphicsDevice.Viewport);

            gamePlayers = new Controller.Players();

            gameMap = new Model.Map(gamePlayers);
            gameMap.setDimension(GameConfig.LEVEL_WIDTH,GameConfig.LEVEL_HEIGHT);

            /* Load all players into map and player controller */
            for (int i = 0; i < GameConfig.MAX_PLAYERS; ++i)
            {
                gameMap.loadEntity(players[i]);

            }

            // Initialize time
            for (int i = 0; i < GameConfig.MAX_PLAYERS; ++i)
            {
                time[i] = 0;
                pressShoot[i] = false;
            }

            //gameMap.loadEntity(e1); // Load first enemy
            gameMap.loadEntity(item1);  // Load first item
            gameMap.loadEntity(item2);

            // Register observers to objects
            gameMap.register(gameView);
            gameMap.register(gamePlayers);

            // Load the map to the View
            gameView.loadMap(gameMap);

            if(currentGameState ==gameState.PLAYMODE)
            {

                 myMenuState = new GameState.Playmode(currentGameState, gameMap, false, input, pressShoot, storeTime, time, gamePlayers,c, gameView);

            }
            base.Initialize();
        }