Add initial implementation of game mechanics and resources management
This commit is contained in:
29
Scripts/Core/Effects/AddResourceEffect.cs
Normal file
29
Scripts/Core/Effects/AddResourceEffect.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using Godot;
|
||||
|
||||
namespace ParasiticGod.Scripts.Core.Effects;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class AddResourceEffect : Effect
|
||||
{
|
||||
[Export] public ResourceType TargetResource { get; set; }
|
||||
[Export] public double Value { get; set; }
|
||||
|
||||
public override void Execute(GameState state)
|
||||
{
|
||||
switch (TargetResource)
|
||||
{
|
||||
case ResourceType.Faith:
|
||||
state.Faith += Value;
|
||||
break;
|
||||
case ResourceType.Followers:
|
||||
state.Followers += (long)Value;
|
||||
break;
|
||||
case ResourceType.Corruption:
|
||||
state.Corruption += Value;
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
}
|
||||
}
|
1
Scripts/Core/Effects/AddResourceEffect.cs.uid
Normal file
1
Scripts/Core/Effects/AddResourceEffect.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://flyhl4i86han
|
24
Scripts/Core/Effects/ApplyBuffEffect.cs
Normal file
24
Scripts/Core/Effects/ApplyBuffEffect.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using Godot;
|
||||
|
||||
namespace ParasiticGod.Scripts.Core.Effects;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class ApplyBuffEffect : Effect
|
||||
{
|
||||
public enum BuffTarget { FaithGeneration }
|
||||
|
||||
[Export] public BuffTarget TargetStat { get; set; }
|
||||
[Export] public float Multiplier { get; set; } = 2.0f;
|
||||
[Export] public double Duration { get; set; } = 30.0;
|
||||
|
||||
public override void Execute(GameState gameState)
|
||||
{
|
||||
var newBuff = new Buff
|
||||
{
|
||||
Multiplier = Multiplier,
|
||||
Duration = Duration
|
||||
};
|
||||
|
||||
gameState.ActiveBuffs.Add(newBuff);
|
||||
}
|
||||
}
|
1
Scripts/Core/Effects/ApplyBuffEffect.cs.uid
Normal file
1
Scripts/Core/Effects/ApplyBuffEffect.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://cmhd8jmckgtep
|
7
Scripts/Core/Effects/Buff.cs
Normal file
7
Scripts/Core/Effects/Buff.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace ParasiticGod.Scripts.Core.Effects;
|
||||
|
||||
public class Buff
|
||||
{
|
||||
public float Multiplier { get; set; } = 1.0f;
|
||||
public double Duration { get; set; }
|
||||
}
|
1
Scripts/Core/Effects/Buff.cs.uid
Normal file
1
Scripts/Core/Effects/Buff.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://c5fq6vt4uyce2
|
36
Scripts/Core/Effects/ConvertResourceEffect.cs
Normal file
36
Scripts/Core/Effects/ConvertResourceEffect.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using Godot;
|
||||
|
||||
namespace ParasiticGod.Scripts.Core.Effects;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class ConvertResourceEffect : Effect
|
||||
{
|
||||
[Export] public ResourceType FromResource { get; set; }
|
||||
[Export] public double FromAmount { get; set; }
|
||||
[Export] public ResourceType ToResource { get; set; }
|
||||
[Export] public double ToAmount { get; set; }
|
||||
|
||||
public override void Execute(GameState gameState)
|
||||
{
|
||||
double GetValue(ResourceType type) => type switch {
|
||||
ResourceType.Faith => gameState.Faith,
|
||||
ResourceType.Followers => gameState.Followers,
|
||||
ResourceType.Corruption => gameState.Corruption,
|
||||
_ => 0
|
||||
};
|
||||
|
||||
void SetValue(ResourceType type, double value) {
|
||||
switch(type) {
|
||||
case ResourceType.Faith: gameState.Faith = value; break;
|
||||
case ResourceType.Followers: gameState.Followers = (long)value; break;
|
||||
case ResourceType.Corruption: gameState.Corruption = value; break;
|
||||
}
|
||||
}
|
||||
|
||||
if (GetValue(FromResource) >= FromAmount)
|
||||
{
|
||||
SetValue(FromResource, GetValue(FromResource) - FromAmount);
|
||||
SetValue(ToResource, GetValue(ToResource) + ToAmount);
|
||||
}
|
||||
}
|
||||
}
|
1
Scripts/Core/Effects/ConvertResourceEffect.cs.uid
Normal file
1
Scripts/Core/Effects/ConvertResourceEffect.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://chiq1n5fde3eo
|
11
Scripts/Core/Effects/DestroySelfEffect.cs
Normal file
11
Scripts/Core/Effects/DestroySelfEffect.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using Godot;
|
||||
|
||||
namespace ParasiticGod.Scripts.Core.Effects;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class DestroySelfEffect : Effect
|
||||
{
|
||||
public override void Execute(GameState gameState)
|
||||
{
|
||||
}
|
||||
}
|
1
Scripts/Core/Effects/DestroySelfEffect.cs.uid
Normal file
1
Scripts/Core/Effects/DestroySelfEffect.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dhnma6yerqpwn
|
8
Scripts/Core/Effects/Effect.cs
Normal file
8
Scripts/Core/Effects/Effect.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
using Godot;
|
||||
|
||||
namespace ParasiticGod.Scripts.Core.Effects;
|
||||
|
||||
public abstract partial class Effect : Resource
|
||||
{
|
||||
public abstract void Execute(GameState gameState);
|
||||
}
|
1
Scripts/Core/Effects/Effect.cs.uid
Normal file
1
Scripts/Core/Effects/Effect.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://c1futvi1xm03q
|
30
Scripts/Core/Effects/ModifyStatEffect.cs
Normal file
30
Scripts/Core/Effects/ModifyStatEffect.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using Godot;
|
||||
|
||||
namespace ParasiticGod.Scripts.Core.Effects;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class ModifyStatEffect : Effect
|
||||
{
|
||||
public enum Stat { FaithPerFollower }
|
||||
public enum Operation { Add, Multiply }
|
||||
|
||||
[Export] public Stat TargetStat { get; set; }
|
||||
[Export] public Operation Op { get; set; }
|
||||
[Export] public double Value { get; set; }
|
||||
|
||||
public override void Execute(GameState gameState)
|
||||
{
|
||||
if (TargetStat == Stat.FaithPerFollower)
|
||||
{
|
||||
switch (Op)
|
||||
{
|
||||
case Operation.Add:
|
||||
gameState.FaithPerFollower += Value;
|
||||
break;
|
||||
case Operation.Multiply:
|
||||
gameState.FaithPerFollower *= Value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
1
Scripts/Core/Effects/ModifyStatEffect.cs.uid
Normal file
1
Scripts/Core/Effects/ModifyStatEffect.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dy6avn8snuuq1
|
3
Scripts/Core/Effects/ResourceType.cs
Normal file
3
Scripts/Core/Effects/ResourceType.cs
Normal file
@@ -0,0 +1,3 @@
|
||||
namespace ParasiticGod.Scripts.Core.Effects;
|
||||
|
||||
public enum ResourceType { Faith, Followers, Corruption }
|
1
Scripts/Core/Effects/ResourceType.cs.uid
Normal file
1
Scripts/Core/Effects/ResourceType.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://do6aurfs8oif0
|
16
Scripts/Core/Effects/UnlockMiracleEffect.cs
Normal file
16
Scripts/Core/Effects/UnlockMiracleEffect.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using Godot;
|
||||
using Godot.Collections;
|
||||
|
||||
namespace ParasiticGod.Scripts.Core.Effects;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class UnlockMiracleEffect : Effect
|
||||
{
|
||||
[Export]
|
||||
public Array<string> MiraclesToUnlock { get; set; }
|
||||
|
||||
public override void Execute(GameState gameState)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
1
Scripts/Core/Effects/UnlockMiracleEffect.cs.uid
Normal file
1
Scripts/Core/Effects/UnlockMiracleEffect.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://c1oieyvbcqjcc
|
Reference in New Issue
Block a user