Esempio n. 1
0
    private void CheckMouse()
    {
        Vector3 worldPos = Camera.main.ScreenToWorldPoint(Input.mousePosition);

        //float fx = worldPos.x + 7.5f;
        //int y = (int) Mathf.Floor(worldPos.y - 1.5f)*-1;

        //if (y%2 != 0) {
        //    fx += 0.5f;
        //}

        //int x = (int) Mathf.Floor(fx);

        MapPosition gridPosition = CombatManager.WorldToGrid(worldPos);

        int x = gridPosition.x;
        int y = gridPosition.y;


        // TODO: every second row
        if (0 <= x && x <= 15)
        {
            if (selectedCard != null && Input.GetMouseButtonDown(0))
            {
                if (CanUseSpell(selectedCard.GetBaseCard(), x, y))
                {
                    UseCard(selectedCard.GetBaseCard(), x, y);
                    Destroy(selectedCard.gameObject);
                }
                // Deselect card on failed attempt for now
                selectedCard = null;
            }
        }
    }