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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
.*
!.gitignore
!.gitignore
19 changes: 19 additions & 0 deletions QueryFantasy.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QuestFantasy", "QuestFantasy.csproj", "{C3FFE992-6D9D-4C12-96BC-1300AAD7C7B7}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
ExportDebug|Any CPU = ExportDebug|Any CPU
ExportRelease|Any CPU = ExportRelease|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C3FFE992-6D9D-4C12-96BC-1300AAD7C7B7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C3FFE992-6D9D-4C12-96BC-1300AAD7C7B7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C3FFE992-6D9D-4C12-96BC-1300AAD7C7B7}.ExportDebug|Any CPU.ActiveCfg = ExportDebug|Any CPU
{C3FFE992-6D9D-4C12-96BC-1300AAD7C7B7}.ExportDebug|Any CPU.Build.0 = ExportDebug|Any CPU
{C3FFE992-6D9D-4C12-96BC-1300AAD7C7B7}.ExportRelease|Any CPU.ActiveCfg = ExportRelease|Any CPU
{C3FFE992-6D9D-4C12-96BC-1300AAD7C7B7}.ExportRelease|Any CPU.Build.0 = ExportRelease|Any CPU
EndGlobalSection
EndGlobal
5 changes: 5 additions & 0 deletions QuestFantasy.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<Project Sdk="Godot.NET.Sdk/3.3.0">
<PropertyGroup>
<TargetFramework>net472</TargetFramework>
</PropertyGroup>
</Project>
19 changes: 19 additions & 0 deletions QuestFantasy.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QuestFantasy", "QuestFantasy.csproj", "{C3FFE992-6D9D-4C12-96BC-1300AAD7C7B7}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
ExportDebug|Any CPU = ExportDebug|Any CPU
ExportRelease|Any CPU = ExportRelease|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C3FFE992-6D9D-4C12-96BC-1300AAD7C7B7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C3FFE992-6D9D-4C12-96BC-1300AAD7C7B7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C3FFE992-6D9D-4C12-96BC-1300AAD7C7B7}.ExportDebug|Any CPU.ActiveCfg = ExportDebug|Any CPU
{C3FFE992-6D9D-4C12-96BC-1300AAD7C7B7}.ExportDebug|Any CPU.Build.0 = ExportDebug|Any CPU
{C3FFE992-6D9D-4C12-96BC-1300AAD7C7B7}.ExportRelease|Any CPU.ActiveCfg = ExportRelease|Any CPU
{C3FFE992-6D9D-4C12-96BC-1300AAD7C7B7}.ExportRelease|Any CPU.Build.0 = ExportRelease|Any CPU
EndGlobalSection
EndGlobal
9 changes: 9 additions & 0 deletions Scenes/Entities/player.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[gd_scene load_steps=3 format=2]

[ext_resource path="res://icon.png" type="Texture" id=1]
[ext_resource path="res://Scripts/Characters/Player.cs" type="Script" id=2]

[node name="Sprite" type="Sprite"]
texture = ExtResource( 1 )
script = ExtResource( 2 )
SpeedMultiplier = 10.0
16 changes: 16 additions & 0 deletions Scripts/Characters/Character.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using QuestFantasy.Core.Base;
using QuestFantasy.Core.Data.Attributes;

namespace QuestFantasy.Characters
{
public class Character : Creature
{
public long Level { get; private set; }
public Status CurrentStatus { get; set; }
public Abilities Abilities;
public Element Element { get; private set; }
public Attributes Attributes;
public virtual void UpdateAttributes()
{ }
}
}
12 changes: 12 additions & 0 deletions Scripts/Characters/Fighter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using QuestFantasy.Core.Data.Items;

namespace QuestFantasy.Characters
{
public class Fighter : Character
{
public virtual void Attack()
{
// TODO: Implement attack logic
}
}
}
11 changes: 11 additions & 0 deletions Scripts/Characters/Monster.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace QuestFantasy.Characters
{
public class Monster : Fighter
{
public int ExperienceReward { get; private set; }
public override void UpdateAttributes()
{
// TODO: implement monster attributes calculation
}
}
}
11 changes: 11 additions & 0 deletions Scripts/Characters/NPC.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using QuestFantasy.Systems.Inventory;

namespace QuestFantasy.Characters
{
public class NPC : Character
{
public Bag Bag { get; private set; }

// TODO: Trade function
}
}
59 changes: 59 additions & 0 deletions Scripts/Characters/Player.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
using Godot;
using System.Collections.Generic;
using QuestFantasy.Core.Data.Attributes;
using QuestFantasy.Core.Data.Items;
using QuestFantasy.Systems.Inventory;

namespace QuestFantasy.Characters
{
public class Player : Fighter
{
[Export] public float SpeedMultiplier = 50f; // pixels per spd point
private Vector2 _velocity = Vector2.Zero;

public Jobs Job { get; private set; }
public int Exp { get; private set; }
public Jobs CurrentJob { get; private set; }
public List<Skills> CurrentSkills { get; private set; } = new List<Skills>();
private Weapon EquippedWeapon { get; set; }
private EquippedItems Equipped { get; set; }
public int Gold { get; private set; }

private Bag Inventory;

// TODO: set Job function
public override void UpdateAttributes()
{
Attributes.TotalAtk = (Job?.BaseAbilities?.Atk ?? 0) + (EquippedWeapon?.WeaponAbilities?.Atk ?? 0) + (Equipped?.TotalAtk() ?? 0);
Attributes.TotalDef = (Job?.BaseAbilities?.Def ?? 0) + (EquippedWeapon?.WeaponAbilities?.Def ?? 0) + (Equipped?.TotalDef() ?? 0);
Attributes.TotalSpd = (Job?.BaseAbilities?.Spd ?? 0) + (EquippedWeapon?.WeaponAbilities?.Spd ?? 0) + (Equipped?.TotalSpd() ?? 0);
Attributes.TotalVit = (Job?.BaseAbilities?.Vit ?? 0) + (EquippedWeapon?.WeaponAbilities?.Vit ?? 0) + (Equipped?.TotalVit() ?? 0);
}

public override void Move()
{
_velocity = Vector2.Zero;

if (Input.IsActionPressed("ui_right"))
_velocity.x += 1;
if (Input.IsActionPressed("ui_left"))
_velocity.x -= 1;
if (Input.IsActionPressed("ui_down"))
_velocity.y += 1;
if (Input.IsActionPressed("ui_up"))
_velocity.y -= 1;

if (_velocity.Length() > 0)
{
var baseSpd = Attributes?.TotalSpd ?? 0;
float actualSpeed = (baseSpd + 1) * SpeedMultiplier;
_velocity = _velocity.Normalized() * actualSpeed;
}
Position += _velocity;
}
public override void _PhysicsProcess(float delta)
{
Move();
}
}
}
15 changes: 15 additions & 0 deletions Scripts/Core/Base/Creature.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using Godot;

namespace QuestFantasy.Core.Base
{
public class Creature : Sprite
{
public string EntityName { get; private set; }
public virtual void Move()
{
}
public virtual void Interact()
{
}
}
}
26 changes: 26 additions & 0 deletions Scripts/Core/Base/EnvironmentalObject.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using Godot;

namespace QuestFantasy.Core.Base
{
/// <summary>
/// Base class for non-animated environmental objects in the game world.
/// Unlike Creature, EnvironmentalObject is designed for static or passive objects
/// that don't have their own movement logic.
/// </summary>
public class EnvironmentalObject : Sprite
{
public string ObjectName { get; protected set; }
public string Description { get; protected set; }
public bool IsDestroyable { get; protected set; } = false;
public bool IsInteractable { get; protected set; } = true;

/// <summary>
/// Called when a character interacts with this environmental object.
/// Override in derived classes to implement specific interaction behavior.
/// </summary>
public virtual void OnInteract(Creature interactor)
{
// Base implementation does nothing; override in subclasses
}
}
}
8 changes: 8 additions & 0 deletions Scripts/Core/Base/NameAndDescription.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace QuestFantasy.Core.Base
{
public class NameAndDescription
{
public string Name { get; private set; }
public string Description { get; private set; }
}
}
31 changes: 31 additions & 0 deletions Scripts/Core/Data/Attributes/Abilities.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
namespace QuestFantasy.Core.Data.Attributes
{
public class Abilities
{
public int Atk { get; private set; } // Attack: determines damage dealt to monsters and other players
public int Def { get; private set; } // Defense: reduces incoming damage
public int Spd { get; private set; } // Speed: determines walk speed and Skills cooldown
public int Vit { get; private set; } // Vitality: determines max HP
private void Set(int atk, int def, int spd, int vit)
{
Atk = atk;
Def = def;
Spd = spd;
Vit = vit;
}
private void Increase(int atk, int def, int spd, int vit)
{
Atk += atk;
Def += def;
Spd += spd;
Vit += vit;
}
private void Decrease(int atk, int def, int spd, int vit)
{
Atk -= atk;
Def -= def;
Spd -= spd;
Vit -= vit;
}
}
}
78 changes: 78 additions & 0 deletions Scripts/Core/Data/Attributes/Attributes.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
namespace QuestFantasy.Core.Data.Attributes
{
public enum ElementsTypes { Normal, Earth, Water, Fire, Wind }

public class Element
{
public ElementsTypes ElementType { get; set; }
public float AgainstGet(Element targetElement)
{
// Calculate effectiveness against another element (input is the Defender's element)

if (ElementType == ElementsTypes.Normal) return 1f;
if (ElementType == ElementsTypes.Earth)
{
if (targetElement.ElementType == ElementsTypes.Wind) return 0.5f;
if (targetElement.ElementType == ElementsTypes.Water) return 2f;
}
if (ElementType == ElementsTypes.Water)
{
if (targetElement.ElementType == ElementsTypes.Earth) return 0.5f;
if (targetElement.ElementType == ElementsTypes.Fire) return 2f;
}
if (ElementType == ElementsTypes.Fire)
{
if (targetElement.ElementType == ElementsTypes.Water) return 0.5f;
if (targetElement.ElementType == ElementsTypes.Wind) return 2f;
}
if (ElementType == ElementsTypes.Wind)
{
if (targetElement.ElementType == ElementsTypes.Fire) return 0.5f;
if (targetElement.ElementType == ElementsTypes.Earth) return 2f;
}
return 1f;
}
}

public class HP
{
public int MaxHP { get; private set; }
public int CurrentHP { get; private set; }
public void UpdateMax(int Vit)
{
const int VIT_TO_HP_RATE = 10;
bool CurrentHPExceedsMax = CurrentHP >= MaxHP;
MaxHP = Vit * VIT_TO_HP_RATE;
if (CurrentHP > MaxHP || CurrentHPExceedsMax)
{
CurrentHP = MaxHP; // Adjust current HP if it exceeds new max
}
}
public void TakeDamage(float rate, int attackerAtk, int Def, Status attackerStatus, Status defenderStatus)
{
const float DAMAGE_RATE = 1f;
CurrentHP -= (int)((attackerAtk * attackerStatus.AtkRate() - defenderStatus.DefRate() * Def) * DAMAGE_RATE * rate);
if (CurrentHP < 0)
{
CurrentHP = 0;
}
}
}

public class Attributes
{
public int TotalAtk { get; internal set; } // Attack: determines damage dealt to monsters and other players
public int TotalDef { get; internal set; } // Defense: reduces incoming damage
public int TotalSpd { get; internal set; } // Speed: determines walk speed and Skills cooldown
public int TotalVit { get; internal set; } // Vitality: determines max HP
public Element Element { get; set; } = new Element { ElementType = ElementsTypes.Normal };
public HP HP { get; private set; } = new HP();
public void Update(int newAtk, int newDef, int newSpd, int newVit)
{
TotalAtk = newAtk;
TotalDef = newDef;
TotalSpd = newSpd;
TotalVit = newVit;
}
}
}
12 changes: 12 additions & 0 deletions Scripts/Core/Data/Attributes/Jobs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System.Collections.Generic;
using QuestFantasy.Core.Base;

namespace QuestFantasy.Core.Data.Attributes
{
public class Jobs : NameAndDescription
{
public Abilities BaseAbilities { get; private set; }
public List<Skills> SkillSet { get; private set; }
// TODO: job init function
}
}
37 changes: 37 additions & 0 deletions Scripts/Core/Data/Attributes/Skills.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using QuestFantasy.Core.Base;
using QuestFantasy.Characters;

namespace QuestFantasy.Core.Data.Attributes
{
public struct Cooldown
{
public float RemainingTime { get; private set; }
public bool IsReady => RemainingTime <= 0;

public void Start(float cooldownTime)
{
RemainingTime = cooldownTime;
}

public void Update(float deltaTime)
{
if (RemainingTime > 0)
{
RemainingTime -= deltaTime;
if (RemainingTime < 0)
RemainingTime = 0;
}
}
}

public class Skills : NameAndDescription
{
public Cooldown CoolDown;

public virtual void Effect(Player player, Monster target)
{
// TODO skill effect include damage rate, special effects, etc. to be implemented in subclasses
// also will call Damage function in HP.cs to calculate damage dealt to target?
}
}
}
Loading