/// <summary>
 /// This is not the recommended ctor
 /// </summary>
 /// <param name="engine"></param>
 /// <param name="nextState"></param>
 public EngineStateStorySegment(Engine engine, EngineStateInterface nextState)
 {
     engine_ = engine;
     nextState_ = nextState;
     framesSpentInStory_ = 0;
     DurationOfStory_ = 1;
     storyText_ = "You hear the cold, metallic clanks of robot feet pacing\n the room ahead, but you must keep moving forward.";
     isUsingImage_ = false;
 }
 /// <summary>
 /// This is not the recommended ctor, either
 /// </summary>
 /// <param name="engine"></param>
 /// <param name="nextState"></param>
 /// <param name="durationOfStorySegment"></param>
 public EngineStateStorySegment(Engine engine, EngineStateInterface nextState, int durationOfStorySegment)
 {
     engine_ = engine;
     nextState_ = nextState;
     framesSpentInStory_ = 0;
     DurationOfStory_ = durationOfStorySegment;
     storyText_ = "You have many questions. The next room could provide the answers you seek.";
     isUsingImage_ = false;
 }
        public EngineStateEditorControls(Engine engine, EngineStateInterface returnState)
        {
            InputSet inputs = InputSet.getInstance();

            controlTitle_ = "CONTROLS";
            engine_ = engine;
            returnState_ = returnState;
            List<string> selectedControlsString = new List<string>();
            selectedControlsString.Add("WITH OBJECT SELECTED");
            selectedControlsString.Add("Deslect: " + inputs.getControlName(InputsEnum.RIGHT_TRIGGER));
            selectedControlsString.Add("Place: " + inputs.getControlName(InputsEnum.LEFT_TRIGGER));
            selectedControlsString.Add("Rotate L: " + inputs.getControlName(InputsEnum.LEFT_BUMPER));
            selectedControlsString.Add("Rotate R: " + inputs.getControlName(InputsEnum.RIGHT_BUMPER));
            selectedControlsString.Add("Delete: " + inputs.getControlName(InputsEnum.BUTTON_3));

            List<string> unselectedControlsString = new List<string>();
            unselectedControlsString.Add("NORMAL EDITOR CONTROLS");
            #if XBOX
            selectedControlsString.Add("(Coming Soon)");
            #endif
            unselectedControlsString.Add("Move Camera/Cursor: " + inputs.getControlName(InputsEnum.LEFT_DIRECTIONAL));
            unselectedControlsString.Add("Select Object/Tile: " + inputs.getControlName(InputsEnum.LEFT_TRIGGER));
            unselectedControlsString.Add("Next Tile: " + inputs.getControlName(InputsEnum.BUTTON_1));
            unselectedControlsString.Add("Prev Tile: " + inputs.getControlName(InputsEnum.BUTTON_2));
            unselectedControlsString.Add("Next Palette: " + inputs.getControlName(InputsEnum.LEFT_BUMPER));
            unselectedControlsString.Add("Prev Palette: " + inputs.getControlName(InputsEnum.RIGHT_BUMPER));
            unselectedControlsString.Add("Place Tile: " + inputs.getControlName(InputsEnum.RIGHT_TRIGGER));
            unselectedControlsString.Add("Options: " + inputs.getControlName(InputsEnum.CANCEL_BUTTON));

            Vector2 selectedControlsMenuPos =
                new Vector2(engine_.GraphicsDevice.Viewport.Width / 2.0f - 200.0f,
                            engine_.GraphicsDevice.Viewport.Height / 2.0f - 125.0f);
            selectedControlsMenuList_ =
                new MenuList(selectedControlsString, selectedControlsMenuPos);
            selectedControlsMenuList_.Font_ = CONTROLS_FONT;
            selectedControlsMenuList_.BaseColor_ = CONTROLS_COLOR;
            selectedControlsMenuList_.SelectedColor_ = CONTROLS_TITLE_COLOR;
            selectedControlsMenuList_.Spacing_ = CONTROLS_SPACING;

            Vector2 unselectedControlsMenuPos =
                new Vector2(engine_.GraphicsDevice.Viewport.Width / 2.0f + 200.0f,
                            engine_.GraphicsDevice.Viewport.Height / 2.0f - 125.0f);
            unselectedControlsMenuList_ = new MenuList(unselectedControlsString, unselectedControlsMenuPos);
            unselectedControlsMenuList_.BaseColor_ = CONTROLS_COLOR;
            unselectedControlsMenuList_.SelectedColor_ = CONTROLS_TITLE_COLOR;
            unselectedControlsMenuList_.Font_ = CONTROLS_FONT;
            unselectedControlsMenuList_.Spacing_ = CONTROLS_SPACING;
        }
 public EngineStateLevelSave(Engine engine, EngineStateLevelEditor state, EngineStateInterface successState, EngineStateInterface cancelState)
 {
     engine_ = engine;
     state_ = state;
     successState_ = successState;
     cancelState_ = cancelState;
     returnState_ = this;
     mainMessage_ = FontMap.getInstance().getFont(MESSAGE_FONT);
     StorageDevice sd = Settings.getInstance().StorageDevice_;
     if (sd == null)
     {
     #if !XBOX
         saveDialog();
     #endif
     }
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Creates a pause state which waits for the user to resume play
        /// </summary>
        /// <param name="engine">Reference to the engine running the state</param>
        /// <param name="savedState">The state of play to return to once the user unpauses</param>
        public EngineStatePause(Engine engine, EngineStateInterface savedState)
        {
            engine_ = engine;
            savedState_ = savedState;

            List<string> menuString = new List<string>();
            menuString.Add(STR_RETURN_TO_GAME);
            menuString.Add(STR_CONTROLS);
            menuString.Add(STR_GAME_OPTIONS);
            menuString.Add(STR_QUIT_GAME);
            int cursor = (int)Settings.getInstance().getMovementType();
            menuList_ = new MenuList(menuString, PAUSE_MENU_POSITION);
            menuList_.Font_ = PAUSE_FONT;
            menuList_.BaseColor_ = PAUSE_MENU_UNSELECTED_COLOR;
            menuList_.SelectedColor_ = PAUSE_MENU_SELECTED_COLOR;
            menuList_.Spacing_ = PAUSE_MENU_SPACING;
            menuList_.CursorPos_ = PAUSE_MENU_DEFAULT_SELECTED_ITEM;
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Creates an options state which allows the user to adjust game settings
        /// </summary>
        /// <param name="engine">Reference to the engine running the state</param>
        /// <param name="savedState">The state of play to return to once the user finishes</param>
        public EngineStateOptions(Engine engine, EngineStateInterface savedState)
        {
            engine_ = engine;
            savedState_ = savedState;

            List<string> menuString = new List<string>();
            if (Settings.getInstance().getMovementType() == MovementType.ABSOLUTE)
            {
                menuString.Add(STR_MOVEMENT_TYPE_ABSOLUTE);
            }
            else
            {
                menuString.Add(STR_MOVEMENT_TYPE_RELATIVE);
            }
            if (Settings.getInstance().IsSoundAllowed_)
            {
                menuString.Add(STR_SOUND_ON);
            }
            else
            {
                menuString.Add(STR_SOUND_OFF);
            }
            menuString.Add(STR_RESOLUTION);
            if (Settings.getInstance().IsGamerServicesAllowed_)
            {
                menuString.Add(STR_CHANGE_STORAGE);
            }
            if (Settings.getInstance().IsInDebugMode_)
            {
                menuString.Add(STR_DEBUG_MODE_ON);
            }
            else
            {
                menuString.Add(STR_DEBUG_MODE_OFF);
            }
            menuString.Add(STR_RETURN);

            menuList_ = new MenuList(menuString, OPTIONS_MENU_POSITION);
            menuList_.Font_ = OPTIONS_FONT;
            menuList_.BaseColor_ = OPTIONS_MENU_UNSELECTED_COLOR;
            menuList_.SelectedColor_ = OPTIONS_MENU_SELECTED_COLOR;
            menuList_.Spacing_ = OPTIONS_MENU_SPACING;
            menuList_.CursorPos_ = OPTIONS_MENU_DEFAULT_SELECTED_ITEM;
        }
 /// <summary>
 /// Use this ctor
 /// </summary>
 /// <param name="engine">A handle to the main Engine class</param>
 /// <param name="nextState">A handle to the EngineState to return when the story segment is done</param>
 /// <param name="durationOfStorySegment">How long, in seconds, you want the story segment to last.
 /// The player can always skip the story segment by pressing B, Start, or Back.</param>
 /// <param name="storyImgFilepath"></param>
 /// <param name="altText"></param>
 public EngineStateStorySegment(Engine engine, EngineStateInterface nextState, int durationOfStorySegment, string storyImgFilepath, string altText)
 {
     engine_ = engine;
     nextState_ = nextState;
     framesSpentInStory_ = 0;
     DurationOfStory_ = durationOfStorySegment;
     storyText_ = altText;
     try
     {
         isUsingImage_ = true;
         storyImg_ = new GameTexture(storyImgFilepath, engine.spriteBatch_, engine.GraphicsDevice);
     }
     catch
     {
         // That's okay, we will just use the altText.
         isUsingImage_ = false;
     }
 }
Ejemplo n.º 8
0
        /// <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()
        {
            // TODO: Add your initialization logic here

            base.Initialize();
            initializeScreen();
            Settings.initialize(this);

            #if XBOX
            Settings.getInstance().IsUsingMouse_ = false;
            #else
            if (GamePad.GetState(PlayerIndex.One).IsConnected)
            {
                Settings.getInstance().IsUsingMouse_ = false;
            }
            else
            {
                Settings.getInstance().IsUsingMouse_ = true;
            }
            #endif

            try
            {
                // Debugging - Uncomment this line to try PC version as if it
                //  were running with the Redistributable runtime in which
                //  GamerServices is not available
                // Note that this is not a truly accurate test, as there could
                //  be lurking calls to GamerServices outside of a block which
                //  tests Settings.IsGamerServicesAllowed_ prior to using
                // throw new Exception();

                GamerServicesComponent gsc = new GamerServicesComponent(this);
                gsc.Initialize();
                this.Components.Add(gsc);
                Settings.getInstance().IsGamerServicesAllowed_ = true;
            }
            catch
            {
                Settings.getInstance().IsGamerServicesAllowed_ = false;
            }

            // creating EngineStateStart must come AFTER setting the
            //  IsGamerServicesAllowed_ member of Settings
            this.engineState_ = new EngineStateSplash(this);

            int tiles = (int)((GraphicsDevice.Viewport.Height / 15) * (GraphicsDevice.Viewport.Width / 15) * 1.2);
            tiles += 350;

            DrawBuffer.initialize(tiles, spriteBatch_);
            DrawBuffer_ = DrawBuffer.getInstance();
            UpdateThread_ = new UpdateThread(this, engineState_);
            RenderThread_ = new RenderThread();
            UpdateThread_.Controls_ = Controls_;
            UpdateThread_.startThread();
        }
Ejemplo n.º 9
0
 public UpdateThread(Engine engine, EngineStateInterface engineState)
 {
     currentEngineState_ = engineState;
     engine_ = engine;
     drawBuffer_ = DrawBuffer.getInstance();
 }
Ejemplo n.º 10
0
        public void update()
        {
            // TODO: Add your update logic here
            if (!engine_.IsActive && !(currentEngineState_ is EngineStateOutofFocus)
            #if !XBOX
             || mouseOutsideWindow() && !(currentEngineState_ is EngineStateOutofFocus)
            #endif
                )
            {
                currentEngineState_ = new EngineStateOutofFocus(engine_, currentEngineState_);
            }

            //if (Controls_ != null)
            //    Controls_.updateInputSet();
            //drawBuffer_.globalSynchronizeControlInput();

            currentEngineState_ = currentEngineState_.update(gameTime_);

            currentEngineState_.draw();
            Camera cam = GlobalHelper.getInstance().getCurrentCamera();
            if (cam != null)
            {
                drawBuffer_.getUpdateStack().getCamera().setPosition(cam.getX(), cam.getY());
            }
        }
Ejemplo n.º 11
0
 public EngineStateControls(Engine engine, EngineStateInterface returnState)
     : this(engine)
 {
     returnState_ = returnState;
 }
Ejemplo n.º 12
0
 public static void ReplaceCurrent(EngineStateInterface esi)
 {
     StateStack.Pop();
     StateStack.Push(esi);
 }
Ejemplo n.º 13
0
 private void saveDialog()
 {
     SaveFileDialog dialog = new SaveFileDialog();
     dialog.Filter = "Commando Level Files (*" + LEVEL_EXTENSION + ")|*" + LEVEL_EXTENSION;
     dialog.RestoreDirectory = true;
     dialog.Title = "Commando Engine Save Prompt";
     InputSet.getInstance().setToggle(InputsEnum.CONFIRM_BUTTON);
     InputSet.getInstance().setToggle(InputsEnum.RIGHT_TRIGGER);
     if (dialog.ShowDialog() == DialogResult.OK)
     {
         state_.myLevel_.writeLevelToFile(dialog.FileName);
         returnState_ = new EngineStateMenu(engine_);
         cancelFlag_ = true;
     }
     else
     {
         returnState_ = state_;
         cancelFlag_ = true;
     }
 }
Ejemplo n.º 14
0
        private void saveLevel(StorageDevice storageDevice)
        {
            StorageContainer container =
                ContainerManager.getOpenContainer();
            string directory = Path.Combine(container.Path, DIRECTORY_NAME);
            System.IO.Directory.CreateDirectory(directory);
            string filename = Path.Combine(directory, currentFilename_);
            state_.myLevel_.writeLevelToFile(filename);
            container.Dispose();

            //returnState_ = new EngineStateMenu(engine_);
            returnState_ = successState_;
        }
Ejemplo n.º 15
0
        private void enterFilename(IAsyncResult result)
        {
            string filename = Guide.EndShowKeyboardInput(result);

            // If they cancelled, go back to LevelEditor
            if (filename == null)
            {
                returnState_ = cancelState_;
                cancelFlag_ = true;
                return;
            }

            currentFilename_ = filename + LEVEL_EXTENSION;

            // TODO
            // Must ensure that if KeyboardInput works, this will always
            //  have a valid storage device
            saveLevel(Settings.getInstance().StorageDevice_);
        }