summaryrefslogtreecommitdiff
path: root/Thronefall_1_0/GameCode/UnitRespawnerForBuildings.cs
diff options
context:
space:
mode:
authorchai <215380520@qq.com>2024-05-19 16:46:27 +0800
committerchai <215380520@qq.com>2024-05-19 16:46:27 +0800
commit8b1fc7063b387542803c6bc214ccf8acb32870bd (patch)
treed310eb99872c8215f1c1f67731ec21f0915cd778 /Thronefall_1_0/GameCode/UnitRespawnerForBuildings.cs
parent8e13e7e2874adc8982e16d1d2ed2e28d7480b45f (diff)
* rename
Diffstat (limited to 'Thronefall_1_0/GameCode/UnitRespawnerForBuildings.cs')
-rw-r--r--Thronefall_1_0/GameCode/UnitRespawnerForBuildings.cs113
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;
- }
- }
- }
-}