Beispiel #1
0
    void Start()
    {
        _touchClick       = gameObject.AddComponent <TouchClick>();
        _randomController = gameObject.AddComponent <RandomController>();
        _sceneController  = gameObject.AddComponent <SceneController>();
        _isUpdate         = true;
        _isLose           = false;
        _lineColor        = new Color32(232, 14, 12, 255);

        String value = Utils.GetRegexMatchValue(_sceneController.GetActiveScene().name);

        if (value.Length > 2)
        {
            LevelNumberController.levelNumber = Int32.Parse(value[0].ToString());
            LevelNumberController.taskNumber  = Int32.Parse(value[value.Length - 1].ToString());
        }

        foreach (Image shape in shapes)
        {
            Utils.ChangeColorImage(shape, colorShape);
        }
    }
    void Update()
    {
        if (Input.GetKeyUp(KeyCode.DownArrow))
        {
            InstantPlace.Invoke();
        }

        if (Input.GetKeyUp(KeyCode.LeftArrow))
        {
            HorizontalMove.Invoke(-1);
        }

        if (Input.GetKeyUp(KeyCode.RightArrow))
        {
            HorizontalMove.Invoke(1);
        }

        if (Input.GetKeyUp(KeyCode.UpArrow))
        {
            TouchClick.Invoke();
        }
    }
Beispiel #3
0
        void Update()
        {
            // mobile touch ?
            if (Input.touchCount > 0)
            {
                var touch = Input.GetTouch(0);

                switch (touch.phase)
                {
                case TouchPhase.Began:
                    Debug.Log(touch.position);

                    touched     = true;
                    forceCancel = false;
                    forceTime   = Time.time;
                    forceVector = Vector2.zero;
                    break;

                case TouchPhase.Moved:
                    if (touched)
                    {
                        if (Mathf.Abs(touch.deltaPosition.x) > Mathf.Abs(touch.deltaPosition.y) * 2f)
                        {
                            dragHorizontal += touch.deltaPosition.x * Time.deltaTime;
                            if (Math.Abs(dragHorizontal) > GameSettings.Instance.BlockSize)
                            {
                                dragHorizontal = 0;
                                forceCancel    = true;
                                HorizontalMove.Invoke(dragHorizontal > 0 ? 1 : -1);
                            }
                        }
                        else
                        {
                            if (Mathf.Abs(touch.deltaPosition.y) > Mathf.Abs(touch.deltaPosition.x) * 2)
                            {
                                forceVector += touch.deltaPosition;
                            }
                        }
                    }
                    break;

                case TouchPhase.Ended:
                    if (touched)
                    {
                        touched = false;
                        float delta = Time.time - forceTime;
                        if (delta < 0.184f)
                        {
                            TouchClick.Invoke();
                        }
                        else if (delta < 0.44f)
                        {
                            if (!forceCancel)
                            {
                                if (Mathf.Abs(forceVector.y) > Mathf.Abs(forceVector.x) * 6)
                                {
                                    InstantPlace.Invoke();
                                }
                            }
                        }
                    }

                    break;
                }
            }
        }