Esempio n. 1
0
        // SUBS

        private Vector3 FindNearestRulerCenterPointUsingRotation(GameObject shipBase)
        {
            Vector3 result                 = new Vector3(float.MaxValue, float.MaxValue, float.MaxValue);
            Vector3 savedRotation          = shipBase.transform.localEulerAngles;
            float   minDistance            = float.MaxValue;
            float   distanceToNearestPoint = float.MaxValue;

            do
            {
                minDistance = distanceToNearestPoint;

                Vector3 point_ShipStandBack = GetShipBaseBackPoint(shipBase);
                Vector3 point_NearestMovementRulerCenter = MovementTemplates.FindNearestRulerCenterPoint(point_ShipStandBack);

                distanceToNearestPoint = Vector3.Distance(point_ShipStandBack, point_NearestMovementRulerCenter);

                if (distanceToNearestPoint < minDistance)
                {
                    result = point_NearestMovementRulerCenter;
                }

                shipBase.transform.localEulerAngles += new Vector3(0, 1 * GetDirectionModifier(), 0);
            }while (distanceToNearestPoint < minDistance);

            shipBase.transform.localEulerAngles = savedRotation;

            return(result);
        }
Esempio n. 2
0
        public void UpdateRotationFinisher()
        {
            if (MovementTemplates.CurrentTemplate.transform.Find("Finisher") != null)
            {
                Vector3 point_ShipStandBack  = Selection.ThisShip.GetCentralBackPoint();
                Vector3 point_ShipStandFront = Selection.ThisShip.GetCentralFrontPoint();

                float pathToProcessFinishingLeft = (MovementTemplates.CurrentTemplate.transform.Find("Finisher").InverseTransformPoint(point_ShipStandFront).x);

                if (pathToProcessFinishingLeft > 0)
                {
                    float turningDirection = 0;
                    if (Direction == ManeuverDirection.Right)
                    {
                        turningDirection = 1;
                    }
                    if (Direction == ManeuverDirection.Left)
                    {
                        turningDirection = -1;
                    }

                    Vector3 point_NearestMovementRulerCenter = MovementTemplates.FindNearestRulerCenterPoint(point_ShipStandBack);

                    Vector3 vector_ShipBackStand_ShipStandFront = point_ShipStandFront - point_ShipStandBack;
                    Vector3 vector_NearestMovementRulerCenter_ShipStandFront   = point_ShipStandFront - point_NearestMovementRulerCenter;
                    float   angle_ToShipStandBack_ToNearestMovementRulerCenter = Vector3.Angle(vector_ShipBackStand_ShipStandFront, vector_NearestMovementRulerCenter_ShipStandFront);

                    Selection.ThisShip.SetRotationHelper2Angles(new Vector3(0, angle_ToShipStandBack_ToNearestMovementRulerCenter * turningDirection, 0));
                }
            }
        }