Ejemplo n.º 1
0
    //sets up link between attacker and blocker
    private void makeAttackBlockLink()
    {
        //check if can block
        if (!DuelFunctions.CanBlock(Library.GetCard(atb.name), Library.GetCard(blockwith.name)))
        {
            blockwith.GetComponent <Image>().color          = Color.white;
            blockwith.GetComponent <Draggable>().isBlocking = false;
            blockwith = null;
            return;
        }

        for (int i = 0; i < attackers.Count; i++)
        {
            if (attackers[i].attacker.GetHashCode().Equals(atb.GetHashCode()))
            {
                AttackBlock ab = attackers[i];
                ab.blocker   = blockwith;
                attackers[i] = ab;
                Debug.Log("Link made");
                break;
            }
        }
        atb       = null;
        blockwith = null;
        Debug.Log("links: " + attackers.Count);
    }
Ejemplo n.º 2
0
    // Play card from my hand to my playing area
    public bool playMyCard(string cardName, GameObject c)
    {
        if (myState.onField.Count >= DuelFunctions.MAX_FIELD)
        {
            return(false);
        }
        for (int i = 0; i < myState.inHand.Count; i++)
        {
            if (myState.inHand[i].CardName.Equals(cardName) && DuelFunctions.CanCast(myState.inHand[i], myState))
            {
                Card played = myState.inHand[i];
                //edit state
                myState.mana -= played.CardCost;
                myState.onField.Add(played);
                myState.inHand.RemoveAt(i);
                Debug.Log("Resolving abilities");
                StartCoroutine(resolveAbilities(played, c));

                //sync with opp
                string data = "play:" + cardName;
                sendDataToOpp(data);
                return(true);
            }
        }

        return(false);
    }
Ejemplo n.º 3
0
 public bool CanCast(GameObject c)
 {
     if (DuelFunctions.CanCast(Library.GetCard(c.name), myState))
     {
         return(true);
     }
     return(false);
 }
Ejemplo n.º 4
0
    /*private void getInfo() {
     *  getProfileRequest req = new getProfileRequest(email, Global.getToken(), "viewProfile");
     *  string json = JsonConvert.SerializeObject(req);
     *  Byte[] data = System.Text.Encoding.ASCII.GetBytes(json);
     *  Global.stream.Write(data, 0, data.Length);
     *  data = new Byte[1024];
     *  string responseData = string.Empty;
     *  Int32 bytes = Global.stream.Read(data, 0, data.Length);
     *  responseData = System.Text.Encoding.ASCII.GetString(data, 0, bytes);
     *
     *  string[] info = responseData.Split(',');
     *
     *  returnedAvatar = info[0].Split('-')[1];
     *  returnedUsername = info[2].Split('-')[1];
     * }*/

    #endregion

    #region Place Cards
    // Called at the beginning of every turn
    private void drawCard()
    {
        if (deckList.Count > 0)
        {
            Card b = DuelFunctions.DrawCard(ref myState);
            myState.inHand.Add(b);
            GameObject c = (GameObject)Instantiate(myCard);
            c.GetComponent <Image>().sprite   = null;
            c.GetComponent <Image>().material = b.CardImage;
            c.name = b.CardName;
            c.transform.SetParent(handAreaPanel.transform, false); // Add card to my play area
            handList.Add(c);                                       // Add card to my play list
        }
    }
Ejemplo n.º 5
0
    // Called at start of game to set up card list from deck being used
    private void setUpDeck()
    {
        Debug.Log("Init Deck");
        myState.library = DuelFunctions.ShuffleLibrary(DuelFunctions.GetLibrary());
        int deckCount = 0;

        while (deckCount < myState.library.Count) // To add 30 card from my deck to my list
        {
            Card       b = myState.library[deckCount];
            GameObject c = (GameObject)Instantiate(myCard);
            c.GetComponent <Image>().sprite   = null;
            c.GetComponent <Image>().material = b.CardImage;
            deckList.Enqueue(c); // Add card to deck list
            Destroy(c);
            deckCount++;
        }
    }
Ejemplo n.º 6
0
    // Called at start of game to fill hand to 6 cards from deck
    IEnumerator initalDraw()
    {
        int handCount = 1;

        while (handCount <= 6) // To add 6 cards to hand
        {
            Card b = DuelFunctions.DrawCard(ref myState);
            if (b == null)
            {
                break;
            }
            GameObject c = (GameObject)Instantiate(myCard);
            c.GetComponent <Image>().sprite   = null;
            c.GetComponent <Image>().material = b.CardImage;
            c.name = b.CardName;
            c.transform.SetParent(handAreaPanel.transform, false); // Add card to hand
            myState.inHand.Add(b);
            handList.Add(c);                                       // Add card to hand list
            handCount++;
            yield return(new WaitForSeconds(0.5f));
        }
    }