Ejemplo n.º 1
0
        void Update()
        {
            if (Input.GetMouseButtonDown(0))
            {
                startPoint = Input.mousePosition;
            }
            else if (Input.GetMouseButtonUp(0))
            {
                if (!dragStarted && !longTapped)
                {
                    TapDetect();
                    return;
                }

                if (dragStarted)
                {
                    draggable.OnDragEnded(Input.mousePosition);
                    draggable   = null;
                    dragStarted = false;
                }
                if (longTapped)
                {
                    longTapAbleSelected = null;
                    longTapped          = false;
                }
            }
            else if (Input.GetMouseButton(0))
            {
                if (dragStarted)
                {
                    if (Math.Abs(Input.GetAxis("Mouse X")) > 0f || Math.Abs(Input.GetAxis("Mouse Y")) > 0f)
                    {
                        draggable.OnDragMoved(Input.mousePosition);
                    }
                    return;
                }

                if (longTapped)
                {
                    return;
                }

                Vector2 diff = startPoint - (Vector2)Input.mousePosition;
                if (diff.magnitude >= minLengthToStart)
                {
                    StartDrag();
                }
                else
                {
                    longTapTimer += Time.deltaTime;
                    if (longTapTimer >= detectionTime)
                    {
                        LongTapDetect();
                        longTapTimer = 0;
                    }
                }
            }
        }
Ejemplo n.º 2
0
        void LongTapDetect()
        {
            int hits = Physics2D.RaycastNonAlloc(Camera.main.ScreenToWorldPoint(Input.mousePosition),
                                                 Vector2.zero, results, Mathf.Infinity, longTapableFilter);

            if (hits == 0)
            {
                // longTapAbleSelected = null;
                return;
            }

            longTapped = true;
            Debug.Log($"# Input # LongTapDetect on {results[hits - 1].transform.gameObject.name}");
            longTapAbleSelected = results[hits - 1].transform.gameObject.GetComponent <LongTapAble>();
            longTapAbleSelected?.OnLongTap(Input.mousePosition);
        }
Ejemplo n.º 3
0
        public void Show(LongTapAble longTapAble)
        {
            if (UILevelControlsManager.Instance.IsSomeControlShown)
            {
                return;
            }

            wizard = longTapAble.GetComponent <Wizard>();

            clouds.Clear();
            SoldiersCountText.text = soldiersCount.ToString();

            ArrowLineTemplate.gameObject.SetActive(false);
            TowerCloudTemplate.gameObject.SetActive(false);

            LeanTween.scale(gameObject, Vector3.zero, 0f);
            gameObject.SetActive(true);
            StartShowAnimation();
        }
Ejemplo n.º 4
0
        public void Show(LongTapAble longTapable)
        {
            Owner = longTapable.gameObject;

            this.tower = longTapable.GetComponent <Tower>();

            // tower.SoldiersCountChangedEvent += UpdateSoldiersCount;
            tower.SoldiersCountChangedEvent += UpdateStats;
            tower.SpecChangedSingleEvent    += SpecChanged;
            // tower.HideCanvas();

            ChooseSpecButton.interactable = false;
            ChooseSpecButton.onClick.AddListener(SpecChoiceButtonClicked);
            ResetSpecButton.interactable = false;

            // UpdateSoldiersCount();
            UpdateStats();
            UpdateSpec();

            LeanTween.scale(gameObject, Vector3.zero, 0f);
            Show();
            StartShowAnimation();
        }