示例#1
0
        /// <summary>
        /// Returns the quadrant of the target vehicle on the track relative to the origin vehicle.
        /// </summary>
        public static RelativeQuadrant GetRelativeQuadrant(BaseVehicleDriver targetDriver, BaseVehicleDriver originDriver)
        {
            Vector2           relativePosition = GetRelativePosition2D(targetDriver, originDriver);
            RelativeDirection relativeX        = relativePosition.x < 0f ? RelativeDirection.Left : RelativeDirection.Right;
            RelativeDirection relativeZ        = relativePosition.y < 0f ? RelativeDirection.Back : RelativeDirection.Front;
            RelativeQuadrant  quadrant         = (RelativeQuadrant)(relativeX | relativeZ);

            return(quadrant);
        }
        /// <summary>
        /// Returns the best available camera to frame the target vehicle.
        /// </summary>
        public MountedCamera GetBestCamera(BaseVehicleDriver targetVehicle)
        {
            if (targetVehicle == null)
            {
                return(GetRandomFrontFacingCamera());
            }
#if UNITY_EDITOR
            LookAtVehicle = targetVehicle;
#endif
            RelativeQuadrant quadrant = TrackHelper.GetRelativeQuadrant(targetVehicle, followVehicle);
            return(WeightedRandom.Get(GetQuadrantCameras(quadrant)));
        }
示例#3
0
        public void SetRelativeQuadrant(Vector2 pos)
        {
            /*
             * setting quadrant of the player's position relative to the enemy
             * it's either positive or not, no neutral territory here.
             * ---------
             | B | A |
             |---|---|
             | C | D |
             | ---------
             */

            Vector2 difference = pos - this.loc;

            if (difference.X <= 0)
            {
                if (difference.Y <= 0)
                {
                    this.relQuad = RelativeQuadrant.C;
                }
                else
                {
                    this.relQuad = RelativeQuadrant.B;
                }
            }
            else
            {
                if (difference.Y <= 0)
                {
                    this.relQuad = RelativeQuadrant.D;
                }
                else
                {
                    this.relQuad = RelativeQuadrant.A;
                }
            }
        }
 private WeightedMountedCamera[] GetQuadrantCameras(RelativeQuadrant quadrant)
 {
     return(camerasPerQuadrant[quadrant]);
 }