Exemplo n.º 1
0
 private Threat CreateThreat(RocketComponent rocket)
 {
     return(new Threat
     {
         GameObject = rocket.gameObject,
         Distance = Vector3.Distance(rocket.transform.position, transform.position)
     });
 }
Exemplo n.º 2
0
        /// <summary>
        /// Tests if the given rocket is flying towards us.
        /// </summary>
        /// <param name="rocket"></param>
        /// <returns></returns>
        private bool FliesTowardsUs(RocketComponent rocket)
        {
            var body = rocket.GetComponent <Rigidbody>();
            var velocityDirection = body.velocity.normalized;
            var delta             = (transform.position - rocket.transform.position).normalized;
            var angle             = Vector3.Angle(velocityDirection, delta);

            if (angle >= 90)
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 3
0
        private bool TargetsUs(RocketComponent rocket)
        {
            if (!rocket.IsActivated)
            {
                return(false);
            }

            if (rocket.target != gameObject)
            {
                return(false);
            }

            if (!FliesTowardsUs(rocket))
            {
                return(false);
            }

            return(true);
        }