Beispiel #1
0
    public IEnumerator Shoot()
    {
        isCasting = true;
        // look at it
        Vector3 targetPoint = selectedTarget.transform.position;

        targetPoint.y = transform.position.y;
        transform.LookAt(targetPoint);

        // place fancy animation below player
        Vector3 spellPosition = transform.position;

        spellPosition.y += 0.01f;
        animator.SetBool("attack", true);
        GameObject spell = Instantiate(spellPrefab, spellPosition, transform.rotation) as GameObject;

        AudioSource.PlayClipAtPoint(castSound, transform.position);
        playerMagic.DecreasePlayerMagic(magicCost);



        yield return(new WaitForSeconds(0.8f));

        AudioSource.PlayClipAtPoint(hammerSound, transform.position);

        GameObject spellDamage = Instantiate(spellDamagePrefab, selectedTarget.transform.position, selectedTarget.transform.rotation) as GameObject;

        //Destroy (selectedTarget);
        bool goodAttack = selectedHealth.DecreaseEnemyHealth(magicDamage);

        animator.SetBool("attack", false);

        yield return(new WaitForSeconds(0.7f));



        if (!goodAttack)
        {
            // character is dead, unselect
            yield return(new WaitForSeconds(0.3f));

            UnSelectTarget();
        }

        Destroy(spell, 0.5f);
        Destroy(spellDamage, 0.5f);
        isCasting = false;
    }