Exemplo n.º 1
0
 /// <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;
     }
 }
Exemplo n.º 2
0
        /// <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));
        }