Skip to content

Commit 6635486

Browse files
authored
Merge branch 'Sprint-4' into loop-fix-attempts
2 parents a9c4446 + f984030 commit 6635486

14 files changed

Lines changed: 239 additions & 45 deletions

File tree

Classes/Notes/Note.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
public partial class Note : Resource, IDisplayable
1010
{
1111
public PuppetTemplate Owner;
12+
public int Id;
1213
public string Name { get; set; }
1314
private int _baseVal;
1415
public float CostModifier { get; private set; }
@@ -18,6 +19,7 @@ public partial class Note : Resource, IDisplayable
1819
public Texture2D Texture { get; set; }
1920

2021
public Note(
22+
int id,
2123
string name,
2224
string tooltip,
2325
Texture2D texture = null,
@@ -27,6 +29,7 @@ public Note(
2729
float costModifier = 1.0f
2830
)
2931
{
32+
Id = id;
3033
Name = name;
3134
Owner = owner;
3235
NoteEffect =
@@ -52,7 +55,16 @@ public Note Clone()
5255
{
5356
//Eventually could look into something more robust, but for now shallow copy is preferable.
5457
//We only would want val and name to be copied by value
55-
Note newNote = new Note(Name, Tooltip, Texture, Owner, _baseVal, NoteEffect, CostModifier);
58+
Note newNote = new Note(
59+
Id,
60+
Name,
61+
Tooltip,
62+
Texture,
63+
Owner,
64+
_baseVal,
65+
NoteEffect,
66+
CostModifier
67+
);
5668
return newNote;
5769
}
5870
}

Classes/Relics/RelicTemplate.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,21 @@
55
public partial class RelicTemplate : Resource, IDisplayable
66
{
77
public RelicEffect[] Effects;
8+
public int Id;
89
public string Name { get; set; }
910

1011
public Texture2D Texture { get; set; }
1112
public string Tooltip { get; set; }
1213

1314
public RelicTemplate(
15+
int id,
1416
string name = "",
1517
string tooltip = "",
1618
Texture2D texture = null,
1719
RelicEffect[] EffectTags = null
1820
)
1921
{
22+
Id = id;
2023
Effects = EffectTags;
2124
Name = name;
2225
Tooltip = tooltip;
@@ -25,7 +28,7 @@ public RelicTemplate(
2528

2629
public RelicTemplate Clone()
2730
{
28-
RelicTemplate newRelic = new RelicTemplate(Name, Tooltip, Texture, Effects);
31+
RelicTemplate newRelic = new RelicTemplate(Id, Name, Tooltip, Texture, Effects);
2932
return newRelic;
3033
}
3134
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
shader_type canvas_item;
2+
3+
uniform sampler2D SCREEN_TEXTURE : hint_screen_texture, filter_linear_mipmap;
4+
5+
void fragment() {
6+
vec4 screen = texture(SCREEN_TEXTURE, SCREEN_UV);
7+
8+
COLOR.rgb =vec3(0.6 * screen.r + 0.6 * screen.g + 0.2 * screen.b);
9+
}
10+
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[gd_scene load_steps=3 format=3 uid="uid://b6bblgxtfs020"]
2+
3+
[ext_resource type="Shader" path="res://Globals/ContrastFilter/ContrastFilter.gdshader" id="1_4bhca"]
4+
5+
[sub_resource type="ShaderMaterial" id="ShaderMaterial_i6hl4"]
6+
shader = ExtResource("1_4bhca")
7+
8+
[node name="CanvasLayer" type="CanvasLayer"]
9+
layer = 128
10+
11+
[node name="Filter" type="ColorRect" parent="."]
12+
z_index = 4096
13+
material = SubResource("ShaderMaterial_i6hl4")
14+
anchors_preset = 15
15+
anchor_right = 1.0
16+
anchor_bottom = 1.0
17+
grow_horizontal = 2
18+
grow_vertical = 2
19+
mouse_filter = 2

Globals/FunkEngineNameSpace.cs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ public enum Stages
6262
Boss,
6363
Quit,
6464
Map,
65-
Controls,
66-
Options,
65+
Load,
6766
}
6867

6968
public class MapGrid
@@ -79,6 +78,12 @@ public Room[] GetRooms()
7978

8079
public class Room
8180
{
81+
public int Idx { get; private set; }
82+
public int[] Children { get; private set; } = Array.Empty<int>();
83+
public int X { get; private set; }
84+
public int Y { get; private set; }
85+
public Stages Type { get; private set; }
86+
8287
public Room(int idx, int x, int y)
8388
{
8489
Idx = idx;
@@ -97,12 +102,6 @@ public void AddChild(int newIdx)
97102
return;
98103
Children = Children.Append(newIdx).ToArray();
99104
}
100-
101-
public int Idx { get; private set; }
102-
public int[] Children { get; private set; } = Array.Empty<int>();
103-
public int X { get; private set; }
104-
public int Y { get; private set; }
105-
public Stages Type { get; private set; }
106105
}
107106

108107
public void InitMapGrid(int width, int height, int paths)

Globals/Scribe.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public partial class Scribe : Node
1212
public static readonly Note[] NoteDictionary = new[]
1313
{
1414
new Note(
15+
0,
1516
"EnemyBase",
1617
"Basic enemy note, deals damage to player.",
1718
null,
@@ -23,6 +24,7 @@ public partial class Scribe : Node
2324
}
2425
),
2526
new Note(
27+
1,
2628
"PlayerBase",
2729
"Basic player note, deals damage to enemy.",
2830
GD.Load<Texture2D>("res://Classes/Notes/assets/single_note.png"),
@@ -34,6 +36,7 @@ public partial class Scribe : Node
3436
}
3537
),
3638
new Note(
39+
2,
3740
"PlayerDouble",
3841
"Basic player note, deals double damage to enemy.",
3942
GD.Load<Texture2D>("res://Classes/Notes/assets/double_note.png"),
@@ -47,6 +50,7 @@ public partial class Scribe : Node
4750
}
4851
),
4952
new Note(
53+
3,
5054
"PlayerHeal",
5155
"Basic player note, heals player.",
5256
GD.Load<Texture2D>("res://Classes/Notes/assets/heal_note.png"),
@@ -58,6 +62,7 @@ public partial class Scribe : Node
5862
}
5963
),
6064
new Note(
65+
4,
6166
"PlayerVampire",
6267
"Steals health from enemy.",
6368
GD.Load<Texture2D>("res://Classes/Notes/assets/vampire_note.png"),
@@ -70,6 +75,7 @@ public partial class Scribe : Node
7075
}
7176
),
7277
new Note(
78+
5,
7379
"PlayerQuarter",
7480
"Basic note at a quarter of the cost.",
7581
GD.Load<Texture2D>("res://Classes/Notes/assets/quarter_note.png"),
@@ -86,6 +92,7 @@ public partial class Scribe : Node
8692
public static readonly RelicTemplate[] RelicDictionary = new[]
8793
{
8894
new RelicTemplate(
95+
0,
8996
"Breakfast", //Reference ha ha, Item to give when relic pool is empty.
9097
"Increases max hp.", //TODO: Description can include the relics values?
9198
GD.Load<Texture2D>("res://Classes/Relics/assets/relic_Breakfast.png"),
@@ -103,6 +110,7 @@ public partial class Scribe : Node
103110
}
104111
),
105112
new RelicTemplate(
113+
1,
106114
"Good Vibes",
107115
"Heals the player whenever they place a note.",
108116
GD.Load<Texture2D>("res://Classes/Relics/assets/relic_GoodVibes.png"),
@@ -119,6 +127,7 @@ public partial class Scribe : Node
119127
}
120128
),
121129
new RelicTemplate(
130+
2,
122131
"Auroboros",
123132
"Bigger number, better person. Increases combo multiplier every riff.",
124133
GD.Load<Texture2D>("res://Classes/Relics/assets/Auroboros.png"),
@@ -136,6 +145,7 @@ public partial class Scribe : Node
136145
}
137146
),
138147
new RelicTemplate(
148+
3,
139149
"Colorboros",
140150
"Taste the rainbow. Charges the freestyle bar every riff.",
141151
GD.Load<Texture2D>("res://Classes/Relics/assets/Colorboros.png"),

Globals/StageProducer.cs

Lines changed: 62 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,13 @@ public partial class StageProducer : Node
88
//Generate a map, starting as a width x height grid, pick a starting spot and do (path) paths from that to the last
99
//row, connecting the path, then connect all at the end to the boss room.
1010
public static RandomNumberGenerator GlobalRng = new RandomNumberGenerator();
11-
private ulong _seed;
12-
private ulong _lastRngState;
1311
public static bool IsInitialized;
1412

1513
private Stages _curStage = Stages.Title; //TODO: State Machine kinda deal?
1614
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
15+
public static int CurRoom { get; private set; }
1916

17+
public static Vector2I MapSize { get; private set; } = new Vector2I(7, 6); //For now, make width an odd number
2018
public static MapGrid Map { get; } = new MapGrid();
2119

2220
public static BattleConfig Config;
@@ -25,6 +23,8 @@ public partial class StageProducer : Node
2523
//TODO: Allow for permanent changes and battle temporary stat changes.
2624
public static PlayerStats PlayerStats;
2725

26+
public static CanvasLayer ContrastFilter;
27+
2828
public override void _EnterTree()
2929
{
3030
InitFromCfg();
@@ -38,21 +38,66 @@ private void InitFromCfg()
3838
TranslationServer.SetLocale(
3939
SaveSystem.GetConfigValue(SaveSystem.ConfigSettings.LanguageKey).As<string>()
4040
);
41+
ContrastFilter = GD.Load<PackedScene>("res://Globals/ContrastFilter/ContrastFilter.tscn")
42+
.Instantiate<CanvasLayer>();
43+
ContrastFilter.Visible = SaveSystem
44+
.GetConfigValue(SaveSystem.ConfigSettings.HighContrast)
45+
.AsBool();
46+
GetTree().Root.CallDeferred("add_child", ContrastFilter);
4147
}
4248

4349
public void StartGame()
4450
{
45-
Map.InitMapGrid(MapSize.X, MapSize.Y, 3);
4651
GlobalRng.Randomize();
47-
_seed = GlobalRng.Seed;
48-
_lastRngState = GlobalRng.State;
52+
GenerateMapConsistent();
4953
PlayerStats = new PlayerStats();
5054

51-
CurRoom = Map.GetRooms()[0];
55+
CurRoom = Map.GetRooms()[0].Idx;
56+
IsInitialized = true;
57+
}
58+
59+
public bool LoadGame()
60+
{
61+
SaveSystem.SaveFile sv = SaveSystem.LoadGame();
62+
if (sv == null)
63+
{
64+
GD.PushError(
65+
"StageProducer.LoadGame(): Can't load game, either file 404 or invalid file."
66+
);
67+
return false;
68+
}
69+
GlobalRng.Seed = sv.RngSeed;
70+
GenerateMapConsistent();
71+
GlobalRng.State = sv.RngState;
72+
CurRoom = sv.LastRoomIdx;
73+
74+
PlayerStats = new PlayerStats();
75+
PlayerStats.CurNotes = Array.Empty<Note>();
76+
foreach (int noteId in sv.NoteIds)
77+
{
78+
PlayerStats.AddNote(Scribe.NoteDictionary[noteId]);
79+
}
80+
foreach (int relicId in sv.RelicIds)
81+
{
82+
PlayerStats.AddRelic(Scribe.RelicDictionary[relicId]);
83+
}
84+
PlayerStats.CurrentHealth = sv.PlayerHealth;
5285
IsInitialized = true;
86+
return true;
87+
}
88+
89+
private void GenerateMapConsistent()
90+
{
91+
GlobalRng.State = GlobalRng.Seed << 5 / 2;
92+
Map.InitMapGrid(MapSize.X, MapSize.Y, 3);
5393
}
5494

55-
public static void ChangeCurRoom(MapGrid.Room room)
95+
public static MapGrid.Room GetCurRoom()
96+
{
97+
return Map.GetRooms()[CurRoom];
98+
}
99+
100+
public static void ChangeCurRoom(int room)
56101
{
57102
CurRoom = room;
58103
}
@@ -64,6 +109,7 @@ public void TransitionFromRoom(int nextRoomIdx)
64109

65110
public void TransitionStage(Stages nextStage, int nextRoomIdx = -1)
66111
{
112+
GetTree().Root.RemoveChild(ContrastFilter);
67113
switch (nextStage)
68114
{
69115
case Stages.Title:
@@ -89,6 +135,11 @@ public void TransitionStage(Stages nextStage, int nextRoomIdx = -1)
89135
StartGame();
90136
}
91137
break;
138+
case Stages.Load:
139+
if (!LoadGame())
140+
StartGame();
141+
GetTree().ChangeSceneToFile("res://scenes/Maps/cartographer.tscn");
142+
break;
92143
case Stages.Quit:
93144
GetTree().Quit();
94145
return;
@@ -97,6 +148,8 @@ public void TransitionStage(Stages nextStage, int nextRoomIdx = -1)
97148
break;
98149
}
99150

151+
//Apply grayscale shader to all scenes
152+
GetTree().Root.AddChild(ContrastFilter);
100153
_curStage = nextStage;
101154
}
102155

Globals/translations.csv

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
keys,en,cn
22
TITLE,Midnight Riff,中夜现场
3-
TITLE_START,Start Game,开始游戏
3+
TITLE_START,New Game,新游戏
4+
TITLE_CONTINUE,Load Game,加载游戏
45
TITLE_QUIT,Quit Game,退出游戏
56
TITLE_OPTIONS,Options,选项
67
TITLE_CONTROLS,Change Controls,更改操控
@@ -21,7 +22,7 @@ CHEST_ROOM_ACCEPT,Accept,接受
2122
BATTLE_ROOM_BEGIN_BUTTON,"Begin Battle [Enter]","开始战斗 [Enter]"
2223
BATTLE_ROOM_PERFECT,Perfect,精准
2324
BATTLE_ROOM_GOOD,Good,良好
24-
BATTLE_ROOM_OK,OK,可以
25+
BATTLE_ROOM_OKAY,Okay,可以
2526
BATTLE_ROOM_MISS,Miss,错误
2627
BATTLE_ROOM_WIN,"You win!","你获胜了!"
2728
BATTLE_ROOM_LOSE,"Game Over!","游戏结束!"

0 commit comments

Comments
 (0)