Esempio n. 1
0
        // Token: 0x06008685 RID: 34437 RVA: 0x0026A27C File Offset: 0x0026847C
        private void UpdateTouch(float dt)
        {
            if (!BJLuaObjHelper.IsSkipLuaHotfix && this.TryInitHotFix("") && this.m_UpdateTouchSingle_hotfix != null)
            {
                this.m_UpdateTouchSingle_hotfix.call(new object[]
                {
                    this,
                    dt
                });
                return;
            }
            BJLuaObjHelper.IsSkipLuaHotfix = false;
            for (int i = 0; i < Input.touchCount; i++)
            {
                Touch touch = Input.GetTouch(i);
                if (touch.fingerId < 2)
                {
                    TouchStatus touchStatus = this.m_touchStatus[touch.fingerId];
                    if (touch.phase == TouchPhase.Began)
                    {
                        if (!this.IsTouchUI(touch.position))
                        {
                            touchStatus.m_beginPosition = (touchStatus.m_currentPosition = (touchStatus.m_prevPosition = touch.position));
                            touchStatus.m_pressed       = true;
                        }
                    }
                    else if (touch.phase == TouchPhase.Ended || touch.phase == TouchPhase.Canceled)
                    {
                        touchStatus.m_pressed = false;
                    }
                    else if (touch.phase == TouchPhase.Moved)
                    {
                        touchStatus.m_currentPosition = touch.position;
                    }
                }
            }
            if (Input.touchCount <= 0)
            {
                TouchStatus touchStatus2 = this.m_touchStatus[0];
                if (Input.GetMouseButtonDown(0) && !this.IsTouchUI(Input.mousePosition))
                {
                    touchStatus2.m_beginPosition = (touchStatus2.m_currentPosition = (touchStatus2.m_prevPosition = Input.mousePosition));
                    touchStatus2.m_pressed       = true;
                }
                if (Input.GetMouseButtonUp(0))
                {
                    touchStatus2.m_pressed = false;
                }
                if (Input.GetMouseButton(0))
                {
                    touchStatus2.m_currentPosition = Input.mousePosition;
                }
            }
            float axis = Input.GetAxis("Mouse ScrollWheel");

            if (axis != 0f)
            {
                float num = 1f - axis;
                this.m_camera.orthographicSize = Mathf.Clamp(this.m_camera.orthographicSize / CameraBase.AspectScale() * num, this.m_viewSizeMin, this.m_viewSizeMax) * CameraBase.AspectScale();
            }
            if (this.m_touchStatus[0].m_pressed || this.m_touchStatus[1].m_pressed)
            {
                float   viewWidth  = this.m_camera.orthographicSize * 2f * this.m_camera.aspect;
                float   viewHeight = this.m_camera.orthographicSize * 2f;
                Vector2 position   = this.m_position;
                if (this.m_touchStatus[0].m_pressed ^ this.m_touchStatus[1].m_pressed)
                {
                    int     num2   = (!this.m_touchStatus[0].m_pressed) ? 1 : 0;
                    Vector2 vector = BattleCamera.ScreenPositionToViewPosition(this.m_touchStatus[num2].m_currentPosition - this.m_touchStatus[num2].m_prevPosition, viewWidth, viewHeight);
                    this.m_touchStatus[num2].m_prevPosition = this.m_touchStatus[num2].m_currentPosition;
                    position.x -= vector.x;
                    position.y -= vector.y;
                }
                else if (this.m_touchStatus[0].m_pressed && this.m_touchStatus[1].m_pressed && axis == 0f)
                {
                    Vector2 b    = (this.m_touchStatus[0].m_prevPosition + this.m_touchStatus[1].m_prevPosition) * 0.5f;
                    Vector2 a    = (this.m_touchStatus[0].m_currentPosition + this.m_touchStatus[1].m_currentPosition) * 0.5f;
                    float   num3 = Vector2.Distance(BattleCamera.ScreenPositionToViewPosition(this.m_touchStatus[0].m_prevPosition, viewWidth, viewHeight), BattleCamera.ScreenPositionToViewPosition(this.m_touchStatus[1].m_prevPosition, viewWidth, viewHeight));
                    float   num4 = Vector2.Distance(BattleCamera.ScreenPositionToViewPosition(this.m_touchStatus[0].m_currentPosition, viewWidth, viewHeight), BattleCamera.ScreenPositionToViewPosition(this.m_touchStatus[1].m_currentPosition, viewWidth, viewHeight));
                    this.m_touchStatus[0].m_prevPosition = this.m_touchStatus[0].m_currentPosition;
                    this.m_touchStatus[1].m_prevPosition = this.m_touchStatus[1].m_currentPosition;
                    Vector2 vector2 = BattleCamera.ScreenPositionToViewPosition(a - b, viewWidth, viewHeight);
                    position.x -= vector2.x;
                    position.y -= vector2.y;
                    if (num3 > 0f && num4 > 0f)
                    {
                        this.m_camera.orthographicSize = Mathf.Clamp(this.m_camera.orthographicSize / CameraBase.AspectScale() * num3 / num4, this.m_viewSizeMin, this.m_viewSizeMax) * CameraBase.AspectScale();
                    }
                }
                if (dt > 0f)
                {
                    this.m_touchMoveVelocity = (position - this.m_position) / dt;
                }
                this.m_position = this.ClampCameraPosition(position);
            }
            else
            {
                float magnitude = this.m_touchMoveVelocity.magnitude;
                if (magnitude > 0f)
                {
                    float d = Math.Max(magnitude - magnitude * dt * 10f, 0f);
                    this.m_touchMoveVelocity = this.m_touchMoveVelocity / magnitude * d;
                    this.m_position          = this.ClampCameraPosition(this.m_position + this.m_touchMoveVelocity * dt);
                }
            }
        }
Esempio n. 2
0
 // Token: 0x06008697 RID: 34455 RVA: 0x0026B0EC File Offset: 0x002692EC
 public LuaExportHelper(BattleCamera owner)
 {
     this.m_owner = owner;
 }
Esempio n. 3
0
 // Token: 0x060086BF RID: 34495 RVA: 0x0026B36C File Offset: 0x0026956C
 public static Vector2 ScreenPositionToViewPosition(Vector2 p, float viewWidth, float viewHeight)
 {
     return(BattleCamera.ScreenPositionToViewPosition(p, viewWidth, viewHeight));
 }