diff options
Diffstat (limited to 'Thronefall_v1.0/Decompile/LevelSelectManager.cs')
-rw-r--r-- | Thronefall_v1.0/Decompile/LevelSelectManager.cs | 114 |
1 files changed, 114 insertions, 0 deletions
diff --git a/Thronefall_v1.0/Decompile/LevelSelectManager.cs b/Thronefall_v1.0/Decompile/LevelSelectManager.cs new file mode 100644 index 0000000..5650ffd --- /dev/null +++ b/Thronefall_v1.0/Decompile/LevelSelectManager.cs @@ -0,0 +1,114 @@ +using TMPro; +using UnityEngine; +using UnityEngine.UI; + +public class LevelSelectManager : MonoBehaviour +{ + public static LevelSelectManager instance; + + private LevelInteractor[] levelInteractors; + + public Vector3 spawnOnLevelOffsetPositon; + + public PlayerMovement playerMovement; + + public TMP_Text levelTitle; + + public TMP_Text levelHighscore; + + public TMP_Text beatenState; + + public string notBeatenYet = "Not beaten yet."; + + public string successfullyBeaten = "Successfully beaten."; + + public string scorePrefix = "Your Best: "; + + public GameObject tooltipObject; + + public Image tooltipImage; + + public TMP_Text tooltipTitle; + + public TMP_Text tooltipDescription; + + private Equippable showingTooltipFor; + + public Canvas levelSelectedCanvas; + + public Camera camMain; + + private LevelInteractor openedLevel; + + private int iFrames; + + private bool fixedLoadout; + + public Equippable ShowingTooltipFor => showingTooltipFor; + + public bool PreLevelMenuIsOpen => openedLevel != null; + + public void ShowTooltip(Equippable _eq) + { + showingTooltipFor = _eq; + tooltipObject.SetActive(_eq != null); + if (!(_eq == null)) + { + tooltipImage.sprite = _eq.icon; + tooltipTitle.text = _eq.displayName; + tooltipDescription.text = _eq.description; + float num = camMain.pixelRect.height / levelSelectedCanvas.pixelRect.height; + tooltipObject.transform.position = Input.mousePosition * num; + } + } + + private void Awake() + { + instance = this; + } + + private void Start() + { + levelInteractors = GetComponentsInChildren<LevelInteractor>(); + ShowTooltip(null); + } + + private void MovePlayerToTheLevelYouCameFrom() + { + SceneTransitionManager sceneTransitionManager = SceneTransitionManager.instance; + if (!sceneTransitionManager || sceneTransitionManager.ComingFromGameplayScene == "") + { + return; + } + for (int i = 0; i < levelInteractors.Length; i++) + { + if (levelInteractors[i].sceneName == sceneTransitionManager.ComingFromGameplayScene) + { + playerMovement.TeleportTo(levelInteractors[i].transform.position + spawnOnLevelOffsetPositon); + break; + } + } + } + + private void Update() + { + if (iFrames <= 1) + { + MovePlayerToTheLevelYouCameFrom(); + } + iFrames++; + } + + public void PlayButtonPressed() + { + if (PreLevelMenuIsOpen) + { + if (openedLevel.fixedLoadout.Count > 0) + { + PerkManager.instance.CurrentlyEquipped.Clear(); + PerkManager.instance.CurrentlyEquipped.AddRange(openedLevel.fixedLoadout); + } + SceneTransitionManager.instance.TransitionFromLevelSelectToLevel(openedLevel.sceneName); + } + } +} |