-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBridge.cs
184 lines (141 loc) · 7.78 KB
/
Bridge.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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
using OpenTK;
using OpenTK.Graphics;
using StorybrewCommon.Mapset;
using StorybrewCommon.Scripting;
using StorybrewCommon.Storyboarding;
using StorybrewCommon.Storyboarding.Util;
using StorybrewCommon.Subtitles;
using StorybrewCommon.Util;
using StorybrewCommon.Animations;
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
namespace StorybrewScripts
{
public class Bridge : StoryboardObjectGenerator
{
public override bool Multithreaded => true;
// Playfield dimensions
float width = 250f;
float height = 400;
public override void Generate()
{
var receptors = GetLayer("receptors");
var notes = GetLayer("notes");
// Define general values
var starttime = 83256;
var endtime = 120444;
var duration = endtime - starttime;
// Note initialization parameters
var bpm = 161.34f;
var offset = -46f;
// DrawInstance configuration
var updatesPerSecond = 100;
var scrollSpeed = 1250f;
var rotateNotesToFaceReceptor = false;
var fadeTime = 60;
var receptorBitmap = GetMapsetBitmap("sb/sprites/receiver.png"); // Receptor sprite
var receptorWidth = receptorBitmap.Width;
Playfield field = new Playfield();
field.initilizePlayField(receptors, notes, starttime, endtime, width, height, 50);
field.initializeNotes(Beatmap.HitObjects.ToList(), bpm, offset, true, false);
DrawInstance draw = new DrawInstance(field, starttime, scrollSpeed, updatesPerSecond, OsbEasing.None, rotateNotesToFaceReceptor, fadeTime, fadeTime);
var flashLayer = GetLayer("flash2");
var whiteBG = flashLayer.CreateSprite("sb/white.png", OsbOrigin.Centre);
whiteBG.Scale(83256, 83256, 2, 2);
whiteBG.Fade(83256, 83628, 1, 0);
whiteBG.Additive(83256, 83256);
List<ColumnType[]> switchEffects = new List<ColumnType[]>{
new ColumnType[] { ColumnType.one, ColumnType.two, ColumnType.three, ColumnType.four },
new ColumnType[] { ColumnType.one, ColumnType.three, ColumnType.two, ColumnType.four },
new ColumnType[] { ColumnType.one, ColumnType.four, ColumnType.two, ColumnType.three },
new ColumnType[] { ColumnType.two, ColumnType.one, ColumnType.four, ColumnType.two }
};
YAxisDropSwitchEffect(field, starttime, 101106, Math.Abs(83442 - starttime), switchEffects);
SlowResizeEffect(field, starttime, 101106, Math.Abs(89113 - starttime));
var index = 0;
var start = 101106;
var beatDuration = (101478 - 101106);
var value = 10;
field.Resize(OsbEasing.OutCirc, 101106, 101106 + 1000, 0.1f, height, true);
field.MoveColumnRelative(OsbEasing.OutCirc, start, start + beatDuration, new Vector2(-13, -75), ColumnType.one);
field.MoveColumnRelative(OsbEasing.OutCirc, start, start + beatDuration, new Vector2(0, 5), ColumnType.two);
field.MoveColumnRelative(OsbEasing.OutCirc, start, start + beatDuration, new Vector2(0, 5), ColumnType.three);
field.MoveColumnRelative(OsbEasing.OutCirc, start, start + beatDuration, new Vector2(13, -75), ColumnType.four);
while (start <= 118957) {
field.RotateColumn(OsbEasing.None, start, start + beatDuration, Math.PI / value, ColumnType.one, CenterType.receptor);
field.RotateColumn(OsbEasing.None, start, start + beatDuration, Math.PI / value * -1, ColumnType.two, CenterType.receptor);
field.RotateColumn(OsbEasing.None, start, start + beatDuration, Math.PI / value, ColumnType.three, CenterType.receptor);
field.RotateColumn(OsbEasing.None, start, start + beatDuration, Math.PI / value * -1, ColumnType.four, CenterType.receptor);
start += beatDuration;
index++;
}
field.moveFieldY(OsbEasing.OutCirc, 101106, 101106 + 1000, 170);
NoteRubberScaleEffect(field, 101106, 118957, beatDuration);
field.Scale(OsbEasing.InCirc, 118957, 120444, new Vector2(1.5f));
field.RotateColumn(OsbEasing.None, 118957, 120444, Math.PI / 0.5, ColumnType.one, CenterType.receptor);
field.RotateColumn(OsbEasing.None, 118957, 120444, Math.PI / -0.5, ColumnType.two, CenterType.receptor);
field.RotateColumn(OsbEasing.None, 118957, 120444, Math.PI / 0.5, ColumnType.three, CenterType.receptor);
field.RotateColumn(OsbEasing.None, 118957, 120444, Math.PI / -0.5, ColumnType.four, CenterType.receptor);
draw.drawNotesByOriginToReceptor(duration, false);
var flashLayer1 = GetLayer("flash");
var whiteBG1 = flashLayer1.CreateSprite("sb/white.png", OsbOrigin.Centre);
whiteBG1.Scale(118957, 118957, 2, 2);
whiteBG1.Fade(118957, 120444, 0, 1);
}
public void YAxisDropSwitchEffect(Playfield field, int start, int end, int effectDuration, List<ColumnType[]> switchEffects) {
var startBeat = start;
var index = 0;
var iterateIndex = 0;
var effectIndex = 0;
var effectCount = switchEffects.Count;
var shouldStartNegativeY = false;
var switchColumn = false;
while (startBeat <= end) {
var currentEffectList = switchEffects[effectIndex];
var value = shouldStartNegativeY ? -75 : 75;
if (switchColumn) {
field.MoveColumnRelativeY(OsbEasing.OutCirc, startBeat, startBeat + effectDuration, value, currentEffectList[2]);
field.MoveColumnRelativeY(OsbEasing.OutCirc, startBeat, startBeat + effectDuration, value, currentEffectList[3]);
} else {
field.MoveColumnRelativeY(OsbEasing.OutCirc, startBeat, startBeat + effectDuration, value, currentEffectList[0]);
field.MoveColumnRelativeY(OsbEasing.OutCirc, startBeat, startBeat + effectDuration, value, currentEffectList[1]);
}
startBeat += effectDuration;
index += 1;
if (iterateIndex == 1) {
iterateIndex = 0;
switchColumn = !switchColumn;
} else {
iterateIndex++;
}
if (index % 16 == 0) {
if (effectIndex < effectCount - 1) {
effectIndex++;
} else {
effectIndex = 0;
}
}
shouldStartNegativeY = !shouldStartNegativeY;
}
}
public void SlowResizeEffect(Playfield field ,int startScale, int endScale, int beatDuration) {
var index = 0;
while (index < 3) {
field.Resize(OsbEasing.InOutCirc, startScale, startScale + beatDuration, index % 2 == 0 ? width + 300 : (width * -1) - 300, height);
startScale += beatDuration;
index += 1;
}
}
public void NoteRubberScaleEffect(Playfield field ,int startScale, int endScale, int beatDuration) {
var index = 0;
while (startScale <= endScale) {
field.Scale(OsbEasing.None, startScale, startScale, new Vector2(1f), true);
field.Scale(OsbEasing.OutCirc, startScale, startScale + beatDuration, new Vector2(0.5f), true);
startScale += beatDuration;
index += 1;
}
}
}
}