Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 21 additions & 18 deletions Globals/FunkEngineNameSpace.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ public enum Timing

public struct BattleConfig
{
public MapRooms RoomType { get; private set; }
public MapGrid.Room CurRoom { get; private set; }
public SongData CurSong { get; set; }
public Stages RoomType;
public MapGrid.Room BattleRoom;
public int TodoEnemyAndChart;
public SongData CurSong;
}

public enum BattleEffectTrigger
Expand All @@ -55,16 +55,11 @@ public enum BattleEffectTrigger
public enum Stages
{
Title,
Battle,
Quit,
Map,
}

public enum MapRooms
{
Battle,
Chest,
Boss,
Quit,
Map,
}

public class MapGrid
Expand All @@ -87,7 +82,7 @@ public Room(int idx, int x, int y)
Y = y;
}

public void SetType(MapRooms type)
public void SetType(Stages type)
{
Type = type;
}
Expand All @@ -103,7 +98,7 @@ public void AddChild(int newIdx)
public int[] Children { get; private set; } = Array.Empty<int>();
public int X { get; private set; }
public int Y { get; private set; }
public MapRooms Type { get; private set; }
public Stages Type { get; private set; }
}

public void InitMapGrid(int width, int height, int paths)
Expand All @@ -114,6 +109,7 @@ public void InitMapGrid(int width, int height, int paths)

int startX = (width / 2);
_rooms = _rooms.Append(new Room(_curIdx, startX, 0)).ToArray();
_rooms[0].SetType(Stages.Battle);
_map[startX, 0] = _curIdx++;

for (int i = 0; i < paths; i++)
Expand All @@ -136,11 +132,7 @@ private void GeneratePath_r(int x, int y, int width, int height)
_rooms = _rooms.Append(new Room(_curIdx, nextX, y + 1)).ToArray();
_map[nextX, y + 1] = _curIdx;
_rooms[_map[x, y]].AddChild(_curIdx++);
_rooms[^1].SetType(MapRooms.Battle);
if (y > 0 && y % 3 == 0)
{
_rooms[^1].SetType(MapRooms.Chest);
}
_rooms[^1].SetType(PickRoomType(x, y));
}
else
{
Expand All @@ -152,6 +144,17 @@ private void GeneratePath_r(int x, int y, int width, int height)
}
}

private Stages PickRoomType(int x, int y)
{
if (y <= 2)
return Stages.Battle;
if (y % 3 == 0)
return Stages.Chest;
if (StageProducer.GlobalRng.Randf() < .1)
return Stages.Chest;
return Stages.Battle;
}

//Asserts that if there is a room at the same x, but y+1 they are connected
private void CreateCommonChildren(int width, int height)
{
Expand All @@ -171,7 +174,7 @@ private void CreateCommonChildren(int width, int height)
private void AddBossRoom(int width, int height)
{
_rooms = _rooms.Append(new Room(_curIdx, width / 2, height)).ToArray();
_rooms[_curIdx].SetType(MapRooms.Boss);
_rooms[_curIdx].SetType(Stages.Boss);
for (int i = 0; i < width; i++) //Attach all last rooms to a boss room
{
if (_map[i, height - 1] != 0)
Expand Down
34 changes: 30 additions & 4 deletions Globals/StageProducer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,17 @@ public void StartGame()
_isInitialized = true;
}

public static void ChangeCurRoom(MapGrid.Room room)
{
CurRoom = room;
}

public void TransitionFromRoom(int nextRoomIdx)
{
//CurRoom = Map.GetRooms()[nextRoomIdx];
TransitionStage(Stages.Battle);
TransitionStage(Map.GetRooms()[nextRoomIdx].Type, nextRoomIdx);
}

public void TransitionStage(Stages nextStage)
public void TransitionStage(Stages nextStage, int nextRoomIdx = -1)
{
GD.Print(GetTree().CurrentScene);
switch (nextStage)
Expand All @@ -52,9 +56,13 @@ public void TransitionStage(Stages nextStage)
GetTree().ChangeSceneToFile("res://scenes/SceneTransitions/TitleScreen.tscn");
break;
case Stages.Battle:
Config = new BattleConfig() { };
Config = MakeConfig(nextStage, nextRoomIdx);
GetTree().ChangeSceneToFile("res://scenes/BattleDirector/test_battle_scene.tscn");
break;
case Stages.Chest:
Config = MakeConfig(nextStage, nextRoomIdx);
GetTree().ChangeSceneToFile("res://scenes/ChestScene/ChestScene.tscn");
break;
case Stages.Map:
GetTree().ChangeSceneToFile("res://scenes/Maps/cartographer.tscn");
if (!_isInitialized)
Expand All @@ -73,4 +81,22 @@ public void TransitionStage(Stages nextStage)

_curStage = nextStage;
}

private BattleConfig MakeConfig(Stages nextRoom, int nextRoomIdx)
{
BattleConfig result = new BattleConfig();
result.BattleRoom = Map.GetRooms()[nextRoomIdx];
result.RoomType = nextRoom;
if (nextRoom is Stages.Battle or Stages.Boss)
{
result.CurSong = new SongData
{
Bpm = 120,
SongLength = -1,
NumLoops = 5,
};
}

return result;
}
}
5 changes: 5 additions & 0 deletions Globals/TimeKeeper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,9 @@ public partial class TimeKeeper : Node
public static float ChartLength;
public static float LoopLength;
public static float Bpm;

public static double PosMod(double i, double mod)
{
return (i % mod + mod) % mod;
}
}
Binary file modified scenes/BattleDirector/assets/BattleFrame1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
45 changes: 14 additions & 31 deletions scenes/BattleDirector/scripts/BattleDirector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ public partial class BattleDirector : Node2D

private SongData _curSong;

private bool _battleEnd;

#endregion

#region Note Handling
Expand Down Expand Up @@ -63,12 +61,11 @@ public PuppetTemplate GetTarget(Note note)
public override void _Ready()
{
//TODO: Should come from transition into battle
_curSong = new SongData
_curSong = StageProducer.Config.CurSong;
if (_curSong.SongLength <= 0)
{
Bpm = 120,
SongLength = Audio.Stream.GetLength(),
NumLoops = 5,
};
_curSong.SongLength = Audio.Stream.GetLength();
}
TimeKeeper.Bpm = _curSong.Bpm;

Player = GD.Load<PackedScene>("res://scenes/Puppets/PlayerPuppet.tscn")
Expand Down Expand Up @@ -119,12 +116,16 @@ private void Begin()
Audio.Play();
}

private void EndBattle()
{
StageProducer.ChangeCurRoom(StageProducer.Config.BattleRoom);
GetNode<StageProducer>("/root/StageProducer").TransitionStage(Stages.Map);
}

public override void _Process(double delta)
{
TimeKeeper.CurrentTime = Audio.GetPlaybackPosition();
CD.CheckMiss();
if (_battleEnd)
GetNode<StageProducer>("/root/StageProducer").TransitionStage(Stages.Map);
}
#endregion

Expand All @@ -137,24 +138,9 @@ public override void _UnhandledInput(InputEvent @event)
{
if (eventKey.Keycode == Key.Key0)
{
//DebugKillEnemy();
DebugKillEnemy();
}
}

if (@event.IsActionPressed("Pause"))
{
var pauseMenu = GD.Load<PackedScene>("res://scenes/UI/Pause.tscn");
GetNode<CanvasLayer>("UILayer").AddChild(pauseMenu.Instantiate());
GetTree().Paused = true;
}
if (@event.IsActionPressed("Inventory"))
{
var invenMenu = GD.Load<PackedScene>("res://scenes/UI/inventory.tscn")
.Instantiate<Inventory>();
GetNode<CanvasLayer>("UILayer").AddChild(invenMenu);
invenMenu.Display(Player.Stats);
GetTree().Paused = true;
}
}

private void OnNotePressed(ArrowType type)
Expand Down Expand Up @@ -213,26 +199,23 @@ private void CheckBattleStatus(PuppetTemplate puppet)
if (puppet == Player)
{
GD.Print("Player is Dead");
Audio.StreamPaused = true;
GetNode<StageProducer>("/root/StageProducer").TransitionStage(Stages.Title);
return;
}

//will have to adjust this to account for when we have multiple enemies at once
if (puppet == Enemy)
{
Audio.StreamPaused = true;
GD.Print("Enemy is dead");
ShowRewardSelection(3);
_battleEnd = true;
}
}

private void ShowRewardSelection(int amount)
{
var rewardUI = GD.Load<PackedScene>("res://scenes/UI/RewardSelectionUI.tscn")
.Instantiate<RewardSelect>();
AddChild(rewardUI);
rewardUI.Initialize(Player.Stats, amount);
GetTree().Paused = true;
RewardSelect.CreateSelection(this, Player.Stats, amount).Selected += EndBattle;
}

#endregion
Expand Down
4 changes: 3 additions & 1 deletion scenes/BattleDirector/test_battle_scene.tscn
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
[gd_scene load_steps=10 format=3 uid="uid://b0mrgr7h0ty1y"]
[gd_scene load_steps=11 format=3 uid="uid://b0mrgr7h0ty1y"]

[ext_resource type="Script" path="res://scenes/BattleDirector/scripts/BattleDirector.cs" id="1_cwqqr"]
[ext_resource type="PackedScene" uid="uid://dfevfib11kou1" path="res://scenes/ChartViewport/ChartViewport.tscn" id="2_cupb3"]
[ext_resource type="Script" path="res://scenes/BattleDirector/scripts/Conductor.cs" id="2_pcp76"]
[ext_resource type="Script" path="res://scenes/UI/scripts/MenuModule.cs" id="3_8hff6"]
[ext_resource type="Texture2D" uid="uid://qhwve7fik4do" path="res://scenes/BattleDirector/assets/bgupdate.png" id="4_13o87"]
[ext_resource type="Texture2D" uid="uid://dbjotl0v1ymia" path="res://scenes/BattleDirector/assets/BattleFrame1.png" id="6_0ak0g"]
[ext_resource type="PackedScene" uid="uid://duhiilcv4tat3" path="res://scenes/BattleDirector/NotePlacementBar.tscn" id="7_3ko4g"]
Expand Down Expand Up @@ -30,6 +31,7 @@ metadata/_edit_lock_ = true
stream = ExtResource("8_caqms")

[node name="UILayer" type="CanvasLayer" parent="."]
script = ExtResource("3_8hff6")

[node name="Conductor" type="Node" parent="." node_paths=PackedStringArray("CM")]
script = ExtResource("2_pcp76")
Expand Down
3 changes: 2 additions & 1 deletion scenes/ChartViewport/ChartManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ public partial class ChartManager : SubViewportContainer
public delegate void NoteReleasedEventHandler(ArrowType arrowType);

//Arbitrary vars, play with these
private double ChartLength = 5000; //Might move this to be song specific?
//Might move this to be song specific? For now, should never go below ~2000, else visual break because there isn't enough room to loop.
private double ChartLength = 5000;
private double _loopLen; //secs
public int BeatsPerLoop;

Expand Down
20 changes: 14 additions & 6 deletions scenes/ChartViewport/ChartViewport.tscn
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
[gd_scene load_steps=5 format=3 uid="uid://dfevfib11kou1"]
[gd_scene load_steps=7 format=3 uid="uid://dfevfib11kou1"]

[ext_resource type="Script" path="res://scenes/ChartViewport/ChartManager.cs" id="1_ruh2l"]
[ext_resource type="Texture2D" uid="uid://cp78odda2doab" path="res://scenes/ChartViewport/LoopMarker.png" id="2_q5cjc"]
[ext_resource type="Script" path="res://scenes/ChartViewport/Loopable.cs" id="3_5u57h"]
[ext_resource type="PackedScene" uid="uid://bn8txx53xlguw" path="res://scenes/NoteManager/note_manager.tscn" id="4_fd5fw"]
[ext_resource type="Shader" path="res://scenes/ChartViewport/StarryNight.gdshader" id="5_kqrxg"]

Expand All @@ -27,11 +29,6 @@ render_target_update_mode = 4
position = Vector2(-50, 0)
anchor_mode = 0

[node name="ChartLoopables" type="CanvasGroup" parent="SubViewport"]
unique_name_in_owner = true

[node name="ArrowGroup" type="Node" parent="SubViewport/ChartLoopables"]

[node name="StarShader" type="ColorRect" parent="SubViewport"]
material = SubResource("ShaderMaterial_5uw0y")
offset_left = -60.0
Expand All @@ -40,4 +37,15 @@ offset_bottom = 177.0
scale = Vector2(2.18, 2.18)
color = Color(0, 0, 0, 1)

[node name="ChartLoopables" type="CanvasGroup" parent="SubViewport"]
unique_name_in_owner = true

[node name="ArrowGroup" type="Node" parent="SubViewport/ChartLoopables"]

[node name="LoopMarker" type="Sprite2D" parent="SubViewport/ChartLoopables"]
position = Vector2(0, 90)
texture = ExtResource("2_q5cjc")
script = ExtResource("3_5u57h")
LoopOffset = 0.0

[node name="noteManager" parent="SubViewport" instance=ExtResource("4_fd5fw")]
Binary file added scenes/ChartViewport/LoopMarker.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions scenes/ChartViewport/LoopMarker.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://cp78odda2doab"
path="res://.godot/imported/LoopMarker.png-01682285489df860e67dba1278ff087a.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://scenes/ChartViewport/LoopMarker.png"
dest_files=["res://.godot/imported/LoopMarker.png-01682285489df860e67dba1278ff087a.ctex"]

[params]

compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
Loading