Skip to content

Commit d4b994f

Browse files
cornerloanLifeHckr
authored andcommitted
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
1 parent fc2333c commit d4b994f

6 files changed

Lines changed: 100 additions & 42 deletions

File tree

Classes/Events/Assets/Event2.png

14.1 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/EventDatabase.cs

Lines changed: 47 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using System;
2-
using System.Collections.Generic;
2+
using System.Threading.Tasks;
33
using Godot;
44

55
/// <summary>
@@ -15,23 +15,23 @@ public partial class EventDatabase
1515
["EVENT_EVENT1_OPTION1", "EVENT_EVENT1_OPTION2", "EVENT_EVENT1_OPTION3"],
1616
["EVENT_EVENT1_OUTCOME1", "EVENT_EVENT1_OUTCOME2", "EVENT_EVENT1_OUTCOME3"],
1717
[
18-
(self) =>
18+
async (self, node) =>
1919
{
2020
int randIndex = StageProducer.GlobalRng.RandiRange(
2121
0,
2222
StageProducer.PlayerStats.CurNotes.Length
2323
);
2424
StageProducer.PlayerStats.RemoveNote(randIndex);
2525
},
26-
(self) =>
26+
async (self, node) =>
2727
{
2828
int randIndex = StageProducer.GlobalRng.RandiRange(
2929
0,
3030
StageProducer.PlayerStats.CurRelics.Length
3131
);
3232
StageProducer.PlayerStats.RemoveRelic(randIndex);
3333
},
34-
(self) =>
34+
async (self, node) =>
3535
{
3636
StageProducer.PlayerStats.Money /= 2;
3737
},
@@ -49,36 +49,55 @@ public partial class EventDatabase
4949
["EVENT_EVENT2_OPTION1", "EVENT_EVENT2_OPTION2"],
5050
["", "EVENT_EVENT2_OUTCOME1"],
5151
[
52-
(self) =>
52+
async (self, node) =>
5353
{
54-
StageProducer.PlayerStats.Money -= 20;
55-
// [do nothing, get money back, win money, get note, get relic, heal]
56-
int spinOutcome = (int)
57-
StageProducer.GlobalRng.RandWeighted([13, 8, 5, 5, 3, 3]); //TODO: adjust odds
54+
var spinner = node.GetNodeOrNull<Sprite2D>("EventSprite");
55+
int spinOutcome = (int)StageProducer.GlobalRng.RandWeighted([1, 1, 1, 1, 1, 1]);
56+
57+
int outcomeCount = 6;
58+
float sectorAngle = 360f / outcomeCount;
59+
float targetAngle = spinOutcome * sectorAngle;
60+
float fullSpins = 6 * 360f;
61+
float finalRotation = spinner.RotationDegrees % 360f + fullSpins + targetAngle;
62+
63+
var tween = node.GetTree().CreateTween();
64+
tween
65+
.TweenProperty(spinner, "rotation_degrees", finalRotation, 2.5f)
66+
.SetTrans(Tween.TransitionType.Cubic)
67+
.SetEase(Tween.EaseType.Out);
68+
69+
var tcs = new TaskCompletionSource<bool>();
70+
tween.TweenCallback(Callable.From(() => tcs.SetResult(true)));
71+
await tcs.Task;
72+
5873
switch (spinOutcome)
5974
{
60-
case 0: //do nothing AKA lose
61-
GD.Print("owned lol");
75+
case 0:
76+
GD.Print("lost half money");
77+
StageProducer.PlayerStats.Money /= 2;
6278
self.OutcomeDescriptions[0] = "EVENT_EVENT2_OUTCOME2";
6379
break;
64-
case 1: // get money back
65-
GD.Print("refund");
80+
case 1:
81+
GD.Print("took damage");
6682
self.OutcomeDescriptions[0] = "EVENT_EVENT2_OUTCOME3";
67-
StageProducer.PlayerStats.Money += 20;
83+
StageProducer.PlayerStats.CurrentHealth = Math.Max(
84+
1,
85+
StageProducer.PlayerStats.CurrentHealth - 10
86+
);
6887
break;
69-
case 2: // get triple money
70-
GD.Print("triple money");
88+
case 2:
89+
GD.Print("gain money");
7190
self.OutcomeDescriptions[0] = "EVENT_EVENT2_OUTCOME4";
72-
StageProducer.PlayerStats.Money += 60;
91+
StageProducer.PlayerStats.Money += 50;
7392
break;
74-
case 3: // get random note
93+
case 3:
7594
GD.Print("random note");
7695
self.OutcomeDescriptions[0] = "EVENT_EVENT2_OUTCOME5";
7796
StageProducer.PlayerStats.AddNote(
7897
Scribe.GetRandomRewardNotes(1, StageProducer.CurRoom + 10)[0]
7998
);
8099
break;
81-
case 4: // get random relic
100+
case 4:
82101
GD.Print("random relic");
83102
self.OutcomeDescriptions[0] = "EVENT_EVENT2_OUTCOME6";
84103
StageProducer.PlayerStats.AddRelic(
@@ -98,32 +117,34 @@ public partial class EventDatabase
98117
);
99118
break;
100119
}
120+
121+
GD.Print($"new description {self.OutcomeDescriptions[0]}");
101122
},
102-
(self) => {
103-
//does nothing
123+
async (self, node) => {
124+
// does nothing
104125
},
105126
],
106-
GD.Load<Texture2D>("res://Classes/Events/Assets/TEMP.png"),
107-
[() => StageProducer.PlayerStats.Money >= 20, () => true]
127+
GD.Load<Texture2D>("res://Classes/Events/Assets/Event2.png"),
128+
[() => true, () => true]
108129
),
109130
new EventTemplate(
110131
2,
111132
"EVENT_EVENT3_DESC",
112133
["EVENT_EVENT3_OPTION1", "EVENT_EVENT3_OPTION2", "EVENT_EVENT3_OPTION3"],
113134
["EVENT_EVENT3_OUTCOME1", "EVENT_EVENT3_OUTCOME2", "EVENT_EVENT3_OUTCOME3"],
114135
[
115-
(self) =>
136+
async (self, node) =>
116137
{
117138
StageProducer.PlayerStats.CurrentHealth = Math.Min(
118139
StageProducer.PlayerStats.CurrentHealth + 10,
119140
StageProducer.PlayerStats.MaxHealth
120141
);
121142
},
122-
(self) =>
143+
async (self, node) =>
123144
{
124145
StageProducer.PlayerStats.MaxComboBar -= 5;
125146
},
126-
(self) =>
147+
async (self, node) =>
127148
{
128149
StageProducer.PlayerStats.Money -= 30;
129150
StageProducer.PlayerStats.AddNote(Scribe.NoteDictionary[3]);

Classes/Events/EventTemplate.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
using System;
2-
using FunkEngine;
2+
using System.Threading.Tasks;
33
using Godot;
44

5-
public delegate void EventAction(EventTemplate self);
5+
public delegate Task EventAction(EventTemplate self, Node contextNode);
66
public delegate bool EventCondition();
77

88
public partial class EventTemplate
@@ -12,8 +12,6 @@ public partial class EventTemplate
1212
public string[] ButtonDescriptions;
1313
public string[] OutcomeDescriptions;
1414
public Texture2D Texture;
15-
16-
// Note: Actions are NOT exported since delegates cannot be serialized
1715
public EventAction[] OptionActions;
1816
public EventCondition[] OptionEnabledConditions;
1917

Globals/Translations/Translations.csv

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -135,16 +135,16 @@ EVENT_EVENT1_OPTION3,"Give them half your gold",(TODO)
135135
EVENT_EVENT1_OUTCOME1,"You got robbed of a random note.",(TODO)
136136
EVENT_EVENT1_OUTCOME2,"You got robbed of a random relic.",(TODO)
137137
EVENT_EVENT1_OUTCOME3,"You got robbed of half your gold.",(TODO)
138-
EVENT_EVENT2_DESC,"There is a slot machine.",(TODO)
139-
EVENT_EVENT2_OPTION1,"Pay 20g to spin",(TODO)
140-
EVENT_EVENT2_OPTION2,"Ignore the machine",(TODO)
141-
EVENT_EVENT2_OUTCOME1,"You saved your money and moved on.",(TODO)
142-
EVENT_EVENT2_OUTCOME2,"You lost your money.",(TODO)
143-
EVENT_EVENT2_OUTCOME3,"You refunded your money.",(TODO)
144-
EVENT_EVENT2_OUTCOME4,"You tripled your money.",(TODO)
145-
EVENT_EVENT2_OUTCOME5,"You gained a random note.",(TODO)
146-
EVENT_EVENT2_OUTCOME6,"You gained a random relic.",(TODO)
147-
EVENT_EVENT2_OUTCOME7,"You gained some health.",(TODO)
138+
EVENT_EVENT2_DESC,"There is a wheel with different outcomes.",(TODO)
139+
EVENT_EVENT2_OPTION1,"Spin the wheel",(TODO)
140+
EVENT_EVENT2_OPTION2,"Ignore the cool wheel",(TODO)
141+
EVENT_EVENT2_OUTCOME1,"You decided not to spin the wheel.",(TODO)
142+
EVENT_EVENT2_OUTCOME2,"You lost half your money.",(TODO)
143+
EVENT_EVENT2_OUTCOME3,"You took some damage.",(TODO)
144+
EVENT_EVENT2_OUTCOME4,"You won a lot of money!",(TODO)
145+
EVENT_EVENT2_OUTCOME5,"You gained a random note!",(TODO)
146+
EVENT_EVENT2_OUTCOME6,"You gained a random relic!",(TODO)
147+
EVENT_EVENT2_OUTCOME7,"You gained some health!",(TODO)
148148
EVENT_EVENT3_DESC,"There is a field medic on the side of the road.",(TODO)
149149
EVENT_EVENT3_OPTION1,"Receive a bit of healing",(TODO)
150150
EVENT_EVENT3_OPTION2,"Decrease max energy",(TODO)

Scenes/EventScene/EventScene.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,15 @@ public void DisplayEvent()
8282
button.Disabled = !isEnabled;
8383

8484
int capturedIndex = i;
85-
button.Pressed += () =>
85+
button.Pressed += async () =>
8686
{
8787
GD.Print($"Selected option: {_eventReference.ButtonDescriptions[capturedIndex]}");
88-
_eventReference.OptionActions[capturedIndex]?.Invoke(_eventReference);
88+
89+
var action = _eventReference.OptionActions[capturedIndex];
90+
if (action != null)
91+
{
92+
await action(_eventReference, this);
93+
}
8994
AnyButtonPressed(capturedIndex);
9095
};
9196

0 commit comments

Comments
 (0)