IEnumerator Die() { isDead = true; // Level Quests if (SceneManager.GetActiveScene().name.Equals("Main")) { questManager.Event($"Defeat 1 {name} 0/1", 0, true); questManager.Event(name, "Defeat", true); if (questManager.Event("monster", "Defeat", false)) { questManager.AddMainQuest("Return to Wigg"); } } // Tutorial Quests else if (SceneManager.GetActiveScene().name.Equals("Tutorial")) { questManager.Event("Defeat the monster 0/1", 0, false); questManager.Event("monster", "Defeat", false); } // Add Aggressive Score PlayerData.Kills += 1; ScoreManager.AddAggressive(1); // Prepare for Respawn soundManager.PlaySound(soundManager.monsterDie); yield return(new WaitForSeconds(0.5f)); // Disable Enemy name = "Respawn"; enemyRenderer.enabled = false; magicAttack = false; groundPoundAttack = false; spawnEnemies = false; healthText.enabled = false; GetComponent <Collider2D>().enabled = false; if (boss) { soundManager.PauseMusic(); soundManager.PlayMusic(soundManager.victoryMusic); dungeonManager.PlaceItem("Boss Key", transform.position); // Create Upgrades if (upgrades.Count > 0) { foreach (string upgrade in upgrades) { yield return(uiManager.Upgrade(upgrade)); } } // Destroy Enemies for (int i = 0; i < enemies.transform.childCount; i++) { Destroy(enemies.transform.GetChild(i).gameObject); } // Save Data player.GetComponent <PlayerController>().SaveData(false, true); } else { // Create Drops if (!SceneManager.GetActiveScene().name.Equals("Tutorial")) { dungeonManager.PlaceItem(drops[Random.Range(0, 12)], transform.position); } // Respawn Enemy if (dungeon != null && !den) { yield return(new WaitForSeconds(10)); dungeonManager.PlaceEnemy(dungeon, PlayerData.Difficulty, false); } } // Destroy Enemy Destroy(gameObject); }
public IEnumerator Talk() { // Give Quest if (!talking && !active) { talking = true; uiManager.PauseGame(); switch (PlayerData.Level) { // Spin Attack case 3: yield return(uiManager.Speak(npcName, "Hello, elf. It seems you have become stronger since the last time we met.")); yield return(uiManager.Speak(npcName, "However, I have found a way for you to become more powerful.")); yield return(uiManager.Speak(npcName, "There is a hidden scroll somewhere in this dungeon. It is said to contain ancient sword techniques, sealed away for centuries.")); yield return(uiManager.Speak(npcName, "You must find this scroll and bring it to me.")); questManager.AddMainQuest("Find the scroll"); dungeonManager.PlaceItem("Scroll", dungeonManager.RandomPosition(dungeonGenerator.RandomDungeon().GetRoom(), false)); break; // Blue Robe case 5: yield return(uiManager.Speak(npcName, "Ah, we meet again. How is your journey?")); yield return(uiManager.Speak(npcName, "I have something that may help you. But first, you must prove your skill.")); yield return(uiManager.Speak(npcName, "If you can defeat 5 monsters I will grant you this power.")); questManager.AddMainQuest("Defeat 5 monsters 0/5"); break; // Ground Pound case 6: yield return(uiManager.Speak(npcName, "Greetings, young adventurer!")); yield return(uiManager.Speak(npcName, "I have watched you advance through these dungeons. Your skill is impressive, but I fear the monsters ahead may be too strong.")); yield return(uiManager.Speak(npcName, "I have located another scroll in this area. I sense its magic...")); yield return(uiManager.Speak(npcName, "Please, find the scroll and return to me.")); questManager.AddMainQuest("Find the scroll"); dungeonManager.PlaceItem("Scroll", dungeonManager.RandomPosition(dungeonGenerator.RandomDungeon().GetRoom(), false)); break; // Red Robe case 8: yield return(uiManager.Speak(npcName, "Hello again, elf. I commend you for getting this far.")); yield return(uiManager.Speak(npcName, "I have one final quest for you. Do this for me and I will award you this final power.")); yield return(uiManager.Speak(npcName, "When four potions come together in unison, an incredible power is made.")); yield return(uiManager.Speak(npcName, "You must find all four potions and bring them to me.")); questManager.AddMainQuest("Collect all four potions"); break; // Kingsbane case 10: yield return(uiManager.Speak(npcName, $"{playerController.playerName}, we meet again for the last time.")); yield return(uiManager.Speak(npcName, "The time has almost come for you to return to Asteron, and your journey will only become tougher.")); yield return(uiManager.Speak(npcName, "You need not prove your strength to me this time, I know you are ready.")); yield return(uiManager.Speak(npcName, "Before you go, I want you to have this gift. It is an ancient heirloom passed down through generations of wizards.")); yield return(uiManager.Speak(npcName, "Only this sword can vanqish the evil king. Take it with you and bring peace to all of Asteron.")); yield return(uiManager.Upgrade("Kingsbane")); StartCoroutine(Disappear()); break; } talking = false; active = true; uiManager.ResumeGame(); } // Quest Complete else if (active) { talking = true; uiManager.PauseGame(); if (PlayerData.Level == 3 && playerController.GetInventory().Contains("Scroll")) { yield return(uiManager.Speak(npcName, "Well done, you found the scroll.")); questManager.Event("Return to Wigg", 0, false); var index = playerController.GetInventory().IndexOf("Scroll"); playerController.RemoveItem("Scroll"); uiManager.activeItem = index; uiManager.UseItem(); uiManager.DisableItem(playerController.GetInventory().Count); yield return(uiManager.Speak(npcName, "This scroll speaks of an ancient technique, the Spin Attack...")); yield return(uiManager.FadeIn()); soundManager.PlaySound(soundManager.powerup); yield return(new WaitForSecondsRealtime(1)); uiManager.SetAttacks(2); yield return(uiManager.FadeOut()); yield return(uiManager.Speak(npcName, "You have learned the Spin Attack. Good luck.")); questManager.AddMainQuest("Use 3 Spin Attacks 0/3"); StartCoroutine(Disappear()); } else if (PlayerData.Level == 5 && questManager.GetQuests().Contains("Return to Wigg")) { yield return(uiManager.Speak(npcName, "Well done, you have proved your skill. In return, I will give you this power.")); yield return(uiManager.Speak(npcName, "The blue robe will grant you more health. Use it wisely.")); yield return(uiManager.Upgrade("Blue Robe")); StartCoroutine(Disappear()); } else if (PlayerData.Level == 6 && playerController.GetInventory().Contains("Scroll")) { yield return(uiManager.Speak(npcName, "Well done, you found the scroll.")); questManager.Event("Return to Wigg", 0, false); uiManager.RemoveItem(playerController.GetInventory().IndexOf("Scroll")); playerController.RemoveItem("Scroll"); yield return(uiManager.Speak(npcName, "This scroll speaks of an ancient technique, the Ground Pound...")); yield return(uiManager.FadeIn()); soundManager.PlaySound(soundManager.powerup); yield return(new WaitForSecondsRealtime(1)); uiManager.SetAttacks(3); yield return(uiManager.FadeOut()); yield return(uiManager.Speak(npcName, "You have learned the Ground Pound. Good luck.")); questManager.AddMainQuest("Use 3 Ground Pounds 0/3"); StartCoroutine(Disappear()); } else if (PlayerData.Level == 8 && questManager.GetQuests().Contains("Return to Wigg")) { yield return(uiManager.Speak(npcName, "Well done, you have proved your skill. In return, I will give you this power.")); yield return(uiManager.Speak(npcName, "The red robe will grant you more health. Use it wisely.")); yield return(uiManager.Upgrade("Red Robe")); StartCoroutine(Disappear()); } // Quest Incomplete else { if (PlayerData.Level == 3 | PlayerData.Level == 6) { yield return(uiManager.Speak(npcName, "Return when you have found the scroll.")); } else if (PlayerData.Level == 5) { yield return(uiManager.Speak(npcName, "Return when you have defeated 5 monsters.")); } else if (PlayerData.Level == 8) { yield return(uiManager.Speak(npcName, "Return when you have found all four potions.")); } } uiManager.ResumeGame(); talking = false; yield return(new WaitForSeconds(3)); questManager.CheckQuests(); } }
public IEnumerator Talk() { if (!talking) { talking = true; if (!active) { yield return(uiManager.Speak(npcName, "An elf? How did you get here?")); yield return(uiManager.Speak(npcName, "...")); yield return(uiManager.Speak(npcName, "You tried to challenge the Evil King? You must be very brave.")); yield return(uiManager.Speak(npcName, "Welcome to the Dungeon Dimension. Most of us wizards escaped here after King Eldar took over the kingdom.")); yield return(uiManager.Speak(npcName, "What is your name, elf?")); yield return(uiManager.NameInput()); yield return(uiManager.Speak(npcName, $"It's nice to meet you, {playerTutorial.playerName}.")); uiManager.info.SetActive(true); uiManager.SetName(playerTutorial.playerName); yield return(uiManager.Speak(npcName, "You can use the player information on the top right to view your status.")); skipButton.transform.localPosition = new Vector3(-765, 300); uiManager.difficulty.transform.parent.gameObject.SetActive(true); yield return(uiManager.Speak(npcName, "The difficulty bar to the left shows how many monsters are nearby. I think we're safe for now.")); yield return(uiManager.Speak(npcName, "You can toggle difficulty adjustment using the little red button.")); uiManager.lives.SetActive(true); yield return(uiManager.Speak(npcName, "And remember to keep an eye on your health too.")); yield return(uiManager.Speak(npcName, "Now, where is your weapon?")); yield return(uiManager.Speak(npcName, "...")); yield return(uiManager.Speak(npcName, "You don't have one? Well, I'm sure we can find you a sword somewhere around here.")); uiManager.minimap.SetActive(true); yield return(uiManager.Speak(npcName, "Here, use this map to help you find your way.")); uiManager.options.SetActive(true); yield return(uiManager.Speak(npcName, "One more thing! You see the menu in the bottom left corner?")); yield return(uiManager.Speak(npcName, "You can use the Interact button to use items, objects, and characters.")); yield return(uiManager.Speak(npcName, "The Inventory button will show you what you're carrying. You can use items you've picked up from here.")); yield return(uiManager.Speak(npcName, "The Quests button will show you what to do next. If you get stuck, try completing all your quests. It might open up a new path.")); yield return(uiManager.Speak(npcName, "The Menu button will let you pause time. You can also restart or exit the dungeon from here.")); questManager.AddMainQuest("Find a weapon"); active = true; while (transform.position.x > -2) { transform.position = new Vector3(transform.position.x - 0.05f, transform.position.y, 0); yield return(new WaitForSecondsRealtime(0.05f)); } } talking = false; } }
private void OnTriggerEnter2D(Collider2D other) { if (other.gameObject.CompareTag("Item") && GetComponent <BoxCollider2D>().IsTouching(other)) { if (!other.gameObject.name.Equals("Coin")) { ScoreManager.AddCollection(1); if ((inventory.Count == 6 && !playerDisciplines.Contains("Collection")) || (inventory.Count == 8 && playerDisciplines.Contains("Collection"))) { uiManager.InvFull(other.transform.position); } } // Check item switch (other.name) { // Coin case "Coin": soundManager.PlaySound(soundManager.coin); Destroy(other.gameObject); playerCoins++; uiManager.SetCoins(playerCoins); questManager.Event("coin", "Collect", true); break; // Scroll case "Scroll": if (inventory.Count < 6 || (inventory.Count < 8 && playerDisciplines.Contains("Collection"))) { soundManager.PlaySound(soundManager.item); Destroy(other.gameObject); uiManager.AddItem("Scroll", inventory.Count); AddItem("Scroll"); if (questManager.Event("Find the scroll", 0, false)) { questManager.AddMainQuest("Return to Wigg"); } } break; // Key case "Key": if (inventory.Count < 6 || (inventory.Count < 8 && playerDisciplines.Contains("Collection"))) { soundManager.PlaySound(soundManager.item); Destroy(other.gameObject); uiManager.AddItem("Key", inventory.Count); AddItem("Key"); } break; // Boss Key case "Boss Key": if (inventory.Count < 6 || (inventory.Count < 8 && playerDisciplines.Contains("Collection"))) { soundManager.PlaySound(soundManager.win); Destroy(other.gameObject); uiManager.AddItem("Boss Key", inventory.Count); AddItem("Boss Key"); } else { uiManager.RemoveItem(inventory.Count - 1); inventory.RemoveAt(inventory.Count - 1); soundManager.PlaySound(soundManager.win); Destroy(other.gameObject); uiManager.AddItem("Boss Key", inventory.Count); AddItem("Boss Key"); } break; // Potion case "Wigg's Brew": if (inventory.Count < 6 || (inventory.Count < 8 && playerDisciplines.Contains("Collection"))) { soundManager.PlaySound(soundManager.item); Destroy(other.gameObject); uiManager.AddItem("Wigg's Brew", inventory.Count); AddItem("Wigg's Brew"); if (inventory.Contains("Wigg's Brew") && inventory.Contains("Liquid Luck") && inventory.Contains("Ogre's Strength") && inventory.Contains("Elixir of Speed") && questManager.Event("Bring all four potions to Wigg", 0, false)) { questManager.AddMainQuest("Return to Wigg"); } } break; case "Liquid Luck": if (inventory.Count < 6 || (inventory.Count < 8 && playerDisciplines.Contains("Collection"))) { soundManager.PlaySound(soundManager.item); Destroy(other.gameObject); uiManager.AddItem("Liquid Luck", inventory.Count); AddItem("Liquid Luck"); if (inventory.Contains("Wigg's Brew") && inventory.Contains("Liquid Luck") && inventory.Contains("Ogre's Strength") && inventory.Contains("Elixir of Speed") && questManager.Event("Bring all four potions to Wigg", 0, false)) { questManager.AddMainQuest("Return to Wigg"); } } break; case "Ogre's Strength": if (inventory.Count < 6 || (inventory.Count < 8 && playerDisciplines.Contains("Collection"))) { soundManager.PlaySound(soundManager.item); Destroy(other.gameObject); uiManager.AddItem("Ogre's Strength", inventory.Count); AddItem("Ogre's Strength"); if (inventory.Contains("Wigg's Brew") && inventory.Contains("Liquid Luck") && inventory.Contains("Ogre's Strength") && inventory.Contains("Elixir of Speed") && questManager.Event("Bring all four potions to Wigg", 0, false)) { questManager.AddMainQuest("Return to Wigg"); } } break; case "Elixir of Speed": if (inventory.Count < 6 || (inventory.Count < 8 && playerDisciplines.Contains("Collection"))) { soundManager.PlaySound(soundManager.item); Destroy(other.gameObject); uiManager.AddItem("Elixir of Speed", inventory.Count); AddItem("Elixir of Speed"); if (inventory.Contains("Wigg's Brew") && inventory.Contains("Liquid Luck") && inventory.Contains("Ogre's Strength") && inventory.Contains("Elixir of Speed") && questManager.Event("Collect all four potions", 0, false)) { questManager.AddMainQuest("Return to Wigg"); } } break; } } else if (other.gameObject.CompareTag("Enemy") && other is CircleCollider2D && GetComponent <BoxCollider2D>().IsTouching(other)) { // Take damage EnemyController enemyController = other.gameObject.GetComponent <EnemyController>(); if (enemyController != null && enemyController.health > 0) { int enemyAttack = other.gameObject.GetComponent <EnemyController>().GetAttack(); StartCoroutine(TakeDamage(enemyAttack)); } } else if (other.gameObject.CompareTag("King") && GetComponent <BoxCollider2D>().IsTouching(other)) { // Take damage KingController kingController = other.gameObject.GetComponent <KingController>(); if (kingController != null && kingController.isActiveAndEnabled && kingController.health > 0) { int kingAttack = other.gameObject.GetComponent <KingController>().GetAttack(); StartCoroutine(TakeDamage(kingAttack)); } } else if (other.gameObject.name.Equals("Spikes") && GetComponent <BoxCollider2D>().IsTouching(other) && other.gameObject.GetComponent <Animator>() != null && other.gameObject.GetComponent <Animator>().GetCurrentAnimatorStateInfo(0).normalizedTime < 0.17f) { // Take damage if (!IsBouncing()) { StartCoroutine(TakeDamage(1)); } // Bounce off the spikes body.AddForce(Vector2.up * 100); isBouncing = true; Invoke("StopBounce", 0.2f); } else if (other.gameObject.name.Equals("Spikes") && GetComponent <BoxCollider2D>().IsTouching(other) && !other.gameObject.GetComponent <SpriteRenderer>().sprite.name.Equals("floor_spikes_anim_f0")) { // Take damage if (!IsBouncing()) { StartCoroutine(TakeDamage(1)); } // Bounce off the spikes body.AddForce(Vector2.up * 100); isBouncing = true; Invoke("StopBounce", 0.2f); } else if (other.gameObject.CompareTag("Projectile") && GetComponent <BoxCollider2D>().IsTouching(other)) { Destroy(other); // Take damage StartCoroutine(TakeDamage(1)); } else if (other.gameObject.CompareTag("Collider") && GetComponent <BoxCollider2D>().IsTouching(other)) { ScoreManager.AddExploration(1); questManager.Event("room", "Explore", true); Destroy(other.gameObject); } }