diff --git a/MrBigsock/Assets/Code/Character.cs b/MrBigsock/Assets/Code/Character.cs index 0d3c07c9282da4ccd139bf1955411242d4f52cb0..14b3e5c4c4fe41079ab46f65a51e49bb1e2c0eae 100644 --- a/MrBigsock/Assets/Code/Character.cs +++ b/MrBigsock/Assets/Code/Character.cs @@ -48,7 +48,16 @@ namespace BigSock { set => baseHP = value; } public float baseHP = 10; + + /* + Mana of the character. + */ + public float Mana { get; set; } + /* + Stamina of the character. + */ + public float Stamina { get; set; } /* Maximum hit points of the character. @@ -133,10 +142,18 @@ namespace BigSock { } + /* + Regenerates mana and stamina. + */ + protected virtual void Regenerate() { + Mana = Math.Min(Stats.MaxMana, Mana + Time.fixedDeltaTime * Stats.RegenMana); + Stamina = Math.Min(Stats.MaxStamina, Stamina + Time.fixedDeltaTime * Stats.RegenStamina); + } + /* Updates the modifiers to the character's stats. */ - public void UpdateModifiers(ICharacterStats modifiers = null) { + public virtual void UpdateModifiers(ICharacterStats modifiers = null) { modifiers ??= Inventory.Modifier; Stats = BaseStats.Modify(modifiers); } diff --git a/MrBigsock/Assets/Code/PlayerController.cs b/MrBigsock/Assets/Code/PlayerController.cs index 484a078495692ab20b6c90b35c43f42d3664719b..f96d1f775666923839d11ba07bd17495275b47c4 100644 --- a/MrBigsock/Assets/Code/PlayerController.cs +++ b/MrBigsock/Assets/Code/PlayerController.cs @@ -18,6 +18,8 @@ namespace BigSock { public HPBar hpBar; public XpBar xpBar; + public XpBar manaBar; + public XpBar staminaBar; public float collisionOffset = 0.05f; @@ -106,6 +108,8 @@ namespace BigSock { } private void Update() { + Regenerate(); + if (Input.GetKeyDown(KeyCode.Space) || Input.GetMouseButton(0)) { // Manage attack cooldown. if(NextTimeCanAttack <= DateTime.Now) { @@ -130,8 +134,24 @@ namespace BigSock { } } + /* + Updates the modifiers to the character's stats. + */ + public override void UpdateModifiers(ICharacterStats modifiers = null) { + super.UpdateModifiers(modifiers); + manaBar?.SetMaxXp(Stats.MaxMana); + staminaBar?.SetMaxXp(Stats.MaxStamina); + } - + + /* + Regenerates mana and stamina. + */ + protected override void Regenerate() { + base.Regenerate(); + manaBar?.SetXp(Mana); + staminaBar?.SetXp(Stamina); + } private bool TryMove_OLD(Vector2 direction) { if(direction != Vector2.zero) { diff --git a/MrBigsock/Assets/Code/orc/EnemyController.cs b/MrBigsock/Assets/Code/orc/EnemyController.cs index e476c952160be5e94e3d394559a47036b11f701e..7f8dea4f8f1dda5d17b8b87806a2047e63edac65 100644 --- a/MrBigsock/Assets/Code/orc/EnemyController.cs +++ b/MrBigsock/Assets/Code/orc/EnemyController.cs @@ -61,6 +61,8 @@ namespace BigSock { } protected virtual void Update() { + Regenerate(); + if (target != null && !isInMelee){ /* //walk