forked from Shardstone/trail-into-darkness
factored the character system - not funtional yet
This commit is contained in:
130
Assets/Code/GameState/Entities/EntitiesDefinitions.cs
Normal file
130
Assets/Code/GameState/Entities/EntitiesDefinitions.cs
Normal file
@@ -0,0 +1,130 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Nox.Game {
|
||||
public interface IEntityDefinition {
|
||||
string ID { get; }
|
||||
string DisplayName { get; }
|
||||
EntityAttributes Attributes { get; }
|
||||
EntityStats Stats { get; }
|
||||
}
|
||||
|
||||
public enum CharacterRole {
|
||||
None,
|
||||
Protagonist,
|
||||
Companion
|
||||
}
|
||||
|
||||
public enum CharacterClass {
|
||||
None,
|
||||
Warrior,
|
||||
Rogue,
|
||||
Mage,
|
||||
Herald
|
||||
}
|
||||
|
||||
public enum CharacterRace {
|
||||
None,
|
||||
Human,
|
||||
DarkElf,
|
||||
Tunneler
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public sealed class EntityAttributes {
|
||||
public int might;
|
||||
public int reflex;
|
||||
public int knowledge;
|
||||
public int perception;
|
||||
|
||||
public int Total => might + reflex + knowledge;
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public sealed class EntityStats {
|
||||
public int health;
|
||||
public int stamina;
|
||||
public int level;
|
||||
public int experience;
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public sealed class PerkDefinition {
|
||||
public string id;
|
||||
public string name;
|
||||
public ModifiersData modifiers = new ();
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public sealed class PerksData {
|
||||
public List<PerkDefinition> perks = new ();
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public sealed class CharacterDefinition : IEntityDefinition {
|
||||
[SerializeField] private string id;
|
||||
[SerializeField] private string displayName;
|
||||
public CharacterRace race;
|
||||
public CharacterClass @class;
|
||||
public CharacterRole role;
|
||||
[SerializeField] EntityAttributes attributes;
|
||||
[SerializeField] EntityStats stats;
|
||||
public PerksData perksData = new();
|
||||
public ModifiersData activeModifiers = new();
|
||||
|
||||
public CharacterDefinition Clone() {
|
||||
return new CharacterDefinition {
|
||||
id = id,
|
||||
displayName = displayName,
|
||||
role = role,
|
||||
race = race,
|
||||
@class = @class,
|
||||
attributes = new EntityAttributes {
|
||||
might = attributes?.might ?? 1,
|
||||
reflex = attributes?.reflex ?? 1,
|
||||
knowledge = attributes?.knowledge ?? 1
|
||||
},
|
||||
stats = new EntityStats {
|
||||
health = stats?.health ?? 1,
|
||||
stamina = stats?.stamina ?? 1
|
||||
},
|
||||
perksData = new PerksData(),
|
||||
activeModifiers = new ModifiersData()
|
||||
};
|
||||
}
|
||||
|
||||
public string ID {
|
||||
get => id;
|
||||
set => id = value;
|
||||
}
|
||||
|
||||
public string DisplayName {
|
||||
get => displayName;
|
||||
set => displayName = value;
|
||||
}
|
||||
public EntityAttributes Attributes {
|
||||
get => attributes;
|
||||
set => attributes = value;
|
||||
}
|
||||
|
||||
public EntityStats Stats {
|
||||
get => stats;
|
||||
set => stats = value;
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public sealed class PartyDefinition {
|
||||
public List<CharacterDefinition> members = new();
|
||||
public int maxPartySize;
|
||||
|
||||
[JsonIgnore]
|
||||
public CharacterDefinition Protagonist => members.FirstOrDefault(m => m.role == CharacterRole.Protagonist);
|
||||
|
||||
[JsonIgnore]
|
||||
public IReadOnlyList<CharacterDefinition> Companions => members.Where(m => m.role == CharacterRole.Companion).ToList();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user