#pragma warning restore 0649 // Set up and events. private void Awake() { player = FindObjectOfType <PlayerController>(); parentCanvasGroup = GetComponent <CanvasGroup>(); upgradeSettings = Resources.Load <PlayerUpgradeSettings>(upgradeSettingsPath); waitForBarAnimationDelay = new WaitForSeconds(barAnimationDelay); waitForBarAnimationFrame = new WaitForFixedUpdate(); GameMaster.OnGameMenuUpdated += FadeAnimation; GameMaster.OnTimeOfDayUpdated += UpdateUiValues; GameMaster.OnGameDayUpdate += UpdateUiValues; GameMaster.OnPlayerStatsUpdated += UpdateUiValues; UpdateUiValues += UpdateUi; UpdateUiValues?.Invoke(); InvokeRepeating(nameof(UpdateUi), 1f, 1f); }
#pragma warning restore 0649 #region Setup and Navigation. // Animates in the canvas and sets up the values. private void Awake() { eventEmitter = GetComponentInChildren <StudioEventEmitter>(); canvasGroup = GetComponent <CanvasGroup>(); canvasGroup.alpha = 0f; GameMaster.Instance.GameState = ExecutionState.PopupPause; upgradeSettings = Resources.Load <PlayerUpgradeSettings>(upgradeSettingsPath); waitFrame = new WaitForEndOfFrame(); waitForItem = new WaitForSeconds(itemInAnimationDuration); waitForStats = new WaitForSeconds(statsAnimationDuration); waitForLetters = new WaitForSeconds(statsAnimationDuration * 0.1f); DOTween.To(() => canvasGroup.alpha, x => canvasGroup.alpha = x, 1f, popinAnimationDuration).onComplete = () => { StartCoroutine(nameof(FillItemSlots)); }; }
#pragma warning restore 0649 // Sets the ship up. private void Awake() { anim = GetComponent <Animator>(); shipCamera = GetComponentInChildren <CinemachineVirtualCamera>(); DontDestroyOnLoad(gameObject); upgradeSettings = Resources.Load <PlayerUpgradeSettings>(playerSettingsPath); // Populate buttons. travelButtons.Add(new ButtonSettings(smallIslandButtonKey.key, Normal, 0)); travelButtons.Add(new ButtonSettings(mediumIslandButtonKey.key, Normal, 1)); travelButtons.Add(new ButtonSettings(largeIslandButtonKey.key, Normal, 2)); travelButtons.Add(new ButtonSettings(confirmButtonKey.key, StrongHighlight, 3)); travelButtons.Add(new ButtonSettings(cancelButtonKey.key, Highlight, 4)); GameMaster.OnCreditsOpen += () => { if (this == null || GameMaster.Instance.ShipTravel == null) { return; } GameMaster.Instance.ShipTravel = null; if (gameObject != null && this != null) { Destroy(gameObject); } }; GameMaster.OnReturnToMenu += () => { if (this == null || GameMaster.Instance.ShipTravel == null) { return; } GameMaster.Instance.ShipTravel = null; if (gameObject != null && this != null) { Destroy(gameObject); } }; }