public static void KeyCollected(int id) { if (!isRegistered) { UnityEngine.SceneManagement.SceneManager.sceneLoaded += (s, m) => { // Clear collected keys on scene reload if (m == UnityEngine.SceneManagement.LoadSceneMode.Single) { keysCollected.Clear(); } }; } keysCollected.Add(id); PortalBoss boss = FindObjectOfType <PortalBoss>(); if (boss) { boss.UpdateState(); } EffectDoor.instance.Simulate(keysCollected.Count); }
private void OnTriggerEnter(Collider other) { if (other.CompareTag("Mage")) { PortalBoss.KeyCollected(id); Destroy(gameObject); } }
public void OnSpawned(char key, int id) { this.id = id; if (PortalBoss.IsKeyCollected(id)) { Destroy(gameObject); // Destoy key if it has already been collected } }
private void Update() { if (Input.GetKeyDown(KeyCode.Z)) { if (invulnerability) { Destroy(invulnerability.gameObject); } else { invulnerability = Instantiate(invincibilitySpell, Mage.instance.transform, false).GetComponent <SpellSelfInvincible>(); invulnerability.fadeTime = 0F; } } if (Input.GetKeyDown(KeyCode.Insert)) { PortalBoss.KeyCollected(Random.Range(int.MinValue, 0)); } }