diff options
Diffstat (limited to 'Assembly_CSharp/Other')
-rw-r--r-- | Assembly_CSharp/Other/DevelopmentManager.cs | 23 | ||||
-rw-r--r-- | Assembly_CSharp/Other/LevelLoader.cs | 116 | ||||
-rw-r--r-- | Assembly_CSharp/Other/LightManager.cs | 62 | ||||
-rw-r--r-- | Assembly_CSharp/Other/MusicManager.cs | 164 | ||||
-rw-r--r-- | Assembly_CSharp/Other/ObjectPool.cs | 58 | ||||
-rw-r--r-- | Assembly_CSharp/Other/ResourceManager.cs | 225 | ||||
-rw-r--r-- | Assembly_CSharp/Other/SFXManager.cs | 158 | ||||
-rw-r--r-- | Assembly_CSharp/Other/Sound.cs | 22 | ||||
-rw-r--r-- | Assembly_CSharp/Other/SteamManager.cs | 123 |
9 files changed, 951 insertions, 0 deletions
diff --git a/Assembly_CSharp/Other/DevelopmentManager.cs b/Assembly_CSharp/Other/DevelopmentManager.cs new file mode 100644 index 0000000..7caec25 --- /dev/null +++ b/Assembly_CSharp/Other/DevelopmentManager.cs @@ -0,0 +1,23 @@ +using UnityEngine; + +public class DevelopmentManager : MonoBehaviour +{ + [SerializeField] + private GameObject[] startingDevelopments; + + private float developmentPercent; + + private void Start() + { + developmentPercent = PlayerPrefs.GetInt("UnlockedCardCount", 0) + PlayerPrefs.GetInt("Development", 0); + developmentPercent *= 0.4f; + GameObject[] array = startingDevelopments; + foreach (GameObject obj in array) + { + if (Random.Range(0f, 100f) > developmentPercent) + { + Object.Destroy(obj); + } + } + } +} diff --git a/Assembly_CSharp/Other/LevelLoader.cs b/Assembly_CSharp/Other/LevelLoader.cs new file mode 100644 index 0000000..1698c15 --- /dev/null +++ b/Assembly_CSharp/Other/LevelLoader.cs @@ -0,0 +1,116 @@ +using System.Collections; +using UnityEngine; +using UnityEngine.SceneManagement; +using UnityEngine.UI; + +public class LevelLoader : MonoBehaviour +{ + public static LevelLoader instance; + + [SerializeField] + private Image circle; + + [SerializeField] + private Text loadingText; + + [SerializeField] + private Text tipText; + + [SerializeField] + private string[] tips; + + private void Awake() + { + instance = this; + } + + private void Start() + { + loadingText.text = ""; + tipText.text = ""; + StartCoroutine(CircleExitStart()); + } + + public void LoadLevel(string sceneName) + { + if (MusicManager.instance != null) + { + MusicManager.instance.FadeOut(2.5f); + } + StartCoroutine(LoadAsyncronously(sceneName)); + } + + private IEnumerator LoadAsyncronously(string sceneName) + { + float num = Mathf.Sqrt(Screen.height * Screen.width) * 1.1f; + Vector2 endSize = new Vector2(2f, 1f) * num * 2f; + Vector2 startSize = new Vector2(0f, 1f) * num * 2f; + circle.rectTransform.sizeDelta = startSize; + Vector3 endPosition = new Vector3((float)Screen.height / 2f, (float)Screen.height / 2f, 0f); + Vector3 startPosition = new Vector3((float)Screen.width * 1.1f, (float)Screen.height / 2f, 0f); + circle.transform.position = startPosition; + float t = 0f; + while (t < 1f) + { + circle.rectTransform.sizeDelta = Vector2.Lerp(startSize, endSize, t); + circle.transform.position = Vector3.Lerp(startPosition, endPosition, t); + t += Time.deltaTime / 1.5f; + yield return null; + } + circle.rectTransform.sizeDelta = endSize; + circle.transform.position = endPosition; + tipText.text = GetTipsText(); + AsyncOperation operation = SceneManager.LoadSceneAsync(sceneName); + operation.allowSceneActivation = false; + float waitFill = 0f; + while (!operation.isDone || waitFill < 1f) + { + waitFill = Mathf.Clamp(waitFill + Time.deltaTime / 3f, 0f, 1f); + float num2 = Mathf.Clamp(operation.progress / 0.9f, 0f, 1f); + if (waitFill >= 1f) + { + operation.allowSceneActivation = true; + } + loadingText.text = GetLoadingText((waitFill * num2 + waitFill) / 2f); + yield return null; + } + } + + private string GetLoadingText(float percent) + { + return "Loading...".Substring(0, (int)Mathf.Round(percent * 10f)); + } + + private string GetTipsText() + { + int num = Random.Range(0, tips.Length); + int @int = PlayerPrefs.GetInt("PreviousTip", 0); + if (num == @int) + { + num = (num + 1) % tips.Length; + } + PlayerPrefs.SetInt("PreviousTip", num); + return tips[num]; + } + + private IEnumerator CircleExitStart() + { + float num = Mathf.Sqrt(Screen.height * Screen.width) * 1.1f; + Vector2 startSize = new Vector2(2f, 1f) * num * 2f; + Vector2 endSize = new Vector2(0f, 1f) * num * 2f; + circle.rectTransform.sizeDelta = startSize; + Vector3 startPosition = new Vector3((float)Screen.height / 2f, (float)Screen.height / 2f, 0f); + Vector3 endPosition = new Vector3((float)(-Screen.width) * 0.1f, (float)Screen.height / 2f, 0f); + circle.transform.position = startPosition; + float t = 0f; + while (t < 1f) + { + circle.rectTransform.sizeDelta = Vector2.Lerp(startSize, endSize, t); + circle.transform.position = Vector3.Lerp(startPosition, endPosition, t); + t += Time.deltaTime / 1.5f; + yield return null; + } + circle.rectTransform.sizeDelta = endSize; + circle.transform.position = endPosition; + } +} diff --git a/Assembly_CSharp/Other/LightManager.cs b/Assembly_CSharp/Other/LightManager.cs new file mode 100644 index 0000000..e38ac0f --- /dev/null +++ b/Assembly_CSharp/Other/LightManager.cs @@ -0,0 +1,62 @@ +using System.Collections; +using UnityEngine; + +public class LightManager : MonoBehaviour +{ + [SerializeField] + private Color stage2Color; + + [SerializeField] + private Color stage3Color; + + [SerializeField] + private Color stage4Color; + + [SerializeField] + private Light light; + + private void Start() + { + } + + public void ChangeColor(int stage) + { + switch (stage) + { + case 2: + StartCoroutine(ShiftLight(stage2Color, 180f)); + break; + case 3: + StartCoroutine(ShiftLight(stage3Color, 180f)); + break; + case 4: + StartCoroutine(ShiftLight(stage4Color, 180f)); + break; + } + } + + private IEnumerator ShiftLight(Color newColor, float rotationInDeg) + { + Color startColor = light.color; + Vector3 startEuler = light.transform.eulerAngles; + Vector3 newEuler = startEuler + new Vector3(0f, rotationInDeg, 0f); + float timer = 0f; + float count = 0f; + while (timer < 1f) + { + light.color = Color.Lerp(startColor, newColor, timer); + light.transform.eulerAngles = Vector3.Lerp(startEuler, newEuler, timer); + count += Time.deltaTime; + if (count > 60f) + { + Debug.LogError("Possible infinite loop"); + break; + } + timer += Time.deltaTime / 30f; + yield return new WaitForEndOfFrame(); + } + light.color = newColor; + light.transform.eulerAngles = newEuler; + yield return null; + } +} diff --git a/Assembly_CSharp/Other/MusicManager.cs b/Assembly_CSharp/Other/MusicManager.cs new file mode 100644 index 0000000..8a39705 --- /dev/null +++ b/Assembly_CSharp/Other/MusicManager.cs @@ -0,0 +1,164 @@ +using System.Collections; +using UnityEngine; + +public class MusicManager : MonoBehaviour +{ + public static MusicManager instance; + + [SerializeField] + private AudioSource[] hard; + + [SerializeField] + private AudioSource[] soft; + + [SerializeField] + private int currentSorceIndex; + + [SerializeField] + private int currentSong; + + private float currentSongLoopDuration; + + [SerializeField] + private AudioClip[] hardTracks; + + [SerializeField] + private AudioClip[] softTracks; + + [SerializeField] + private int[] BPMin; + + [SerializeField] + private int[] BPMeasure; + + [SerializeField] + private int[] measures; + + private int intensity = 1; + + private void Awake() + { + instance = this; + } + + private void Start() + { + PlaySong(0, action: false); + } + + private void Update() + { + if (hard[currentSorceIndex].time >= currentSongLoopDuration) + { + int num = (currentSorceIndex + 1) % 2; + hard[num].Stop(); + soft[num].Stop(); + hard[num].Play(); + soft[num].Play(); + currentSorceIndex = num; + } + int num2 = (currentSorceIndex + 1) % 2; + if (hard[num2].time >= hard[num2].clip.length - 0.1f) + { + hard[num2].Stop(); + soft[num2].Stop(); + } + } + + public void SetIntensity(bool action) + { + int num = (action ? 1 : 0); + if (num != intensity) + { + intensity = num; + StartCoroutine(CrossFade(intensity)); + } + } + + public void UpdateVolume(float newVolume) + { + hard[0].volume = newVolume * (float)intensity; + hard[1].volume = newVolume * (float)intensity; + soft[0].volume = newVolume * (float)(1 - intensity); + soft[1].volume = newVolume * (float)(1 - intensity); + } + + public void PlaySong(int songNumber, bool action) + { + StopAllCoroutines(); + hard[0].Stop(); + hard[1].Stop(); + soft[0].Stop(); + soft[1].Stop(); + currentSong = songNumber; + currentSongLoopDuration = (float)(60 * measures[currentSong] * BPMeasure[currentSong]) / (float)BPMin[currentSong]; + hard[0].clip = hardTracks[currentSong]; + hard[1].clip = hardTracks[currentSong]; + soft[0].clip = softTracks[currentSong]; + soft[1].clip = softTracks[currentSong]; + intensity = (action ? 1 : 0); + float num = OptionsMenu.instance.masterVolume * OptionsMenu.instance.musicVolume; + hard[0].volume = (float)intensity * num; + hard[1].volume = (float)intensity * num; + soft[0].volume = (float)(1 - intensity) * num; + soft[1].volume = (float)(1 - intensity) * num; + currentSorceIndex = 0; + hard[0].Play(); + soft[0].Play(); + } + + private IEnumerator CrossFade(int newIntensity) + { + float startIntensity = ((newIntensity != 1) ? 1 : 0); + float vMod = OptionsMenu.instance.masterVolume * OptionsMenu.instance.musicVolume; + float fadeTime = 2f; + int saftyCount = 0; + for (float f = startIntensity; f != (startIntensity + 1f) % 2f; f = Mathf.Clamp(f + Time.unscaledDeltaTime * ((float)newIntensity - startIntensity) / fadeTime, 0f, 1f)) + { + hard[0].volume = f * vMod; + hard[1].volume = f * vMod; + soft[0].volume = (1f - f) * vMod; + soft[1].volume = (1f - f) * vMod; + yield return null; + saftyCount++; + if ((float)saftyCount > 1000f * fadeTime) + { + Debug.LogError("Possible infinite loop"); + break; + } + } + hard[0].volume = (float)newIntensity * vMod; + hard[1].volume = (float)newIntensity * vMod; + soft[0].volume = (float)(1 - newIntensity) * vMod; + soft[1].volume = (float)(1 - newIntensity) * vMod; + } + + public void FadeOut(float t) + { + StartCoroutine(FadeOutCo(t)); + } + + private IEnumerator FadeOutCo(float fadeTime) + { + float vMod = OptionsMenu.instance.masterVolume * OptionsMenu.instance.musicVolume; + int saftyCount = 0; + for (float f = 1f; f > 0f; f -= Time.unscaledDeltaTime / fadeTime) + { + hard[0].volume = (float)intensity * vMod * f; + hard[1].volume = (float)intensity * vMod * f; + soft[0].volume = (float)(1 - intensity) * vMod * f; + soft[1].volume = (float)(1 - intensity) * vMod * f; + yield return null; + saftyCount++; + if ((float)saftyCount > 1000f * fadeTime) + { + Debug.LogError("Possible infinite loop"); + break; + } + } + hard[0].volume = 0f; + hard[1].volume = 0f; + soft[0].volume = 0f; + soft[1].volume = 0f; + } +} diff --git a/Assembly_CSharp/Other/ObjectPool.cs b/Assembly_CSharp/Other/ObjectPool.cs new file mode 100644 index 0000000..feb9c40 --- /dev/null +++ b/Assembly_CSharp/Other/ObjectPool.cs @@ -0,0 +1,58 @@ +using System.Collections.Generic; +using UnityEngine; + +public class ObjectPool : MonoBehaviour +{ + public enum ObjectType + { + DamageNumber + } + + public static ObjectPool instance; + + [SerializeField] + private GameObject damageNumberPrefab; + + [SerializeField] + private List<GameObject> pooledDamageNumbers = new List<GameObject>(); + + private void Awake() + { + instance = this; + } + + public GameObject SpawnObject(ObjectType type, Vector3 position, Quaternion rotation) + { + if (type == ObjectType.DamageNumber) + { + return SpawnDamageNumber(position, rotation); + } + Debug.LogError("Failed to spawn object from pool"); + return null; + } + + private GameObject SpawnDamageNumber(Vector3 position, Quaternion rotation) + { + while (pooledDamageNumbers.Count > 0 && pooledDamageNumbers[0] == null) + { + pooledDamageNumbers.RemoveAt(0); + } + if (pooledDamageNumbers.Count > 0) + { + GameObject gameObject = pooledDamageNumbers[0]; + pooledDamageNumbers.Remove(gameObject); + gameObject.SetActive(value: true); + gameObject.transform.position = position; + gameObject.transform.rotation = rotation; + gameObject.GetComponent<DamageNumber>().Start(); + return gameObject; + } + return Object.Instantiate(damageNumberPrefab, position, rotation); + } + + public void PoolDamageNumber(GameObject damageNumber) + { + pooledDamageNumbers.Add(damageNumber); + damageNumber.SetActive(value: false); + } +} diff --git a/Assembly_CSharp/Other/ResourceManager.cs b/Assembly_CSharp/Other/ResourceManager.cs new file mode 100644 index 0000000..5b9867f --- /dev/null +++ b/Assembly_CSharp/Other/ResourceManager.cs @@ -0,0 +1,225 @@ +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.UI; + +public class ResourceManager : MonoBehaviour +{ + public static ResourceManager instance; + + [SerializeField] + private int gold; + + [SerializeField] + private Text goldText; + + [SerializeField] + private int mana; + + private float manaLoss = 1f; + + [SerializeField] + private int maxMana; + + [SerializeField] + private int manaGatherRate; + + [SerializeField] + private Text manaText; + + [SerializeField] + private Image maskBar; + + [SerializeField] + private Image manaBar; + + [SerializeField] + private Image manaLossBar; + + private float manaTimer; + + private int manaGen; + + public float manaMaxRegenPercent; + + [SerializeField] + private GameObject manaHUDObject; + + [SerializeField] + private Text manaHUDText; + + public int enemyBonusGoldDrop; + + public List<ManaBank> manaBanks = new List<ManaBank>(); + + public int manaBankBonusMana; + + private void Awake() + { + instance = this; + } + + private void Start() + { + gold = 1000 + 100 * (PlayerPrefs.GetInt("StartGold1", 0) + PlayerPrefs.GetInt("StartGold2", 0) + PlayerPrefs.GetInt("StartGold3", 0) + PlayerPrefs.GetInt("StartGold4", 0) + PlayerPrefs.GetInt("StartGold5", 0) + PlayerPrefs.GetInt("StartGold6", 0) + PlayerPrefs.GetInt("StartGold7", 0) + PlayerPrefs.GetInt("StartGold8", 0) + PlayerPrefs.GetInt("StartGold9", 0) + PlayerPrefs.GetInt("StartGold10", 0)); + maxMana = 100 + 20 * (PlayerPrefs.GetInt("MaxMana1", 0) + PlayerPrefs.GetInt("MaxMana2", 0) + PlayerPrefs.GetInt("MaxMana3", 0) + PlayerPrefs.GetInt("MaxMana4", 0) + PlayerPrefs.GetInt("MaxMana5", 0)); + enemyBonusGoldDrop = PlayerPrefs.GetInt("GoldDrop1", 0) + PlayerPrefs.GetInt("GoldDrop2", 0) + PlayerPrefs.GetInt("GoldDrop3", 0) + PlayerPrefs.GetInt("GoldDrop4", 0) + PlayerPrefs.GetInt("GoldDrop5", 0); + manaGen = PlayerPrefs.GetInt("ManaGen1", 0) + PlayerPrefs.GetInt("ManaGen2", 0) + PlayerPrefs.GetInt("ManaGen3", 0); + UpdateManaGatherRate(manaGen); + SetManaBar(); + } + + private void Update() + { + if (manaLoss > (float)mana) + { + float num = 20f; + if (maxMana >= 500) + { + num = 100f; + } + manaLoss = Mathf.Clamp(manaLoss - num * Time.deltaTime, mana, manaLoss); + manaLossBar.rectTransform.sizeDelta = new Vector2(manaLoss / num, 0.25f); + } + if (manaTimer <= 0f) + { + AddMana(manaGen); + AddManaPercentMax(manaMaxRegenPercent); + manaTimer = 1f; + } + else if (manaGen > 0 && SpawnManager.instance.combat) + { + manaTimer -= Time.deltaTime; + } + } + + public void Spend(int goldCost) + { + gold -= goldCost; + UpdateResourceText(); + } + + public void AddMoney(int addedGold) + { + gold += addedGold; + UpdateResourceText(); + } + + public bool CheckMoney(int goldCost) + { + if (gold >= goldCost) + { + return true; + } + return false; + } + + public void SpendMana(int manaCost) + { + mana -= manaCost; + UpdateResourceText(); + } + + public void AddMana(int addedMana) + { + mana = Mathf.Clamp(mana + addedMana, 0, maxMana); + if (manaLoss < (float)mana) + { + manaLoss = mana; + } + UpdateResourceText(); + } + + public void AddManaPercentMax(float percent) + { + AddMana(Mathf.FloorToInt(percent * (float)maxMana)); + } + + public void AddMaxMana(int amount) + { + maxMana += amount; + float num = 20f; + if (maxMana >= 500) + { + num = 100f; + } + maskBar.rectTransform.localScale = new Vector3(num * 200f / (float)maxMana, 50f, 10f); + maskBar.rectTransform.sizeDelta = new Vector2((float)maxMana / num, 0.25f); + UpdateResourceText(); + } + + public bool CheckMana(int manaCost) + { + if (mana >= manaCost) + { + return true; + } + return false; + } + + public void UpdateManaGatherRate(int addedGatherRate) + { + manaGatherRate += addedGatherRate; + UpdateResourceText(); + } + + public void UpdateManaHUD() + { + string text = ""; + if (manaMaxRegenPercent > 0f) + { + text = text + "+" + Mathf.FloorToInt(101f * manaMaxRegenPercent) + "%/s\n"; + } + if (MonsterManager.instance.manaDropOnDeath > 0f) + { + text = text + Mathf.FloorToInt(101f * MonsterManager.instance.manaDropOnDeath) + "%/kill"; + } + if (text.Length > 1) + { + manaHUDObject.SetActive(value: true); + manaHUDText.text = text; + } + } + + public void AddPercentManaGathering(float percent) + { + manaMaxRegenPercent += percent; + UpdateResourceText(); + } + + private void UpdateResourceText() + { + goldText.text = "Gold: " + gold; + manaText.text = "Mana: " + mana + "/" + maxMana + " (+" + (manaGatherRate + Mathf.FloorToInt(manaMaxRegenPercent * (float)maxMana)) + "/s)"; + float num = 20f; + if (maxMana >= 500) + { + num = 100f; + } + manaBar.rectTransform.sizeDelta = new Vector2((float)mana / num, 0.25f); + } + + public void SetManaBar() + { + float num = 20f; + if (maxMana >= 500) + { + num = 100f; + } + maskBar.rectTransform.localScale = new Vector3(num * 200f / (float)maxMana, 50f, 10f); + maskBar.rectTransform.sizeDelta = new Vector2((float)maxMana / num, 0.25f); + manaLossBar.rectTransform.sizeDelta = new Vector2((float)maxMana / num, 0.25f); + UpdateResourceText(); + } + + public void UpgradeManaBankMaxMana(int addition) + { + manaBankBonusMana += addition; + foreach (ManaBank manaBank in manaBanks) + { + if (manaBank != null) + { + manaBank.UpgradeMaxMana(addition); + } + } + } +} diff --git a/Assembly_CSharp/Other/SFXManager.cs b/Assembly_CSharp/Other/SFXManager.cs new file mode 100644 index 0000000..9c972e5 --- /dev/null +++ b/Assembly_CSharp/Other/SFXManager.cs @@ -0,0 +1,158 @@ +using System.Collections.Generic; +using UnityEngine; + +public class SFXManager : MonoBehaviour +{ + public float volume = 0.5f; + + [SerializeField] + private AudioClip ballistaClip; + + [SerializeField] + private AudioClip mortarClip; + + [SerializeField] + private AudioClip teslaClip; + + [SerializeField] + private AudioClip[] explosions; + + [SerializeField] + private AudioClip biPlaneGunClip; + + [SerializeField] + private AudioClip particleCannonClip; + + [SerializeField] + private AudioClip shredderClip; + + [SerializeField] + private AudioClip[] ballistaHits; + + [SerializeField] + private AudioClip frostHitClip; + + [SerializeField] + private AudioClip shredderHitClip; + + [SerializeField] + private AudioClip[] bulletHits; + + [SerializeField] + private AudioClip particleHitClip; + + [SerializeField] + private AudioClip[] coinLongClips; + + [SerializeField] + private AudioClip[] coinShortClips; + + [SerializeField] + private AudioClip buttonClick; + + [SerializeField] + private AudioClip[] critSmall; + + [SerializeField] + private AudioClip[] critBig; + + [SerializeField] + private AudioClip cards; + + [SerializeField] + private GameObject sourceObject; + + public List<AudioPoolSource> sources = new List<AudioPoolSource>(); + + public static SFXManager instance; + + private void Awake() + { + instance = this; + } + + private void Start() + { + volume = OptionsMenu.instance.masterVolume * OptionsMenu.instance.sfxVolume; + } + + public void ButtonClick() + { + PlaySound(Sound.ButtonClick, MusicManager.instance.transform.position, MusicManager.instance.transform); + } + + public void PlaySound(Sound s, Vector3 pos) + { + PlaySound(s, pos, null); + } + + public void PlaySound(Sound s, Vector3 pos, Transform parent) + { + if (!(volume <= 0f)) + { + AudioClip clip = GetClip(s); + AudioPoolSource audioPoolSource; + if (sources.Count < 1) + { + audioPoolSource = Object.Instantiate(sourceObject).GetComponent<AudioPoolSource>(); + } + else + { + audioPoolSource = sources[0]; + sources.Remove(audioPoolSource); + } + audioPoolSource.transform.position = pos; + audioPoolSource.PlayClip(clip, volume, 0.08333f); + if (parent != null) + { + audioPoolSource.transform.parent = parent; + } + } + } + + private AudioClip GetClip(Sound s) + { + switch (s) + { + case Sound.Ballista: + return ballistaClip; + case Sound.Mortar: + return mortarClip; + case Sound.TeslaZap: + return teslaClip; + case Sound.Explosion: + return explosions[Random.Range(0, explosions.Length)]; + case Sound.BiPlaneGun: + return biPlaneGunClip; + case Sound.ParticleCannon: + return particleCannonClip; + case Sound.Shredder: + return shredderClip; + case Sound.BallistaHit: + return ballistaHits[Random.Range(0, ballistaHits.Length)]; + case Sound.FrostHit: + return frostHitClip; + case Sound.ShredderHit: + return shredderHitClip; + case Sound.BulletHit: + return bulletHits[Random.Range(0, bulletHits.Length)]; + case Sound.ParticleHit: + return particleHitClip; + case Sound.CoinLong: + return coinLongClips[Random.Range(0, coinLongClips.Length)]; + case Sound.CoinShort: + return coinShortClips[Random.Range(0, coinShortClips.Length)]; + case Sound.ButtonClick: + return buttonClick; + case Sound.CritSmall: + return critSmall[Random.Range(0, critSmall.Length)]; + case Sound.CritBig: + return critBig[Random.Range(0, critBig.Length)]; + case Sound.Cards: + return cards; + default: + Debug.LogError("No Audio Clip Found Type " + s); + return null; + } + } +} diff --git a/Assembly_CSharp/Other/Sound.cs b/Assembly_CSharp/Other/Sound.cs new file mode 100644 index 0000000..8a1528f --- /dev/null +++ b/Assembly_CSharp/Other/Sound.cs @@ -0,0 +1,22 @@ +public enum Sound +{ + None, + Ballista, + Mortar, + TeslaZap, + Explosion, + BiPlaneGun, + ParticleCannon, + Shredder, + BallistaHit, + FrostHit, + ShredderHit, + BulletHit, + ParticleHit, + CoinLong, + CoinShort, + ButtonClick, + CritSmall, + CritBig, + Cards +} diff --git a/Assembly_CSharp/Other/SteamManager.cs b/Assembly_CSharp/Other/SteamManager.cs new file mode 100644 index 0000000..642003a --- /dev/null +++ b/Assembly_CSharp/Other/SteamManager.cs @@ -0,0 +1,123 @@ +using System; +using System.Text; +using AOT; +using Steamworks; +using UnityEngine; + +[DisallowMultipleComponent] +public class SteamManager : MonoBehaviour +{ + protected static bool s_EverInitialized; + + protected static SteamManager s_instance; + + protected bool m_bInitialized; + + protected SteamAPIWarningMessageHook_t m_SteamAPIWarningMessageHook; + + protected static SteamManager Instance + { + get + { + if (s_instance == null) + { + return new GameObject("SteamManager").AddComponent<SteamManager>(); + } + return s_instance; + } + } + + public static bool Initialized => Instance.m_bInitialized; + + [MonoPInvokeCallback(typeof(SteamAPIWarningMessageHook_t))] + protected static void SteamAPIDebugTextHook(int nSeverity, StringBuilder pchDebugText) + { + Debug.LogWarning(pchDebugText); + } + + [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)] + private static void InitOnPlayMode() + { + s_EverInitialized = false; + s_instance = null; + } + + protected virtual void Awake() + { + if (s_instance != null) + { + UnityEngine.Object.Destroy(base.gameObject); + return; + } + s_instance = this; + if (s_EverInitialized) + { + throw new Exception("Tried to Initialize the SteamAPI twice in one session!"); + } + UnityEngine.Object.DontDestroyOnLoad(base.gameObject); + if (!Packsize.Test()) + { + Debug.LogError("[Steamworks.NET] Packsize Test returned false, the wrong version of Steamworks.NET is being run in this platform.", this); + } + if (!DllCheck.Test()) + { + Debug.LogError("[Steamworks.NET] DllCheck Test returned false, One or more of the Steamworks binaries seems to be the wrong version.", this); + } + try + { + if (SteamAPI.RestartAppIfNecessary((AppId_t)1843760u)) + { + Application.Quit(); + return; + } + } + catch (DllNotFoundException ex) + { + Debug.LogError("[Steamworks.NET] Could not load [lib]steam_api.dll/so/dylib. It's likely not in the correct location. Refer to the README for more details.\n" + ex, this); + Application.Quit(); + return; + } + m_bInitialized = SteamAPI.Init(); + if (!m_bInitialized) + { + Debug.LogError("[Steamworks.NET] SteamAPI_Init() failed. Refer to Valve's documentation or the comment above this line for more information.", this); + } + else + { + s_EverInitialized = true; + } + } + + protected virtual void OnEnable() + { + if (s_instance == null) + { + s_instance = this; + } + if (m_bInitialized && m_SteamAPIWarningMessageHook == null) + { + m_SteamAPIWarningMessageHook = SteamAPIDebugTextHook; + SteamClient.SetWarningMessageHook(m_SteamAPIWarningMessageHook); + } + } + + protected virtual void OnDestroy() + { + if (!(s_instance != this)) + { + s_instance = null; + if (m_bInitialized) + { + SteamAPI.Shutdown(); + } + } + } + + protected virtual void Update() + { + if (m_bInitialized) + { + SteamAPI.RunCallbacks(); + } + } +} |