Exemplo n.º 1
0
        private void HandleRotate()
        {
            //Debug.Log("rotate");

            if (LastGameState == IngameSettings.IngameState.Rotate)
            {
                if (EraserButton.interactable)
                {
                    LastGameState = IngameSettings.IngameState.Erase;
                }
                else if (PaintButton.interactable)
                {
                    LastGameState = IngameSettings.IngameState.Paint;
                }
            }

            var touch = Input.GetTouch(0);
            if (touch.deltaTime > 0)
            {
                float swipeSpeed = touch.deltaPosition.magnitude / touch.deltaTime;
                //Vector3 newAngle = ModelTransform.rotation.eulerAngles;
                Vector3 angle = Vector3.zero;

                if (Mathf.Abs(touch.deltaPosition.x) > Mathf.Abs(touch.deltaPosition.y))
                {
                    //Debug.Log("Moving x");
                    float swipeDirectionX = touch.deltaPosition.x < 0 ? 1.0f : -1.0f;
                    angle.y += swipeDirectionX * swipeSpeed * DegreesToRotate.y;
                    //ModelTransform.rotation = Quaternion.AngleAxis(swipeAngle.x, Vector3.up);
                }
                else
                {
                    //Debug.Log("Moving y");
                    float swipeDirectionY = touch.deltaPosition.y < 0 ? 1.0f : -1.0f;
                    angle.x += swipeDirectionY * swipeSpeed * DegreesToRotate.x;
                    //ModelTransform.rotation = Quaternion.AngleAxis(swipeAngle.y, Vector3.forward);
                }

                //newAngle.z = 0;
                ModelTransform.rotation *= Quaternion.Euler(angle);
            }
        }
Exemplo n.º 2
0
        private void Update()
        {
            //todo debounce

            if (Input.touchCount > 0)
            {
                // Check if finger is over a UI element
                if (IsPointerOverUI(Input.GetTouch(0).fingerId))
                {
                    return;
                }
            }

            if (Input.touchCount == 2)
            {
                if (IngameSettings.GameState != IngameSettings.IngameState.Zoom)
                {
                    LastGameState = IngameSettings.GameState;
                    IngameSettings.GameState = IngameSettings.IngameState.Zoom;
                }

                HandleZoom();
            }
            else if (Input.touchCount == 1)
            {
                switch (IngameSettings.GameState)
                {
                    case IngameSettings.IngameState.Paint:
                    case IngameSettings.IngameState.Erase:
                        HandlePaint();
                        break;

                    case IngameSettings.IngameState.Rotate:
                        HandleRotate();
                        break;

                    case IngameSettings.IngameState.Zoom:
                        IngameSettings.GameState = LastGameState;
                        break;
                }
            }
            else
            {
                if (IngameSettings.GameState == IngameSettings.IngameState.Zoom)
                {
                    IngameSettings.GameState = LastGameState;
                }
            }

            //Debug.Log("Game state " + IngameSettings.GameState.ToString());
        }
Exemplo n.º 3
0
        public void OnRotateSelect()
        {
            if (IngameSettings.GameState == IngameSettings.IngameState.Rotate)
            {
                IngameSettings.GameState = LastGameState;

                //RotateImage.sprite = OriginalRotate;
                //un grey out

                if (LastGameState == IngameSettings.IngameState.Paint)
                {
                    TogglePaint(true);
                    ToggleEraser(false);
                }
                else if (LastGameState == IngameSettings.IngameState.Erase)
                {
                    TogglePaint(false);
                    ToggleEraser(true);
                }

                //Slider.sprite = OriginalSlider;
                //SliderBar.sprite = OriginalSliderBar;
                //BrushSliderControl.interactable = true;
            }
            else
            {
                LastGameState = IngameSettings.GameState;
                IngameSettings.GameState = IngameSettings.IngameState.Rotate;
                Palette.gameObject.SetActive(false);

                //if (LastGameState == IngameSettings.IngameState.Paint)
                //{
                //	RotateImage.sprite = OriginalPaintSprite;
                //	PaintImage.sprite = GreyPaintSprite;
                //}
                //else if (LastGameState == IngameSettings.IngameState.Erase)
                //{
                //	RotateImage.sprite = OriginalEraserSprite;
                //	PaintImage.sprite = GreyEraserSprite;
                //}

                //grey out
                //Slider.sprite = GreySlider;
                //SliderBar.sprite = GreySliderBar;
                //BrushSliderControl.interactable = false;
                TogglePaint(false);
                ToggleEraser(false);
            }
        }