public bool checkQueue(ProgressCardColor color)
    {
        switch (color)
        {
        case ProgressCardColor.Yellow:
            return(yellowCardsQueue.Count > 0);

        case ProgressCardColor.Blue:
            return(blueCardsQueue.Count > 0);

        case ProgressCardColor.Green:
            return(greenCardsQueue.Count > 0);
        }
        return(false);
    }
    public void SubmitCard(ProgressCardColor color, ProgressCardType type)
    {
        this.gameObject.SetActive(true);
        confirm.onClick.RemoveAllListeners();
        cardType  = type;
        cardColor = color;

        //first display card on panel
        cardToDisplay.sprite = Resources.Load <Sprite> ("ProgressCards/" + cardType.ToString());

        titleText.text = "Do You Want To Play This Card?";
        //assign play card option to panel and cancel as disable panel
        confirm.onClick.AddListener(PlayCard);
        cancel.onClick.AddListener(Cancel);
        cancel.gameObject.SetActive(true);
    }
    //this displays a new card and creates the card
    public void newCard(ProgressCardColor color, ProgressCardType type)
    {
        this.gameObject.SetActive(true);
        confirm.onClick.RemoveAllListeners();
        cardType  = type;
        cardColor = color;
        //first display card on panel
        cardToDisplay.sprite = Resources.Load <Sprite> ("ProgressCards/" + cardType.ToString());
        titleText.text       = "New Progress Card";
        //spawn this new card in the ui
        StartCoroutine(cardHolder.SpawnCard(color, type));

        //on click for confirm is decativation of this panel
        confirm.onClick.AddListener(Cancel);
        //no cancel button
        cancel.gameObject.SetActive(false);
    }
    // Use this for returning cards to deck
    public void returnCard(ProgressCardColor color, ProgressCardType type)
    {
        switch (color)
        {
        case ProgressCardColor.Yellow:
            yellowCardsQueue.Add(type);
            break;

        case ProgressCardColor.Blue:
            blueCardsQueue.Add(type);
            break;

        case ProgressCardColor.Green:
            greenCardsQueue.Add(type);
            break;
        }
    }
    //use this for drawing cards from deck
    public ProgressCardType drawCard(ProgressCardColor color)
    {
        ProgressCardType temp;

        switch (color)
        {
        case ProgressCardColor.Yellow:
            if (yellowCardsQueue.Count > 0)
            {
                temp = yellowCardsQueue [0];
                yellowCardsQueue.RemoveAt(0);
            }
            else
            {
                temp = ProgressCardType.None;
            }
            return(temp);

        case ProgressCardColor.Blue:
            if (blueCardsQueue.Count > 0)
            {
                temp = blueCardsQueue [0];
                blueCardsQueue.RemoveAt(0);
            }
            else
            {
                temp = ProgressCardType.None;
            }
            return(temp);

        case ProgressCardColor.Green:
            if (greenCardsQueue.Count > 0)
            {
                temp = greenCardsQueue [0];
                greenCardsQueue.RemoveAt(0);
            }
            else
            {
                temp = ProgressCardType.None;
            }
            return(temp);
        }
        return(ProgressCardType.None);
    }
 public void returnCardToStack(ProgressCardColor color, ProgressCardType type)
 {
     //delete function for later
     EventTransferManager.instance.removeCardFromHand(PhotonNetwork.player.ID - 1, type);
     EventTransferManager.instance.ReturnProgressCard(color, type);
 }
Beispiel #7
0
    //adds new cards to the ui
    public IEnumerator SpawnCard(ProgressCardColor color, ProgressCardType type)
    {
        //spawn gameobject
        GameObject   card      = Instantiate(progressCardPrefab);
        ProgressCard newcard   = card.GetComponent <ProgressCard> ();
        Image        cardImage = card.GetComponent <Image> ();

        Debug.Log("card type: " + type.ToString());
        //set values
        newcard.type        = type;
        newcard.color       = color;
        newcard.cardSprite  = Resources.Load <Sprite> ("ProgressCards/" + type.ToString());
        newcard.DisplayCard = DisplayCardref;
        newcard.UIinstance  = UIinstance;
        cardImage.sprite    = newcard.cardSprite;
        card.name           = type.ToString();
        if (type == ProgressCardType.Printer || type == ProgressCardType.Constitution)
        {
            GameObject.FindGameObjectWithTag("ProgressCardsStackManager").GetComponent <ProgressCardStackManager> ().playCard(type);
        }
        else
        {
            EventTransferManager.instance.addCardToHand(PhotonNetwork.player.ID - 1, type);
        }
        card.transform.parent = this.transform;
        card.gameObject.SetActive(true);
        //add to list
        progressCardList.Add(newcard);

        CatanManager clientCatanManager = GameObject.FindGameObjectWithTag("CatanManager").GetComponent <CatanManager> ();

        if (clientCatanManager.players[PhotonNetwork.player.ID - 1].progressCards.Count > 4)
        {
            bool selectionMade = false;
            //get the selection
            clientCatanManager.uiManager.spyPanel.openPanel(clientCatanManager.players[PhotonNetwork.player.ID - 1].progressCards, "You have too many cards, select 1 to discard");
            while (!selectionMade)
            {
                if (!clientCatanManager.uiManager.spyPanel.selectionMade)
                {
                    yield return(StartCoroutine(CatanManager.instance.uiManager.spyPanel.waitUntilButtonDown()));
                }
                else
                {
                    selectionMade = true;
                }
                Debug.Log("test: " + selectionMade.ToString());
            }

            ProgressCardType selectedcard = clientCatanManager.uiManager.spyPanel.selection;
            clientCatanManager.uiManager.spyPanel.selectionMade = false;
            clientCatanManager.uiManager.spyPanel.gameObject.SetActive(false);

            int temp = (int)selectedcard;
            ProgressCardColor selectedcolor;
            if (temp <= 10)
            {
                selectedcolor = ProgressCardColor.Green;
            }
            else if (temp <= 16)
            {
                selectedcolor = ProgressCardColor.Yellow;
            }
            else
            {
                selectedcolor = ProgressCardColor.Blue;
            }
            selectionMade = false;
            clientCatanManager.uiManager.spyPanel.selectionMade = false;
            clientCatanManager.uiManager.spyPanel.gameObject.SetActive(false);



            GameObject.FindGameObjectWithTag("ProgressCardsStackManager").GetComponent <ProgressCardStackManager> ().returnCardToStack(selectedcolor, selectedcard);
        }
    }