Esempio n. 1
0
    private void RotateTowardsTarget()
    {
        //gameObject.transform.LookAt(eyes.restingPos.transform);
        //Vector3 dir = (this.transform.position - eyes.restingPos.transform.position).normalized;
        if (target.tag == "Player")
        {
            //Debug.Log("Enemy direction: " + dir);
            Vector3 dir = (this.transform.position - target.transform.position).normalized;

            Vector3 heading = target.transform.position - transform.position;
            float   dirNum  = AngleDir(transform.forward, heading, transform.up);

            if (dirNum > 0)
            {
                enemyRB.AddRelativeTorque(dir * rotationStrength, ForceMode.Force);
            }
            else if (dirNum < 0)
            {
                enemyRB.AddRelativeTorque(dir * -rotationStrength, ForceMode.Force);
            }


            if (dirNum > -aimConeSize && dirNum < aimConeSize)
            {
                if (enemyGun.canFire)
                {
                    enemyGun.Fire();
                }
            }
        }
    }
Esempio n. 2
0
    void FireAll()
    {
        gunScript.Fire(aimAngleH, aimAngleV);

        /*
         * public float bulletCountCurrent;
         * public float fireIntervalCurrent;
         * public float reloadTimeCurrent;*/

        Task.current.debugInfo = string.Format("Bullets: {0} / {1} Reload: {2} / {3}",
                                               gunScript.bulletCountCurrent, gunScript.bulletCountMax
                                               , gunScript.reloadTimeCurrent, gunScript.reloadTimeMax);

        if (gunScript.bulletCountCurrent == 0)
        {
            Task.current.Succeed();
        }
    }
Esempio n. 3
0
 private void Fire()
 {
     FaceToTarget();
     gun.Fire();
 }
Esempio n. 4
0
 private void AttackBehaviour()
 {
     engine.ProcessLook(target);
     gun.Fire();
 }