Example #1
0
        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;
            }
        }
        public void update(InputState input)
        {
            foreach (KeyValuePair<Move, Boolean> state in this.moveStates) {
                this.lastStates[state.Key] = state.Value;
            }
            foreach (KeyValuePair<Control, Boolean> state in this.controlStates) {
                this.lastStates[state.Key] = state.Value;
            }

            this.copyState(input);
        }
        public RatedMoves nextRating(float measure, DanceSequence sequence, InputState input)
        {
            RatedMoves rating = new RatedMoves();
            if (null == sequence)
                return rating;

            List<DanceSequence.Input> possibleMatches = sequence.findReachableInputs(measure);
            List<DanceSequence.Input> rated = new List<DanceSequence.Input>();

            this.addNotYetRated(possibleMatches);

            foreach (InputState.Move move in input.activeStates) {
                DanceSequence.Input matching = this.getMatchingInput(possibleMatches, move);
                if (null != matching && matching.positionInSong <= this.ratedUntil)
                    continue;

                if (null != matching) {
                    float accuracy = matching.getAccuracy(measure);
                    if (accuracy <= Song.MusicTimeInFractions(Song.MusicTime.SIXTEENTH) / 2.0f) {
                        this.score += 25;
                        rating.perfect.Add(matching);
                    } else if (accuracy <= Song.MusicTimeInFractions(Song.MusicTime.SIXTEENTH)) {
                        this.score += 15;
                        rating.good.Add(matching);
                    } else {
                        this.score += 5;
                        rating.ok.Add(matching);
                    }

                    rated.Add(matching);
                    this.notYetRated.Remove(matching);
                    if (measure > this.ratedUntil) {
                        this.ratedUntil = matching.positionInSong;
                    }
                } else {
                    rating.addWrongMove(sequence, measure, move);
                }
            }

            foreach (DanceSequence.Input possibleMiss in this.notYetRated) {
                if (!possibleMiss.isReachable(measure) ||
                        this.ratedUntil > possibleMiss.positionInSong) {

                    rating.missed.Add(possibleMiss);
                    rated.Add(possibleMiss);
                }
            }
            ListUtil.removeAllFromList(this.notYetRated, rating.missed);

            rating.validate();
            return rating;
        }
Example #4
0
        public virtual void update(InputState input)
        {
            if (this.wantsToExit()) {
                return;
            }

            activeScene.update(input);
            if (activeScene.wantsToExit()) {
                IScene nextScene = this.manager.getNextSceneFor(activeScene);
                activeScene.cleanup();

                if (null == nextScene) {
                    this.activateNext();
                } else {
                    this.activeScene = nextScene;
                }
            }
        }
        public void update(InputState input)
        {
            if (input.isActive(InputState.Control.EXIT)) {
                this.exit = true;
                return;
            }
            if (null == this.runningTime)
                this.runningTime = Stopwatch.StartNew();

            long deltaT = this.runningTime.ElapsedMilliseconds;
            if (deltaT > this.fadeInTime + this.fadeOutTime) {
                this.fadeAmount = 0.0f;
            } else if (deltaT > this.fadeInTime) {
                this.fadeAmount = 1.0f - (float) (deltaT - fadeInTime) / (float) fadeOutTime;
            } else {
                this.fadeAmount = (float)deltaT / (float)fadeInTime;
            }
        }
 private DanceSequence.Input getMatchingInput(List<DanceSequence.Input> possibleMatches, InputState.Move move)
 {
     foreach (DanceSequence.Input input in possibleMatches) {
         if (input.handicap.Equals(move)) {
             return input;
         }
     }
     return null;
 }
 internal void addWrongMove(DanceSequence sequence, float measure, InputState.Move move)
 {
     DanceSequence.Input input = new DanceSequence.Input(sequence);
     input.positionInSong = measure;
     input.handicap = move;
     this.wrong.Add(input);
 }
        internal void addInput(InputState.Move move, Song.MusicTime musicLength, bool isTriplet)
        {
            Input input = new Input(this);
            input.handicap = move;
            input.musicLength = musicLength;
            input.partOfTriole = isTriplet;
            input.positionInSequence = this._length;

            this.sequence.Add(input);
            this._length += input.length;
        }
Example #9
0
 public bool Equals(InputState other)
 {
     return null != other
         && other.moveStates.Equals(this.moveStates)
         && other.controlStates.Equals(this.controlStates);
 }
 public void startOpponentAnimation(InputState.Move move, long startPoint)
 {
     this.startAnimation(this.opponent, move, startPoint);
 }
 public void startPlayerAnimation(InputState.Move move, long startPoint, PlayerProgress.Rating rating)
 {
     this.startAnimation(this.player[rating], move, startPoint);
 }
 private void startAnimation(Dictionary<InputState.Move, ButtonAnimation> bundle,
         InputState.Move move, long startPoint)
 {
     if (!bundle.ContainsKey(move))
         return;
     bundle[move].addStartPoint(startPoint);
 }
Example #13
0
        public void update(InputState currentInput)
        {
            if (!this.next && this.backgroundSong.stoppedPlaying())
                this.backgroundSong.play();

            this.input.update(currentInput);

            // 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.EXIT)){
                this.next = true;
                this.exit = true;
                this.clickSound.play();
                this.backgroundSong.stop();
                return;
            }*/

            foreach (MenuItem item in this.items) {
                item.update(this.input);
                if (item.isSelected()) {
                    this.next = item.nextScene;
                }
            }
        }
Example #14
0
 public void initPreviousMove(InputState previous)
 {
     if (null == previous)
         return;
     this.previousMove = previous.lastMove;
     this.lastMove = this.previousMove;
 }
Example #15
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            //this.checkForExitSignals();

            if (Keyboard.GetState().IsKeyDown(Keys.F11)){
                this.graphics.ToggleFullScreen();
            }

            GamePadDPad dpad = GamePad.GetState(PlayerIndex.One).DPad;
            GamePadButtons buttons = GamePad.GetState(PlayerIndex.One).Buttons;

            InputState input = createInputState(ref dpad, ref buttons);

            this.scene.update(input);

            this.previousInput = input;

            if (this.scene.wantsToExit())
                this.Exit();

            base.Update(gameTime);
        }
Example #16
0
        private bool hasExitState(InputState input)
        {
            if (this.exit) {
                return true;
            }

            if (this.song.stoppedPlaying() ||
                    input.isActive(InputState.Control.EXIT)) {
                exit = true;
                return true;
            }

            return false;
        }
Example #17
0
 public void update(InputState input)
 {
     this.input.update(input);
     this.updateInternal(this.input);
 }
 public override void update(InputState input)
 {
     if (this.song.stoppedPlaying())
         this.song.play();
     base.update(input);
 }
Example #19
0
        private InputState createInputState(ref GamePadDPad dpad, ref GamePadButtons buttons)
        {
            InputState input = new InputState();
            input.initPreviousMove(this.previousInput);
            input.set(InputState.Move.UP,
                dpad.Up == ButtonState.Pressed ||
                buttons.Y == ButtonState.Pressed ||
                Keyboard.GetState().IsKeyDown(Keys.W) ||
                Keyboard.GetState().IsKeyDown(Keys.Up));

            input.set(InputState.Move.DOWN,
                dpad.Down == ButtonState.Pressed ||
                buttons.A == ButtonState.Pressed ||
                Keyboard.GetState().IsKeyDown(Keys.S) ||
                Keyboard.GetState().IsKeyDown(Keys.Down));

            input.set(InputState.Move.LEFT,
                dpad.Left == ButtonState.Pressed ||
                buttons.X == ButtonState.Pressed ||
                Keyboard.GetState().IsKeyDown(Keys.A) ||
                Keyboard.GetState().IsKeyDown(Keys.Left));

            input.set(InputState.Move.RIGHT,
                dpad.Right == ButtonState.Pressed ||
                buttons.B == ButtonState.Pressed ||
                Keyboard.GetState().IsKeyDown(Keys.D) ||
                Keyboard.GetState().IsKeyDown(Keys.Right));

            input.set(InputState.Control.EXIT,
                buttons.Back == ButtonState.Pressed ||
                Keyboard.GetState().IsKeyDown(Keys.Escape));

            input.set(InputState.Control.BACK,
                buttons.B == ButtonState.Pressed ||
                Keyboard.GetState().IsKeyDown(Keys.Escape) ||
                Keyboard.GetState().IsKeyDown(Keys.Back));

            input.set(InputState.Control.PAUSE,
                buttons.Start == ButtonState.Pressed ||
                Keyboard.GetState().IsKeyDown(Keys.P) ||
                Keyboard.GetState().IsKeyDown(Keys.Space));

            input.set(InputState.Control.SELECT,
                buttons.A == ButtonState.Pressed ||
                Keyboard.GetState().IsKeyDown(Keys.Enter));

            input.set(InputState.Control.UP,
                dpad.Up == ButtonState.Pressed ||
                Keyboard.GetState().IsKeyDown(Keys.W) ||
                Keyboard.GetState().IsKeyDown(Keys.Up));

            input.set(InputState.Control.DOWN,
                dpad.Down == ButtonState.Pressed ||
                Keyboard.GetState().IsKeyDown(Keys.S) ||
                Keyboard.GetState().IsKeyDown(Keys.Down));

            input.set(InputState.Control.LEFT,
                dpad.Left == ButtonState.Pressed ||
                Keyboard.GetState().IsKeyDown(Keys.A) ||
                Keyboard.GetState().IsKeyDown(Keys.Left));

            input.set(InputState.Control.RIGHT,
                dpad.Right == ButtonState.Pressed ||
                Keyboard.GetState().IsKeyDown(Keys.D) ||
                Keyboard.GetState().IsKeyDown(Keys.Right));
            return input;
        }
 public void startFailAnimation(InputState.Move move, long startPoint)
 {
     this.startAnimation(this.fail, move, startPoint);
 }
Example #21
0
        public void update(InputState input)
        {
            if (this.exit)
                return;

            if (null == this.activeScene) {
                SceneActivationParameters sceneParams =
                    this.initSceneParamsUsingDefaults(this.nextSceneParams);

                this.activeScene = this.initScene(sceneParams);
            }

            this.activeScene.update(input);

            if (this.activeScene.wantsToExit()) {
                this.nextSceneParams = this.initSceneParamsUsingDefaults(this.activeScene.nextScene());
                this.activeScene.cleanup();

                if ("exit".Equals(this.nextSceneParams.sceneName.ToLower())) {
                    this.exit = true;
                } else {
                    this.activeScene = null;
                }
            }
        }
Example #22
0
 protected void copyState(InputState state)
 {
     this.moveStates = state.moveStates;
     this.controlStates = state.controlStates;
     this.lastMove = state.lastMove;
     this.previousMove = state.previousMove;
 }