public void update(InputState inputState) { if (this.wantsToExit()) return; if (null == this.input) { this.input = new ExplicitInputState(); } this.input.update(inputState); if (null == this.player) { this.player = new VideoPlayer(); this.player.Play(this.video); } // We ignore the first update after initializing the scene, // to prevent older button presses carrying on. if (this.firstUpdate) { this.firstUpdate = false; return; } if (this.input.isActive(InputState.Control.BACK) || this.input.isActive(InputState.Control.EXIT)) { this.forceExit = true; } }
protected virtual void updateState(ExplicitInputState input) { if (input.isActive(InputState.Control.SELECT)) { this.perform(); } if (input.isActive(InputState.Control.UP)) { this.selectSound.play(); this.previous.select(); } if (input.isActive(InputState.Control.DOWN)) { this.selectSound.play(); this.next.select(); } }
protected override void updateState(ExplicitInputState input) { if (this.active) { if (input.isActive(InputState.Control.UP) || input.isActive(InputState.Control.DOWN)) { this.active = false; this.clickSound.play(); base.updateState(input); } else if (input.isActive(InputState.Control.EXIT) || input.isActive(InputState.Control.BACK)) { this.active = false; this.clickSound.play(); } else if (input.isActive(InputState.Control.RIGHT)) { this.selectSound.play(); this.next(); this.selectedItem.select(); } else if (input.isActive(InputState.Control.LEFT)) { this.selectSound.play(); this.prev(); this.selectedItem.select(); } else if (input.isActive(InputState.Control.SELECT)) { this.clickSound.play(); this.selectedItem.select(); this.selectedItem.perform(); this.perform(); } } else if (input.isActive(InputState.Control.SELECT)) { this.active = true; this.selectedIndex = 0; this.selectedItem.select(); this.clickSound.play(); } else { base.updateState(input); } }
public void update(ExplicitInputState input) { if (!this.selected) return; updateState(input); }
private void updatePauseState(ExplicitInputState input) { if (input.isActive(InputState.Control.PAUSE)) { if (this.paused) { this.song.play(); } else { this.song.pause(); } this.paused = !this.paused; } }
private void updateInternal(ExplicitInputState input) { if (this.hasExitState(input)) return; updatePauseState(input); this.song.calculateMetaInfo(); long time = this.song.timeRunningInMs; long deltaT = time - this.lastTime; this.lastTime = time; float measures = this.song.timeRunningInMeasures; float timeInSequence = -1.0f; this.currentSequence = sequences.atMeasure(measures); if (null != this.currentSequence) { timeInSequence = (measures - this.currentSequence.startMeasure) / this.currentSequence.length; if (this.currentSequence.isEnemyActive(measures)) { this.progress.errorInLastSequence = false; this.missed = 0; this.wrong = 0; InputState.Move move = this.currentSequence.getActiveMoveAt(measures); if (this.lastMove != move) this.enemy.activate(move); this.lastMove = move; } } this.background.update(measures, timeInSequence); PlayerProgress.RatedMoves rated = null; bool sequenceComplete = false; if ((null == this.currentSequence || this.currentSequence.playerInputAllowed(measures))) { rated = this.progress.nextRating(measures, this.currentSequence, input); if (rated.hasErrors()) { this.progress.errorInLastSequence = true; this.missed += rated.missed.Count; this.wrong += rated.wrong.Count; } if (input.lastMoveIsNew()) { this.player.activate(input.lastMove); this.progress.score -= rated.wrong.Count * 20; sequenceComplete = this.checkSequenceCompletion(rated, sequenceComplete); } } if (sequenceComplete) { this.progress.score += 100; } this.ui.update(rated, sequenceComplete, time, deltaT); this.player.update(deltaT); this.enemy.update(deltaT); }
public void initialize(ContentUtil content, SceneActivationParameters parameters) { this.exit = false; this.paused = false; this.textures.clear(); this.currentSequence = null; this.input = new ExplicitInputState(); script.reload(); this.textures.loadTextures(content, "player_character", "btn_up", "btn_down", "btn_left", "btn_right", "btn_fail"); //this.backgroundTexture = this.script.get("background"); //this.textures.loadTextures(content, this.backgroundTexture); this.background.initialize(content, this.script); this.song = new Song(this.script, content); this.progress = new PlayerProgress(); this.sequences.initialize(this.script); float uiSpeed = 1.0f; if (this.script.contains("ui_speed")) uiSpeed = this.script.asFloat["ui_speed"][0]; this.ui.initialize(content, this.sequences, this.song.beatTimeInMs, uiSpeed); long beatTimeMs = (long) this.song.beatTimeInMs; this.enemy = new AnimatedCharacter(this.script.get("enemy"), content, beatTimeMs); this.player = new AnimatedCharacter("toasty/toasty", content, beatTimeMs); this.lastTime = 0; this.song.play(); }
public void initialize(ContentUtil content, SceneActivationParameters parameters) { this.input = new ExplicitInputState(); this.next = false; this.exit = false; this.firstUpdate = true; this.background = content.load<Texture2D>("menu/background01"); this.clickSound = new Sound("menu/click", content); this.selectSound = new Sound("menu/select", content); if (null == this.backgroundSong || this.backgroundSong.stoppedPlaying()) this.backgroundSong = new Song("menu/backgroundsong", content, 120f); ScaledTexture[][] buttonTextures = this.loadButtonTextures(content); foreach (MenuItem item in this.items) { int texIndex = SystemRef.nextRandomInt(0, 4); item.initialize(this.clickSound, this.selectSound, buttonTextures[texIndex][0], buttonTextures[texIndex][1]); } this.items[0].select(); }