コード例 #1
0
        public unsafe IEnumerator FocusOnMapRegion([NotNull] IMapDefinition mapDefinition, int regionIndex, [CanBeNull] CameraControlParameters parameters = null)
        {
            if (m_regionFocusCoroutine != null)
            {
                this.StopCoroutine(m_regionFocusCoroutine);
                m_regionFocusCoroutine = null;
            }
            Camera    camera          = this.camera;
            Transform cameraContainer = m_cameraContainer;

            if (null == camera || null == cameraContainer)
            {
                yield break;
            }
            float panTweenDuration;
            Ease  val;
            float num;
            Ease  val2;

            if (null == parameters)
            {
                CameraControlParameters defaultControlParameters = m_defaultControlParameters;
                if (null == defaultControlParameters)
                {
                    panTweenDuration = m_panTweenDuration;
                    val  = 9;
                    num  = m_zoomTweenDuration;
                    val2 = 9;
                }
                else
                {
                    panTweenDuration = defaultControlParameters.panTweenDuration;
                    val  = defaultControlParameters.panTweenEase;
                    num  = defaultControlParameters.zoomTweenMaxDuration;
                    val2 = defaultControlParameters.zoomTweenEase;
                }
            }
            else
            {
                panTweenDuration = parameters.panTweenDuration;
                val  = parameters.panTweenEase;
                num  = parameters.zoomTweenMaxDuration;
                val2 = parameters.zoomTweenEase;
            }
            FightMapRegionDefinition region = mapDefinition.GetRegion(regionIndex);
            Vector3 val3 = Vector3Int.op_Implicit(mapDefinition.origin);
            Vector2 val4 = Vector2Int.op_Implicit(region.sizeMin);
            Vector2 val5 = Vector2Int.op_Implicit(region.sizeMax);
            Vector3 val6 = cameraContainer.get_rotation() * m_cameraPositionOffset;
            Vector2 val7 = val4 + 0.5f * (val5 - Vector2.get_one() - val4);
            Vector3 targetCameraPosition = new Vector3(((IntPtr)(void *)val7).x, 0f, ((IntPtr)(void *)val7).y) + val3 + val6;
            Vector3 val8 = default(Vector3);

            val8._002Ector(((IntPtr)(void *)val4).x, 0f, ((IntPtr)(void *)val4).y);
            Vector3 val9 = default(Vector3);

            val9._002Ector(((IntPtr)(void *)val5).x, 0f, ((IntPtr)(void *)val5).y);
            Vector3 val10 = default(Vector3);

            val10._002Ector(((IntPtr)(void *)val8).x, 0f, ((IntPtr)(void *)val9).z);
            Vector3 val11 = default(Vector3);

            val11._002Ector(((IntPtr)(void *)val9).x, 0f, ((IntPtr)(void *)val8).z);
            Vector3 val12       = cameraContainer.get_rotation() * new Vector3(1f, 0f, 1f);
            Vector3 normalized  = val12.get_normalized();
            Vector3 normalized2 = val6.get_normalized();

            val12 = val9 - val8;
            float num2 = Mathf.Abs(Vector3.Dot(val12.get_normalized(), normalized));

            val12 = val11 - val10;
            float   num3             = Mathf.Abs(Vector3.Dot(val12.get_normalized(), normalized));
            float   num4             = Mathf.Abs(Vector3.Dot(normalized2, normalized));
            float   num5             = Vector3.Distance(val8, val9);
            float   num6             = Vector3.Distance(val10, val11);
            float   num7             = 2f * val6.get_magnitude();
            Vector2 val13            = 2.828427f * m_regionFocusMargin;
            float   num8             = num2 * num5 + num3 * num6 + num4 * num7 + ((IntPtr)(void *)val13).y;
            float   num9             = (1f - num2) * num5 + (1f - num3) * num6 + (1f - num4) * num7 + ((IntPtr)(void *)val13).x;
            float   num10            = num8 / 4f;
            float   num11            = num9 / 2f / camera.get_aspect();
            float   num12            = Mathf.Max(num10, num11);
            float   targetZoomLevel2 = Mathf.InverseLerp(6f, m_maxOrthoSize, num12);

            targetZoomLevel2       = Mathf.Floor(targetZoomLevel2 / m_zoomIncrement) * m_zoomIncrement;
            m_targetCameraPosition = targetCameraPosition;
            m_targetZoomLevel      = targetZoomLevel2;
            m_userHasControl       = false;
            if (m_panTween != null && TweenExtensions.IsPlaying(m_panTween))
            {
                TweenSettingsExtensions.SetEase <Tweener>(m_panTween.ChangeEndValue((object)targetCameraPosition, panTweenDuration, true), val);
            }
            else
            {
                m_panTween = TweenSettingsExtensions.SetEase <TweenerCore <Vector3, Vector3, VectorOptions> >(DOTween.To(new DOGetter <Vector3>((object)this, (IntPtr)(void *) /*OpCode not supported: LdFtn*/), new DOSetter <Vector3>((object)this, (IntPtr)(void *) /*OpCode not supported: LdFtn*/), targetCameraPosition, panTweenDuration), val);
            }
            float num13 = Mathf.Lerp(0f, num, Mathf.Abs(targetZoomLevel2 - m_zoomLevel) / m_zoomIncrement);

            if (m_zoomTween != null && TweenExtensions.IsPlaying(m_zoomTween))
            {
                TweenSettingsExtensions.SetEase <Tweener>(m_zoomTween.ChangeEndValue((object)targetZoomLevel2, num13, true), val2);
            }
            else
            {
                m_zoomTween = TweenSettingsExtensions.SetEase <TweenerCore <float, float, FloatOptions> >(DOTween.To(new DOGetter <float>((object)this, (IntPtr)(void *) /*OpCode not supported: LdFtn*/), new DOSetter <float>((object)this, (IntPtr)(void *) /*OpCode not supported: LdFtn*/), targetZoomLevel2, num13), val2);
            }
            while (TweenExtensions.IsPlaying(m_panTween) || TweenExtensions.IsPlaying(m_zoomTween))
            {
                yield return(null);

                if (m_targetCameraPosition != targetCameraPosition || m_targetZoomLevel != targetZoomLevel2)
                {
                    break;
                }
            }
            m_regionFocusCoroutine = null;
            m_userHasControl       = true;
        }
コード例 #2
0
 public void StartFocusOnMapRegion([NotNull] IMapDefinition mapDefinition, int regionIndex, [CanBeNull] CameraControlParameters parameters = null)
 {
     m_regionFocusCoroutine = this.StartCoroutine(FocusOnMapRegion(mapDefinition, regionIndex, parameters));
 }