예제 #1
0
        internal override IncreaseScoreType Hit(HitObject h)
        {
            IncreaseScoreType val = base.Hit(h);

            if (val > 0)
            {
                float rotation = (float)(targetRandom.NextDouble() * Math.PI * 2);

                for (int i = 0; i < 5; i++)
                {
                    double actualPiceAngle = piece_angles[i] + rotation;
                    double velocity        = 300 + targetRandom.NextDouble() * 100;

                    switch (val & IncreaseScoreType.BaseHitValuesOnly)
                    {
                    case IncreaseScoreType.Hit100:
                        velocity *= 0.4;
                        break;

                    case IncreaseScoreType.Hit50:
                        velocity *= 0.01;
                        break;
                    }

                    velocity *= Math.Pow(((HitCircleOsuTarget)h).TargetAccuracy, 4);

                    Vector2 gravityVector = new Vector2(
                        (float)(velocity * Math.Cos(actualPiceAngle)),
                        (float)(velocity * Math.Sin(actualPiceAngle))
                        );

                    const int   duration = 600;
                    const int   weight   = 100;
                    const float scale    = 0.8f;

                    pSprite piece =
                        new pSprite(TextureManager.Load(@"target-pt-" + (i + 1)),
                                    Fields.Gamefield,
                                    Origins.Centre,
                                    Clocks.AudioOnce, h.EndPosition, 0.99f, false, h.Colour);
                    piece.Rotation = rotation;
                    piece.ScaleTo(piece.Scale * scale, duration);
                    piece.FadeOutFromOne(duration);

                    spriteManager.Add(piece);
                    physics.Add(piece, gravityVector).weight = weight;

                    piece =
                        new pSprite(TextureManager.Load(@"targetoverlay-pt-" + (i + 1)),
                                    Fields.Gamefield,
                                    Origins.Centre,
                                    Clocks.AudioOnce, h.EndPosition, 1, false, Color.White);
                    piece.Rotation = rotation;
                    piece.ScaleTo(piece.Scale * scale, duration);
                    piece.FadeOutFromOne(duration);

                    spriteManager.Add(piece);
                    physics.Add(piece, gravityVector).weight = weight;
                }
            }

            return(val);
        }
예제 #2
0
 internal void FlashColour(Color colour)
 {
     background.InitialColour = colour;
     background.FadeOutFromOne(1500);
 }
예제 #3
0
        public override void Update()
        {
            base.Update();

            progressBar.SetProgress((float)(elapsedTime / test_time_cooldown));

            if (!running)
            {
                return;
            }

            elapsedTime += GameBase.ElapsedMilliseconds;

            if (elapsedTime > test_time_cooldown)
            {
                startNextStage();
                return;
            }
            else if (elapsedTime > test_time)
            {
                if (!cooldown)
                {
                    benchmarkSpriteManager.SpriteList.ForEach(s => s.FadeOut(300));
                    cooldown = true;
                }

                GC.Collect();
            }

            if (stageScores.ContainsKey(activeStage))
            {
                stageScores[activeStage]++;
            }

            if (cooldown)
            {
                return;
            }

            switch (activeStage)
            {
            case Stages.TextRendering:
                const int text_lines = 4;

                if (benchmarkSpriteManager.SpriteList.Count == 0)
                {
                    for (int i = 0; i < text_lines; i++)
                    {
                        benchmarkSpriteManager.Add(new pText("Testing text rendering", 20, new Vector2(RNG.Next(0, GameBase.WindowManager.Width), RNG.Next(0, GameBase.WindowManager.Height)), new Vector2(400, 0), 1, true, Color.White, true)
                        {
                            TextAlignment = TextAlignment.Centre,
                            Origin        = Origins.Centre,
                        });
                    }
                }

                for (int i = 0; i < text_lines; i++)
                {
                    ((pText)benchmarkSpriteManager.SpriteList[i]).Text = RNG.NextDouble().ToString();
                }
                break;

            case Stages.CPUPerformance:
            case Stages.GarbageCollection:
                Color col = Color.MediumPurple;
                if (activeStage == Stages.CPUPerformance)
                {
                    benchmarkSpriteManager.Clear();
                    col = Color.GreenYellow;
                }
                else
                {
                    benchmarkSpriteManager.SpriteList.Clear();
                }

                for (int i = 0; i < 1000; i++)
                {
                    benchmarkSpriteManager.Add(new pSprite(GameBase.WhitePixel, Fields.Native, Origins.TopLeft, Clocks.Game, new Vector2(RNG.Next(0, GameBase.WindowManager.Width), RNG.Next(0, GameBase.WindowManager.Height)), 0, true, col)
                    {
                        Alpha = 1, Additive = true
                    });
                }
                break;

            case Stages.TextureLoading:
            {
                TextureManager.ClearDefaultCache();
                pSprite p = new pSprite(TextureManager.Load(@"sliderb" + RNG.Next(0, 10), SkinSource.Osu), Fields.TopLeft, Origins.TopLeft, Clocks.Game, new Vector2(RNG.Next(0, GameBase.WindowManager.Width), RNG.Next(0, GameBase.WindowManager.Height)), 0, false, Color.White)
                {
                    Additive = true,
                };
                p.FadeOutFromOne(500);

                benchmarkSpriteManager.Add(p);

                benchmarkSpriteManager.SpriteList.ForEach(s => ((pSprite)s).Texture = TextureManager.Load(@"sliderb" + RNG.Next(0, 10), SkinSource.Osu));
            }
            break;

            case Stages.Threading:
                if (benchmarkSpriteManager.SpriteList.Count == 0)
                {
                    pSprite p = new pSprite(GameBase.WhitePixel, Fields.Native, Origins.TopLeft, Clocks.Game, Vector2.Zero, 0, true, Color.Orange)
                    {
                        Additive    = true,
                        VectorScale = new Vector2(GameBase.WindowManager.Width, GameBase.WindowManager.Height)
                    };
                    p.FadeInFromZero(test_time);
                    benchmarkSpriteManager.Add(p);

                    for (int i = 0; i < 2; i++)
                    {
                        GameBase.RunBackgroundThread(delegate { while (elapsedTime < test_time)
                                                                {
                                                                    Thread.SpinWait(1);
                                                                }
                                                     });
                    }
                }
                break;

            case Stages.FillRate:
                if (benchmarkSpriteManager.SpriteList.Count == 0)
                {
                    for (int i = 0; i < 10; i++)
                    {
                        pSprite p = new pSprite(GameBase.WhitePixel, Fields.Native, Origins.TopLeft, Clocks.Game, Vector2.Zero, 0, true,
                                                new Color((byte)RNG.Next(0, 255), (byte)RNG.Next(0, 255), (byte)RNG.Next(0, 255), 255))
                        {
                            Additive    = true,
                            VectorScale = new Vector2(GameBase.WindowManager.Width, GameBase.WindowManager.Height)
                        };

                        p.FadeInFromZero(RNG.Next(10000, 30000));
                        benchmarkSpriteManager.Add(p);
                    }
                }
                break;

            case Stages.TexturedFillRate:
                if (benchmarkSpriteManager.SpriteList.Count == 0)
                {
                    for (int i = 0; i < 10; i++)
                    {
                        pSprite p = new pSprite(TextureManager.Load(@"menu-background", SkinSource.Osu), Fields.Native, Origins.TopLeft, Clocks.Game, Vector2.Zero, 0, true, Color.White);

                        if (GameBase.WindowManager.Width / GameBase.WindowManager.Height > 1.6f)
                        {
                            p.VectorScale = new Vector2(GameBase.WindowManager.Width / GameBase.WindowManager.Ratio / WindowManager.DEFAULT_WIDTH, GameBase.WindowManager.Height / GameBase.WindowManager.Ratio / WindowManager.DEFAULT_HEIGHT);
                        }

                        p.Additive = true;

                        p.FadeInFromZero(20000);
                        benchmarkSpriteManager.Add(p);
                    }
                }
                break;
            }
        }