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
4 changes: 2 additions & 2 deletions Classes/MidiMaestro/SongTemplate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ public struct SongTemplate
public string Name;
public readonly string AudioLocation;
public string MIDILocation;
public readonly string EnemyScenePath;
public readonly string[] EnemyScenePath;
public SongData SongData;

public SongTemplate(
SongData songData,
string name = "",
string audioLocation = "",
string midiLocation = "",
string enemyScenePath = ""
string[] enemyScenePath = null
)
{
Name = name;
Expand Down
10 changes: 8 additions & 2 deletions Classes/Notes/Note.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public partial class Note : Resource, IDisplayable
public string Name { get; set; }
private int _baseVal;
public float CostModifier { get; private set; }
public Targetting TargetType { get; private set; }
private Action<BattleDirector, Note, Timing> NoteEffect;

public const double TimingMax = 0.5d; //The max range for a note to be timed is its beat +/- this const
Expand All @@ -27,7 +28,8 @@ public Note(
PuppetTemplate owner = null,
int baseVal = 1,
Action<BattleDirector, Note, Timing> noteEffect = null,
float costModifier = 1.0f
float costModifier = 1.0f,
Targetting targetType = Targetting.First
)
{
Id = id;
Expand All @@ -38,13 +40,17 @@ public Note(
?? (
(BD, source, timing) =>
{
BD.GetTarget(this).TakeDamage((int)timing * source._baseVal);
Array.ForEach(
BD.GetTargets(source), //Ok, sure
enemy => enemy.TakeDamage((int)timing * source._baseVal)
);
}
);
_baseVal = baseVal;
Texture = texture;
Tooltip = tooltip;
CostModifier = costModifier;
TargetType = targetType;
}

public void OnHit(BattleDirector BD, Timing timing)
Expand Down
10 changes: 8 additions & 2 deletions Globals/FunkEngineNameSpace.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public struct BattleConfig
{
public Stages RoomType;
public MapGrid.Room BattleRoom;
public string EnemyScenePath;
public string[] EnemyScenePath;
public SongTemplate CurSong;
}

Expand Down Expand Up @@ -222,6 +222,12 @@ public enum Timing
Perfect = 4,
}

public enum Targetting
{
First,
All,
}

public enum BattleEffectTrigger
{
NotePlaced,
Expand Down Expand Up @@ -262,7 +268,7 @@ public Room[] GetRooms()
public class Room
{
public int Idx { get; private set; }
public int[] Children { get; private set; } = Array.Empty<int>();
public int[] Children { get; private set; } = [];
public int X { get; private set; }
public int Y { get; private set; }
public Stages Type { get; private set; }
Expand Down
29 changes: 21 additions & 8 deletions Globals/Scribe.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public partial class Scribe : Node
{
if (timing == Timing.Miss)
return;
director.Enemy.TakeDamage((int)timing * note.GetBaseVal());
director.GetFirstEnemy()?.TakeDamage((int)timing * note.GetBaseVal());
}
),
new Note(
Expand All @@ -47,7 +47,7 @@ public partial class Scribe : Node
{
if (timing == Timing.Miss)
return;
director.Enemy.TakeDamage(note.GetBaseVal() * (int)timing);
director.GetFirstEnemy()?.TakeDamage(note.GetBaseVal() * (int)timing);
}
),
new Note(
Expand Down Expand Up @@ -76,7 +76,7 @@ public partial class Scribe : Node
if (timing == Timing.Miss)
return;
director.Player.Heal((int)timing * note.GetBaseVal());
director.Enemy.TakeDamage((int)timing * note.GetBaseVal());
director.GetFirstEnemy()?.TakeDamage((int)timing * note.GetBaseVal());
}
),
new Note(
Expand All @@ -90,7 +90,7 @@ public partial class Scribe : Node
{
if (timing == Timing.Miss)
return;
director.Enemy.TakeDamage((int)timing + note.GetBaseVal());
director.GetFirstEnemy()?.TakeDamage((int)timing + note.GetBaseVal());
},
0.25f
),
Expand Down Expand Up @@ -171,7 +171,7 @@ public partial class Scribe : Node
),
};

public static readonly SongTemplate[] SongDictionary = new[]
public static readonly SongTemplate[] SongDictionary = new[] //Generalize and make pools for areas/room types
{
new SongTemplate(
new SongData
Expand All @@ -182,7 +182,8 @@ public partial class Scribe : Node
},
"Song1",
"Audio/Song1.ogg",
"Audio/Midi/Song1.mid"
"Audio/Midi/Song1.mid",
[P_BossBlood.LoadPath]
),
new SongTemplate(
new SongData
Expand All @@ -194,7 +195,19 @@ public partial class Scribe : Node
"Song2",
"Audio/Song2.ogg",
"Audio/Midi/Song2.mid",
P_Parasifly.LoadPath
[P_Parasifly.LoadPath]
),
new SongTemplate(
new SongData
{
Bpm = 60,
SongLength = -1,
NumLoops = 1,
},
"Song2",
"Audio/Song2.ogg",
"Audio/Midi/Song2.mid",
[P_Parasifly.LoadPath, P_Parasifly.LoadPath]
),
new SongTemplate(
new SongData
Expand All @@ -206,7 +219,7 @@ public partial class Scribe : Node
"Song3",
"Audio/Song3.ogg",
"Audio/Midi/Song3.mid",
P_TheGWS.LoadPath
[P_TheGWS.LoadPath]
),
};

Expand Down
4 changes: 2 additions & 2 deletions Globals/StageProducer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,12 @@ private BattleConfig MakeBattleConfig(Stages nextRoom, int nextRoomIdx)
switch (nextRoom)
{
case Stages.Battle:
int songIdx = stageRng.RandiRange(1, 2);
int songIdx = stageRng.RandiRange(1, 3);
result.CurSong = Scribe.SongDictionary[songIdx];
result.EnemyScenePath = Scribe.SongDictionary[songIdx].EnemyScenePath;
break;
case Stages.Boss:
result.EnemyScenePath = P_BossBlood.LoadPath;
result.EnemyScenePath = Scribe.SongDictionary[0].EnemyScenePath;
result.CurSong = Scribe.SongDictionary[0];
break;
case Stages.Chest:
Expand Down
21 changes: 17 additions & 4 deletions Scenes/BattleDirector/BattleScene.tscn
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[gd_scene load_steps=10 format=3 uid="uid://b0mrgr7h0ty1y"]

[ext_resource type="Script" path="res://Scenes/BattleDirector/Scripts/BattleDirector.cs" id="1_jmdo1"]
[ext_resource type="Script" path="res://Scenes/UI/Scripts/MenuModule.cs" id="2_ka0ws"]
[ext_resource type="Script" path="res://Scenes/BattleDirector/Scripts/Conductor.cs" id="3_elcaj"]
[ext_resource type="Script" uid="uid://bttu0wmy2fp64" path="res://Scenes/BattleDirector/Scripts/BattleDirector.cs" id="1_jmdo1"]
[ext_resource type="Script" uid="uid://pl57giqyhckb" path="res://Scenes/UI/Scripts/MenuModule.cs" id="2_ka0ws"]
[ext_resource type="Script" uid="uid://tg14hkh1n7iv" path="res://Scenes/BattleDirector/Scripts/Conductor.cs" id="3_elcaj"]
[ext_resource type="PackedScene" uid="uid://duhiilcv4tat3" path="res://Scenes/BattleDirector/NotePlacementBar.tscn" id="4_qk7om"]
[ext_resource type="PackedScene" uid="uid://dfevfib11kou1" path="res://Scenes/ChartViewport/ChartViewport.tscn" id="5_r2xh0"]
[ext_resource type="Texture2D" uid="uid://qhwve7fik4do" path="res://SharedAssets/BackGround_Full.png" id="6_0jtpx"]
Expand All @@ -17,9 +17,10 @@ gradient = SubResource("Gradient_8uy3a")
fill_from = Vector2(1, 0)
fill_to = Vector2(0.738532, 1)

[node name="ProtoBattleDirector" type="Node2D" node_paths=PackedStringArray("CD", "CM", "NPB", "Audio", "_focusedButton")]
[node name="ProtoBattleDirector" type="Node2D" node_paths=PackedStringArray("PuppetMarkers", "CD", "CM", "NPB", "Audio", "_focusedButton")]
process_mode = 1
script = ExtResource("1_jmdo1")
PuppetMarkers = [NodePath("PlayerMarker"), NodePath("Enemy1Marker"), NodePath("Enemy2Marker"), NodePath("Enemy3Marker")]
CD = NodePath("Conductor")
CM = NodePath("SubViewport")
NPB = NodePath("NotePlacementBar")
Expand All @@ -37,6 +38,18 @@ CurSceneNode = NodePath("..")
script = ExtResource("3_elcaj")
CM = NodePath("../SubViewport")

[node name="PlayerMarker" type="Marker2D" parent="."]
position = Vector2(158, 125)

[node name="Enemy1Marker" type="Marker2D" parent="."]
position = Vector2(350, 125)

[node name="Enemy2Marker" type="Marker2D" parent="."]
position = Vector2(450, 125)

[node name="Enemy3Marker" type="Marker2D" parent="."]
position = Vector2(550, 125)

[node name="NotePlacementBar" parent="." instance=ExtResource("4_qk7om")]
offset_top = 183.0
offset_bottom = 183.0
Expand Down
67 changes: 52 additions & 15 deletions Scenes/BattleDirector/Scripts/BattleDirector.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Linq;
using FunkEngine;
using Godot;
using Melanchall.DryWetMidi.Interaction;
Expand All @@ -12,7 +13,10 @@ public partial class BattleDirector : Node2D
public static readonly string LoadPath = "res://Scenes/BattleDirector/BattleScene.tscn";

public PlayerPuppet Player;
public EnemyPuppet Enemy;
private EnemyPuppet[] _enemies;

[Export]
public Marker2D[] PuppetMarkers = new Marker2D[4]; //[0] is always player

[Export]
private Conductor CD;
Expand Down Expand Up @@ -49,14 +53,31 @@ private bool PlayerAddNote(ArrowType type, Beat beat)
return true;
}

public PuppetTemplate GetTarget(Note note)
public PuppetTemplate[] GetTargets(Note note)
{
if (!note.IsPlayerNote())
return [Player];
switch (note.TargetType)
{
case Targetting.First:
if (GetFirstEnemy() != null)
return [GetFirstEnemy()];
return [];
case Targetting.All:
return _enemies.Where(x => x.GetCurrentHealth() > 0).ToArray();
}
return null;
}

public PuppetTemplate GetFirstEnemy()
{
if (note.Owner == Player)
foreach (var enemy in _enemies)
{
return Enemy;
if (enemy.GetCurrentHealth() > 0)
return enemy;
}

return Player;
return null;
}
#endregion

Expand Down Expand Up @@ -99,7 +120,7 @@ public override void _Ready()
private void InitPlayer()
{
Player = GD.Load<PackedScene>(PlayerPuppet.LoadPath).Instantiate<PlayerPuppet>();
AddChild(Player);
PuppetMarkers[0].AddChild(Player);
Player.Defeated += CheckBattleStatus;
EventizeRelics();
NPB.Setup(StageProducer.PlayerStats);
Expand All @@ -108,11 +129,19 @@ private void InitPlayer()
private void InitEnemies()
{
//TODO: Refine
Enemy = GD.Load<PackedScene>(StageProducer.Config.EnemyScenePath)
.Instantiate<EnemyPuppet>();
AddChild(Enemy);
Enemy.Defeated += CheckBattleStatus;
AddEnemyEffects();
_enemies = new EnemyPuppet[StageProducer.Config.EnemyScenePath.Length];
for (int i = 0; i < StageProducer.Config.EnemyScenePath.Length; i++)
{
EnemyPuppet enemy = GD.Load<PackedScene>(StageProducer.Config.EnemyScenePath[0])
.Instantiate<EnemyPuppet>();
if (_enemies.Length == 1)
PuppetMarkers[2].AddChild(enemy);
else
PuppetMarkers[i + 1].AddChild(enemy);
enemy.Defeated += CheckBattleStatus;
_enemies[i] = enemy;
AddEnemyEffects(enemy);
}
}

public override void _Process(double delta)
Expand Down Expand Up @@ -207,10 +236,15 @@ private void CheckBattleStatus(PuppetTemplate puppet) //Called when a puppet die
OnBattleLost();
return;
}
if (puppet == Enemy)
if (puppet is EnemyPuppet && IsBattleWon())
OnBattleWon(); //will have to adjust this to account for when we have multiple enemies at once
}

private bool IsBattleWon()
{
return GetFirstEnemy() == null;
}

private void OnBattleWon()
{
Audio.StreamPaused = true;
Expand Down Expand Up @@ -258,9 +292,9 @@ private void AddEvent(IBattleEvent bEvent)
}
}

private void AddEnemyEffects()
private void AddEnemyEffects(EnemyPuppet enemy)
{
foreach (var effect in Enemy.GetBattleEvents())
foreach (var effect in enemy.GetBattleEvents())
{
AddEvent(effect);
}
Expand Down Expand Up @@ -347,6 +381,9 @@ public void InvokeChartLoop(int incLoop)

private void DebugKillEnemy()
{
Enemy.TakeDamage(1000);
foreach (EnemyPuppet enemy in _enemies)
{
enemy.TakeDamage(1000);
}
}
}
5 changes: 4 additions & 1 deletion Scenes/ChestScene/ChestScene.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@ public partial class ChestScene : Node2D
[Export]
public Button ChestButton;

[Export]
public Marker2D PlayerMarker;

public override void _Ready()
{
_player = GD.Load<PackedScene>(PlayerPuppet.LoadPath).Instantiate<PlayerPuppet>();
AddChild(_player);
PlayerMarker.AddChild(_player);

ChestButton.Pressed += GetLoot;
}
Expand Down
Loading