private void OnEndSlide(CameraEdgeSliderEventArgs e) { if (m_endSlide != null) { m_endSlide(this, e); } //print("End Slide"); }
private void OnStartSlide(CameraEdgeSliderEventArgs e) { if (m_startSlide != null) { m_startSlide(this, e); } // print("Start Slide"); }
IEnumerator CameraTranslateEnumerator() { var intervalTime = 0.02f; WaitForSeconds wait = new WaitForSeconds(intervalTime); while (true) { var msPos = Input.mousePosition; var widthBorder = Screen.width * m_edgeRatio; var heightBorder = Screen.height * m_edgeRatio; Vector3 deltaVec = Vector3.zero; var lastDirection = m_currentDirection; m_currentDirection = 0; if (msPos.y > Screen.height - heightBorder) { var tempAmount = (msPos.y - (Screen.height - heightBorder)); deltaVec += tempAmount * m_topDirection; m_currentDirection = m_currentDirection | Direction.Up; //m_currentDirection = Direction.Up; } if (msPos.y < heightBorder) { var tempAmount = (msPos.y - heightBorder); deltaVec += tempAmount * m_topDirection; m_currentDirection = m_currentDirection | Direction.Down; //m_currentDirection = Direction.Down; } if (msPos.x > Screen.width - widthBorder) { var tempAmount = (msPos.x - (Screen.width - widthBorder)); deltaVec += tempAmount * m_rightDirection; m_currentDirection = m_currentDirection | Direction.Right; //m_currentDirection = Direction.Right; } if (msPos.x < widthBorder) { var tempAmount = (msPos.x - widthBorder); deltaVec += tempAmount * m_rightDirection; m_currentDirection = m_currentDirection | Direction.Left; //m_currentDirection = Direction.Left; } var common = m_currentDirection & lastDirection; var newStart = m_currentDirection & (~common); //(Direction)((1 << (int)m_currentDirection) - (1 << (int)common)); var newEnd = lastDirection & (~common); //(Direction)((1 << (int)lastDirection) - (1 << (int)common)); if (newStart != 0) { var startArgs = new CameraEdgeSliderEventArgs(); startArgs.m_direction = newStart; OnStartSlide(startArgs); } if (newEnd != 0) { var endArgs = new CameraEdgeSliderEventArgs(); endArgs.m_direction = newEnd; OnEndSlide(endArgs); } deltaVec *= m_cameraTargetTranslateSpeed * intervalTime; // Camera.main.transform.position += deltaVec; m_cameraTarget.parent.position = Vector3.Lerp(m_cameraTarget.parent.position, m_cameraTarget.parent.position + deltaVec, 0.8f); yield return(wait); } }