Beispiel #1
0
    public void spawnLoad()
    {
        CatanManager clientCatanManager = GameObject.FindGameObjectWithTag("CatanManager").GetComponent <CatanManager> ();
        Player       currentplayer      = clientCatanManager.players[PhotonNetwork.player.ID];

        //spawn the 2 odd ones if needed
        if (currentplayer.playedConstitution)
        {
            GameObject   card      = Instantiate(progressCardPrefab);
            ProgressCard newcard   = card.GetComponent <ProgressCard> ();
            Image        cardImage = card.GetComponent <Image> ();
            //set values
            newcard.type          = ProgressCardType.Constitution;
            newcard.color         = ProgressCardColor.Blue;
            newcard.cardSprite    = Resources.Load <Sprite> ("ProgressCards/" + ProgressCardType.Constitution.ToString());
            newcard.DisplayCard   = DisplayCardref;
            newcard.UIinstance    = UIinstance;
            cardImage.sprite      = newcard.cardSprite;
            card.name             = ProgressCardType.Constitution.ToString();
            card.transform.parent = this.transform;
            card.gameObject.SetActive(true);
        }
        if (currentplayer.playedPrinter)
        {
            GameObject   card      = Instantiate(progressCardPrefab);
            ProgressCard newcard   = card.GetComponent <ProgressCard> ();
            Image        cardImage = card.GetComponent <Image> ();
            //set values
            newcard.type          = ProgressCardType.Printer;
            newcard.color         = ProgressCardColor.Green;
            newcard.cardSprite    = Resources.Load <Sprite> ("ProgressCards/" + ProgressCardType.Printer.ToString());
            newcard.DisplayCard   = DisplayCardref;
            newcard.UIinstance    = UIinstance;
            cardImage.sprite      = newcard.cardSprite;
            card.name             = ProgressCardType.Printer.ToString();
            card.transform.parent = this.transform;
            card.gameObject.SetActive(true);
        }
        for (int i = 0; i < currentplayer.progressCards.Count; i++)
        {
            ProgressCardType curr      = currentplayer.progressCards[i];
            GameObject       card      = Instantiate(progressCardPrefab);
            ProgressCard     newcard   = card.GetComponent <ProgressCard> ();
            Image            cardImage = card.GetComponent <Image> ();
            //set values
            newcard.type          = curr;
            newcard.color         = ProgressCardColor.Green;
            newcard.cardSprite    = Resources.Load <Sprite> ("ProgressCards/" + curr.ToString());
            newcard.DisplayCard   = DisplayCardref;
            newcard.UIinstance    = UIinstance;
            cardImage.sprite      = newcard.cardSprite;
            card.name             = curr.ToString();
            card.transform.parent = this.transform;
            card.gameObject.SetActive(true);
        }
    }
 //mixes order of cards
 private ProgressCardType[] shuffle(ProgressCardType[] arr)
 {
     for (int i = arr.Length - 1; i > 0; i--)
     {
         int r = Random.Range(0, i);
         ProgressCardType tmp = arr [i];
         arr [i] = arr [r];
         arr [r] = tmp;
     }
     return(arr);
 }
    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;
        }
    }
Beispiel #6
0
 public void openPanel(List <ProgressCardType> cards, string title)
 {
     this.gameObject.SetActive(true);
     //set the selection to nothing
     paneltitle.text = title;
     selection       = ProgressCardType.None;
     //hide the glow
     glow.gameObject.SetActive(false);
     //for test = 4
     for (int i = 0; i < 5; i++)
     {
         if (i < cards.Count)
         {
             buttons [i].gameObject.SetActive(true);
             buttons [i].card          = cards [i];
             buttons[i].display.sprite = Resources.Load <Sprite> ("ProgressCards/" + cards[i].ToString());
             buttons [i].instance      = this;
         }
         else
         {
             buttons [i].gameObject.SetActive(false);
         }
     }
 }
 public void returnCardToStack(ProgressCardColor color, ProgressCardType type)
 {
     //delete function for later
     EventTransferManager.instance.removeCardFromHand(PhotonNetwork.player.ID - 1, type);
     EventTransferManager.instance.ReturnProgressCard(color, type);
 }
    private IEnumerator playSpy()
    {
        CatanManager clientCatanManager = GameObject.FindGameObjectWithTag("CatanManager").GetComponent <CatanManager> ();
        //first get possible players
        List <Player> possibleplayer = new List <Player>();

        for (int i = 0; i < PhotonNetwork.playerList.Length; i++)
        {
            if (PhotonNetwork.player.ID - 1 != i && clientCatanManager.players [i].progressCards.Count > 0)
            {
                possibleplayer.Add(clientCatanManager.players [i]);
            }
        }
        //make user select 1 of the players
        clientCatanManager.uiManager.robberStealPanel.displayPanelForChoices(possibleplayer);
        bool selectionMade = false;

        //get the selection
        while (!selectionMade)
        {
            if (!CatanManager.instance.uiManager.robberStealPanel.selectionMade)
            {
                yield return(StartCoroutine(CatanManager.instance.uiManager.robberStealPanel.waitUntilButtonDown()));
            }
            if (CatanManager.instance.uiManager.robberStealPanel.selectionMade)
            {
                selectionMade = true;
            }
        }
        //get player selection
        int selection = clientCatanManager.uiManager.robberStealPanel.selection;

        //take off robber steal panel
        clientCatanManager.uiManager.robberStealPanel.selectionMade = false;
        clientCatanManager.uiManager.robberStealPanel.gameObject.SetActive(false);

        selectionMade = false;
        //get the selection
        clientCatanManager.uiManager.spyPanel.openPanel(clientCatanManager.players[selection].progressCards, "Select Card To Steal: ");
        while (!selectionMade)
        {
            if (!CatanManager.instance.uiManager.spyPanel.selectionMade)
            {
                yield return(StartCoroutine(CatanManager.instance.uiManager.spyPanel.waitUntilButtonDown()));
            }
            if (CatanManager.instance.uiManager.spyPanel.selectionMade)
            {
                selectionMade = true;
            }
        }
        ProgressCardType selectedcard = clientCatanManager.uiManager.spyPanel.selection;
        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);

        StartCoroutine(clientCatanManager.uiManager.progressCardHolder.SpawnCard(selectedcolor, selectedcard));
        EventTransferManager.instance.sendNotification(clientCatanManager.players [PhotonNetwork.player.ID - 1].playerName + " has played the Spy card and stolen your " + selectedcard.ToString() + " card", selection);
        EventTransferManager.instance.removeCardFromHand(selection, selectedcard);
        returnCardToStack(ProgressCardColor.Blue, ProgressCardType.Spy);
    }
    public void playCard(ProgressCardType type)
    {
        switch (type)
        {
        case ProgressCardType.Merchant:
            StartCoroutine(playMerchant());
            break;

        case ProgressCardType.CommercialHarbor:
            StartCoroutine(playCommercialHarbor());
            break;

        case ProgressCardType.MerchantFleet:
            StartCoroutine(playMerchantFleet());
            break;

        case ProgressCardType.MasterMerchant:
            StartCoroutine(playMasterMerchant());
            break;

        case ProgressCardType.TradeMonopoly:
            StartCoroutine(playTradeMonopoly());
            break;

        case ProgressCardType.ResourceMonopoly:
            StartCoroutine(playResourceMonopoly());
            break;

        case ProgressCardType.Bishop:
            StartCoroutine(playBishop());
            break;

        case ProgressCardType.Diplomat:
            StartCoroutine(playDiplomat());
            break;

        case ProgressCardType.Warlord:
            playWarlord();
            break;

        case ProgressCardType.Wedding:
            playWedding();
            break;

        case ProgressCardType.Intrigue:
            StartCoroutine(playIntrigue());
            break;

        case ProgressCardType.Saboteur:
            playSaboteur();
            break;

        case ProgressCardType.Spy:
            StartCoroutine(playSpy());
            break;

        case ProgressCardType.Deserter:
            StartCoroutine(playDeserter());
            break;

        case ProgressCardType.Constitution:
            playConstitution();
            break;

        case ProgressCardType.Alchemist:
            StartCoroutine(playAlchemist());
            break;

        case ProgressCardType.Crane:
            playCrane();
            break;

        case ProgressCardType.Mining:
            playMining();
            break;

        case ProgressCardType.Irrigation:
            playIrrigation();
            break;

        case ProgressCardType.Printer:
            playPrinter();
            break;

        case ProgressCardType.Inventor:
            StartCoroutine(playInventor());
            break;

        case ProgressCardType.Engineer:
            playEngineer();
            break;

        case ProgressCardType.Medicine:
            StartCoroutine(playMedicine());
            break;

        case ProgressCardType.Smith:
            StartCoroutine(playSmith());
            break;

        case ProgressCardType.RoadBuilding:
            StartCoroutine(playRoadBuilding());
            break;
        }
    }
Beispiel #10
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);
        }
    }