Exemple #1
0
        /// <summary>
        /// Get the JudgementValue:Texture KVP for the HitError bar given the current JudgementValue
        /// </summary>
        /// <param name="judgeVal">The JudgementValue used to find the KVP.</param>
        /// <returns>The JudgementValue:Texture KVP for a HitError bar.</returns>
        public KeyValuePair <JudgementValue, Texture2D> GetJudge(JudgementValue judgeVal)
        {
            KeyValuePair <JudgementValue, Texture2D> judgePair = new KeyValuePair <JudgementValue, Texture2D>();

            foreach (KeyValuePair <JudgementValue, Texture2D> pair in judges)
            {
                if (pair.Key.Judge == judgeVal.Judge)
                {
                    judgePair = pair;
                    break;
                }
            }

            return(judgePair);
        }
Exemple #2
0
        /// <summary>
        /// Used to determine where to draw each HitError on the bar.
        /// </summary>
        /// <param name="error">The error time of the hit.</param>
        /// <returns></returns>
        private Vector2 GetErrorPixelPosition(int error)
        {
            JudgementValue judgement = Judgement.GetJudgementValueByError(Math.Abs(error));

            int baseX         = (int)(TruePosition.X + Size.X / 2);
            int sectionLength = getJudgePixelLength();
            int sectionX      = Judgement.Judgements.IndexOf(judgement) * sectionLength;
            int timeSize      = judgement.Judge - Judgement.GetPreviousJudgementValue(judgement).Judge;

            float judgePos = 0;

            if (timeSize > 0)
            {
                judgePos = (judgement.Judge - Math.Abs(error)) / (float)timeSize;
            }

            int errorX = (int)((sectionX + (1 - judgePos) * sectionLength) * Math.Sign(error));

            return(new Vector2(baseX - errorX, TruePosition.Y));
        }
        /// <summary>
        /// Add the judgement and the total of that judgement to the Result Screen.
        /// </summary>
        /// <param name="name">The name of the judgement.</param>
        private void AddJudgeInfo(string name)
        {
            string         configName = char.ToUpper(name[0]) + name.Substring(1);
            JudgementValue judgement  = Judgement.GetJudgementValueByName(name);

            // Judge
            Vector2 position = Skin.GetConfigStartPosition(Config, Sections[2], $"{configName}StartPos", scorecard);
            int     offsetX  = GetSkinnableJudgementInt($"{configName}X");
            int     offsetY  = GetSkinnableJudgementInt($"{configName}Y");
            float   scale    = GetSkinnableJudgementFloat($"{configName}Scale") * Pulsarc.HeightScale;

            Judge judge = new Judge(judgement.Score, position, scale);

            judge.Move(offsetX, offsetY);

            // JudgeCount
            TextDisplayElement text = MakeTextDisplayElement($"{configName}Count", Sections[2]);

            text.Name  = name;
            text.Color = judgement.Color;

            judgements.Add(new KeyValuePair <Judge, TextDisplayElement>(judge, text));
        }
Exemple #4
0
        /// <summary>
        /// A graph that shows all the hits of a play on the Result Screen.
        /// </summary>
        /// <param name="position">The position of the Graph</param>
        /// <param name="width">The width of the Graph</param>
        /// <param name="height">The height of the Graph</param>
        /// <param name="hits">A list of all hits, KVP[time, judgescore]</param>
        public HitErrorGraph(Vector2 position, int width, int height, List <KeyValuePair <double, int> > hits, Anchor anchor = Anchor.TopLeft)
            : base(Skin.DefaultTexture, position, anchor: anchor)
        {
            Width  = width;
            Height = height;
            Hits   = hits;

            Texture = new Texture2D(Pulsarc.Graphics.GraphicsDevice, width, height);
            Color[] graphBG = new Color[width * height];

            JudgementValue miss = Judgement.GetMiss();

            // Draw the graph
            for (int x = 0; x < width; x++)
            {
                for (int y = 0; y < height; y++)
                {
                    graphBG[(y * width) + x] = Judgement.GetJudgementValueByError((int)Math.Abs(((y - (height / 2)) * miss.Judge / (float)height * 2))).Color * 0.3f;
                }
            }

            /*
             * hits = new List<KeyValuePair<long, int>>();
             * int t = 1;
             * for (int j = -Judgement.getMiss().judge; j <= Judgement.getMiss().judge; j++)
             * {
             *  hits.Add(new KeyValuePair<long, int>(t++, j));
             * }
             * for (int j = Judgement.getMiss().judge; j >= -Judgement.getMiss().judge; j--)
             * {
             *  hits.Add(new KeyValuePair<long, int>(t++, j));
             * }
             */

            // Draw the hits
            if (hits.Count > 0)
            {
                maxTime = 0;

                foreach (KeyValuePair <double, int> hit in hits)
                {
                    maxTime = maxTime < hit.Key ? hit.Key : maxTime;
                }

                maxTime += 4000;

                foreach (KeyValuePair <double, int> hit in hits)
                {
                    KeyValuePair <Vector2, Color> info = getHitInfo(hit);

                    for (int yp = -1; yp < 2; yp++)
                    {
                        for (int xp = -1; xp < 2; xp++)
                        {
                            int pos = (int)((int)(info.Key.Y + yp) * width + (info.Key.X + xp));

                            if (pos >= 0 && pos < width * height)
                            {
                                graphBG[pos] = info.Value;
                            }
                        }
                    }
                }
            }

            Texture.SetData(graphBG);
        }