diff options
Diffstat (limited to 'Thronefall_1_0/GameCode/UnitRespawnerForBuildings.cs')
| -rw-r--r-- | Thronefall_1_0/GameCode/UnitRespawnerForBuildings.cs | 113 |
1 files changed, 0 insertions, 113 deletions
diff --git a/Thronefall_1_0/GameCode/UnitRespawnerForBuildings.cs b/Thronefall_1_0/GameCode/UnitRespawnerForBuildings.cs deleted file mode 100644 index a405fb5..0000000 --- a/Thronefall_1_0/GameCode/UnitRespawnerForBuildings.cs +++ /dev/null @@ -1,113 +0,0 @@ -using System.Collections.Generic; -using UnityEngine; - -public class UnitRespawnerForBuildings : MonoBehaviour -{ - public Hp hp; - - public List<Hp> units; - - public List<float> timeToRespawnAUnitDependingOnLevel = new List<float>(); - - private float timeTillNextRespawn; - - public BuildSlot myBuildSlot; - - public TaggedObject taggedObject; - - public ProductionBar productionBar; - - [Header("Quick arrange units:")] - public Transform copyUnitPositionsFrom; - - private bool gladiatorSchool; - - private bool elliteWarriors; - - private float gladiatorSchoolSpeed; - - private float elliteWarriorSpeed; - - private float totalTrainingSpeed = 1f; - - [SerializeField] - private Equippable gladiatorSchoolPerk; - - [SerializeField] - private Equippable elliteWarriorsPerk; - - private bool godOfDeathActive; - - private float ResetCooldownTime => timeToRespawnAUnitDependingOnLevel[Mathf.Clamp(myBuildSlot.Level, 0, timeToRespawnAUnitDependingOnLevel.Count - 1)]; - - private void Start() - { - godOfDeathActive = PerkManager.instance.GodOfDeathActive; - timeTillNextRespawn = ResetCooldownTime; - productionBar.UpdateVisual(0f); - gladiatorSchool = PerkManager.IsEquipped(gladiatorSchoolPerk); - elliteWarriors = PerkManager.IsEquipped(elliteWarriorsPerk); - gladiatorSchoolSpeed = PerkManager.instance.gladiatorSchool_TrainingSpeedMultiplyer; - elliteWarriorSpeed = PerkManager.instance.elliteWarriors_TrainingSpeedMultiplyer; - totalTrainingSpeed = 1f * (gladiatorSchool ? gladiatorSchoolSpeed : 1f) * (elliteWarriors ? elliteWarriorSpeed : 1f); - } - - private void Update() - { - if (godOfDeathActive) - { - return; - } - if (hp.KnockedOut) - { - productionBar.UpdateVisual(0f); - } - else if (AtLeastOneUnitIsKnockedOut()) - { - timeTillNextRespawn -= Time.deltaTime; - productionBar.UpdateVisual(1f - timeTillNextRespawn / ResetCooldownTime * totalTrainingSpeed); - if (timeTillNextRespawn <= 0f) - { - timeTillNextRespawn += ResetCooldownTime; - timeTillNextRespawn /= totalTrainingSpeed; - RespawnAKnockedOutUnit(); - } - } - else - { - timeTillNextRespawn = ResetCooldownTime; - timeTillNextRespawn /= totalTrainingSpeed; - productionBar.UpdateVisual(0f); - } - } - - private bool AtLeastOneUnitIsKnockedOut() - { - for (int i = 0; i < units.Count; i++) - { - Hp hp = units[i]; - if (hp.gameObject.activeInHierarchy && hp.KnockedOut) - { - return true; - } - } - return false; - } - - private void RespawnAKnockedOutUnit() - { - for (int i = 0; i < units.Count; i++) - { - Hp hp = units[i]; - if (hp.gameObject.activeInHierarchy && hp.KnockedOut) - { - hp.Revive(); - PathfindMovementPlayerunit component = hp.GetComponent<PathfindMovementPlayerunit>(); - Vector3 position = taggedObject.colliderForBigOjectsToMeasureDistance.ClosestPoint(component.HopePositionOriginal); - hp.transform.position = position; - component.SnapToNavmesh(); - break; - } - } - } -} |
