Exemple #1
0
    void OnMouseUp()
    {
        if (_activeInputLens != null)
        {
            CameraOrbit.unlockedLens.RemoveRequestsWithContext(this);
            CameraOrbit.inputFreeLens.RemoveRequestsWithContext(this);
            _activeInputLens = null;

            List <BitSlotWidget> bitSlots = GetBreed().GetBitSlots();
            for (int i = 0; i < bitSlots.Count; i++)
            {
                bitSlots[i].SetHighlight(false);
            }

            ResetFadeoutTimer();

            bool allMatched = _spriteToSlotMap.Count == _bitSprites.Length;
            if (allMatched)
            {
                GetBreed().AssignBlock(this);
                Destroy(gameObject);
            }
            else
            {
                GameSounds.PostEvent2D(GameSound.SFX_BlockDeny);

                Vector2 screenMin       = Vector2.zero;
                Vector2 screenMax       = new Vector2(Screen.width, Screen.height);
                Vector2 screenBoundDiff = screenMax - screenMin;
                screenMin += screenBoundDiff * 0.001f;
                screenMax -= screenBoundDiff * 0.001f;
                Vector3 mousePos = ((Vector3)WadeUtils.Clamp((Vector2)Input.mousePosition, screenMin, screenMax)).SetZ(Input.mousePosition.z);

                bool uiOverlap = RectTransformUtility.RectangleContainsScreenPoint(GetBreed().GetBreedRect(), mousePos, Camera.main);
                if (!uiOverlap)
                {
                    Vector3 worldPos = Camera.main.ScreenToWorldPoint(mousePos);
                    if (Physics.Raycast(worldPos, Camera.main.transform.forward, out _hitInfo, Mathf.Infinity, _planetLayer, QueryTriggerInteraction.Ignore))
                    {
                        _dropPos = _hitInfo.point + _hitInfo.normal * _dropGroundOffset;
                    }
                }

                if (_changeScaleRoutine != null)
                {
                    StopCoroutine(_changeScaleRoutine);
                }

                _changeScaleRoutine = StartCoroutine(ChangeScaleRoutine(false));
                _dropRoutine        = StartCoroutine(DropRoutine());
            }

            BreedPanel breedPanel = UIManager.GetPanel <BreedPanel>();
            breedPanel.GetLeftRotateRect().gameObject.SetActive(false);
            breedPanel.GetRightRotateRect().gameObject.SetActive(false);
        }
    }
Exemple #2
0
    BreedPanel GetBreed()
    {
        if (!_breedPanel)
        {
            _breedPanel = UIManager.GetPanel <BreedPanel>();
        }

        return(_breedPanel);
    }
Exemple #3
0
    void OnMouseDown()
    {
        if (CameraOrbit.inputFreeLens && _dropRoutine == null)
        {
            _dropPos = transform.position;
            _groundShadow.enabled = false;

            for (int i = 0; i < _bitSprites.Length; i++)
            {
                _bitSprites[i].sortingOrder = _uiLayerOrder;
            }

            _activeInputLens = new LensHandle <bool>(this, false);

            CameraOrbit.unlockedLens.AddRequest(new LensHandle <bool>(this, false));
            CameraOrbit.inputFreeLens.AddRequest(_activeInputLens);

            Vector2 screenMin = Vector2.zero;
            Vector2 screenMax = new Vector2(Screen.width, Screen.height);
            screenMin += (screenMax - screenMin) * 0.001f;
            screenMax -= (screenMax - screenMin) * 0.001f;
            Vector3 mousePos = ((Vector3)WadeUtils.Clamp((Vector2)Input.mousePosition, screenMin, screenMax)).SetZ(Input.mousePosition.z);

            BreedPanel breedPanel = UIManager.GetPanel <BreedPanel>();
            breedPanel.GetLeftRotateRect().gameObject.SetActive(true);
            breedPanel.GetRightRotateRect().gameObject.SetActive(true);

            if (!breedPanel.gameObject.activeSelf)
            {
                UIManager.GetPanel <SwapPanel>().OnClickBreed();
            }



            _prevUIOverlap = RectTransformUtility.RectangleContainsScreenPoint(breedPanel.GetBreedRect(), mousePos, Camera.main);

            ResetFadeoutTimer();
        }
    }