예제 #1
0
        protected virtual void Awake()
        {
            if (shipCollider != null)
            {
                shipCollider.Initalise(this);
            }
            if (shieldCollider != null)
            {
                shieldCollider.Initalise(this);
            }

            boid = GetComponent <BoidActor> ();

            foreach (Debris debris in debrisObjects)
            {
                debris.gameObject.SetActive(false);
            }

            foreach (Gun gun in guns)
            {
                gun.ship = this;
            }

            if (engineAudioSource != null)
            {
                if (engineAudioSource.clip != null)
                {
                    engineAudioSource.time = Random.Range(0f, engineAudioSource.clip.length);
                }
            }
        }
예제 #2
0
        protected virtual void Awake()
        {
            boid = GetComponent <BoidActor> ();

            if (enabled)
            {
                calculationsCo = StartCoroutine(UpdateCalculations());
            }
        }
예제 #3
0
        public bool AimingAt(BoidActor targetBoid, float accuracy)
        {
            float   timeToTarget   = Vector3.Distance(targetBoid.transform.position, ship.transform.position) / projectileSpeed;
            Vector3 targetPosition = targetBoid.transform.position + (targetBoid.velocity * timeToTarget);

            if (Vector3.Angle(ship.transform.forward, targetPosition - ship.transform.position) <= accuracy)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }