Beispiel #1
0
    // Called to attack a target
    public void Attack()
    {
        var target = getAvailableTarget();

        if (target != null)
        {
            // TODO this should be in Projectile on Start()
            // Play shoot sound
            if (!source_shoot.isPlaying)
            {
                source_shoot.PlayOneShot(shootSound);
            }

            //Animation data
            if (tag == "Unit")
            {
                animScript.Attack();
            }

            //Creates projectile with its properties and destroys it after 3 seconds
            var proj_clone =
                (GameObject)Instantiate(proj_obj, proj_origin.transform.position, proj_origin.transform.rotation);
            proj_clone.GetComponent <Projectile>().Shoot(target, currentDamage);
            Destroy(proj_clone, 3.0f);
        }
    }