public void UpdateCameraHight(UpdateEvent e, HangarCameraFlightToLocationNode hangar)
        {
            HangarConfigComponent hangarConfig = hangar.hangarConfig;
            Vector3 position = hangar.cameraRootTransform.Root.position;

            position.y = this.CalculateBezierPoint(Mathf.Clamp01((UnityTime.time - hangar.hangarCameraFlightData.StartFlightTime) / hangarConfig.FlightToLocationTime), hangar.hangarCameraFlightData.OriginCameraPosition, hangar.hangarTankPosition.transform.position + (Vector3.up * hangarConfig.FlightToLocationHigh), hangar.hangarCameraFlightData.DestinationCameraPosition).y;
            hangar.cameraRootTransform.Root.position = position;
            base.ScheduleEvent <HangarCameraRotateToDestinationEvent>(hangar);
        }
예제 #2
0
        public void UpdateCameraHight(UpdateEvent e, HangarCameraFlightToTankNode hangar)
        {
            HangarConfigComponent hangarConfig = hangar.hangarConfig;
            Vector3 position = hangar.cameraRootTransform.Root.position;

            position.y = Vector3.Lerp(hangar.hangarCameraFlightData.OriginCameraPosition, hangar.hangarCameraFlightData.DestinationCameraPosition, Mathf.Clamp01((UnityTime.time - hangar.hangarCameraFlightData.StartFlightTime) / hangarConfig.FlightToTankTime)).y;
            hangar.cameraRootTransform.Root.position = position;
            base.ScheduleEvent <HangarCameraRotateToDestinationEvent>(hangar);
        }
        public void CalculateFlightToLocation(NodeAddedEvent e, HangarLocationScreenNode screen, [JoinAll] HangarCameraNode hangar, [JoinAll] ICollection <HangarLocationScreenNode> activeLocationScreen)
        {
            Transform transform;

            if ((activeLocationScreen.Count <= 1) && hangar.hangarLocations.Locations.TryGetValue(screen.hangarLocation.HangarLocation, out transform))
            {
                base.ScheduleEvent <HangarCameraStopFlightEvent>(hangar);
                HangarConfigComponent hangarConfig = hangar.hangarConfig;
                Vector3 position = hangar.cameraRootTransform.Root.position;
                Vector3 a        = hangar.hangarTankPosition.transform.position;
                a.y = position.y;
                Vector3 b = transform.position;
                b.y = position.y;
                Vector3 from = position - a;
                from.y = 0f;
                from.Normalize();
                Vector3 to = b - a;
                to.y = 0f;
                to.Normalize();
                float   num      = Vector3.Distance(a, position);
                float   num2     = Vector3.Angle(from, to) * 0.01745329f;
                Vector3 vector8  = Vector3.Cross(to, from);
                Vector3 vector9  = ((from + to) / 2f).normalized * (num / Mathf.Cos(num2 / 2f));
                float   num4     = 3.141593f - num2;
                float   num5     = (num * Mathf.Tan(num2 / 2f)) * num4;
                Vector3 vector10 = a + (to * num);
                float   num6     = Vector3.Distance(vector10, b);
                if (num5 > num6)
                {
                    num5 = 0f;
                }
                float      num7       = hangarConfig.FlightToLocationTime / (num5 + num6);
                Vector3    vector11   = Vector3.Cross((Vector3)(hangar.cameraRootTransform.Root.rotation * Vector3.forward), (Vector3)(transform.rotation * Vector3.forward));
                Quaternion quaternion = Quaternion.Slerp(hangar.cameraRootTransform.Root.rotation, transform.rotation, 0.5f);
                if ((MathUtil.Sign(vector8.y) > 0f) && (MathUtil.Sign(vector11.y) < 0f))
                {
                    quaternion = Quaternion.AngleAxis(180f, Vector3.up) * quaternion;
                }
                HangarCameraFlightDataComponent component = new HangarCameraFlightDataComponent {
                    FlightTime          = hangarConfig.FlightToLocationTime,
                    ArcFlightPivotPoint = vector9,
                    ArcFlightTime       = num5 * num7
                };
                if (num5 > 0f)
                {
                    component.ArcFlightAngleSpeed = ((num4 * 57.29578f) / component.ArcFlightTime) * MathUtil.Sign(vector8.y);
                }
                component.ArcToLinearPoint          = vector10;
                component.LinearFlightTime          = num6 * num7;
                component.OriginCameraRotation      = hangar.cameraRootTransform.Root.rotation;
                component.OriginCameraPosition      = hangar.cameraRootTransform.Root.position;
                component.MiddleCameraRotation      = quaternion;
                component.DestinationCameraPosition = transform.position;
                component.DestinationCameraRotation = transform.rotation;
                component.StartFlightTime           = UnityTime.time;
                if (hangar.Entity.HasComponent <HangarCameraFlightDataComponent>())
                {
                    hangar.Entity.RemoveComponent <HangarCameraFlightDataComponent>();
                }
                hangar.Entity.AddComponent(component);
                hangar.hangarCameraViewState.Esm.ChangeState <HangarCameraViewState.FlightToLocationState>();
            }
        }
예제 #4
0
        private void StartFlightToTank(HangarCameraNode hangar)
        {
            base.ScheduleEvent <HangarCameraStopFlightEvent>(hangar);
            HangarConfigComponent hangarConfig = hangar.hangarConfig;
            Vector3 position = hangar.cameraRootTransform.Root.position;
            Vector3 a        = hangar.hangarTankPosition.transform.position;

            a.y = position.y;
            Vector3 vector3 = position - a;

            vector3.y = 0f;
            vector3.Normalize();
            Vector3 b = hangar.hangarCameraStartPosition.transform.position;

            b.y = position.y;
            float   num2    = Vector3.Distance(a, position);
            float   num3    = Mathf.Asin(hangarConfig.FlightToTankRadius / num2) * 2f;
            Vector3 vector5 = (Vector3)(Quaternion.Euler(0f, num3 * 57.29578f, 0f) * vector3);

            vector5.Normalize();
            Vector3 vector8 = ((vector3 + vector5) / 2f).normalized * (num2 / Mathf.Cos(num3 / 2f));

            vector8.y = position.y;
            float   num5     = 3.141593f + num3;
            float   num6     = (num2 * Mathf.Tan(num3 / 2f)) * num5;
            Vector3 vector9  = a + (vector5 * Vector3.Distance(a, b));
            Vector3 vector10 = a + (vector5 * num2);
            float   num7     = Vector3.Distance(vector10, vector9);

            if (num6 > num7)
            {
                num6 = 0f;
            }
            vector9.y = hangar.hangarCameraStartPosition.transform.position.y;
            float      num8        = hangarConfig.FlightToTankTime / (num6 + num7);
            Quaternion quaternion  = Quaternion.LookRotation(hangar.hangarTankPosition.transform.position - vector9, Vector3.up);
            Quaternion quaternion2 = Quaternion.Slerp(hangar.cameraRootTransform.Root.rotation, quaternion, 0.5f);
            HangarCameraFlightDataComponent component = new HangarCameraFlightDataComponent {
                FlightTime          = hangarConfig.FlightToTankTime,
                ArcFlightPivotPoint = vector8,
                ArcFlightTime       = num6 * num8
            };

            if (num6 > 0f)
            {
                component.ArcFlightAngleSpeed = (num5 * 57.29578f) / component.ArcFlightTime;
            }
            component.ArcToLinearPoint          = vector10;
            component.LinearFlightTime          = num7 * num8;
            component.OriginCameraRotation      = hangar.cameraRootTransform.Root.rotation;
            component.OriginCameraPosition      = hangar.cameraRootTransform.Root.position;
            component.MiddleCameraRotation      = quaternion2;
            component.DestinationCameraPosition = vector9;
            component.DestinationCameraRotation = quaternion;
            component.StartFlightTime           = UnityTime.time;
            if (hangar.Entity.HasComponent <HangarCameraFlightDataComponent>())
            {
                hangar.Entity.RemoveComponent <HangarCameraFlightDataComponent>();
            }
            hangar.Entity.AddComponent(component);
            hangar.hangarCameraViewState.Esm.ChangeState <HangarCameraViewState.FlightToTankState>();
        }