Skip to content

Commit 676bdae

Browse files
committed
Fixed Controller, Stats, XP, Effects and more.
Have no reliable internet so was only just able to update the repo in case I break everything. Changes include an Effects system that can handle Healing, Damage, Speed, Stat Modifiers and a lot more (and more coming). Also included are Stats, which will be used to calculate Stamina, HP, Magic, etc (added that too). Also fixed a lot of issues with Humanoid slope speed. Also added a combat system with combos. Works alongside the HumanoidAnim and the Animator to handle all combat visuals.
1 parent 1fc85b6 commit 676bdae

27 files changed

+932
-347
lines changed

Creatures/Creature.cs

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
using System.Collections;
2+
using System.Collections.Generic;
3+
using UnityEngine;
4+
5+
public class Creature : MonoBehaviour
6+
{
7+
public CreatureModifyableProperties modifyableProperties;
8+
9+
protected CharacterController cControl; // Movement handling.
10+
protected GroundCheck gndCheck; // If grounded, incline checks, etc.
11+
protected StatXPManager statXPAccess;
12+
protected void Awake()
13+
{
14+
modifyableProperties = GetComponent<CreatureModifyableProperties>();
15+
cControl = GetComponent<CharacterController>();
16+
gndCheck = GetComponent<GroundCheck>();
17+
statXPAccess = GetComponent<StatXPManager>();
18+
}
19+
20+
21+
#region Health, Magica, Stamina
22+
/// <summary>
23+
/// Base health points. Calculated using minimum HP and stat points.
24+
/// </summary>
25+
private int _baseMaxHp = 0;
26+
/// <summary>
27+
/// Maximum health. Calculated using base HP and 'effect modifiers' (e.g. armor).
28+
/// </summary>
29+
public int MaxHealth
30+
{
31+
get { return _baseMaxHp + modifyableProperties.MaxHpEffectMod; }
32+
}
33+
34+
/// <summary>
35+
/// Base magica points. Calculated using minimum MP and stat points.
36+
/// </summary>
37+
private int _baseMaxMp = 0;
38+
/// <summary>
39+
/// Maximum magica. Calculated using base MP and 'effect modifiers' (e.g. magic staff).
40+
/// </summary>
41+
public int MaxMagica
42+
{
43+
get { return _baseMaxMp + modifyableProperties.MaxMpEffectMod; }
44+
}
45+
46+
/// <summary>
47+
/// Base stamina points. Calculated using minimum SP and stat points.
48+
/// </summary>
49+
private int _baseMaxSp = 0;
50+
/// <summary>
51+
/// Maximum stamina. Calculated using base MP and 'effect modifiers' (e.g. shoes).
52+
/// </summary>
53+
public int MaxStamina
54+
{
55+
get { return _baseMaxSp + modifyableProperties.MaxSpEffectMod; }
56+
}
57+
#endregion
58+
59+
60+
#region Max Speed
61+
/// <summary>
62+
/// Used to calculate Dynamic Max Speed, by acting as the base movement speed set by a subclass creature (e.g. set it to 5 for running).
63+
/// </summary>
64+
///
65+
protected float baseMoveStateMaxSpd = 0;
66+
/// <summary>
67+
/// Used to calculate Dynamic Max Speed, by enabling the creature to faster/slower based on the terrain.
68+
/// </summary>
69+
protected float terrainMaxSpdMod = 0;
70+
/// <summary>
71+
/// Returns base max speed in addition to environmental and effect modifiers whilst moving.
72+
/// </summary>
73+
protected float DynamicMaxSpd
74+
{
75+
get
76+
{
77+
if (baseMoveStateMaxSpd == 0) return 0; // No dynamic movement if not moving legs.
78+
return Mathf.Clamp((modifyableProperties.MaxSpdEffectMod + baseMoveStateMaxSpd) + terrainMaxSpdMod, 0, 99);
79+
}
80+
}
81+
#endregion
82+
83+
84+
#region Rotation
85+
/// <summary>
86+
/// Base speed of creature rotation before penalty, dampening and 'Rotation Speed Effects Modifier'.
87+
/// </summary>
88+
[SerializeField] private int baseRotSpd = 6;
89+
90+
/// <summary>
91+
/// Active rotation speed of creature after 'Rotation Speed Effects Modifier' is added to the base speed.
92+
/// </summary>
93+
protected int RotationSpeed
94+
{
95+
get
96+
{
97+
return baseRotSpd + modifyableProperties.RotSpdEffectsMod;
98+
}
99+
}
100+
#endregion
101+
102+
103+
104+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using System.Collections;
2+
using System.Collections.Generic;
3+
using UnityEngine;
4+
5+
public class CreatureHpSpMpManager : MonoBehaviour
6+
{
7+
Creature creature;
8+
private int stamina, health, magica;
9+
// Start is called before the first frame update
10+
void Start()
11+
{
12+
creature.GetComponent<Creature>();
13+
stamina = creature.MaxStamina;
14+
health = creature.MaxHealth;
15+
magica = creature.MaxMagica;
16+
}
17+
18+
19+
public void UseStamina(int amount)
20+
{
21+
22+
}
23+
24+
25+
26+
// Update is called once per frame
27+
void Update()
28+
{
29+
30+
}
31+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
using System.Collections;
2+
using System.Collections.Generic;
3+
using UnityEngine;
4+
5+
/// <summary>
6+
/// Modular exposure of modifyable variables specifically for IEffects usage.
7+
/// </summary>
8+
public class CreatureModifyableProperties : MonoBehaviour
9+
{
10+
/// <summary>
11+
/// Maximum speed modifier for effects that affect how max a creature can move.
12+
/// </summary>
13+
[HideInInspector] public float MaxSpdEffectMod { get; set; } = 0; // Modifiers use to increase/decrease max base speed.
14+
15+
/// <summary>
16+
/// Modifier added to creature rotation speed before dampening and penalty. Used for Effects.
17+
/// </summary>
18+
[HideInInspector] public int RotSpdEffectsMod { get; set; }
19+
20+
/// <summary>
21+
/// Modifier for maximum health points. Allows effects to increase/decrease a creature's max health.
22+
/// </summary>
23+
[HideInInspector] public int MaxHpEffectMod { get; set; } = 0;
24+
25+
/// <summary>
26+
/// Modifier for maximum magica points. Allows effects to increase/decrease a creature's max magic.
27+
/// </summary>
28+
[HideInInspector] public int MaxMpEffectMod { get; set; } = 0;
29+
30+
/// <summary>
31+
/// Modifier for maximum health points. Allows effects to increase/decrease a creature's max stamina.
32+
/// </summary>
33+
[HideInInspector] public int MaxSpEffectMod { get; set; } = 0;
34+
35+
/// <summary>
36+
/// Modifier for increasing/decreasing the maximum jump height of a creature.
37+
/// </summary>
38+
[HideInInspector] public float JmpAmountEffectMod { get; set; } = 0;
39+
40+
[HideInInspector] public int StatPhysicalMod { get; set; } = 0;
41+
[HideInInspector] public int StatCharismaMod { get; set; } = 0;
42+
[HideInInspector] public int StatAgilityMod { get; set; } = 0;
43+
[HideInInspector] public int StatMindMod { get; set; } = 0;
44+
45+
}

0 commit comments

Comments
 (0)