Skip to content

Commit b353299

Browse files
cornerloanLifeHckr
authored andcommitted
Event outcomes added
1 parent 40a7281 commit b353299

4 files changed

Lines changed: 50 additions & 11 deletions

File tree

Classes/Events/EventDatabase.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ public partial class EventDatabase
1313
1,
1414
"EVENT_EVENT1_DESC",
1515
new string[] { "EVENT_EVENT1_OPTION1", "EVENT_EVENT1_OPTION2", "EVENT_EVENT1_OPTION3" },
16+
new string[]
17+
{
18+
"EVENT_EVENT1_OUTCOME1",
19+
"EVENT_EVENT1_OUTCOME2",
20+
"EVENT_EVENT1_OUTCOME3",
21+
},
1622
new EventAction[]
1723
{
1824
() =>

Classes/Events/EventTemplate.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ public partial class EventTemplate
99
public int Id;
1010
public string EventDescription;
1111
public string[] ButtonDescriptions;
12+
public string[] OutcomeDescriptions;
1213
public Texture2D Texture;
1314

1415
// Note: Actions are NOT exported since delegates cannot be serialized
@@ -20,13 +21,15 @@ public EventTemplate(
2021
int id,
2122
string eventDescription,
2223
string[] buttonDescriptions,
24+
string[] outcomeDescriptions,
2325
EventAction[] optionActions,
2426
Texture2D texture
2527
)
2628
{
2729
Id = id;
2830
EventDescription = eventDescription;
2931
ButtonDescriptions = buttonDescriptions;
32+
OutcomeDescriptions = outcomeDescriptions;
3033
OptionActions = optionActions;
3134
Texture = texture;
3235
}

Globals/Translations/Translations.csv

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,11 @@ TUTORIAL_FINAL_1,"Good job, you placed a note! You either healed yourself, or de
127127
TUTORIAL_FINAL_2,"As a refresher: Hit notes to build a combo and fill the bar. When the bar is full, press one of your buttons for a lane that doesn't have a note at the current beat. Notes in the chart will loop around. Keep it up to win.",(TODO)
128128
TUTORIAL_FINAL_3,"Good luck! I believe in you.",(TODO)
129129
TUTORIAL_BOSS,"This may take some getting used to, but death is ok in the grand scheme of things. Just have some patience with yourself, you'll learn in the end.",(TODO)
130+
EVENT_CONTINUE_BUTTON,"Continue",(TODO)
130131
EVENT_EVENT1_DESC,"A wild creature appears in the forest.",(TODO)
131132
EVENT_EVENT1_OPTION1,Fight,(TODO)
132133
EVENT_EVENT1_OPTION2,Run,(TODO)
133-
EVENT_EVENT1_OPTION3,Mysterious Third Option,(TODO)
134+
EVENT_EVENT1_OPTION3,Mysterious Third Option,(TODO)
135+
EVENT_EVENT1_OUTCOME1,"You chose to fight.",(TODO)
136+
EVENT_EVENT1_OUTCOME2,"You chose to run.",(TODO)
137+
EVENT_EVENT1_OUTCOME3,"You chose the third option.",(TODO)

Scenes/EventScene/EventScene.cs

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ public partial class EventScene : Node
2121

2222
private static Theme _buttonTheme = GD.Load<Theme>("res://Scenes/UI/Assets/GeneralTheme.tres"); // Store the theme
2323

24+
private EventTemplate _eventReference;
25+
2426
public static EventScene NewEventScene(int eventId = 0)
2527
{
2628
EventScene result = GD.Load<PackedScene>(LoadPath).Instantiate<EventScene>();
@@ -36,6 +38,7 @@ public override void _Ready()
3638
_player = GD.Load<PackedScene>(PlayerPuppet.LoadPath).Instantiate<PlayerPuppet>();
3739
PlayerMarker.AddChild(_player);
3840

41+
_eventReference = EventDatabase.EventDictionary[0];
3942
DisplayEvent(0);
4043
}
4144

@@ -53,16 +56,14 @@ public override void _Process(double delta)
5356
/// <param name="eventIndex">Index of the event in EventDatabase.</param>
5457
public void DisplayEvent(int eventIndex)
5558
{
56-
var eventTemplate = EventDatabase.EventDictionary[eventIndex];
57-
58-
_eventDescription.Text = eventTemplate.EventDescription;
59-
EventSprite.Texture = eventTemplate.Texture;
59+
_eventDescription.Text = _eventReference.EventDescription;
60+
EventSprite.Texture = _eventReference.Texture;
6061

61-
for (int i = 0; i < eventTemplate.ButtonDescriptions.Length; i++)
62+
for (int i = 0; i < _eventReference.ButtonDescriptions.Length; i++)
6263
{
6364
var button = new Button
6465
{
65-
Text = eventTemplate.ButtonDescriptions[i],
66+
Text = _eventReference.ButtonDescriptions[i],
6667
Theme = _buttonTheme,
6768
};
6869

@@ -71,15 +72,40 @@ public void DisplayEvent(int eventIndex)
7172
int capturedIndex = i; // was given a warning to capture the index
7273
button.Pressed += () =>
7374
{
74-
GD.Print($"Selected option: {eventTemplate.ButtonDescriptions[capturedIndex]}");
75-
eventTemplate.OptionActions[capturedIndex]?.Invoke();
76-
StageProducer.LiveInstance.TransitionStage(Stages.Map);
75+
GD.Print($"Selected option: {_eventReference.ButtonDescriptions[capturedIndex]}");
76+
_eventReference.OptionActions[capturedIndex]?.Invoke();
77+
AnyButtonPressed(capturedIndex);
7778
};
7879
if (capturedIndex == 0)
7980
{
80-
button.GrabFocus();
81+
button.CallDeferred("grab_focus");
8182
}
83+
8284
_buttonContainer.AddChild(button);
8385
}
8486
}
87+
88+
private void AnyButtonPressed(int capturedIndex)
89+
{
90+
foreach (var choices in _buttonContainer.GetChildren())
91+
{
92+
if (choices is not Button)
93+
continue;
94+
choices.QueueFree();
95+
}
96+
97+
_eventDescription.Text = _eventReference.OutcomeDescriptions[capturedIndex];
98+
var button = new Button { Text = "EVENT_CONTINUE_BUTTON", Theme = _buttonTheme };
99+
100+
button.Pressed += ContinuePressed;
101+
102+
button.SizeFlagsVertical = Control.SizeFlags.Expand | Control.SizeFlags.Fill;
103+
button.CallDeferred("grab_focus");
104+
_buttonContainer.AddChild(button);
105+
}
106+
107+
private void ContinuePressed()
108+
{
109+
StageProducer.LiveInstance.TransitionStage(Stages.Map);
110+
}
85111
}

0 commit comments

Comments
 (0)