Esempio n. 1
0
    public void Attack(Vector3 position)
    {
        Vector3 attackStart = Vector3.MoveTowards(transform.position, position, 2f);

        spellInstance       = GameObject.Instantiate(spell, attackStart, transform.rotation) as GameObject;
        basicAttackInstance = spellInstance.GetComponent <BasicAttack> ();
        basicAttackInstance.SetTarget(position);
    }
Esempio n. 2
0
    void Update()
    {
        if (targetTag != null)
        {
            if (Time.time > shotCooldown)
            {
                Vector3 attackStart = Vector3.MoveTowards(transform.position, targetTag.transform.position, 2f);
                attackStart  += Random.onUnitSphere;
                spellInstance = GameObject.Instantiate(spellPrefab, attackStart, transform.rotation) as GameObject;
                BasicAttack attack = spellInstance.GetComponent <BasicAttack> ();

                if (attack != null)
                {
                    attack.SetTarget(targetTag);
                }

                shotCooldown = Time.time + shotRate;
            }
        }
    }