コード例 #1
0
    public void OnClick()
    {
        NetworkIdentity netID = NetworkClient.connection.identity;

        playerCtrlr = netID.GetComponent <My_PlayerController>();
        playerCtrlr.CmdDrawCard(3);
    }
コード例 #2
0
    public void discard()
    {
        NetworkIdentity     netID = NetworkClient.connection.identity;
        My_PlayerController p     = netID.GetComponent <My_PlayerController>();

        if (p.spellcardGO)
        {
            p.spellcardGO.GetComponent <CardView>().discard();
        }
    }
コード例 #3
0
    public bool checkManaCost()
    {
        NetworkIdentity     netID  = NetworkClient.connection.identity;
        My_PlayerController player = netID.GetComponent <My_PlayerController>();

        if (player.hasEnoughManaToPlay(card.cCard))
        {
            return(true);
        }
        else
        {
            Debug.Log("No enough mana");
            return(false);
        }
    }
コード例 #4
0
 public void RpcSetTurn()
 {
     isOurTurn = !isOurTurn;
     Debug.Log("isOurTurn:  ----   " + isOurTurn);
     turn_button.gameObject.SetActive(isOurTurn);
     if (isOurTurn)
     {
         //  playerController = My_PlayerController.localPlayer;
         // playerController.CmdDrawCard(1);
         NetworkIdentity     netID = NetworkClient.connection.identity;
         My_PlayerController p     = netID.GetComponent <My_PlayerController>();
         p.CmdDrawCard(1);
         p.addMana();
     }
 }
コード例 #5
0
    public void OnDrop(PointerEventData eventData)
    {
        if (isOnHAnd)
        {
            return;
        }
        Draggable d = eventData.pointerDrag.GetComponent <Draggable>();

        // Debug.Log(d.gameObject.GetComponent<CardView>().cName.text);
        //  Debug.Log("Drop on card" + cCard.boardPosition[0] + "/" + cCard.boardPosition[1] + " " + ctrl.currentAction);
        if (d != null &&
            ctrl.isOurTurn)
        {
            Debug.Log("switch");
            switch (ctrl.currentAction)
            {
            case "attacking":
                if (d.GetComponent <CardView>().isOnHAnd || isMyCard)
                {
                    return;
                }
                ctrl.CmdAttackToUnit(cCard.boardPosition[0], cCard.boardPosition[1]);
                break;

            case "spellcasting":
                if (isOnHAnd)
                {
                    return;
                }
                Debug.Log("carview spellcasting");
                Debug.Log(cCard.boardPosition[0] + " / " + cCard.boardPosition[1]);
                NetworkIdentity     netID  = NetworkClient.connection.identity;
                My_PlayerController player = netID.GetComponent <My_PlayerController>();


                if (checkCurrentTarget(player.targetType))
                {
                    player.castSpell(cCard.boardPosition[0], cCard.boardPosition[1], hasAuthority);
                    Debug.Log("checking tags");
                }
                break;

            default:
                break;
            }
        }
    }
コード例 #6
0
    public void OnBeginDrag(PointerEventData eventData)
    {
        if (!ctrl.isOurTurn)
        {
            return;
        }

        // Debug.Log("... bgin draging");
        isOnHand = gameObject.GetComponent <CardView>().isOnHAnd;
        if (canBePLayedFromHand())
        {
            playing     = true;
            placeholder = new GameObject();
            placeholder.transform.SetParent(this.transform.parent);
            LayoutElement le = placeholder.AddComponent <LayoutElement>();
            le.preferredHeight = this.GetComponent <LayoutElement>().preferredHeight;
            le.preferredWidth  = this.GetComponent <LayoutElement>().preferredWidth;
            le.flexibleHeight  = 0;
            le.flexibleWidth   = 0;

            placeholder.transform.SetSiblingIndex(this.transform.GetSiblingIndex());

            // view.GetComponent<cardOverview>().hideOverview();
            parentToReturn = this.transform.parent;
            this.transform.SetParent(this.transform.parent.parent);
            GetComponent <CanvasGroup>().blocksRaycasts = false;

            if (card.cCard.type == "spell")
            {
                List <string> spell = new List <string>(card.cCard.skill);
                Debug.Log("0 index ->" + spell[0]);
                NetworkIdentity     netID  = NetworkClient.connection.identity;
                My_PlayerController player = netID.GetComponent <My_PlayerController>();
                player.setSpell(spell, gameObject);
            }
        }
        else
        {
            playing = false;
        }

        if (!isOnHand && isMyCard && ctrl.isOurTurn)
        {
            ctrl.CmdUpdateAttacker(card.cCard.boardPosition[0], card.cCard.boardPosition[1]);
        }
    }
コード例 #7
0
 public void registerPlayers(GameObject player)
 {
     playerController = player.GetComponent <My_PlayerController>();
     if (player1 == null)
     {
         Debug.Log("registered player 1");
         player1     = player.GetComponent <My_PlayerController>();
         player1.tag = "player1";
         playerCount++;
     }
     else
     {
         Debug.Log("registered player 2");
         player2     = player.GetComponent <My_PlayerController>();
         player2.tag = "player2";
         playerCount++;
     }
 }
コード例 #8
0
    public void startGame(bool hostFirst)
    {
        // My_PlayerController player = My_PlayerController.localPlayer; // to set thing on current player
        isOurTurn = true;
        turn_button.gameObject.SetActive(true);
        if (!hostFirst)
        {
            CmdEndTurn();
            //playerController.CmdDrawCard(1);
            return;
        }
        else
        {
            NetworkIdentity     netID = NetworkClient.connection.identity;
            My_PlayerController p     = netID.GetComponent <My_PlayerController>();

            p.CmdDrawCard(1);
        }
    }
コード例 #9
0
    public void OnDrop(PointerEventData eventData)
    {
        Draggable d = eventData.pointerDrag.GetComponent <Draggable>();

        // Debug.Log(d.gameObject.GetComponent<CardView>().cName.text);

        if (d != null &&
            !hasCard &&
            d.GetComponent <Draggable>().canBePLayedFromHand() &&
            d.GetComponent <CardView>().cCard.type != "spell"
            )
        {
            if (zone == "enemy")
            {
                return;
            }
            d.parentToReturn = this.transform;
            d.GetComponent <CardView>().isOnHAnd = false;
            hasCard = true;

            /*battleController.GetComponent<BattleController>().addCardToField(
             *  new int[] { zoneCol, zoneRow },
             *  d.gameObject,
             *  d.GetComponent<CardView>().player);
             */
            NetworkIdentity networkIdentity = NetworkClient.connection.identity;
            playerController = networkIdentity.GetComponent <My_PlayerController>();
            playerController.playCard(d.gameObject, new int[] { zoneCol, zoneRow });
        }
        if (d != null &&
            d.GetComponent <Draggable>().canBePLayedFromHand() &&
            !hasCard &&
            d.GetComponent <CardView>().cCard.type == "spell")
        {
            // ex: summon thing on empty space
        }
    }