From 64e763dbce376ceaf8be66f7156bd4b1c4af3a73 Mon Sep 17 00:00:00 2001 From: Adrian Paschkowski <git@wasdennnoch.me> Date: Thu, 15 Apr 2021 19:08:30 +0200 Subject: [PATCH] On AntiPlayer death, upgrade and restart round --- Assets/Scenes/Forest.unity | 4 ++++ Assets/Scripts/Fighters/AntiPlayer.cs | 4 ++++ Assets/Scripts/RoundController.cs | 7 +++++++ Assets/Scripts/StatsManager.cs | 9 +++++++++ 4 files changed, 24 insertions(+) diff --git a/Assets/Scenes/Forest.unity b/Assets/Scenes/Forest.unity index a130338..32b5a35 100644 --- a/Assets/Scenes/Forest.unity +++ b/Assets/Scenes/Forest.unity @@ -460,6 +460,10 @@ PrefabInstance: propertyPath: startSprite value: objectReference: {fileID: 21300000, guid: d42cfe7bed8439c439378d1a7e76f4e3, type: 3} + - target: {fileID: 1805415820362754139, guid: afeb708bd829d8a4aa0310ed2cd87a74, type: 3} + propertyPath: delayAfterAntiHeroDeath + value: 1.75 + objectReference: {fileID: 0} - target: {fileID: 5959683136170450115, guid: afeb708bd829d8a4aa0310ed2cd87a74, type: 3} propertyPath: m_Name value: GlobalScripts diff --git a/Assets/Scripts/Fighters/AntiPlayer.cs b/Assets/Scripts/Fighters/AntiPlayer.cs index e159efe..3312aa2 100644 --- a/Assets/Scripts/Fighters/AntiPlayer.cs +++ b/Assets/Scripts/Fighters/AntiPlayer.cs @@ -74,6 +74,10 @@ public class AntiPlayer : Fighter, IFighterCallback { var actualDamage = base.DealDamage(dmg); StatsManager.instance.AddDamageBasedMana(actualDamage, !alive); + if (!alive) + { + StatsManager.instance.UpgradeAntiPlayer(); + } return actualDamage; } diff --git a/Assets/Scripts/RoundController.cs b/Assets/Scripts/RoundController.cs index 2d8ee13..1cf58d2 100644 --- a/Assets/Scripts/RoundController.cs +++ b/Assets/Scripts/RoundController.cs @@ -11,11 +11,15 @@ public interface IRoundCallback public class RoundController : MonoBehaviour, IFighterCallback { + public static RoundController instance { get; private set; } public List<IRoundCallback> roundCallbacks = new List<IRoundCallback>(); public bool roundRunning { get; private set; } + [SerializeField, Tooltip("After the AntiHero died, how many seconds to wait until ending the current round")] + float delayAfterAntiHeroDeath = 1.75f; + BaseCameraController cameraController; public void StartRound() @@ -76,7 +80,10 @@ public class RoundController : MonoBehaviour, IFighterCallback public void OnFighterDeath(Fighter fighter) { + // The AntiHero has died SetGameSpeed(0.5f); cameraController.AnimateToPosition(fighter.transform.position + new Vector3(0f, 0.75f), 1.5f, 0.05f); + Invoke(nameof(StopRound), delayAfterAntiHeroDeath); } + } diff --git a/Assets/Scripts/StatsManager.cs b/Assets/Scripts/StatsManager.cs index 6ecacf6..63abd6a 100644 --- a/Assets/Scripts/StatsManager.cs +++ b/Assets/Scripts/StatsManager.cs @@ -123,6 +123,15 @@ public class StatsManager : MonoBehaviour } } + public void UpgradeAntiPlayer() + { + var playerStats = fighterStats[FighterTypes.ANTI_PLAYER]; + playerStats.healthMultiplier += 0.2f; + playerStats.damageMultiplier += 0.2f; + playerStats.armorMultiplier += 0.1f; + fighterStats[FighterTypes.ANTI_PLAYER] = playerStats; + } + void RecalculateStatMultipliers() { var enemyStats = fighterStats[FighterTypes.ENEMY]; -- GitLab