예제 #1
0
    //press button on keyboard to use card
    //Make public to call from UI?
    public void UseCard(Vector2 position)
    {
        // Ignore clicks over UI elements and check mana
        if (!EventSystem.current.IsPointerOverGameObject() && !playerCursor.GetComponent <CursorScript>().collidingWithButton&& currentMana >= playerHand[cardSelected].manaCost)
        {
            currentMana -= playerHand[cardSelected].manaCost;

            Vector3 point = Camera.main.ScreenToWorldPoint(new Vector3(position.x, position.y, Camera.main.nearClipPlane));
            point.z = 0f;

            Faction faction = isServer ? Faction.Friendly : Faction.Enemy;

            // Tell the server to do the card action
            CmdDoCardAction(cardSelected, (Vector2)point, faction);

            // Update local player deck
            RemoveCardFromHand();
            DrawCardFromDeck();
        }
    }