예제 #1
0
        protected virtual void attack()
        {
            GameObject target = minionMovement.getTarget();

            if (target != null)
            {
                if (minionType == MinionType.Range)
                {
                    if (Vector3.Distance(this.transform.position, target.transform.position) < attackRadius.get() && Time.time >= rangeLastFire + rangeFireRate)
                    {
                        GameObject   bulletGO = (GameObject)Instantiate(bulletPrefab, this.transform.position, this.transform.rotation);
                        TargetBullet bullet   = bulletGO.GetComponent <TargetBullet>();
                        if (bullet != null)
                        {
                            bullet.setSource(this.gameObject);
                            bullet.seek(target.transform);
                            bullet.setDamage(damage.get());
                            bullet.setSpeed(70f);
                            bullet.setBuffToApply(null);
                            bullet.setTargetTag(target.tag);
                        }
                        rangeLastFire = Time.time;
                    }
                }
                else
                {
                    Damageable component = (Damageable)target.GetComponent(typeof(Damageable));
                    if (component != null && Vector3.Distance(this.transform.position, target.transform.position) < attackRadius.get())
                    {
                        component.takeDamage(damage.get() * damageModifier.get() / 100f * Time.deltaTime, this.gameObject, false);
                    }
                }
            }
        }
예제 #2
0
        void shootTargetProjectile(GameObject prefab, float damage, float explosionRadius, Buff buffToApply)
        {
            GameObject   bulletGO = (GameObject)Instantiate(prefab, firePoint.position, firePoint.rotation);
            TargetBullet bullet   = bulletGO.GetComponent <TargetBullet>();

            if (bullet != null)
            {
                bullet.setSource(this.gameObject);
                bullet.seek(target);
                bullet.setDamage(damage);
                bullet.setExplosionRadius(explosionRadius);
                bullet.setSpeed(projectileSpeed.get());
                bullet.setBuffToApply(buffToApply);
                bullet.setTargetTag(targetTag);
            }
        }