Skip to content

Commit cf8e11a

Browse files
cornerloanLifeHckr
andauthored
Event rooms (#207)
* Event room added currently not accessible in the game, but can be tested through running the scene * added translations to event * Fix up EventScene Prep for eventual integration * Event outcomes added * First event added I don't see any reasons why this shouldn't work, but I haven't tested it * events now on the map, events now have prerequisites Hope you like Italian, I'm making spaghetti * 2 events, events now have self reference 🍝 Added parmesan to the spaghetti * Game now saves MaxComboBar, added field medic event We never actually needed to save MaxComboBar since energy drink was an onPickup effect. With this event, we now need to save the MaxComboBar value between sessions. Also adjusted event 2's translations and healing effect since I messed up both of those. * Finished event 2 Now no longer costs money to play. All spin odds are equal chance to occur. Wheel colors are synced to events, in case we decide to add art to each segment. 4 positive events, 2 negative events * async? more like not async if we have any events that have multiple different text outputs based on RNG we should set their initial output to "" * Refine event scene EventActions take EventScene as a node Conditions and actions can be null instead of holding a func point to () => true Handle continue button in scene instead of ContinuePressed * Fix Wheel event not resetting Events pull from a common reference, so modifying them modifies future uses. * Simplify EventScene Process Better handling different continue container for grab focus * Goodbye heathcliff cat, you will be missed Don't forget to RSVP to his funeral. --------- Co-authored-by: LifeHckr <jarodthereal@gmail.com>
1 parent db5c9b6 commit cf8e11a

18 files changed

Lines changed: 629 additions & 5 deletions

Classes/Events/Assets/Event1.png

13.7 KB
Loading
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
[remap]
2+
3+
importer="texture"
4+
type="CompressedTexture2D"
5+
uid="uid://76wufdnhkrvk"
6+
path="res://.godot/imported/Event1.png-2f5f476395c8adde38110b361ff5d5f3.ctex"
7+
metadata={
8+
"vram_texture": false
9+
}
10+
11+
[deps]
12+
13+
source_file="res://Classes/Events/Assets/Event1.png"
14+
dest_files=["res://.godot/imported/Event1.png-2f5f476395c8adde38110b361ff5d5f3.ctex"]
15+
16+
[params]
17+
18+
compress/mode=0
19+
compress/high_quality=false
20+
compress/lossy_quality=0.7
21+
compress/hdr_compression=1
22+
compress/normal_map=0
23+
compress/channel_pack=0
24+
mipmaps/generate=false
25+
mipmaps/limit=-1
26+
roughness/mode=0
27+
roughness/src_normal=""
28+
process/fix_alpha_border=true
29+
process/premult_alpha=false
30+
process/normal_map_invert_y=false
31+
process/hdr_as_srgb=false
32+
process/hdr_clamp_exposure=false
33+
process/size_limit=0
34+
detect_3d/compress_to=1

Classes/Events/Assets/Event2.png

1.26 KB
Loading
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
[remap]
2+
3+
importer="texture"
4+
type="CompressedTexture2D"
5+
uid="uid://cex5vg2ycajdi"
6+
path="res://.godot/imported/Event2.png-a647bc6675ac54fecafbb5f9d56de04d.ctex"
7+
metadata={
8+
"vram_texture": false
9+
}
10+
11+
[deps]
12+
13+
source_file="res://Classes/Events/Assets/Event2.png"
14+
dest_files=["res://.godot/imported/Event2.png-a647bc6675ac54fecafbb5f9d56de04d.ctex"]
15+
16+
[params]
17+
18+
compress/mode=0
19+
compress/high_quality=false
20+
compress/lossy_quality=0.7
21+
compress/hdr_compression=1
22+
compress/normal_map=0
23+
compress/channel_pack=0
24+
mipmaps/generate=false
25+
mipmaps/limit=-1
26+
roughness/mode=0
27+
roughness/src_normal=""
28+
process/fix_alpha_border=true
29+
process/premult_alpha=false
30+
process/normal_map_invert_y=false
31+
process/hdr_as_srgb=false
32+
process/hdr_clamp_exposure=false
33+
process/size_limit=0
34+
detect_3d/compress_to=1

Classes/Events/Assets/Event3.png

13.7 KB
Loading
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
[remap]
2+
3+
importer="texture"
4+
type="CompressedTexture2D"
5+
uid="uid://c0d0dwwnotlfq"
6+
path="res://.godot/imported/Event3.png-445c0675f61362532d1032be33503df0.ctex"
7+
metadata={
8+
"vram_texture": false
9+
}
10+
11+
[deps]
12+
13+
source_file="res://Classes/Events/Assets/Event3.png"
14+
dest_files=["res://.godot/imported/Event3.png-445c0675f61362532d1032be33503df0.ctex"]
15+
16+
[params]
17+
18+
compress/mode=0
19+
compress/high_quality=false
20+
compress/lossy_quality=0.7
21+
compress/hdr_compression=1
22+
compress/normal_map=0
23+
compress/channel_pack=0
24+
mipmaps/generate=false
25+
mipmaps/limit=-1
26+
roughness/mode=0
27+
roughness/src_normal=""
28+
process/fix_alpha_border=true
29+
process/premult_alpha=false
30+
process/normal_map_invert_y=false
31+
process/hdr_as_srgb=false
32+
process/hdr_clamp_exposure=false
33+
process/size_limit=0
34+
detect_3d/compress_to=1

Classes/Events/EventDatabase.cs

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
using System;
2+
using Godot;
3+
4+
/// <summary>
5+
/// Holds all game events and their associated logic.
6+
/// </summary>
7+
public class EventDatabase
8+
{
9+
public static readonly EventTemplate[] EventDictionary = new[]
10+
{
11+
new EventTemplate(
12+
1,
13+
"EVENT_EVENT1_DESC",
14+
["EVENT_EVENT1_OPTION1", "EVENT_EVENT1_OPTION2", "EVENT_EVENT1_OPTION3"],
15+
["EVENT_EVENT1_OUTCOME1", "EVENT_EVENT1_OUTCOME2", "EVENT_EVENT1_OUTCOME3"],
16+
[
17+
(self, node) =>
18+
{
19+
int randIndex = StageProducer.GlobalRng.RandiRange(
20+
0,
21+
StageProducer.PlayerStats.CurNotes.Length - 1
22+
);
23+
StageProducer.PlayerStats.RemoveNote(randIndex);
24+
},
25+
(self, node) =>
26+
{
27+
int randIndex = StageProducer.GlobalRng.RandiRange(
28+
0,
29+
StageProducer.PlayerStats.CurRelics.Length - 1
30+
);
31+
StageProducer.PlayerStats.RemoveRelic(randIndex);
32+
},
33+
(self, node) =>
34+
{
35+
StageProducer.PlayerStats.Money /= 2;
36+
},
37+
],
38+
GD.Load<Texture2D>("res://Classes/Events/Assets/Event1.png"),
39+
[
40+
() => StageProducer.PlayerStats.CurNotes.Length > 0,
41+
() => StageProducer.PlayerStats.CurRelics.Length > 0,
42+
() => StageProducer.PlayerStats.Money > 0,
43+
]
44+
),
45+
new EventTemplate(
46+
1,
47+
"EVENT_EVENT2_DESC",
48+
["EVENT_EVENT2_OPTION1", "EVENT_EVENT2_OPTION2"],
49+
["", "EVENT_EVENT2_OUTCOME1"],
50+
[
51+
(self, node) =>
52+
{
53+
var spinner = node.EventSprite;
54+
int spinOutcome = StageProducer.GlobalRng.RandiRange(0, 5);
55+
56+
int outcomeCount = 6;
57+
float sectorAngle = 360f / outcomeCount;
58+
float targetAngle = spinOutcome * sectorAngle;
59+
float fullSpins = 6 * 360f;
60+
float finalRotation = spinner.RotationDegrees % 360f + fullSpins + targetAngle;
61+
62+
var tween = node.CreateTween();
63+
tween
64+
.TweenProperty(spinner, "rotation_degrees", finalRotation, 2.5f)
65+
.SetTrans(Tween.TransitionType.Cubic)
66+
.SetEase(Tween.EaseType.Out);
67+
68+
// Defer execution of the outcome until the tween finishes
69+
tween.TweenCallback(
70+
Callable.From(() =>
71+
{
72+
switch (spinOutcome)
73+
{
74+
case 0:
75+
StageProducer.PlayerStats.Money /= 2;
76+
self.OutcomeDescriptions[0] = "EVENT_EVENT2_OUTCOME2";
77+
break;
78+
case 1:
79+
self.OutcomeDescriptions[0] = "EVENT_EVENT2_OUTCOME3";
80+
StageProducer.PlayerStats.CurrentHealth = Math.Max(
81+
1,
82+
StageProducer.PlayerStats.CurrentHealth - 10
83+
);
84+
break;
85+
case 2:
86+
self.OutcomeDescriptions[0] = "EVENT_EVENT2_OUTCOME4";
87+
StageProducer.PlayerStats.Money += 50;
88+
break;
89+
case 3:
90+
self.OutcomeDescriptions[0] = "EVENT_EVENT2_OUTCOME5";
91+
StageProducer.PlayerStats.AddNote(
92+
Scribe.GetRandomRewardNotes(1, StageProducer.CurRoom + 10)[
93+
0
94+
]
95+
);
96+
break;
97+
case 4:
98+
self.OutcomeDescriptions[0] = "EVENT_EVENT2_OUTCOME6";
99+
StageProducer.PlayerStats.AddRelic(
100+
Scribe.GetRandomRelics(
101+
1,
102+
StageProducer.CurRoom + 10,
103+
StageProducer.PlayerStats.RarityOdds
104+
)[0]
105+
);
106+
break;
107+
case 5:
108+
self.OutcomeDescriptions[0] = "EVENT_EVENT2_OUTCOME7";
109+
StageProducer.PlayerStats.CurrentHealth = Math.Min(
110+
StageProducer.PlayerStats.CurrentHealth + 20,
111+
StageProducer.PlayerStats.MaxHealth
112+
);
113+
break;
114+
}
115+
node.AnyButtonPressed(0);
116+
self.OutcomeDescriptions[0] = ""; //Will need to fix later, currently changes the primary reference
117+
})
118+
);
119+
},
120+
null,
121+
],
122+
GD.Load<Texture2D>("res://Classes/Events/Assets/Event2.png"),
123+
[null, null]
124+
),
125+
new EventTemplate(
126+
2,
127+
"EVENT_EVENT3_DESC",
128+
["EVENT_EVENT3_OPTION1", "EVENT_EVENT3_OPTION2", "EVENT_EVENT3_OPTION3"],
129+
["EVENT_EVENT3_OUTCOME1", "EVENT_EVENT3_OUTCOME2", "EVENT_EVENT3_OUTCOME3"],
130+
[
131+
(self, node) =>
132+
{
133+
StageProducer.PlayerStats.CurrentHealth = Math.Min(
134+
StageProducer.PlayerStats.CurrentHealth + 10,
135+
StageProducer.PlayerStats.MaxHealth
136+
);
137+
},
138+
(self, node) =>
139+
{
140+
StageProducer.PlayerStats.MaxComboBar -= 5;
141+
},
142+
(self, node) =>
143+
{
144+
StageProducer.PlayerStats.Money -= 30;
145+
StageProducer.PlayerStats.AddNote(Scribe.NoteDictionary[3]);
146+
StageProducer.PlayerStats.AddNote(Scribe.NoteDictionary[3]);
147+
},
148+
],
149+
GD.Load<Texture2D>("res://Classes/Events/Assets/Event3.png"),
150+
[null, null, () => StageProducer.PlayerStats.Money >= 30]
151+
),
152+
};
153+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
uid://c7pukvtaeda8h

Classes/Events/EventTemplate.cs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
using System;
2+
using Godot;
3+
4+
public delegate void EventAction(EventTemplate self, EventScene contextNode);
5+
public delegate bool EventCondition();
6+
7+
//TODO: Consider making event option struct for better parallelizing of option parameters
8+
9+
public class EventTemplate
10+
{
11+
public int Id;
12+
public string EventDescription;
13+
public string[] ButtonDescriptions;
14+
public string[] OutcomeDescriptions;
15+
public Texture2D Texture;
16+
public EventAction[] OptionActions;
17+
public EventCondition[] OptionEnabledConditions;
18+
19+
public EventTemplate() { }
20+
21+
public EventTemplate(
22+
int id,
23+
string eventDescription,
24+
string[] buttonDescriptions,
25+
string[] outcomeDescriptions,
26+
EventAction[] optionActions,
27+
Texture2D texture,
28+
EventCondition[] optionEnabledConditions = null
29+
)
30+
{
31+
Id = id;
32+
EventDescription = eventDescription;
33+
ButtonDescriptions = buttonDescriptions;
34+
OutcomeDescriptions = outcomeDescriptions;
35+
OptionActions = optionActions;
36+
Texture = texture;
37+
OptionEnabledConditions = optionEnabledConditions;
38+
}
39+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
uid://4ro8fwi5f8uk

0 commit comments

Comments
 (0)