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
18 changes: 0 additions & 18 deletions Classes/Note.cs

This file was deleted.

47 changes: 47 additions & 0 deletions Classes/Notes/Note.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using System;
using FunkEngine;
using Godot;

/**
* @class Note
* @brief Data structure class for holding data and methods for a battle time note. WIP
*/
public partial class Note : Resource
{
public PuppetTemplate Owner;
public string Name;
private int _baseVal;
private Action<BattleDirector, Note, Timing> NoteEffect; //TODO: Where/How to deal with timing.

//public string Tooltip;

public Note(
string name,
PuppetTemplate owner = null,
int baseVal = 1,
Action<BattleDirector, Note, Timing> noteEffect = null
)
{
Name = name;
Owner = owner;
NoteEffect =
noteEffect
?? (
(BD, source, Timing) =>
{
BD.GetTarget(this).TakeDamage(source._baseVal);
}
);
_baseVal = baseVal;
}

public void OnHit(BattleDirector BD, Timing timing)
{
NoteEffect(BD, this, timing);
}

public Note Clone()
{
return (Note)MemberwiseClone();
}
}
31 changes: 31 additions & 0 deletions Classes/Relics/RelicEffect.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using System;
using FunkEngine;
using Godot;

public partial class RelicEffect : IBattleEvent
{
private BattleEffectTrigger Trigger { get; set; }
public int BaseValue;
private Action<BattleDirector, int> OnRelicEffect;

public RelicEffect(
BattleEffectTrigger trigger,
int val,
Action<BattleDirector, int> onRelicEffect
)
{
BaseValue = val;
Trigger = trigger;
OnRelicEffect = onRelicEffect;
}

public void OnTrigger(BattleDirector battleDirector)
{
OnRelicEffect(battleDirector, BaseValue);
}

public BattleEffectTrigger GetTrigger()
{
return Trigger;
}
}
22 changes: 22 additions & 0 deletions Classes/Relics/RelicTemplate.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System;
using FunkEngine;
using Godot;

public partial class RelicTemplate : Resource
{
public RelicEffect[] Effects;
public string Name;

//public Texture2D Texture
//public string Tooltip
public RelicTemplate(string Name = "", RelicEffect[] EffectTags = null)
{
Effects = EffectTags;
this.Name = Name;
}

public RelicTemplate Clone()
{
return (RelicTemplate)MemberwiseClone();
}
}
56 changes: 56 additions & 0 deletions Globals/FunkEngineNameSpace.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using Godot;

namespace FunkEngine;

public enum ArrowType
{
Up = 0,
Down = 1,
Left = 2,
Right = 3,
}

public enum BattleEffectTrigger
{
NotePlaced,
NoteHit,
SelfNoteHit,
}

public enum Timing
{
Miss = 0,
Bad = 1,
Okay = 2,
Good = 3,
Perfect = 4,
}

public enum Stages
{
Title,
Battle,
Quit,
Map,
}

public struct SongData
{
public int Bpm;
public double SongLength;
public int NumLoops;
}

public struct ArrowData
{
public Color Color;
public string Key;
public NoteChecker Node;
public ArrowType Type;
}

public interface IBattleEvent
{
void OnTrigger(BattleDirector BD);
BattleEffectTrigger GetTrigger();
}
49 changes: 49 additions & 0 deletions Globals/Scribe.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using System;
using FunkEngine;
using Godot;

/**
* Global for storing defined data, e.g. Notes and Relic Dictionaries.
*/
public partial class Scribe : Node
{
public static readonly Note[] NoteDictionary = new[]
{
new Note(
"EnemyBase",
null,
1,
(director, note, timing) =>
{
director.Player.TakeDamage(4 - (int)timing);
}
),
new Note(
"PlayerBase",
null,
1,
(director, note, timing) =>
{
director.Enemy.TakeDamage((int)timing);
}
),
};

public static readonly RelicTemplate[] RelicDictionary = new[]
{
new RelicTemplate(
"Good Vibes",
new RelicEffect[]
{
new RelicEffect(
BattleEffectTrigger.NotePlaced,
5,
(director, val) =>
{
director.Player.Heal(val);
}
),
}
),
};
}
128 changes: 128 additions & 0 deletions Globals/StageProducer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
using System;
using System.Linq;
using FunkEngine;
using Godot;

public partial class StageProducer : Node
{
//Generate a map, starting as a width x height grid, pick a starting spot and do (path) paths from that to the last
//row, connecting the path, then connect all at the end to the boss room.
public static RandomNumberGenerator GlobalRng = new RandomNumberGenerator();
private ulong _seed;
private ulong _lastRngState;

private Stages _curStage = Stages.Title;
private Node _curScene;

private MapGrid _map = new MapGrid();

public class MapGrid
{
private int[,] _map;
private Room[] _rooms;
private int _curIdx = 0;
private int _curRoom = 0;

Check warning on line 24 in Globals/StageProducer.cs

View workflow job for this annotation

GitHub Actions / build

The field 'StageProducer.MapGrid._curRoom' is assigned but its value is never used

Check warning on line 24 in Globals/StageProducer.cs

View workflow job for this annotation

GitHub Actions / build

The field 'StageProducer.MapGrid._curRoom' is assigned but its value is never used

public class Room
{
public Room(int idx, int x, int y)
{
Idx = idx;
X = x;
Y = y;
}

public void SetType(string type)
{
Type = type;
}

public void AddChild(int newIdx)
{
if (Children.Contains(newIdx))
return;
Children = Children.Append(newIdx).ToArray();
}

private int Idx;
private int[] Children = Array.Empty<int>();
private int X;
private int Y;
private string Type;
}

public void InitMapGrid(int width, int height, int paths)
{
_curIdx = 0;
_rooms = Array.Empty<Room>();
_map = new int[width, height]; //x,y

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

for (int i = 0; i < paths; i++)
{
GeneratePath_r(startX, 0, width, height);
}

AddBossRoom(width, height);
}

//Start at x, y, assume prev room exists. Picks new x pos within +/- 1, attaches recursively
private void GeneratePath_r(int x, int y, int width, int height)
{
int nextX = GlobalRng.RandiRange(Math.Max(x - 1, 0), Math.Min(x + 1, width - 1));
if (_map[nextX, y + 1] == 0)
{
_rooms = _rooms.Append(new Room(_curIdx, nextX, y + 1)).ToArray();
_map[nextX, y + 1] = _curIdx;
_rooms[_map[x, y]].AddChild(_curIdx++);
}
else
{
_rooms[_map[x, y]].AddChild(_map[nextX, y + 1]);
}
if (y < height - 2)
{
GeneratePath_r(nextX, y + 1, width, height);
}
}

private void AddBossRoom(int width, int height)
{
_rooms = _rooms.Append(new Room(_curIdx, 0, height)).ToArray();
_rooms[_curIdx].SetType("Boss");
for (int i = 0; i < width; i++) //Attach all last rooms to a boss room
{
if (_map[i, height - 1] != 0)
{
_rooms[_map[i, height - 1]].AddChild(_curIdx);
}
}
}
}

public void StartGame()
{
_map.InitMapGrid(2, 2, 1);
_seed = GlobalRng.Seed;
_lastRngState = GlobalRng.State;
}

public void TransitionStage(Stages nextStage)
{
GD.Print(GetTree().CurrentScene);
switch (nextStage)
{
case Stages.Title:
GetTree().ChangeSceneToFile("res://scenes/SceneTransitions/TitleScreen.tscn");
break;
case Stages.Battle:
GetTree().ChangeSceneToFile("res://scenes/BattleDirector/test_battle_scene.tscn");
break;
}

_curStage = nextStage;
}
}
File renamed without changes.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ Current team members include:


#### Attributions:
Note icon: <a href="https://www.flaticon.com/free-icons/next" title="next icons">Next icons created by Pixel perfect - Flaticon</a>

First Song: <a href="https://freesound.org/people/Magntron/sounds/335571/" title="gameMusic">gameMusic by Magntron - freesound.org</a>


6 changes: 4 additions & 2 deletions project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ config_version=5
[application]

config/name="Funk Engine"
run/main_scene="res://scenes/BattleDirector/test_battle_scene.tscn"
run/main_scene="res://scenes/SceneTransitions/TitleScreen.tscn"
config/features=PackedStringArray("4.3", "C#", "Forward Plus")
config/icon="res://icon.svg"

[autoload]

TimeKeeper="*res://scripts/TimeKeeper.cs"
TimeKeeper="*res://Globals/TimeKeeper.cs"
Scribe="*res://Globals/Scribe.cs"
StageProducer="*res://Globals/StageProducer.cs"

[display]

Expand Down
Loading