/// <summary> /// Constructor determines whether PC or Xbox 360 and initializes /// variables accordingly. /// /// For PC, this means creating the controller and trying to get a /// storage device. /// /// For the Xbox 360, we don't need to do much as we rely on update() /// logic to determine active controller and storage device. /// </summary> /// <param name="engine"></param> public EngineStateStart(Engine engine) { engine_ = engine; logo_ = TextureMap.fetchTexture("TitleScreen"); #if !XBOX { Settings settings = Settings.getInstance(); if (Settings.getInstance().IsUsingMouse_) { engine_.Controls_ = new PCControllerInput(engine_); settings.CurrentPlayer_ = PlayerIndex.One; TEXT_MESSAGE = "Press " + engine_.Controls_.getControlName(InputsEnum.CONFIRM_BUTTON).ToUpper() + " to Continue"; } else { engine_.Controls_ = new X360ControllerInput(engine_, PlayerIndex.One); settings.CurrentPlayer_ = PlayerIndex.One; TEXT_MESSAGE = "Press " + engine_.Controls_.getControlName(InputsEnum.CONFIRM_BUTTON).ToUpper() + " to Continue"; } prepareStorageDevice(); returnFlag_ = true; } #else { engine_.Controls_ = null; // reset controls if they are coming back to this returnFlag_ = false; } #endif }
/// <summary> /// Creates a main menu state /// </summary> /// <param name="engine">A reference to the engine running the state</param> public EngineStateMenu(Engine engine) { engine_ = engine; logo_ = TextureMap.fetchTexture("TitleScreen"); List<string> menuString = new List<string>(); menuString.Add(STR_MENU_START_GAME); menuString.Add(STR_MENU_CUSTOM_LEVEL); menuString.Add(STR_MENU_CONTROLS); menuString.Add(STR_MENU_LEVEL_EDITOR); menuString.Add(STR_MENU_QUIT); GlobalHelper.getInstance().setCurrentCamera(new Camera()); InputSet inputs = InputSet.getInstance(); /*controlTips_ = "Select: " + inputs.getControlName(InputsEnum.CONFIRM_BUTTON) + " | " + "Cancel: " + inputs.getControlName(InputsEnum.CANCEL_BUTTON);*/ controlTips_ = ""; // currrently refreshed every frame in draw() mainMenuList_ = new MenuList(menuString, MENU_POSITION); mainMenuList_.BaseColor_ = MENU_UNSELECTED_COLOR; mainMenuList_.SelectedColor_ = MENU_SELECTED_COLOR; mainMenuList_.CursorPos_ = MENU_DEFAULT_CURSOR_POSITION; mainMenuList_.Font_ = MENU_FONT; mainMenuList_.Spacing_ = MENU_SPACING; mainMenuList_.LayerDepth_ = MENU_DEPTH; SoundEngine.getInstance().playCue("go_commando"); SoundEngine.getInstance().playMusic("menu"); }
/// <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; } }
internal void set(GameTexture texture, int imageIndex, Rectangle destination, CoordinateTypeEnum coordType, float depth, bool centered, Color color, Vector2 direction, float scale) { Texture = texture; Destination = destination; Dest = true; ImageIndex = imageIndex; CoordinateType = coordType; Depth = depth; Centered = centered; Effects = SpriteEffects.None; Color = color; Direction = direction; Scale = scale; }
/* * td.Texture = sprites_; td.ImageIndex = currentFrame_; td.Position = position_; td.Dest = false; td.CoordinateType = CoordinateTypeEnum.RELATIVE; td.Depth = depth_; td.Centered = true; td.Color = Color.White; td.Effects = SpriteEffects.None; td.Direction = rotation_; td.Scale = 1.0f; */ internal void set(GameTexture texture, int imageIndex, Vector2 position, CoordinateTypeEnum coordType, float depth, bool centered, Color color, float rotation, float scale) { Texture = texture; Position = position; Dest = false; ImageIndex = imageIndex; CoordinateType = coordType; Depth = depth; Centered = centered; Effects = SpriteEffects.None; Color = color; Rotation = rotation; Scale = scale; }
internal TextureDrawer(GameTexture texture, Vector2 position, float depth) { Texture = texture; Position = position; Depth = depth; Rotation = 0; CoordinateType = CoordinateTypeEnum.RELATIVE; Color = Color.White; ImageIndex = 0; Effects = SpriteEffects.None; Scale = 1.0f; Centered = true; }
/// <summary> /// Create a copy of the GameTexture gTexture. /// </summary> /// <param name="gTexture">The GameTexture to be copied</param> public GameTexture(GameTexture gTexture) { spriteBatch_ = gTexture.spriteBatch_; texture_ = gTexture.texture_; Array.Copy(gTexture.imageDimensions_, imageDimensions_, gTexture.imageDimensions_.GetLength(0)); helper_ = GlobalHelper.getInstance(); }
/// <summary> /// Create a NonAnimatedMovableObject with the specified texture, current image, /// position, direction, and depth with the specified velocity. /// </summary> /// <param name="pipeline">List of objects from which the object should be drawn.</param> /// <param name="texture">GameTexture of this object</param> /// <param name="curImage">The number of the current image</param> /// <param name="velocity">Vector of velocity, representing both direction of movement and magnitude</param> /// <param name="position">Position of object relative to the top left corner</param> /// <param name="direction">Vector representing the direction of the object</param> /// <param name="depth">Depth the object is to be drawn to</param> public NonAnimatedMovableObjectAbstract(List<DrawableObjectAbstract> pipeline, GameTexture texture, int curImage, Vector2 velocity, Vector2 position, Vector2 direction, float depth) : base(pipeline, velocity, position, direction, depth) { texture_ = texture; }
public EngineStateSplash(Engine engine) { engine_ = engine; splash_ = new GameTexture(@"Sprites\splash", engine.spriteBatch_, engine.GraphicsDevice, engine_.Content); }