示例#1
0
    public void ShowUpdatePanel()
    {
        if (EventSystem.current.IsPointerOverGameObject())
        {
            return;
        }

        ignoreRaycastPanel.SetActive(true);
        updatePanel.SetActive(true);

        Vector2 screenPoint   = mainCamera.ScreenToWorldPoint(Input.mousePosition);
        Vector2 roundMousePos = new Vector2(Mathf.RoundToInt(screenPoint.x), Mathf.RoundToInt(screenPoint.y));

        Vector2 pointToMove = mainCamera.WorldToScreenPoint(roundMousePos);

        updatePanel.GetComponent <RectTransform>().position = pointToMove;

        RectTransformExtensions.CheckScreenPosition(towerPanel, sellPanelScreenBounds.x, sellPanelScreenBounds.y);

        float updatePrice = TowerToWork.GetComponent <Tower>().GetUpdatePrice();

        onUpdatePanelShowed(updatePrice);
    }
示例#2
0
    private void OnMouseDown()
    {
        if (EventSystem.current.IsPointerOverGameObject())
        {
            return;
        }

        if (RectTransformExtensions.IsPointerOverUIObject())
        {
            return;
        }

        towerWindow.SetActive(true);

        Vector2 screenPoint   = cam.ScreenToWorldPoint(Input.mousePosition);
        Vector2 roundMousePos = new Vector2(Mathf.RoundToInt(screenPoint.x), Mathf.RoundToInt(screenPoint.y));

        Vector2 pointToMove = cam.WorldToScreenPoint(roundMousePos);

        windowRectTransform.position = pointToMove;

        RectTransformExtensions.CheckScreenPosition(towerWindow, windowScreenBound.x, windowScreenBound.y);
        towerWindow.GetComponent <TowerSpawner>().spawnPos = roundMousePos;
    }