public override void update(float elapsed) { Vector2 mousePos = InputManager.getInstance().MousePosition; this.playButton.processActorsMovement(mousePos); this.instructionsButton.processActorsMovement(mousePos); this.exitButton.processActorsMovement(mousePos); // mouse over sfx if (this.playButton.isActorOver(mousePos) || this.exitButton.isActorOver(mousePos)) { if (!base.previousMouseOverButton) { SoundManager.getInstance().sfxEngine.playSoundEffect(ResourceManager.getInstance().MouseOverSfx); } base.previousMouseOverButton = true; } else { base.previousMouseOverButton = false; } if (StateManager.getInstance().CurrentTransitionState == StateManager.TransitionState.None) { if (InputManager.getInstance().wasLeftButtonPressed() || InputManager.getInstance().wasButtonPressed(PlayerIndex.One, Buttons.A)) { if (this.playButton.isActorOver(mousePos)) { StateManager.getInstance().CurrentTransitionState = StateManager.TransitionState.TransitionOut; StateManager.getInstance().CurrentGameState = StateManager.GameState.ModeSelect; SoundManager.getInstance().sfxEngine.playSoundEffect(this.outroSfx); } else if (this.instructionsButton.isActorOver(mousePos)) { StateManager.getInstance().CurrentTransitionState = StateManager.TransitionState.TransitionOut; StateManager.getInstance().CurrentGameState = StateManager.GameState.Instructions; } else if (this.exitButton.isActorOver(mousePos)) { StateManager.getInstance().CurrentGameState = StateManager.GameState.Exit; } } } else if (StateManager.getInstance().CurrentTransitionState == StateManager.TransitionState.TransitionIn) { if (this.playButton.isActorOver(mousePos)) { this.playButton.updateColours(base.fadeIn(ResourceManager.MOUSE_OVER_COLOUR)); this.instructionsButton.updateColours(base.fadeIn(ResourceManager.TEXT_COLOUR)); this.exitButton.updateColours(base.fadeIn(ResourceManager.TEXT_COLOUR)); } else if (this.exitButton.isActorOver(mousePos)) { this.exitButton.updateColours(base.fadeIn(ResourceManager.MOUSE_OVER_COLOUR)); this.instructionsButton.updateColours(base.fadeIn(ResourceManager.TEXT_COLOUR)); this.playButton.updateColours(base.fadeIn(ResourceManager.TEXT_COLOUR)); } else if (this.instructionsButton.isActorOver(mousePos)) { this.instructionsButton.updateColours(base.fadeIn(ResourceManager.MOUSE_OVER_COLOUR)); this.playButton.updateColours(base.fadeIn(ResourceManager.TEXT_COLOUR)); this.exitButton.updateColours(base.fadeIn(ResourceManager.TEXT_COLOUR)); } else { this.playButton.updateColours(base.fadeIn(ResourceManager.TEXT_COLOUR)); this.exitButton.updateColours(base.fadeIn(ResourceManager.TEXT_COLOUR)); this.instructionsButton.updateColours(base.fadeIn(ResourceManager.TEXT_COLOUR)); } this.backGround.LightColour = base.fadeIn(Color.White); this.title.LightColour = base.fadeIn(Color.White); } else if (StateManager.getInstance().CurrentTransitionState == StateManager.TransitionState.TransitionOut) { if (this.playButton.isActorOver(mousePos)) { this.playButton.updateColours(base.fadeOut(ResourceManager.MOUSE_OVER_COLOUR)); this.exitButton.updateColours(base.fadeOut(ResourceManager.TEXT_COLOUR)); this.instructionsButton.updateColours(base.fadeOut(ResourceManager.TEXT_COLOUR)); } else if (this.exitButton.isActorOver(mousePos)) { this.exitButton.updateColours(base.fadeOut(ResourceManager.MOUSE_OVER_COLOUR)); this.playButton.updateColours(base.fadeOut(ResourceManager.TEXT_COLOUR)); this.instructionsButton.updateColours(base.fadeOut(ResourceManager.TEXT_COLOUR)); } else if (this.instructionsButton.isActorOver(mousePos)) { this.playButton.updateColours(base.fadeOut(ResourceManager.TEXT_COLOUR)); this.exitButton.updateColours(base.fadeOut(ResourceManager.TEXT_COLOUR)); this.instructionsButton.updateColours(base.fadeOut(ResourceManager.MOUSE_OVER_COLOUR)); } else { this.playButton.updateColours(base.fadeOut(ResourceManager.TEXT_COLOUR)); this.exitButton.updateColours(base.fadeOut(ResourceManager.TEXT_COLOUR)); this.instructionsButton.updateColours(base.fadeOut(ResourceManager.TEXT_COLOUR)); } this.backGround.LightColour = base.fadeOut(Color.White); this.title.LightColour = base.fadeOut(Color.White); //reset the idle timer this.timeIdle = 0f; } // if our transition time is up change our state if (base.transitionTimeElapsed()) { if (StateManager.getInstance().CurrentTransitionState == StateManager.TransitionState.TransitionIn) { StateManager.getInstance().CurrentTransitionState = StateManager.TransitionState.None; } else if (StateManager.getInstance().CurrentTransitionState == StateManager.TransitionState.TransitionOut) { StateManager.getInstance().CurrentTransitionState = StateManager.TransitionState.TransitionIn; } } this.timeIdle += elapsed; if (this.timeIdle >= PLAY_IDLE_AT) { Random rand = new Random(); int idleToPlay = this.idleLastPlayed; do { idleToPlay = rand.Next(this.idleSfxs.Length); } while (idleToPlay == this.idleLastPlayed); SoundManager.getInstance().sfxEngine.playSoundEffect(this.idleSfxs[idleToPlay]); this.idleLastPlayed = idleToPlay; this.timeIdle = 0f; } base.update(elapsed); }