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
10 changes: 6 additions & 4 deletions Classes/Relics/RelicEffect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,21 @@ public partial class RelicEffect : IBattleEvent
private BattleEffectTrigger Trigger { get; set; }
private int _baseValue;
public int Value;
private Action<BattleDirector, RelicEffect, int> _onRelicEffect;
private Action<BattleEventArgs, RelicEffect, int> _onRelicEffect;
private bool _effectPersists = false;

public RelicEffect(
BattleEffectTrigger trigger,
int val,
Action<BattleDirector, RelicEffect, int> onRelicEffect
Action<BattleEventArgs, RelicEffect, int> onRelicEffect,
bool persists = false
)
{
_baseValue = val;
Value = _baseValue;
Trigger = trigger;
_onRelicEffect = onRelicEffect;
_effectPersists = persists;
}

public void OnBattleEnd()
Expand All @@ -31,9 +33,9 @@ public void OnBattleEnd()
Value = _baseValue;
}

public void OnTrigger(BattleDirector battleDirector)
public void OnTrigger(BattleEventArgs e)
{
_onRelicEffect(battleDirector, this, Value);
_onRelicEffect(e, this, Value);
}

public BattleEffectTrigger GetTrigger()
Expand Down
8 changes: 7 additions & 1 deletion Globals/FunkEngineNameSpace.cs
Original file line number Diff line number Diff line change
Expand Up @@ -372,12 +372,18 @@ private void AddBossRoom(int width, int height)
}

#region Interfaces

public class BattleEventArgs(BattleDirector director) : EventArgs
{
public BattleDirector BD = director;
}

/**
* <summary>A BattleDirector driven battle event. Needs an enum defined trigger.</summary>
*/
public interface IBattleEvent
{
void OnTrigger(BattleDirector BD);
void OnTrigger(BattleEventArgs e);
BattleEffectTrigger GetTrigger();
}

Expand Down
14 changes: 7 additions & 7 deletions Globals/Scribe.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public partial class Scribe : Node
new RelicEffect(
BattleEffectTrigger.OnPickup,
10,
(director, self, val) =>
(e, self, val) =>
{
StageProducer.PlayerStats.MaxHealth += val;
StageProducer.PlayerStats.CurrentHealth += val;
Expand All @@ -126,9 +126,9 @@ public partial class Scribe : Node
new RelicEffect(
BattleEffectTrigger.NotePlaced,
2,
(director, self, val) =>
(e, self, val) =>
{
director.Player.Heal(val);
e.BD.Player.Heal(val);
}
),
}
Expand All @@ -143,9 +143,9 @@ public partial class Scribe : Node
new RelicEffect(
BattleEffectTrigger.OnLoop,
1,
(director, self, val) =>
(e, self, val) =>
{
director.NPB.IncreaseBonusMult(val);
e.BD.NPB.IncreaseBonusMult(val);
self.Value++;
}
),
Expand All @@ -161,9 +161,9 @@ public partial class Scribe : Node
new RelicEffect(
BattleEffectTrigger.OnLoop,
10,
(director, self, val) =>
(e, self, val) =>
{
director.NPB.IncreaseCharge(val);
e.BD.NPB.IncreaseCharge(val);
self.Value += 5;
}
),
Expand Down
2 changes: 1 addition & 1 deletion Globals/Translations/Translations.csv
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ CONTROLS_RETURN_BUTTON,Return,返回
ESCAPE_MENU_RESUME,Resume,继续
ESCAPE_MENU_QUIT,Quit,退出
ESCAPE_MENU_TITLE,Quit to Title,返回标题
CHEST_ROOM_REWARDS,Rewards!,奖励!
CHEST_ROOM_REWARDS,Reward Selection!,奖励!
CHEST_ROOM_SKIP,Skip,跳过
CHEST_ROOM_ACCEPT,Accept,接受
BATTLE_ROOM_BEGIN_BUTTON,"Begin Battle [Enter]","开始战斗 [Enter]"
Expand Down
27 changes: 14 additions & 13 deletions Scenes/BattleDirector/NotePlacementBar.tscn
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[gd_scene load_steps=12 format=3 uid="uid://duhiilcv4tat3"]

[ext_resource type="Script" path="res://Scenes/BattleDirector/Scripts/NotePlacementBar.cs" id="1_456es"]
[ext_resource type="Script" uid="uid://gj666xe815py" path="res://Scenes/BattleDirector/Scripts/NotePlacementBar.cs" id="1_456es"]
[ext_resource type="Texture2D" uid="uid://cnyr5usjdv0ni" path="res://Scenes/BattleDirector/Assets/NoteQueue_Frame.png" id="2_3tw16"]
[ext_resource type="Texture2D" uid="uid://c3chrsxrulapd" path="res://Classes/Notes/Assets/Note_PlayerBasic.png" id="3_6ylx6"]
[ext_resource type="Texture2D" uid="uid://caw70lr5e1yiq" path="res://Classes/Notes/Assets/Note_PlayerDouble.png" id="4_6w8ha"]
Expand All @@ -14,14 +14,23 @@ width = 34
height = 100

[sub_resource type="Gradient" id="Gradient_xvck1"]
offsets = PackedFloat32Array(0, 0.373239, 0.690141, 1)
colors = PackedColorArray(0, 1, 0, 1, 1, 0, 0.4, 1, 0, 1, 0.95, 1, 1, 0, 0, 1)
offsets = PackedFloat32Array(0)
colors = PackedColorArray(0, 0, 0, 1)

[sub_resource type="GradientTexture2D" id="GradientTexture2D_0bqho"]
gradient = SubResource("Gradient_xvck1")
width = 32
height = 98
fill_to = Vector2(0, 1)
fill_from = Vector2(0, 1)
fill_to = Vector2(0, 0)

[sub_resource type="Gradient" id="Gradient_2uknl"]
offsets = PackedFloat32Array(0)
colors = PackedColorArray(0.46, 0.2162, 0.39905, 1)

[sub_resource type="GradientTexture1D" id="GradientTexture1D_d62c7"]
gradient = SubResource("Gradient_2uknl")
width = 1

[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_fy2uu"]
lifetime_randomness = 0.32
Expand All @@ -41,14 +50,6 @@ turbulence_noise_scale = 5.0
turbulence_influence_min = 0.0
turbulence_influence_max = 0.018

[sub_resource type="Gradient" id="Gradient_2uknl"]
offsets = PackedFloat32Array(0)
colors = PackedColorArray(0.46, 0.2162, 0.39905, 1)

[sub_resource type="GradientTexture1D" id="GradientTexture1D_d62c7"]
gradient = SubResource("Gradient_2uknl")
width = 1

[node name="NotePlacementBar" type="Control" node_paths=PackedStringArray("_notePlacementBar", "_particles", "_fullBarParticles", "_currentComboMultText", "_currentNote", "_nextNote")]
layout_mode = 3
anchors_preset = 15
Expand Down Expand Up @@ -80,12 +81,12 @@ z_index = 1
position = Vector2(-1, -32)
emitting = false
amount = 22
process_material = SubResource("ParticleProcessMaterial_fy2uu")
texture = SubResource("GradientTexture1D_d62c7")
lifetime = 2.0
preprocess = 0.1
explosiveness = 0.3
randomness = 0.05
process_material = SubResource("ParticleProcessMaterial_fy2uu")

[node name="FullBarParticles" type="CPUParticles2D" parent="PlacementBar"]
position = Vector2(14, 98)
Expand Down
80 changes: 66 additions & 14 deletions Scenes/BattleDirector/Scripts/BattleDirector.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using FunkEngine;
using Godot;
using Melanchall.DryWetMidi.Interaction;

/**<summary>BattleDirector: Higher priority director to manage battle effects. Can directly access managers, which should signal up to Director WIP</summary>
*/
Expand Down Expand Up @@ -42,8 +43,9 @@ private bool PlayerAddNote(ArrowType type, Beat beat)

Note noteToPlace = NPB.NotePlaced();
noteToPlace.OnHit(this, Timing.Okay);

CD.AddPlayerNote(noteToPlace, type, beat);
NotePlaced?.Invoke(this);
Harbinger.Instance.InvokeNotePlaced(new ArrowData(type, beat, noteToPlace));
return true;
}

Expand Down Expand Up @@ -84,6 +86,7 @@ public override void _Ready()
}

TimeKeeper.InitVals(curSong.Bpm);
Harbinger.Init(this);
InitPlayer();
InitEnemies();
CD.Initialize(curSong);
Expand Down Expand Up @@ -128,7 +131,7 @@ private void UpdateBeat(Beat beat)
}
if (beat.Loop > TimeKeeper.LastBeat.Loop)
{
ChartLooped?.Invoke(this);
Harbinger.Instance.InvokeChartLoop(beat.Loop);
}
TimeKeeper.LastBeat = beat;
}
Expand Down Expand Up @@ -164,13 +167,13 @@ private void OnTimedInput(ArrowData data, double beatDif)
Timing timed = CheckTiming(beatDif);

data.NoteRef.OnHit(this, timed);
NPB.HandleTiming(timed);
NPB.HandleTiming(timed, data.Type);
CM.ComboText(timed, data.Type, NPB.GetCurrentCombo());
}

private void ForceMiss(ArrowType type)
{
NPB.HandleTiming(Timing.Miss);
NPB.HandleTiming(Timing.Miss, type);
CM.ComboText(Timing.Miss, type, NPB.GetCurrentCombo());
Player.TakeDamage(4);
}
Expand Down Expand Up @@ -242,22 +245,15 @@ private void TransitionOutOfBattle()
#endregion

#region BattleEffect Handling

private delegate void NotePlacedHandler(BattleDirector BD);
private event NotePlacedHandler NotePlaced;

private delegate void ChartLoopHandler(BattleDirector BD);
private event ChartLoopHandler ChartLooped;

private void AddEvent(IBattleEvent bEvent)
{
switch (bEvent.GetTrigger()) //TODO: Look into a way to get eventhandler from string
{
case BattleEffectTrigger.NotePlaced:
NotePlaced += bEvent.OnTrigger;
Harbinger.Instance.NotePlaced += bEvent.OnTrigger;
break;
case BattleEffectTrigger.OnLoop:
ChartLooped += bEvent.OnTrigger;
Harbinger.Instance.ChartLooped += bEvent.OnTrigger;
break;
}
}
Expand Down Expand Up @@ -293,8 +289,64 @@ private void CleanUpRelics()
}
#endregion

public partial class Harbinger : Resource
{
private static Harbinger _instance;
public static Harbinger Instance => _instance;

private BattleDirector _curDirector;

static Harbinger() { }

private Harbinger(BattleDirector BD)
{
_curDirector = BD;
}

internal static void Init(BattleDirector BD)
{
_instance = new Harbinger(BD);
}

/// <summary>
/// Event Args to handle event types triggering from the action of a note, without timing.
/// </summary>
/// <param name="bd">The BattleDirector calling the event.</param>
/// <param name="data">The note data of the passing note.</param>
public class NoteEventArgs(BattleDirector bd, ArrowData data) : BattleEventArgs(bd)
{
public ArrowData Data = data;
}

/// <summary>
/// Event Args to handle event types triggering from the start of a new loop.
/// </summary>
/// <param name="bd">The BattleDirector calling the event.</param>
/// <param name="incomingLoop">The loop starting.</param>
public class LoopEventArgs(BattleDirector bd, int incomingLoop) : BattleEventArgs(bd)
{
public int Loop = incomingLoop;
}

internal delegate void NotePlacedHandler(BattleEventArgs e);
internal event NotePlacedHandler NotePlaced;

public void InvokeNotePlaced(ArrowData data)
{
NotePlaced?.Invoke(new NoteEventArgs(_curDirector, data));
}

internal delegate void ChartLoopHandler(BattleEventArgs e);
internal event ChartLoopHandler ChartLooped;

public void InvokeChartLoop(int incLoop)
{
ChartLooped?.Invoke(new LoopEventArgs(_curDirector, incLoop));
}
}

private void DebugKillEnemy()
{
//Enemy.TakeDamage(1000);
Enemy.TakeDamage(1000);
}
}
Loading