-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathKiaiGameplayFountains.cs
106 lines (86 loc) · 3.19 KB
/
KiaiGameplayFountains.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Utils;
using osu.Game.Configuration;
using osu.Game.Graphics.Containers;
using osu.Game.Screens.Menu;
namespace osu.Game.Screens.Play
{
public partial class KiaiGameplayFountains : BeatSyncedContainer
{
private StarFountain leftFountain = null!;
private StarFountain rightFountain = null!;
private Bindable<bool> kiaiStarFountains = null!;
private Sample? sample;
private SampleChannel? sampleChannel;
[BackgroundDependencyLoader]
private void load(OsuConfigManager config, AudioManager audio)
{
kiaiStarFountains = config.GetBindable<bool>(OsuSetting.StarFountains);
RelativeSizeAxes = Axes.Both;
Children = new[]
{
leftFountain = new GameplayStarFountain
{
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
X = 75,
},
rightFountain = new GameplayStarFountain
{
Anchor = Anchor.BottomRight,
Origin = Anchor.BottomRight,
X = -75,
},
};
sample = audio.Samples.Get(@"Gameplay/fountain-shoot");
}
private bool isTriggered;
protected override void Update()
{
base.Update();
if (!kiaiStarFountains.Value)
return;
if (EffectPoint.KiaiMode && !isTriggered)
{
bool isNearEffectPoint = Math.Abs(BeatSyncSource.Clock.CurrentTime - EffectPoint.Time) < 500;
if (isNearEffectPoint)
Shoot();
}
isTriggered = EffectPoint.KiaiMode;
}
public void Shoot()
{
leftFountain.Shoot(1);
rightFountain.Shoot(-1);
// Track sample channel to avoid overlapping playback
sampleChannel?.Stop();
sampleChannel = sample?.GetChannel();
sampleChannel?.Play();
}
public partial class GameplayStarFountain : StarFountain
{
protected override StarFountainSpewer CreateSpewer() => new GameplayStarFountainSpewer();
private partial class GameplayStarFountainSpewer : StarFountainSpewer
{
protected override double ShootDuration => 400;
public GameplayStarFountainSpewer()
: base(perSecond: 180)
{
}
protected override float GetCurrentAngle()
{
const float x_velocity_from_direction = 450;
const float x_velocity_to_direction = 600;
return LastShootDirection * RNG.NextSingle(x_velocity_from_direction, x_velocity_to_direction);
}
}
}
}
}