Example #1
0
    private void Update()
    {
        if (_state == ECameraState.Undefined)
        {
            return;
        }

        if (Input.GetMouseButton(0))
        {
            _currentX += Input.GetAxis("Mouse X");
            _currentY += Input.GetAxis("Mouse Y");
            _currentY  = Mathf.Clamp(_currentY, _minangleY, _maxangleY);
        }

        if (Input.GetKeyDown(KeyCode.Tab))
        {
            if (_state == ECameraState.LookAtPlayer)
            {
                _state  = ECameraState.LookAtEnemy;
                _target = CWorld.Instance.GetNearestEnemy(CWorld.Instance.GetPlayerPosition());
            }
            else if (_state == ECameraState.LookAtEnemy)
            {
                _state  = ECameraState.LookAtPlayer;
                _target = CWorld.Instance.GetPlayer();
            }
        }
    }
Example #2
0
 // Stop all shaking, and begin the lerp from room to room...
 //
 public void BeginRoomTransition(Vector3 vNewOrigin)
 {
     m_fCamShakeAmplitude   = 0.0f;
     m_vOldCameraOrigin     = m_vCameraOrigin;
     m_vCameraOrigin        = vNewOrigin;
     m_vCameraOrigin.z      = Types.s_fCAM_ZOffset;
     m_vCameraOrigin.y     -= Types.s_fCAM_VerticalPixelOffset;
     m_fTransitionEventTime = TimerManager.fGameTime;
     m_iState = ECameraState._TRANSITIONING;
     Messenger.Invoke(Types.s_sGF_BeginRoomTransition);
 }
Example #3
0
    // Lerp, quickly, between two rooms...
    // Because the lerp duration is standardised, the camera doesn't need to
    // report anywhere that it's complete, it can safely revert to idle.
    //
    void TransitionUpdate()
    {
        float fRatio = (TimerManager.fGameTime - m_fTransitionEventTime) / Types.s_fCAM_RoomTransitionDuration;

        transform.position = Vector3.Lerp(m_vOldCameraOrigin, m_vCameraOrigin, Easing.EaseIn(fRatio, EEasingType.Quintic));

        // Ensure the camera has snapped into the correct position and then revert to normal update
        if (fRatio >= 1.0f)
        {
            transform.position     = m_vCameraOrigin;
            m_iState               = ECameraState._IDLE;
            m_fTransitionEventTime = 0.0f;
        }
    }
Example #4
0
    private IEnumerator CameraZoom()
    {
        while (true)
        {
            currentZoomSpeed = 1f / zoomSpeed;

            if (InputManager.Instance.buttonScroll.ReadValue().y > 0)
            {
                cameraState = ECameraState.ZOOMIN;
            }

            if (InputManager.Instance.buttonScroll.ReadValue().y < 0)
            {
                cameraState = ECameraState.ZOOMOUT;
            }
            yield return(null);
        }
    }
Example #5
0
    public void Init()
    {
        offset = confineCollider.offset;
        size   = confineCollider.size;
        height = currentCamera.orthographicSize;
        width  = height * Screen.width / Screen.height;

        #region if <=0

        if (currentCamera == null)
        {
            Debug.Log("currentCamera가 null");
            currentCamera = Camera.main;
        }
        currentTransform = currentCamera.transform;
        if (zoomSpeed <= 0f)
        {
            zoomSpeed = 1f;
        }

        if (followSpeed <= 0f)
        {
            followSpeed = 5f;
        }

        if (BGObject == null)
        {
            BGObject = new GameObject();
            BGObject.transform.parent = gameObject.transform;
            //그냥 오류 방지를 위해 빈깡 하나 넣기.
        }
        #endregion

        limitCalSize     = 0.03f;
        currentZoomSpeed = 1f / zoomSpeed;
        cameraState      = ECameraState.DEFAULT;
        isTimeMode       = true;

        scObjX = BGObject.transform.localScale.x;
        scObjY = BGObject.transform.localScale.y;
        //cameraDefaultPositionZ = -10f;

        originBGObjectScale = BGObject.transform.localScale;
    }
Example #6
0
    private void Start()
    {
        CWorld.Instance.SetCamera(this);
        _cam            = Camera.main;
        _cam_transform  = transform;
        _state          = ECameraState.Undefined;
        _start_position = _cam_transform.position;
        _camera_shift   = new Vector3(0, 1f, -_distance);
        _velocity       = Vector3.zero;
        _excel_data     = new List <DataToExcel>();
        customCulture   = (CultureInfo)System.Threading.Thread.CurrentThread.CurrentCulture.Clone();
        customCulture.NumberFormat.NumberDecimalSeparator = ".";

        CWorld.Instance.OnNewPlayer += OnNewPlayer;
        if (CWorld.Instance.GetPlayer() != null)
        {
            OnNewPlayer(this, EventArgs.Empty);
        }
    }
Example #7
0
    private IEnumerator CameraZoomIn(float _size)
    {
        if (NowCameraState() == ECameraState.ZOOMOUT)
        {
            _size = cameraDefaultSize;
        }

        if (isTimeMode) //시간 모드일 경우
        {
            zoomTimer = 0f;
            float oldOrthographicSize = currentCamera.orthographicSize; // 원래 사이즈를 저장

            while (Mathf.Abs(currentCamera.orthographicSize - _size) > limitCalSize)
            {
                zoomTimer += Time.smoothDeltaTime * currentZoomSpeed;
                currentCamera.orthographicSize = Mathf.Lerp(oldOrthographicSize, _size, zoomTimer);

                // BG 크기 체인지
                ChangeScaleBGObject();

                yield return(YieldInstructionCache.WaitForEndOfFrame);
            }
        }
        else //아닐 경우
        {
            while (Mathf.Abs(currentCamera.orthographicSize - _size) > limitCalSize)
            {
                // zoomTimer += Time.deltaTime;
                currentCamera.orthographicSize = Mathf.SmoothDamp(currentCamera.orthographicSize, _size, ref velocity, zoomSpeed);

                // BG 크기 체인지
                ChangeScaleBGObject();

                yield return(YieldInstructionCache.WaitForEndOfFrame);
            }
        }

        currentCamera.orthographicSize = _size;
        cameraState = ECameraState.STAY;

        // BG 크기 체인지
        ChangeScaleBGObject();
    }
Example #8
0
    public void SwitchState(ECameraState state)
    {
        this.mState = state;
        switch (mState)
        {
        case ECameraState.NONE:
            break;

        case ECameraState.ENTER:
            OnEnter();
            break;

        case ECameraState.UPDATE:
            break;

        case ECameraState.LEAVE:
            OnLeave();
            break;
        }
    }
Example #9
0
 private void OnNewPlayer(object sender, EventArgs e)
 {
     _state  = ECameraState.LookAtPlayer;
     _target = CWorld.Instance.GetPlayer();
 }
 /**
  * Disable rotation (user can't move the screen)
  **/
 public void StopRotation()
 {
     mRotationMode = ECameraState.OFF;
 }
 /**
  * Enable manual rotation mode
  **/
 public void ManualRotation()
 {
     mRotationMode = ECameraState.MANUAL;
 }
 /**
  * Enable automatic rotation mode
  **/
 public void AutomaticRotation(Timeout screenTimeout)
 {
     mRotationMode  = ECameraState.AUTO;
     mScreenTimeout = screenTimeout;
 }