//===================================================== private void OnPopupSpecialKeyUnlocked(ePuzzleKeyType keyType) { if (_keyType != keyType) { return; } StartCoroutine(PlayCutscene(_startDelay)); }
//===================================================== private IEnumerator ShowKeyCollectedPopup(ICutsceneObject obj, ePuzzleKeyType keyType) { var isFinalKey = GameDataManager.Instance.GetNumKeysCollected(CurrentLocation) >= Convert.ToInt32(SettingsManager.GetSettingsItem("NUM_PUZZLE_ROOM_KEYS", (int)CurrentLocation)); yield return(new WaitForSeconds(1.5f)); PopupKeyCollected.PopupKeyExitScene += OnPopupKeyExitScene; PopupKeyCollected.Instance.Show(obj, keyType, isFinalKey); }
//===================================================== public void OnKeyCollected(ICutsceneObject obj, ePuzzleKeyType keyType) { if (InputManager.Instance != null) { InputManager.Instance.OnBlockInput(true); } // Eject player from puzzle-room - ensure player isn't flagged as dead _isPlayerDead = false; PlayerManager.OnCelebrate(); StartCoroutine(ShowKeyCollectedPopup(obj, keyType)); }
//===================================================== public void Show(ePuzzleKeyType keyType) { if (_camera == null) { _camera = transform.FindChild("GuiCamera").gameObject; } if (_camera == null) { return; } _keyType = keyType; StartCoroutine(DelayShowPopup()); }
//===================================================== public void Show(ICutsceneObject obj, ePuzzleKeyType keyType, bool _isFinalKey) { // ToDo: show additional info for collecting all keys in scene if (_camera == null) { _camera = transform.FindChild("GuiCamera").gameObject; } if (_camera == null) { return; } // Store cutscene object - pass back to GameManager when closing popup _keyCutsceneObject = obj; _camera.SetActive(true); _keyType = keyType; //var id = ""; switch (_keyType) { default: _imgKey.sprite = _keyDefault; _txtKeyId.text = TextManager.GetText("POPUP_KEY") + " " + ((int)_keyType - 1); break; case ePuzzleKeyType.KEY_GEM_RED: _imgKey.sprite = _keyRedGems; _txtKeyId.text = TextManager.GetText("POPUP_KEY_RED_GEMS"); break; case ePuzzleKeyType.KEY_GEM_100: _imgKey.sprite = _key100Gems; _txtKeyId.text = TextManager.GetText("POPUP_KEY_100_GEMS"); break; } //_txtKeyId.text = TextManager.GetText( "POPUP_KEY" ) + " " + id; _txtCollected.text = TextManager.GetText("POPUP_KEY_COLLECTED"); }
//===================================================== private static void AddCollectableOfType(eCollectable type, ePuzzleKeyType keyType = ePuzzleKeyType.NULL) { var pfb = ResourcesCollectables.GetPrefab(); Object mdl = null; mdl = ResourcesCollectables.GetModel(type, (type == eCollectable.KEY) ? (int)keyType : 0); if (pfb == null) { return; } // Create containers for collectables if they don't already exist var container = GameObject.Find("Collectables"); var gems = GameObject.Find("Gems"); var redGems = GameObject.Find("RedGems"); var keys = GameObject.Find("Keys"); if (container == null) { container = CreateContainer("Collectables"); if (gems == null) { gems = CreateContainer("Gems", container); } if (redGems == null) { redGems = CreateContainer("RedGems", container); } if (keys == null) { keys = CreateContainer("Keys", container); } } var prefab = PrefabUtility.InstantiatePrefab(pfb) as GameObject; if (prefab == null) { return; } var script = prefab.GetComponent <Collectable>(); switch (type) { case eCollectable.GEM: prefab.name = "Gem"; prefab.transform.parent = gems.transform; break; case eCollectable.RED_GEM: prefab.name = "RedGem"; prefab.transform.parent = redGems.transform; break; case eCollectable.KEY: switch (keyType) { default: prefab.name = "Key"; break; case ePuzzleKeyType.KEY_GEM_RED: prefab.name = "Red Gem Key"; break; case ePuzzleKeyType.KEY_GEM_100: prefab.name = "100 Gem Key"; break; } prefab.transform.parent = keys.transform; break; } if (script != null) { script.Type = type; if (mdl != null) { var model = PrefabUtility.InstantiatePrefab(mdl) as GameObject; script.Init(model); if (type == eCollectable.KEY) { switch (keyType) { default: script.KeyId = ePuzzleKeyType.KEY_001; break; case ePuzzleKeyType.KEY_GEM_RED: script.KeyId = ePuzzleKeyType.KEY_GEM_RED; break; case ePuzzleKeyType.KEY_GEM_100: script.KeyId = ePuzzleKeyType.KEY_GEM_100; break; } } script.Refresh(); } } PositionObjectAndSelect(prefab); }