private bool onClick(object sender, EventArgs e) { if (coinsDialog != null && coinsDialog.Alpha == 1) { if (coinsDialog.Hovering) { pSprite error; spriteManagerDialog.Add(error = new pSprite(@"coins-error", new Vector2(0, 0), SkinSource.All, Origins.Centre, Fields.Centre) { Depth = 0.9f, Scale = 1.4f }); error.AlwaysDraw = false; error.FadeOut(5000, EasingTypes.InExpo); error.ScaleTo(1, 200, EasingTypes.OutElastic); Recharge(); } else { coinsDialog.FadeOut(100); } coinsDialog.AlwaysDraw = false; coinsDialog = null; return(true); } return(false); }
private void explode(int beat, float strength = 1) { pDrawable explosion = explosions[beat]; if (explosion.Alpha == 0 && !menuBackgroundNew.IsAwesome && osuLogo.ScaleScalar >= 0.6f) { explosion.ScaleScalar *= 1.3f; explosion.FadeIn(100); } if (!menuBackgroundNew.IsAwesome) { float adjust = beat == 0 ? (1 - 0.1f * strength) : (beat == 1 ? (1 + 0.05f * strength) : 1); if (osuLogo.Transformations.Count != 0 && osuLogo.Transformations[0] is TransformationBounce) { ((TransformationBounce)osuLogo.Transformations[0]).EndFloat *= adjust; } else { osuLogo.ScaleScalar *= adjust; osuLogo.ScaleTo(0.625f, 500, EasingTypes.In); } } explosion.FlashColour(ColourHelper.Lighten2(explosion.Colour, 0.4f * strength), 350); explosion.ScaleScalar *= 1 + (0.2f * strength); explosion.ScaleTo(sizeForExplosion(beat), 400, EasingTypes.In); }
private void fadeInThumbnail() { if (previewThumbnail.Texture == null) { return; } if (disallowAudioPreview || sampleTrack != null) { previewThumbnail.FadeTo(1, 400, EasingTypes.Out); previewThumbnail.ScaleTo(1.2f, 600, EasingTypes.OutElastic); } else { previewThumbnail.FadeTo(0.6f, 5000, EasingTypes.Out); previewThumbnail.ScaleTo(1.2f, 20000, EasingTypes.Out); } }
internal override void UpdateInput() { if (GameBase.SixtyFramesPerSecondFrame) { if ((!InputManager.ReplayMode && KeyboardHandler.IsKeyDown(BindingManager.For(Bindings.OsuSmoke))) || (InputManager.ReplayMode && InputManager.CurrentReplayFrame != null && (InputManager.CurrentReplayFrame.buttonState & pButtonState.Smoke) > 0)) { float distance = lastSmokeSprite != null?Vector2.Distance(lastSmokeSprite.Position, InputManager.CursorPosition) : 0; float acceptedWidth = Math.Max(2, lastSmokeSprite != null ? (lastSmokeSprite.DrawWidth * 0.625f * GameBase.WindowManager.Ratio) / 4f : 0); int steps = Math.Max(1, (int)(distance / acceptedWidth)); Vector2 end = InputManager.CursorPosition; if (lastSmokeSprite == null || lastSmokeSprite.Position != end) { Vector2 start = lastSmokeSprite != null ? lastSmokeSprite.Position + Vector2.Normalize(end - lastSmokeSprite.Position) * Math.Min(distance, acceptedWidth) : InputManager.CursorPosition; for (int j = 0; j < steps; j++) { pSprite smoke = new pSprite(t_smoke, Fields.NativeStandardScale, Origins.Centre, Clocks.Game, Vector2.Lerp(start, end, (float)j / steps), 1, false, Color.White); smoke.Additive = true; smoke.Alpha = 0.6f; smoke.Scale = 0.5f; smoke.Rotation = RNG.NextSingle(10f); smoke.RotateTo(smoke.Rotation + RNG.NextSingle(-0.25f, 0.25f), 500, EasingTypes.Out); smoke.ScaleTo(smoke.Scale * 1f, 2000, EasingTypes.Out); smoke.FadeOut(4000); player.spriteManagerBelowHitObjectsWidescreen.Add(smoke); lastSmokeTrailLength.Add(smoke); lastSmokeSprite = smoke; } } if (lastSmokeTrailLength.Count > 50 && Vector2.Distance(lastSmokeSprite.Position, lastSmokeTrailLength[0].Position) < 10) { endTrail(); } } else { endTrail(); lastSmokeSprite = null; } } base.UpdateInput(); }
internal void SetStatus(bool status, Mods specificStatus = Mods.None, bool playSound = true) { Sprites.ForEach(s => { s.FadeOut(100); s.ScaleTo(1, 400, EasingTypes.OutElastic); s.RotateTo(0, 400, EasingTypes.OutElastic); }); Mods lastState = State; if (!status) { State = Mods.None; Sprites[0].FadeIn(100); } else { pSprite match = Sprites.Find(s => s.TagNumeric == (int)specificStatus); if (match == null || specificStatus == Mods.None) { match = Sprites[0]; } State = (Mods)match.TagNumeric; match.FadeIn(100); match.ScaleTo(1.2f, 400, EasingTypes.OutElastic); match.RotateTo(0.1f, 400, EasingTypes.OutElastic); } glow.FadeTo(State == Mods.None ? 0 : 0.2f, 100); if (lastState != State && playSound) { AudioEngine.Click(null, State != Mods.None ? @"check-on" : @"check-off"); } if (StateChanged != null) { StateChanged(this, null); } }
internal void UpdateStarDifficultyDisplay(bool instant) { if (!IsLoaded || Beatmap == null || state < TreeItemState.ExtrasVisible) { return; } double stars = Math.Min(Beatmap.StarDisplay, 10.0); // We don't want to deal with more than 10 stars in this display if (currentlyVisibleStars == stars) { return; } double previouslyVisibleStars = currentlyVisibleStars; currentlyVisibleStars = stars; UpdateDifficultyText(); // We want the -1 placeholder for "inexistant difficulty" to be treated like 0 stars here if (stars < 0) { stars = 0; int BackgroundStarSpritesEndIndex = starSpritesBeginIndex + AMOUNT_STARS; for (int i = starSpritesBeginIndex; i < BackgroundStarSpritesEndIndex; ++i) { pDrawable starSprite = SpriteCollection[i]; starSprite.FadeOut(instant ? 0 : (OldLayout ? 1000 : 600)); } } // ... with the exception of the background stars appearing. We want these to only appear once difficulty has been computed. (for looking good!) else { int BackgroundStarSpritesEndIndex = starSpritesBeginIndex + AMOUNT_STARS; for (int i = starSpritesBeginIndex; i < BackgroundStarSpritesEndIndex; ++i) { pDrawable starSprite = SpriteCollection[i]; starSprite.FadeIn(instant ? 0 : (OldLayout ? 1000 : 600)); } } int StarSpritesEndIndex = starSpritesBeginIndex + AMOUNT_STARS * 2; for (int i = starSpritesBeginIndex + AMOUNT_STARS; i < StarSpritesEndIndex; ++i) { int starIndex = i - (starSpritesBeginIndex + AMOUNT_STARS); double starsLeft = stars - starIndex; pSprite starSprite = SpriteCollection[i] as pSprite; starSprite.Transformations.Clear(); if (OldLayout) { int targetWidth = (int)(starSprite.Width * starsLeft); // It is important to also clip the width to negative values so the animation is delayed when the stars potentially appear again after the difficulty has been computed. // Don't optimize this and set to 0! starSprite.ClipWidthTo(targetWidth, instant ? 0 : 500, EasingTypes.OutCubic); } else { float newScale = starsLeft <= 0 ? 0 : star_scale * (float)Math.Max(0.5f, Math.Min(1, starsLeft) + starIndex * 0.04f); int amountStarsScaled = (int)Math.Floor(starIndex - Math.Min(stars, previouslyVisibleStars)); if (instant) { starSprite.ScaleTo(newScale, 0); } else { int timeAddition = previouslyVisibleStars <= stars ? amountStarsScaled : (int)Math.Floor(previouslyVisibleStars - stars) - amountStarsScaled - 1; int startTime = GameBase.Time + timeAddition * 80 + 50; starSprite.Transformations.Add(new Transformation(TransformationType.Scale, starSprite.Scale, newScale, startTime, startTime + 500, EasingTypes.OutBack)); } } } }
private void initializeDifficultySelection() { const float yOffset = 0; s_ModeButtonStream = new pSprite(TextureManager.Load(OsuTexture.songselect_mode_stream), FieldTypes.StandardSnapCentre, OriginTypes.Centre, ClockTypes.Mode, new Vector2(0, 0), 0.4f, true, Color4.White) { Offset = new Vector2(0, yOffset), HandleClickOnUp = true }; s_ModeButtonStream.OnClick += onModeButtonClick; spriteManagerDifficultySelect.Add(s_ModeButtonStream); s_SongInfo = new pSprite(TextureManager.Load(OsuTexture.songselect_songinfo), FieldTypes.StandardSnapRight, OriginTypes.TopRight, ClockTypes.Mode, new Vector2(0, 0), 0.95f, true, Color4.White); s_SongInfo.Alpha = 0; s_SongInfo.OnClick += onSongInfoClick; topmostSpriteManager.Add(s_SongInfo); s_ModeButtonEasy = new pSprite(TextureManager.Load(OsuTexture.songselect_mode_easy), FieldTypes.StandardSnapCentre, OriginTypes.Centre, ClockTypes.Mode, new Vector2(0, 0), 0.4f, true, Color4.White) { Offset = new Vector2(-mode_button_width, yOffset), HandleClickOnUp = true }; s_ModeButtonEasy.OnClick += onModeButtonClick; spriteManagerDifficultySelect.Add(s_ModeButtonEasy); s_ModeButtonExpert = new pSprite(TextureManager.Load(OsuTexture.songselect_mode_expert), FieldTypes.StandardSnapCentre, OriginTypes.Centre, ClockTypes.Mode, new Vector2(0, 0), 0.4f, true, Color4.White) { Offset = new Vector2(mode_button_width, yOffset), HandleClickOnUp = true }; s_ModeButtonExpert.OnClick += onModeButtonClick; spriteManagerDifficultySelect.Add(s_ModeButtonExpert); const float arrow_spread = 180; s_ModeArrowLeft = new pSprite(TextureManager.Load(OsuTexture.songselect_mode_arrow), FieldTypes.StandardSnapCentre, OriginTypes.Centre, ClockTypes.Mode, new Vector2(-arrow_spread, yOffset), 0.45f, true, Color4.White); s_ModeArrowLeft.ClickableMargin = 30; s_ModeArrowLeft.OnHover += delegate { s_ModeArrowLeft.ScaleTo(1.2f, 100, EasingTypes.In); }; s_ModeArrowLeft.OnHoverLost += delegate { s_ModeArrowLeft.ScaleTo(1f, 100, EasingTypes.In); }; s_ModeArrowLeft.OnClick += onSelectPreviousMode; spriteManagerDifficultySelect.Add(s_ModeArrowLeft); s_ModeArrowRight = new pSprite(TextureManager.Load(OsuTexture.songselect_mode_arrow), FieldTypes.StandardSnapCentre, OriginTypes.Centre, ClockTypes.Mode, new Vector2(arrow_spread, yOffset), 0.45f, true, Color4.DarkGray); s_ModeArrowRight.ClickableMargin = 30; s_ModeArrowRight.OnHover += delegate { s_ModeArrowRight.ScaleTo(1.2f, 100, EasingTypes.In); }; s_ModeArrowRight.OnHoverLost += delegate { s_ModeArrowRight.ScaleTo(1f, 100, EasingTypes.In); }; s_ModeArrowRight.OnClick += onSelectNextMode; s_ModeArrowRight.Rotation = 1; spriteManagerDifficultySelect.Add(s_ModeArrowRight); s_ModeDescriptionText = new pText(string.Empty, 30, new Vector2(0, 110), 1, true, Color4.White) { Field = FieldTypes.StandardSnapCentre, Origin = OriginTypes.Centre, TextAlignment = TextAlignment.Centre }; spriteManagerDifficultySelect.Add(s_ModeDescriptionText); s_ScoreInfo = new pText(null, 24, new Vector2(GameBase.SuperWidePadding, 64), Vector2.Zero, 1, true, Color4.White, true); s_ScoreInfo.OnClick += Handle_ScoreInfoOnClick; spriteManagerDifficultySelect.Add(s_ScoreInfo); s_ScoreRank = new pSprite(null, new Vector2(GameBase.SuperWidePadding, 72)) { DrawDepth = 0.95f }; s_ScoreRank.OnClick += Handle_ScoreInfoOnClick; spriteManagerDifficultySelect.Add(s_ScoreRank); }
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); }
private void Director_OnTransitionEnded() { //hit -> combo -> accuracy -> spin int time = cameFromSongSelect ? 0 : 500; int increment = cameFromSongSelect ? 0 : 500; GameBase.Scheduler.Add(delegate { AudioEngine.PlaySample(OsuSamples.RankingBam); countScoreHit.ShowInt(RankableScore.hitScore, 6); countScoreHit.AdditiveFlash(500, 1); addedScore += RankableScore.hitScore; countTotalScore.ShowInt(addedScore, 6, true); countTotalScore.FlashColour(Color4.White, 1000); }, time); time += increment; GameBase.Scheduler.Add(delegate { AudioEngine.PlaySample(OsuSamples.RankingBam); countScoreCombo.ShowInt(RankableScore.comboBonusScore, 6); countScoreCombo.AdditiveFlash(500, 1); addedScore += RankableScore.comboBonusScore; countTotalScore.ShowInt(addedScore, 6, true); countTotalScore.FlashColour(Color4.White, 1000); }, time); time += increment; GameBase.Scheduler.Add(delegate { AudioEngine.PlaySample(OsuSamples.RankingBam); countScoreAccuracy.ShowInt(RankableScore.accuracyBonusScore, 6); countScoreAccuracy.AdditiveFlash(500, 1); addedScore += RankableScore.accuracyBonusScore; countTotalScore.ShowInt(addedScore, 6, true); countTotalScore.FlashColour(Color4.White, 1000); }, time); time += increment; GameBase.Scheduler.Add(delegate { AudioEngine.PlaySample(OsuSamples.RankingBam); countScoreSpin.ShowInt(RankableScore.spinnerBonusScore, 6); countScoreSpin.AdditiveFlash(500, 1); addedScore += RankableScore.spinnerBonusScore; countTotalScore.ShowInt(addedScore, 6, true); countTotalScore.FlashColour(Color4.White, 1000); }, time); time += increment; GameBase.Scheduler.Add(delegate { if (RankableScore.Ranking == Rank.D) { AudioEngine.PlaySample(OsuSamples.RankFail); rankGraphic.FadeIn(2000); rankGraphic.ScaleScalar = 0.7f; rankGraphic.ScaleTo(1, 1400, EasingTypes.In); GameBase.Scheduler.Add(delegate { int interval = 100; rankGraphic.Transform(new TransformationF(TransformationType.Rotation, 0, 0.3f, Clock.Time, Clock.Time + interval)); rankGraphic.Transform(new TransformationF(TransformationType.Rotation, 0.3f, -0.3f, Clock.Time + interval, Clock.Time + interval * 3)); rankGraphic.Transform(new TransformationF(TransformationType.Rotation, -0.3f, 0, Clock.Time + interval * 3, Clock.Time + interval * 4)); }, 1550); } else { AudioEngine.PlaySample(OsuSamples.RankPass); rankGraphic.FadeIn(4000); GameBase.Scheduler.Add(delegate { rankGraphic.Transformations.Clear(); rankGraphic.Alpha = 1; rankGraphic.AdditiveFlash(1500, 1); }, 1400); } }, time); time += increment + 1200; if (isPersonalBest) { GameBase.Scheduler.Add(delegate { pSprite personalBest = new pSprite(TextureManager.Load(OsuTexture.personalbest), FieldTypes.StandardSnapBottomRight, OriginTypes.Centre, ClockTypes.Mode, new Vector2(80, 250), 1, true, Color4.White); personalBest.FadeInFromZero(250); personalBest.ScaleScalar = 1.6f; personalBest.RotateTo(0.2f, 250); personalBest.ScaleTo(1, 250, EasingTypes.Out); GameBase.Scheduler.Add(delegate { personalBest.AdditiveFlash(1000, 1).ScaleTo(1.05f, 1000); }, 250); layer1.Add(personalBest); }, time); } time += increment; if (!cameFromSongSelect) { GameBase.Scheduler.Add(finishDisplaying, time); } }
private void doSubmission() { int deviceType = 0; #if iOS if (!GameBase.Mapper) { deviceType = (int)osum.Support.iPhone.HardwareDetection.Version; //todo: for iOS5 twitter authentication, we need to double-check we actually have auth. string hash = GameBase.Config.GetValue <string>("hash", null); if (hash == null) { //todo: no twitter auth. are we not submitting anymore? return; } else if (hash.StartsWith("ios-")) { hash = hash.Substring(4); using (ACAccountStore store = new ACAccountStore()) { ACAccount account = store.FindAccount(hash); if (account != null) { //yay, i think. //todo: test that this actually checks grants (it should in theory). } else { GameBase.Notify("Twitter authentication failed. Please visit the options screen to login again."); GameBase.Config.SetValue <string>("username", null); GameBase.Config.SetValue <string>("hash", null); GameBase.Config.SetValue <string>("twitterId", null); GameBase.Config.SaveConfig(); return; } } } string check = CryptoHelper.GetMd5String("moocow" + GameBase.Instance.DeviceIdentifier + RankableScore.count100 + RankableScore.count300 + RankableScore.count50 + RankableScore.countMiss + RankableScore.maxCombo + RankableScore.spinnerBonusScore + RankableScore.comboBonusScore + RankableScore.accuracyBonusScore + RankableScore.Ranking + Path.GetFileName(Player.Beatmap.ContainerFilename) + deviceType + RankableScore.hitScore + (int)Player.Difficulty); string postString = "udid=" + GameBase.Instance.DeviceIdentifier + "&count300=" + RankableScore.count300 + "&count100=" + RankableScore.count100 + "&count50=" + RankableScore.count50 + "&countMiss=" + RankableScore.countMiss + "&maxCombo=" + RankableScore.maxCombo + "&spinnerBonus=" + RankableScore.spinnerBonusScore + "&comboBonus=" + RankableScore.comboBonusScore + "&accuracyBonus=" + RankableScore.accuracyBonusScore + "&hitScore=" + RankableScore.hitScore + "&rank=" + RankableScore.Ranking + "&filename=" + NetRequest.UrlEncode(Path.GetFileName(Player.Beatmap.ContainerFilename)) + "&cc=" + GameBase.Config.GetValue <string>("hash", string.Empty) + "&c=" + check + "&difficulty=" + (int)Player.Difficulty + "&username="******"username", string.Empty) + "&twitterid=" + GameBase.Config.GetValue <string>("twitterId", string.Empty) + "&dt=" + deviceType + "&offset=" + avg; spriteSubmitting = new pSprite(TextureManager.Load(OsuTexture.songselect_audio_preview), FieldTypes.StandardSnapRight, OriginTypes.Centre, ClockTypes.Game, new Vector2(20, 20), 0.999f, true, Color4.White) { ExactCoordinates = false, DimImmune = true, ScaleScalar = 0.7f }; spriteSubmitting.Transform(new TransformationF(TransformationType.Rotation, 0, MathHelper.Pi * 2, Clock.Time, Clock.Time + 1500) { Looping = true }); GameBase.MainSpriteManager.Add(spriteSubmitting); spriteSubmitting.FadeInFromZero(300); StringNetRequest nr = new StringNetRequest("https://www.osustream.com/score/submit.php", "POST", postString); nr.onFinish += delegate(string result, Exception e) { spriteSubmitting.AlwaysDraw = false; if (e == null) { spriteSubmitting.FadeOut(200); spriteSubmitting.ScaleTo(3, 200); spriteSubmitting.Colour = Color4.YellowGreen; } else { spriteSubmitting.FadeOut(1000); spriteSubmitting.ScaleTo(1.2f, 200, EasingTypes.In); spriteSubmitting.Colour = Color4.Red; } if (e == null && result != null && result.StartsWith("message:")) { rankingNotification = new Notification("Ranking", result.Replace("message:", string.Empty), NotificationStyle.Okay); if (finishedDisplaying) { GameBase.Notify(rankingNotification); } } }; NetManager.AddRequest(nr); } #endif }