예제 #1
0
        private void DrawUi()
        {
            var time = (long)FindSystem <GameTimeSystem>().Time;

            // Debug things
            _spriteBatch.DrawString(Skin.Font, time.ToString(), new Vector2(12, 12), Color.Red);
            _spriteBatch.DrawString(Skin.Font, ScrollingSpeed.ToString("F1"), new Vector2(12, 48), Color.Red);

            _spriteBatch.DrawString(Skin.Font,
                                    $"Song Speed: {FindSystem<MusicSystem>().PlaybackRate:F1}",
                                    new Vector2(12, 64),
                                    Color.DarkRed);

            var scoreSystem = GameSystemManager.FindSystem <ScoreV1System>();

            string scores = $"Marvelous: {scoreSystem.MarvelousCount}\n" +
                            $"Perfect: {scoreSystem.PerfectCount}\n" +
                            $"Great: {scoreSystem.GreatCount}\n" +
                            $"Good: {scoreSystem.GoodCount}\n" +
                            $"Bad: {scoreSystem.BadCount}\n" +
                            $"Miss: {scoreSystem.MissCount}";

            _spriteBatch.DrawString(Skin.Font, scores, new Vector2(800, 10), Color.Black);
            _spriteBatch.DrawString(Skin.Font,
                                    $"ScoremeterScore: {scoreSystem.Score}\n" +
                                    $"Combo: {scoreSystem.Combo}\n" +
                                    $"Accuracy: {scoreSystem.Accuracy * 100:F2}%\n" +
                                    $"HP: {FindSystem<HealthSystem>().Health}",
                                    new Vector2(15, 300), Color.Black);
        }
예제 #2
0
        public override void Initialize()
        {
            base.Initialize();

            GameplaySystem gs = GameSystemManager.FindSystem <GameplaySystem>();


            _scores = new List <ScoremeterScore>();
            _od     = gs.Beatmap.Settings.Difficulty.OverallDifficutly;

            SizeMultiplier = 1.0f;

            var scoreSys = FindSystem <ScoreV1System>();

            Size     = new Vector2((float)scoreSys.HitThresholds[scoreSys.ScoreMiss] * 2.0f, 8);
            Position = new Vector2(
                gs.Skin.Settings.PlayfieldPositionX +
                gs.Skin.PlayfieldLineTexture.Width * gs.Beatmap.Settings.Difficulty.KeyAmount / 2.0f -
                Size.X * SizeMultiplier / 2.0f, 400);

            _hitColors = new Dictionary <string, Color>
            {
                { scoreSys.ScoreMarvelous, new Color(255, 255, 255) },
                { scoreSys.ScorePerfect, new Color(233, 201, 27) },
                { scoreSys.ScoreGreat, new Color(0, 231, 33) },
                { scoreSys.ScoreGood, new Color(0, 185, 231) },
                { scoreSys.ScoreBad, new Color(229, 0, 151) },
                { scoreSys.ScoreMiss, new Color(199, 0, 0) }
            };
        }
예제 #3
0
        private void DoScore(HitObject hitObject, int hitValue)
        {
            if (hitValue < 0)
            {
                return;
            }

            string hitValueName;

            if (hitValue == HitValues[ScoreMarvelous])
            {
                CurrentScoreSplash = new ScoreSplash(_gameplay.Skin.ScoreMarvelousTexture);
                MarvelousCount++;
                hitValueName = ScoreMarvelous;
            }
            else if (hitValue == HitValues[ScorePerfect])
            {
                CurrentScoreSplash = new ScoreSplash(_gameplay.Skin.ScorePerfectTexture);
                PerfectCount++;
                hitValueName = ScorePerfect;
            }
            else if (hitValue == HitValues[ScoreGreat])
            {
                CurrentScoreSplash = new ScoreSplash(_gameplay.Skin.ScoreGreatTexture);
                GreatCount++;
                hitValueName = ScoreGreat;
            }
            else if (hitValue == HitValues[ScoreGood])
            {
                CurrentScoreSplash = new ScoreSplash(_gameplay.Skin.ScoreGoodTexture);
                GoodCount++;
                hitValueName = ScoreGood;
            }
            else if (hitValue == HitValues[ScoreBad])
            {
                CurrentScoreSplash = new ScoreSplash(_gameplay.Skin.ScoreBadTexture);
                BadCount++;
                hitValueName = ScoreBad;
            }
            else if (hitValue == HitValues[ScoreMiss])
            {
                CurrentScoreSplash = new ScoreSplash(_gameplay.Skin.ScoreMissTexture);
                MissCount++;
                DoBreakCombo();
                hitValueName = ScoreMiss;
            }
            else
            {
                throw new InvalidDataException("ScoremeterScore not found");
            }

            OnScoreGet?.Invoke(this, new OnScoreGetEventHandler(hitValueName, HitValues[hitValueName], (float)FindSystem <GameTimeSystem>().Time - hitObject.Position));
            GameSystemManager.FindSystem <ScoremeterSystem>()?.AddScore((long)FindSystem <GameTimeSystem>().Time,
                                                                        hitObject.Position, hitValueName);

            ProceedCombo(hitValue);
            CalculateScore(hitValueName);
            CalculateAccuracy();
        }
예제 #4
0
        public override void Initialize()
        {
            base.Initialize();

            _gameplay = GameSystemManager.FindSystem <GameplaySystem>();

            InitValues();
        }
예제 #5
0
        private void DrawHitObjects()
        {
            var time = (long)FindSystem <GameTimeSystem>().Time;

            //foreach (var lines in SeparatedLines)
            {
                foreach (var o in Beatmap.HitObjects)
                {
                    // TODO: Make more precise work on the numbers
                    // TODO: Make _isUpsideDown (upside down) work
                    // TODO: Skip unnecessary loops
                    //int k = IsUpsideDown ? -1 : 1;

                    // Set correct position for the object
                    Vector2 position = new Vector2(
                        // x
                        Skin.Settings.PlayfieldPositionX +
                        ((o.Column - 1) * (Skin.PlayfieldLineTexture.Width)),
                        // y
                        (ScrollingSpeed * (time - o.Position) +
                         (Settings.WindowHeight - Skin.ButtonTexture.Height)) +
                        Skin.Settings.HitPosition
                        );

                    Texture2D hitObjectTexture = Skin.NoteClickTexture;

                    if (Skin.Settings.NoteType.ToLower() == "arrow")
                    {
                        // For 'arrow' skin type use texture collection
                        hitObjectTexture = Skin.NoteClickTextures[o.Column - 1];
                    }

                    // if it is a 'Click' note, just draw its texture
                    if (o is NoteClick)
                    {
                        _spriteBatch.Draw(hitObjectTexture, position, o.IsExpired ? Color.Black : Color.White);
                    }
                    else if (o is NoteHold) // if it is a 'Hold' note, draw its texture one time per 5 pixels
                    {
                        var noteHold = o as NoteHold;
                        for (int i = 0; i <= noteHold.EndPosition - noteHold.Position; i += 5)
                        {
                            position = new Vector2(
                                // x
                                Skin.Settings.PlayfieldPositionX +
                                ((noteHold.Column - 1) * (Skin.PlayfieldLineTexture.Width)),
                                // y
                                (ScrollingSpeed * (time - (noteHold.Position + i)) +
                                 (Settings.WindowHeight - Skin.ButtonTexture.Height)) +
                                Skin.Settings.HitPosition
                                );

                            _spriteBatch.Draw(hitObjectTexture, position, null, noteHold.IsExpired ? Color.Black : Color.White);
                        }
                    }

                    // Proceed miss
                    // It handles in draw method because of optimization
                    if (o.IsExpired)
                    {
                        continue;
                    }

                    var scoreSys = GameSystemManager.FindSystem <ScoreV1System>();

                    if (o.Position + scoreSys.HitThresholds[scoreSys.ScoreMiss] < time)
                    {
                        o.DoHit();
                    }
                }
            }
        }
예제 #6
0
 public T FindSystem <T>() where T : GameSystem
 {
     return(GameSystemManager?.FindSystem <T>());
 }