Skip to content

Commit 4590b5c

Browse files
authored
Merge pull request #51 from Project-Funk-Engine/SomeUI
Begin Sprint 2 wrap-up
2 parents cb1446e + 74506ee commit 4590b5c

26 files changed

Lines changed: 595 additions & 74 deletions

Classes/Notes/Note.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,20 @@ public partial class Note : Resource
1313
private int _baseVal;
1414
private Action<BattleDirector, Note, Timing> NoteEffect; //TODO: Where/How to deal with timing.
1515

16+
public string Tooltip;
1617
public Texture2D Texture;
1718

18-
//public string Tooltip;
19-
2019
public Note(
2120
string name,
22-
PuppetTemplate owner = null,
21+
string tooltip,
2322
Texture2D texture = null,
23+
PuppetTemplate owner = null,
2424
int baseVal = 1,
2525
Action<BattleDirector, Note, Timing> noteEffect = null
2626
)
2727
{
2828
Name = name;
2929
Owner = owner;
30-
Texture = texture;
3130
NoteEffect =
3231
noteEffect
3332
?? (
@@ -37,6 +36,8 @@ public Note(
3736
}
3837
);
3938
_baseVal = baseVal;
39+
Texture = texture;
40+
Tooltip = tooltip;
4041
}
4142

4243
public void OnHit(BattleDirector BD, Timing timing)
@@ -48,6 +49,7 @@ public Note Clone()
4849
{
4950
//Eventually could look into something more robust, but for now shallow copy is preferable.
5051
//We only would want val and name to be copied by value
51-
return (Note)MemberwiseClone();
52+
Note newNote = new Note(Name, Tooltip, Texture, Owner, _baseVal, NoteEffect);
53+
return newNote;
5254
}
5355
}

Classes/Relics/RelicTemplate.cs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,25 @@ public partial class RelicTemplate : Resource
77
public RelicEffect[] Effects;
88
public string Name;
99

10-
//public Texture2D Texture
11-
//public string Tooltip
12-
public RelicTemplate(string Name = "", RelicEffect[] EffectTags = null)
10+
public Texture2D Texture;
11+
public string Tooltip;
12+
13+
public RelicTemplate(
14+
string name = "",
15+
string tooltip = "",
16+
Texture2D texture = null,
17+
RelicEffect[] EffectTags = null
18+
)
1319
{
1420
Effects = EffectTags;
15-
this.Name = Name;
21+
Name = name;
22+
Tooltip = tooltip;
23+
Texture = texture;
1624
}
1725

1826
public RelicTemplate Clone()
1927
{
20-
return (RelicTemplate)MemberwiseClone();
28+
RelicTemplate newRelic = new RelicTemplate(Name, Tooltip, Texture, Effects);
29+
return newRelic;
2130
}
2231
}
703 Bytes
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://csjx2hb4tdlw8"
6+
path="res://.godot/imported/relic_Breakfast.png-c1b968058adbb855fcf957a2aec74dc2.ctex"
7+
metadata={
8+
"vram_texture": false
9+
}
10+
11+
[deps]
12+
13+
source_file="res://Classes/Relics/assets/relic_Breakfast.png"
14+
dest_files=["res://.godot/imported/relic_Breakfast.png-c1b968058adbb855fcf957a2aec74dc2.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
447 Bytes
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://dg4tnp7plxmp7"
6+
path="res://.godot/imported/relic_GoodVibes.png-cd102b29bb163411bb7ce8cf724ef0c0.ctex"
7+
metadata={
8+
"vram_texture": false
9+
}
10+
11+
[deps]
12+
13+
source_file="res://Classes/Relics/assets/relic_GoodVibes.png"
14+
dest_files=["res://.godot/imported/relic_GoodVibes.png-cd102b29bb163411bb7ce8cf724ef0c0.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

Globals/FunkEngineNameSpace.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public enum BattleEffectTrigger
1515
NotePlaced,
1616
NoteHit,
1717
SelfNoteHit,
18+
OnPickup,
1819
}
1920

2021
public enum Timing

Globals/Scribe.cs

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ public partial class Scribe : Node
1212
{
1313
new Note(
1414
"EnemyBase",
15-
null,
15+
"Basic enemy note, deals damage to player.",
16+
GD.Load<Texture2D>("res://scenes/BattleDirector/assets/Character1.png"),
1617
null,
1718
1,
1819
(director, note, timing) =>
@@ -22,8 +23,9 @@ public partial class Scribe : Node
2223
),
2324
new Note(
2425
"PlayerBase",
25-
null,
26+
"Basic player note, deals damage to enemy",
2627
GD.Load<Texture2D>("res://Classes/Notes/assets/single_note.png"),
28+
null,
2729
1,
2830
(director, note, timing) =>
2931
{
@@ -32,8 +34,9 @@ public partial class Scribe : Node
3234
),
3335
new Note(
3436
"PlayerDouble",
35-
null,
37+
"Basic player note, deals double damage to enemy",
3638
GD.Load<Texture2D>("res://Classes/Notes/assets/double_note.png"),
39+
null,
3740
1,
3841
(director, note, timing) =>
3942
{
@@ -48,39 +51,30 @@ public partial class Scribe : Node
4851
{
4952
new RelicTemplate(
5053
"Breakfast", //Reference ha ha, Item to give when relic pool is empty.
54+
"Increases max hp.", //TODO: Description can include the relics values?
55+
GD.Load<Texture2D>("res://Classes/Relics/assets/relic_Breakfast.png"),
5156
new RelicEffect[]
5257
{
5358
new RelicEffect(
54-
BattleEffectTrigger.NotePlaced,
55-
1,
59+
BattleEffectTrigger.OnPickup,
60+
10,
5661
(director, val) =>
5762
{
58-
director.Player.Heal(val);
63+
StageProducer.PlayerStats.MaxHealth += val;
64+
StageProducer.PlayerStats.CurrentHealth += val;
5965
}
6066
),
6167
}
6268
),
6369
new RelicTemplate(
6470
"Good Vibes",
71+
"Good vibes, heals the player whenever they place a note.", //TODO: Description can include the relics values?
72+
GD.Load<Texture2D>("res://Classes/Relics/assets/relic_GoodVibes.png"),
6573
new RelicEffect[]
6674
{
6775
new RelicEffect(
6876
BattleEffectTrigger.NotePlaced,
69-
5,
70-
(director, val) =>
71-
{
72-
director.Player.Heal(val);
73-
}
74-
),
75-
}
76-
),
77-
new RelicTemplate(
78-
"Dummy Item",
79-
new RelicEffect[]
80-
{
81-
new RelicEffect(
82-
BattleEffectTrigger.NotePlaced,
83-
100,
77+
1,
8478
(director, val) =>
8579
{
8680
director.Player.Heal(val);

Globals/StageProducer.cs

Lines changed: 50 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,14 @@ public partial class StageProducer : Node
1010
public static RandomNumberGenerator GlobalRng = new RandomNumberGenerator();
1111
private ulong _seed;
1212
private ulong _lastRngState;
13+
private bool _isInitialized = false;
1314

1415
private Stages _curStage = Stages.Title;
1516
private Node _curScene;
17+
public static MapGrid.Room CurRoom { get; private set; }
18+
public static Vector2I MapSize { get; private set; } = new Vector2I(7, 6); //For now, make width an odd number
1619

17-
private MapGrid _map = new MapGrid();
20+
public static MapGrid Map { get; } = new MapGrid();
1821

1922
//Hold here to persist between changes
2023
//TODO: Allow for permanent changes and battle temporary stat changes.
@@ -27,6 +30,11 @@ public class MapGrid
2730
private int _curIdx = 0;
2831
private int _curRoom = 0;
2932

33+
public Room[] GetRooms()
34+
{
35+
return _rooms;
36+
}
37+
3038
public class Room
3139
{
3240
public Room(int idx, int x, int y)
@@ -48,10 +56,10 @@ public void AddChild(int newIdx)
4856
Children = Children.Append(newIdx).ToArray();
4957
}
5058

51-
private int Idx;
52-
private int[] Children = Array.Empty<int>();
53-
private int X;
54-
private int Y;
59+
public int Idx { get; private set; }
60+
public int[] Children { get; private set; } = Array.Empty<int>();
61+
public int X { get; private set; }
62+
public int Y { get; private set; }
5563
private string Type;
5664
}
5765

@@ -61,15 +69,15 @@ public void InitMapGrid(int width, int height, int paths)
6169
_rooms = Array.Empty<Room>();
6270
_map = new int[width, height]; //x,y
6371

64-
int startX = GlobalRng.RandiRange(0, width - 1); //TODO: Replace with seeding
72+
int startX = (width / 2);
6573
_rooms = _rooms.Append(new Room(_curIdx, startX, 0)).ToArray();
6674
_map[startX, 0] = _curIdx++;
6775

6876
for (int i = 0; i < paths; i++)
6977
{
7078
GeneratePath_r(startX, 0, width, height);
7179
}
72-
80+
CreateCommonChildren(width, height);
7381
AddBossRoom(width, height);
7482
}
7583

@@ -93,9 +101,25 @@ private void GeneratePath_r(int x, int y, int width, int height)
93101
}
94102
}
95103

104+
//Asserts that if there is a room at the same x, but y+1 they are connected
105+
private void CreateCommonChildren(int width, int height)
106+
{
107+
foreach (Room room in _rooms)
108+
{
109+
Vector2I curPos = new Vector2I(room.X, room.Y);
110+
if (room.Y + 1 >= height)
111+
continue;
112+
if (_map[curPos.X, curPos.Y + 1] == 0)
113+
continue;
114+
GD.Print("Added child on same X.");
115+
room.AddChild(_map[curPos.X, curPos.Y + 1]);
116+
}
117+
}
118+
119+
//Adds a boss room at the end of rooms, all max height rooms connect to it.
96120
private void AddBossRoom(int width, int height)
97121
{
98-
_rooms = _rooms.Append(new Room(_curIdx, 0, height)).ToArray();
122+
_rooms = _rooms.Append(new Room(_curIdx, width / 2, height)).ToArray();
99123
_rooms[_curIdx].SetType("Boss");
100124
for (int i = 0; i < width; i++) //Attach all last rooms to a boss room
101125
{
@@ -109,10 +133,19 @@ private void AddBossRoom(int width, int height)
109133

110134
public void StartGame()
111135
{
112-
_map.InitMapGrid(2, 2, 1);
136+
Map.InitMapGrid(MapSize.X, MapSize.Y, 3);
113137
_seed = GlobalRng.Seed;
114138
_lastRngState = GlobalRng.State;
115139
PlayerStats = new PlayerStats();
140+
141+
CurRoom = Map.GetRooms()[0];
142+
_isInitialized = true;
143+
}
144+
145+
public void TransitionFromRoom(int nextRoomIdx)
146+
{
147+
//CurRoom = Map.GetRooms()[nextRoomIdx];
148+
TransitionStage(Stages.Battle);
116149
}
117150

118151
public void TransitionStage(Stages nextStage)
@@ -121,12 +154,19 @@ public void TransitionStage(Stages nextStage)
121154
switch (nextStage)
122155
{
123156
case Stages.Title:
157+
_isInitialized = false;
124158
GetTree().ChangeSceneToFile("res://scenes/SceneTransitions/TitleScreen.tscn");
125159
break;
126160
case Stages.Battle:
127-
StartGame();
128161
GetTree().ChangeSceneToFile("res://scenes/BattleDirector/test_battle_scene.tscn");
129162
break;
163+
case Stages.Map:
164+
GetTree().ChangeSceneToFile("res://scenes/Maps/cartographer.tscn");
165+
if (!_isInitialized)
166+
{
167+
StartGame();
168+
}
169+
break;
130170
case Stages.Quit:
131171
GD.Print("Exiting game");
132172
GetTree().Quit();

project.godot

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ Pause={
6363
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194305,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
6464
]
6565
}
66+
Inventory={
67+
"deadzone": 0.5,
68+
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":73,"key_label":0,"unicode":105,"location":0,"echo":false,"script":null)
69+
]
70+
}
6671

6772
[rendering]
6873

0 commit comments

Comments
 (0)