Пример #1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="hit"></param>
 /// <returns></returns>
 private KeyValuePair <Vector2, Color> getHitInfo(KeyValuePair <double, int> hit)
 {
     return(new KeyValuePair <Vector2, Color>(
                new Vector2
                (
                    (float)((2000 + hit.Key) / maxTime * Width),
                    (-hit.Value / (float)Judgement.GetMiss().Judge *Height / 2f) + Height / 2
                ),
                Judgement.GetJudgementValueByError(Math.Abs(hit.Value)).Color));
 }
Пример #2
0
        /// <summary>
        /// Draw the meter and every HitError bar on the meter. Makes HitError bars transparent depending on how much "Life" they have left.
        /// </summary>
        public override void Draw()
        {
            Pulsarc.SpriteBatch.Draw(Texture, position: TruePosition, rotation: Rotation, origin: origin, color: Color.White * 0.3f);

            foreach (KeyValuePair <double, int> error in errors)
            {
                KeyValuePair <JudgementValue, Texture2D> judgeBar = GetJudge(Judgement.GetJudgementValueByError(Math.Abs(error.Value)));

                Pulsarc.SpriteBatch.Draw(judgeBar.Value, position: GetErrorPixelPosition(error.Value), rotation: Rotation, origin: origin, color: judgeBar.Key.Color * (float)LifeLeft(error.Key, lastTime));
            }
        }
Пример #3
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));
        }
Пример #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);
        }