/// <summary> /// Casts currently selected Spell /// </summary> private void CastSpell() { //If the player is allowed to shoot if (!GameManager.Instance.Paused && spellCooldown[selectedSpellIndex] <= 0) { if (runningRoutine != null) { StopCoroutine(runningRoutine); } SpellData spell = selectedSpells[selectedSpellIndex]; if (spell == null) // Current spell is invalid (e.g. after changing spells, but not changing the selected index) { SelectNextSpell(); spell = selectedSpells[selectedSpellIndex]; } // Spawn Spell spell.SpawnSpell(spawnLocation.position, spawnLocation.up, targetingMask); // Run Event castEvent?.Invoke(selectedSpellIndex, spell.Cooldown); // Set animation bookAnimator.SetBool("Cast", true); runningRoutine = StartCoroutine(CoroutineMethods.RunDelayed(() => { bookAnimator.SetBool("Cast", false); }, 0.1f)); // Set cooldown spellCooldown[selectedSpellIndex] = spell.Cooldown; } }
/// <summary> /// Returns the book to the player, after hanging in the air for a short time /// </summary> private void Return() { back = true; savedPosition = transform.position; movedSpace = 0; pause = true; StartCoroutine(CoroutineMethods.RunDelayed(() => { pause = false; }, hangTime)); }
/// <summary> /// Ends dialogue and clears queue /// </summary> private void EndDialogue() { // Closes dialogue box animator.SetBool("IsOpen", false); onComplete?.Invoke(); onComplete = null; StartCoroutine(CoroutineMethods.RunDelayed(() => dialogueUI.ClearDialogue(), .25f)); enabled = false; }
/// <summary> /// Performs attack on Player /// </summary> private void Attack() { enemyAnimator.SetBool("Attacking", true); List <Projectile> projectiles = spell.SpawnSpell(transform.position + transform.right * 0.2f, transform.right, attackCollisionMask); for (int i = 0; i < projectiles.Count; i++) { projectiles[i].transform.localScale *= .75f; // Fire Small-Scale objects (compared to what the Player fires) } StartCoroutine(CoroutineMethods.RunDelayed(() => { enemyAnimator.SetBool("Attacking", false); }, .75f)); }
/// <summary> /// Checks if the Player has solved the current DataSet /// </summary> public void CheckIfSolved() { if (currentSet.CheckDataSolved()) { spellManager.UnlockSpell(); unlockMsg.enabled = true; checkButton.enabled = false; StartCoroutine(CoroutineMethods.RunDelayed(SwitchToSpellPage, 3f)); } else { unlockMsg.enabled = false; } }
/// <summary> /// Damages this Enemy /// </summary> /// <param name="amount">Amount of Damage to inflict</param> /// <returns>True if Damage was inflicted</returns> public bool Damage(ushort amount) { if (Health == 0) { return(false); // Already Dead. Hit while animating death } if (amount >= Health) { Health = 0; Die(); } else { Health -= amount; } enemyRenderer.SetSpriteColor(Color.red); PopupFactory.CreateDamageUI(transform.position, amount, enemyRenderer, Color.red); StartCoroutine(CoroutineMethods.RunDelayed(() => enemyRenderer.SetSpriteColor(Color.white), .1f)); return(true); }
/// <summary> /// Runs GameStartDialogue for first Room /// </summary> /// <param name="loadedRoom">Room that was Loaded</param> private void RunGameStartDialogue(Room loadedRoom) { if (loadedRoom.name != StartRoomName) { return; } // Remove Listener from RoomLoad FloorManager.Instance.RemoveRoomLoadListener(RunGameStartDialogue); // Lock Movement & Casting PlayerManager.Instance.MovementManager.enabled = false; PlayerManager.Instance.CastingManager.enabled = false; // Lock Current Room FloorManager.Instance.CurrentRoom.CloseDoors(); // Display dialogue after 1 second StartCoroutine(CoroutineMethods.RunDelayed(() => { // Prevent opening Menu during Dialogue GameUIManager.Instance.enabled = false; // Run Dialogue DialogueManager.Instance.StartDialogue(dialogues[(int)TutorialSteps.GameStart], EndGameStartDialogue); } , 1f)); }