summaryrefslogtreecommitdiff
path: root/Thronefall_v1.0/Decompile/ScoreManager.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Thronefall_v1.0/Decompile/ScoreManager.cs')
-rw-r--r--Thronefall_v1.0/Decompile/ScoreManager.cs150
1 files changed, 150 insertions, 0 deletions
diff --git a/Thronefall_v1.0/Decompile/ScoreManager.cs b/Thronefall_v1.0/Decompile/ScoreManager.cs
new file mode 100644
index 0000000..daccfb5
--- /dev/null
+++ b/Thronefall_v1.0/Decompile/ScoreManager.cs
@@ -0,0 +1,150 @@
+using System.Collections.Generic;
+using UnityEngine;
+using UnityEngine.Events;
+
+public class ScoreManager : MonoBehaviour, DayNightCycle.IDaytimeSensitive
+{
+ private static ScoreManager instance;
+
+ private EnemySpawner enemySpawner;
+
+ [Min(0f)]
+ public int baseScorePerNight = 100;
+
+ [Min(0f)]
+ public int protectionScorePerNight = 200;
+
+ [Min(0f)]
+ public int timeScorePerNight = 200;
+
+ [Min(0f)]
+ public float timebonusMultiplier = 1f;
+
+ [Min(0f)]
+ public float timeBonusMinTime = 10f;
+
+ [Min(0f)]
+ public float timeBonusMaxTime = 120f;
+
+ [Min(0f)]
+ public float protectionScoreMultiplier = 1f;
+
+ [Range(1f, 2f)]
+ public float scoreExponent = 2f;
+
+ private int currentScore;
+
+ private List<TagManager.ETag> buildingTags = new List<TagManager.ETag>(new TagManager.ETag[2]
+ {
+ TagManager.ETag.Building,
+ TagManager.ETag.PlayerOwned
+ });
+
+ [HideInInspector]
+ public UnityEvent<int, int, float, int> OnNightScoreAdd = new UnityEvent<int, int, float, int>();
+
+ private bool tauntTheTiger;
+
+ private bool tauntTheTurtle;
+
+ private bool tauntTheFalcon;
+
+ private bool tauntTheRat;
+
+ private float scoreMultiplyerFromPerks;
+
+ public float victoryGoldBonusMultiplyer = 10f;
+
+ public static ScoreManager Instance => instance;
+
+ public int CurrentScore => currentScore;
+
+ public int VictoryGoldBonus => Mathf.CeilToInt((float)PlayerInteraction.instance.TrueBalance * victoryGoldBonusMultiplyer);
+
+ public int VictoryMutatorBonus
+ {
+ get
+ {
+ float num = 1f;
+ foreach (Equippable item in PerkManager.instance.CurrentlyEquipped)
+ {
+ if (item.GetType() == typeof(EquippableMutation))
+ {
+ num *= ((EquippableMutation)item).scoreMultiplyerOnWin;
+ }
+ }
+ return Mathf.CeilToInt((float)(currentScore + VictoryGoldBonus) * (num - 1f));
+ }
+ }
+
+ public int MaxScorePerNight => Mathf.RoundToInt((float)(baseScorePerNight + protectionScorePerNight + timeScorePerNight) * scoreMultiplyerFromPerks);
+
+ private void Awake()
+ {
+ if (instance != null)
+ {
+ Debug.LogWarning("More than one Scoremanger in Scene. Old Scoremanager destroyed.");
+ Object.Destroy(instance);
+ }
+ instance = this;
+ }
+
+ private void Start()
+ {
+ enemySpawner = EnemySpawner.instance;
+ DayNightCycle.Instance.RegisterDaytimeSensitiveObject(this);
+ tauntTheTiger = PerkManager.IsEquipped(PerkManager.instance.tigerGodPerk);
+ tauntTheTurtle = PerkManager.IsEquipped(PerkManager.instance.turtleGodPerk);
+ tauntTheFalcon = PerkManager.IsEquipped(PerkManager.instance.falconGodPerk);
+ tauntTheRat = PerkManager.IsEquipped(PerkManager.instance.ratGodPerk);
+ scoreMultiplyerFromPerks = 1f;
+ }
+
+ public void CalculateEndOfNightScore()
+ {
+ int num = Mathf.RoundToInt((float)baseScorePerNight * scoreMultiplyerFromPerks);
+ int num2 = num;
+ float currentNightLength = DayNightCycle.Instance.CurrentNightLength;
+ float lastSpawnPeriodDuration = enemySpawner.LastSpawnPeriodDuration;
+ int num3 = Mathf.RoundToInt(Mathf.Pow(Mathf.InverseLerp(timeBonusMaxTime + lastSpawnPeriodDuration, timeBonusMinTime + lastSpawnPeriodDuration, currentNightLength), scoreExponent) * (float)timeScorePerNight * scoreMultiplyerFromPerks);
+ num2 += num3;
+ List<TaggedObject> list = new List<TaggedObject>();
+ TagManager.instance.FindAllTaggedObjectsWithTags(list, buildingTags, null);
+ int num4 = 0;
+ foreach (TaggedObject item in list)
+ {
+ BuildingInteractor componentInChildren = item.transform.parent.GetComponentInChildren<BuildingInteractor>(includeInactive: true);
+ if ((bool)componentInChildren && componentInChildren.KnockedOutTonight)
+ {
+ num4++;
+ }
+ }
+ float f = 1f - Mathf.InverseLerp(0f, list.Count, num4);
+ f = Mathf.Pow(f, scoreExponent);
+ int num5 = Mathf.RoundToInt((float)protectionScorePerNight * f * scoreMultiplyerFromPerks);
+ num2 += num5;
+ currentScore += num2;
+ OnNightScoreAdd.Invoke(num, num3, f, num5);
+ LevelData levelDataForActiveScene = LevelProgressManager.instance.GetLevelDataForActiveScene();
+ levelDataForActiveScene.highscore = currentScore;
+ levelDataForActiveScene.dayToDayScore.Add(currentScore);
+ }
+
+ public void OnDusk()
+ {
+ }
+
+ public void OnDawn_AfterSunrise()
+ {
+ }
+
+ public void OnDawn_BeforeSunrise()
+ {
+ CalculateEndOfNightScore();
+ }
+
+ public void AddDebugPoints(int amount)
+ {
+ currentScore += amount;
+ }
+}