Ejemplo n.º 1
0
        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;
        }
        private DanceSequence readSequenceDetails(int startMeasure, String[] scriptSource)
        {
            DanceSequence sequence = new DanceSequence(startMeasure);

            Song.MusicTime lastMusicTime = Song.MusicTime.QUARTER;
            bool isTriplet = false;
            foreach (String _step in scriptSource) {
                String step = _step.Trim();
                Match m = regexStep.Match(step);
                if (m.Success) {
                    String mtPart = m.Groups[1].Value.Trim();
                    String mtFraction = m.Groups[2].Value.Trim();
                    String mtDotted = m.Groups[3].Value.Trim();
                    String tripletStart = m.Groups[4].Value.Trim();
                    String move = m.Groups[5].Value.Trim();
                    String tripletEnd = m.Groups[6].Value.Trim();

                    if (!"".Equals(mtPart) && !"".Equals(mtFraction)) {
                        float fraction = ParserUtil.toFloat(mtPart) / ParserUtil.toFloat(mtFraction);
                        bool dotted = !"".Equals(mtDotted);
                        lastMusicTime = Song.FractionsInMusicTime(fraction, dotted);
                    }

                    if (!"".Equals(tripletStart))
                        isTriplet = true;

                    sequence.addInput(
                            InputState.moveFromString(move),
                            lastMusicTime,
                            isTriplet);

                    if (!"".Equals(tripletEnd))
                        isTriplet = false;
                }
            }
            return sequence;
        }
Ejemplo n.º 3
0
 internal bool contains(DanceSequence.Input input)
 {
     if (null == input)
         return false;
     return this.allFromUserInput.Contains(input) ||
         this.missed.Contains(input);
 }
Ejemplo n.º 4
0
 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);
 }
Ejemplo n.º 5
0
 public Input(DanceSequence parent)
 {
     this.parent = parent;
 }
Ejemplo n.º 6
0
        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);
        }
Ejemplo n.º 7
0
        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();
        }
Ejemplo n.º 8
0
 private Sound getSoundForRating(PlayerProgress.RatedMoves rated, DanceSequence.Input ratedInput)
 {
     Sound sound;
     if (rated.ok.Contains(ratedInput)) {
         sound = this.successSound;
     } else if (rated.good.Contains(ratedInput)) {
         sound = this.successSound;
     } else if (rated.perfect.Contains(ratedInput)) {
         sound = this.successSound;
     } else {
         sound = this.errorSound;
     }
     return sound;
 }
Ejemplo n.º 9
0
 private static Color getColorForRating(PlayerProgress.RatedMoves rated, DanceSequence.Input ratedInput)
 {
     Color color;
     if (rated.ok.Contains(ratedInput)) {
         color = Color.Yellow;
     } else if (rated.good.Contains(ratedInput)) {
         color = Color.GreenYellow;
     } else if (rated.perfect.Contains(ratedInput)) {
         color = Color.Lime;
     } else {
         color = Color.Red;
     }
     return color;
 }