private void OnTriggerEnter2D(Collider2D other) { if (other.tag == "Player") { if (possessionCheck) { if (other.GetComponent <PlayerPossession>().itemName == conditionalItem) { changeScene(); Debug.Log(other.GetComponent <PlayerPossession>().itemName); } else { SaySmt.PrepLine("Priest", "Hey, no ghosts allowed!"); SaySmt.PrepLine("Clyde", "I think I need a disguise to get in..."); SaySmt.PlayLines(); } } else if (destinationSwitchId < 0) { SaySmt.Line("", "A mysterious voice tells you to not look back."); SaySmt.prepClose = true; } else { changeScene(); } } }
void OnTriggerEnter2D(Collider2D other) { if (other.CompareTag("Player")) { if (isLocked) { if (other.GetComponent <PlayerPossession>().itemName == unlockingKey) { GetComponent <SpriteRenderer>().sprite = unlockedSprite; GetComponents <AudioSource>()[0].Play(0); other.GetComponent <PlayerPossession>().Depossess(); StartCoroutine(waitForDepossess()); Destroy(GameObject.Find(unlockingKey)); } else if (other.GetComponent <PlayerPossession>().itemName == "FalseKey") { SaySmt.Line("Clyde", "Looks like this is a fake key! :("); SaySmt.prepClose = true; } else if (other.GetComponent <PlayerPossession>().itemName.Contains("Key")) { SaySmt.Line("Clyde", "Doesn't look like the right key..."); SaySmt.prepClose = true; } else { GetComponents <AudioSource>()[1].Play(0); SaySmt.Line("Clyde", "The door is locked. I think I need a key."); SaySmt.prepClose = true; Debug.Log("Door locked! Need key"); } } } }
private void Update() { if (Input.GetKeyDown("escape")) { SaySmt.Line("", "Press J to unpause,\nPress Q to go to quit to the main menu", false, true); SaySmt.prepClose = true; } }
IEnumerator PlayerDeath() { yield return(new WaitForSeconds(5f)); player.GetComponent <PlayerMovement>().gameOverSFX[1].Play(0); SaySmt.Line("", "GAME OVER!", true); SaySmt.prepClose = true; }
IEnumerator WaitForDeathAnim() { yield return(new WaitForSeconds(1.5f)); gameOverSFX[1].Play(0); SaySmt.Line("", "GAME OVER!", true); SaySmt.prepClose = true; // This is to enable the Coffin Dance music if we want // main.GetComponents<AudioSource>()[2].enabled = true; }
// Update is called once per frame public void Speak() { if (!spoken && lines.Count > 0) { foreach (var line in lines) { SaySmt.PrepLine(line.speaker != "" ? line.speaker : "", line.message); } SaySmt.PlayLines(); spoken = true; } else { SaySmt.Line(endLine.speaker, endLine.message); } }