Esempio n. 1
0
    public override void Attack()
    {
        LaserBullet bulletClone = Instantiate(bullet, attackSource.position, attackSource.rotation) as LaserBullet;

        bulletClone.SetDamage(baseDamage, false);
        bulletClone.isPlayerBullet = false;
    }
Esempio n. 2
0
    private void Attack()
    {
        if (Time.time > nextAttack)
        {
            LaserBullet bulletClone = Instantiate(bullet, attackSource.position, attackSource.rotation) as LaserBullet;
            bulletClone.SetDamage(baseDamage, false);
            bulletClone.isPlayerBullet = false;

            nextAttack = Time.time + attackRate;
        }
    }
Esempio n. 3
0
    public override bool Shoot(bool isVampire = false, bool isQuick = false)
    {
        if (power > 0 && Time.time > nextFire)
        {
            power--;

            // Create the bullet.
            LaserBullet bulletClone = Instantiate(bullet, spawnPoint.position, transform.rotation) as LaserBullet;
            bulletClone.SetDamage(baseDamage, isVampire);
            bulletClone.OnTargetReached = HealPlayer;   // Register the vampibot delegate.

            // Adjust the bullet direction.
            RaycastHit hit;
            if (Physics.Raycast(cameraTransform.position, cameraTransform.forward, out hit, 500.0f))
            {
                // If the raycast impacts, shoot exactly in that direction.
                bulletClone.transform.LookAt(hit.point);
            }
            else
            {
                // If the raycast does not impact, shoot to the point in the perpendicular direction of the camera.
                bulletClone.transform.LookAt(spawnPoint.position + cameraTransform.forward * 500.0f);
            }

            // Adjust the dispersion.
            Vector3 euler = bulletClone.transform.localRotation.eulerAngles;
            euler.x += Random.Range(-5.0f + accuracyCapacity * 4.0f, 5.0f - accuracyCapacity * 4.0f);
            euler.y += Random.Range(-5.0f + accuracyCapacity * 4.0f, 5.0f - accuracyCapacity * 4.0f);
            bulletClone.transform.localRotation = Quaternion.Euler(euler);

            if (isQuick)
            {
                nextFire = Time.time + fireRate * 0.5f;
            }
            else
            {
                nextFire = Time.time + fireRate;
            }

            nextRecharge = Time.time + rechargeRate;
            return(true);
        }
        return(false);
    }
Esempio n. 4
0
 protected override void SetProjectileDamage()
 {
     _bullet.SetDamage(Damage);
 }