public void Add(int category, int cardType, bool isMyturn) { Player localPlayer = GameObject.Find("Local Player Panel").GetComponent <Player> (); ProgressCard newCard = new ProgressCard(); newCard = newCard.setPg((pgCardType)Enum.Parse(typeof(pgCardType), cardType.ToString()), category); if (cardType == (int)pgCardType.Constitution || cardType == (int)pgCardType.Printer) { playProgressCard(newCard); } else { cards.Add(newCard); if (cardType == 0) { localPlayer.CmdNotifyHasAlchemist(true); } if (localPlayer.progressCardSum < 4) { localPlayer.CmdProgressCardSumChange(1); if (!isMyturn) { localPlayer.CmdResponseToServer(); } } else { localPlayer.CmdProgressCardSumChange(1); RequestDiscard(isMyturn); } } }
public void Update() { if (myPlayers._players.Count == numberOfPlayer && currentPhase == GamePhase.LoadingPlayers) { //make sure all players are really set up bool ready = true; foreach (Player p in myPlayers._players) { if (p.isReady == false) { ready = false; } } if (ready) { currentPlayer = myPlayers._players [0]; hostPlayer = myPlayers._players [0]; currentPhase = GamePhase.SetupRoundOne; OnBarbarianPositionChanged(0); OnBarbarianStrengthChanged(0); OnKnightStrengthChanged(0); ProgressCard helper = new ProgressCard(); tradeCardsQueue = helper.generateDeck(0); politicsCardsQueue = helper.generateDeck(1); scienceCardsQueue = helper.generateDeck(2); } } if (!started && !isWaiting && currentPhase == GamePhase.SetupRoundOne) { StartCoroutine(TurnRotationCoroutine()); started = true; } }
public ProgressCard setPg(pgCardType type, int cate) { ProgressCard newCard = new ProgressCard(); newCard.myType = type; newCard.category = (Improvement)Enum.Parse(typeof(Improvement), cate.ToString()); return(newCard); }
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); } }
public void shuffle(List <ProgressCard> alpha) { for (int i = 0; i < alpha.Count; i++) { ProgressCard temp = alpha[i]; int randomIndex = UnityEngine.Random.Range(i, alpha.Count); alpha[i] = alpha[randomIndex]; alpha[randomIndex] = temp; } }
public void LookAndChooseCards(int fromPlayerIndex, int[] categories, int[] cardTypes) { Debug.Log(categories.Length + " " + cardTypes.Length); Player localPlayer = GameObject.Find("Local Player Panel").GetComponent <Player> (); List <Player> l = GameObject.Find("panelPlayers").GetComponent <PlayerList> ()._players; gameObject.SetActive(true); transform.GetChild(2).gameObject.GetComponent <Button> ().interactable = false; for (int i = slots.childCount - 1; i >= 0; i--) { Destroy(slots.GetChild(i).gameObject); } List <ProgressCard> tempList = new List <ProgressCard> (); for (int i = 0; i < cardTypes.Length; i++) { ProgressCard newCard = new ProgressCard(); newCard = newCard.setPg((pgCardType)cardTypes[i], categories[i]); tempList.Add(newCard); } foreach (ProgressCard p in tempList) { GameObject newCardObj = Instantiate(ProgressCardObj); newCardObj.transform.GetChild(0).gameObject.GetComponent <Image>().sprite = titleBarSprites[(int)p.category]; newCardObj.transform.GetChild(1).gameObject.GetComponent <Text> ().text = p.myType.ToString(); newCardObj.transform.SetParent(slots); newCardObj.GetComponent <Button> ().onClick.AddListener( delegate { DisplayCard(p.category, p.myType.ToString(), pgCardDescription[(int)p.myType], delegate { Add((int)p.category, (int)p.myType, true); localPlayer.CmdTakeProgressCard(fromPlayerIndex, (int)p.myType); localPlayer.CmdAnnounce(localPlayer.playerName + " has taken " + l[fromPlayerIndex].playerName + "'s " + p.myType.ToString() + " card!"); transform.GetChild(2).gameObject.GetComponent <Button> ().interactable = true; }); }); } }
public IEnumerator TurnRotationCoroutine() { while (currentPhase == GamePhase.SetupRoundOne) { hostPlayer.TargetRequestBuildSettlementAndRoad(currentPlayer.connectionToClient); isWaiting = true; yield return(new WaitWhile(() => isWaiting)); } while (currentPhase == GamePhase.SetupRoundTwo) { hostPlayer.TargetRequestBuildCityAndRoad(currentPlayer.connectionToClient); isWaiting = true; yield return(new WaitWhile(() => isWaiting)); } while (currentPhase != GamePhase.Completed) { yellowDie = UnityEngine.Random.Range(1, 7); redDie = UnityEngine.Random.Range(1, 7); eventDie = UnityEngine.Random.Range(1, 7); if (currentPlayer.hasAlchemist) { currentPlayer.TargetAskPlayAlchemistCard(currentPlayer.connectionToClient); isWaiting = true; yield return(new WaitWhile(() => isWaiting)); } // Display the dice hostPlayer.RpcRollDice(yellowDie, redDie, eventDie); // If so, ask the player for the number of yellowDie and redDie, roll eventDie normally ///////////////////////////// // check barbarian if (eventDie == 1 || eventDie == 2 || eventDie == 3) { OnBarbarianPositionChanged(-1); // barbarian attack if (barbarianPosition == 0) { // catan wins! if (barbarianStrength <= knightStrength) { hostPlayer.RpcAnnounce("Barbarians arrive but they are defeated! "); int highestContribution = -1; int numofDefender = 0; // get the highest contribution and how many people deserve the reward foreach (Player p in myPlayers._players) { int contribution = 0; foreach (Knight k in p.knights) { if (k.isActive) { contribution += k.level; } } if (contribution > highestContribution) { highestContribution = contribution; numofDefender = 1; } else if (contribution == highestContribution) { numofDefender++; } } // count each contribution of the players and give the reward int currentPlayerIndex = myPlayers._players.IndexOf(currentPlayer); Player playerRotated; for (int i = currentPlayerIndex; i < myPlayers._players.Count + currentPlayerIndex; i++) { if (i < myPlayers._players.Count) { playerRotated = myPlayers._players [i]; } else { playerRotated = myPlayers._players [i - myPlayers._players.Count]; } int contribution = 0; foreach (Knight k in playerRotated.knights) { if (k.isActive) { contribution += k.level; GameObject itsVertex = k.gameObject.transform.parent.gameObject; int vertexIndex = GameObject.Find("GameBoard").GetComponent <GameBoard> ().junctions.IndexOf(itsVertex); playerRotated.CmdSetKnightActive(vertexIndex, false); } } // get the reward if (contribution == highestContribution) { // Defender of catan if (numofDefender == 1) { if (defenderRemaining >= 0) { hostPlayer.RpcAnnounce(playerRotated.playerName + " is declared to be the “Defender of Catan” and receive 1 VP!"); playerRotated.CmdDefendCountChange(1); defenderRemaining--; } else { hostPlayer.RpcAnnounce("No more Defender of Catan available"); } } else { hostPlayer.RpcAnnounce(playerRotated.playerName + " can draw a progress card."); playerRotated.TargetRequestDrawProgressCard(playerRotated.connectionToClient, (tradeCardsQueue.Count > 0), (politicsCardsQueue.Count > 0), (scienceCardsQueue.Count > 0)); selectionIndicator = 3; yield return(new WaitUntil(() => (selectionIndicator >= 0 && selectionIndicator <= 2))); ProgressCard drawn = new ProgressCard(); if (selectionIndicator == 0) { drawn = tradeCardsQueue.Dequeue(); } else if (selectionIndicator == 1) { drawn = politicsCardsQueue.Dequeue(); } else if (selectionIndicator == 2) { drawn = scienceCardsQueue.Dequeue(); } playerRotated.TargetGetProgressCard(playerRotated.connectionToClient, (int)drawn.category, (int)drawn.myType); isWaiting = true; yield return(new WaitWhile(() => isWaiting)); } } } /* * foreach (Player p in myPlayers._players) { * int contribution = 0; * foreach (Knight k in p.knights) { * if (k.isActive) { * contribution += k.level; * GameObject itsVertex = k.gameObject.transform.parent.gameObject; * int vertexIndex = GameObject.Find ("GameBoard").GetComponent<GameBoard> ().junctions.IndexOf (itsVertex); * p.CmdSetKnightActive (vertexIndex, false); * } * } * // get the reward * if (contribution == highestContribution) { * // Defender of catan * if (numofDefender == 1) { * if (defenderRemaining >= 0) { * hostPlayer.RpcAnnounce ("Barbarians arrive but they are defeated! "); * hostPlayer.RpcAnnounce (p.playerName + " is declared to be the “Defender of Catan” and receive 1 VP!"); * p.CmdDefendCountChange (1); * defenderRemaining--; * } * } else { * // TODO PgCard * // TODO grabProgressCard(type) UI is needed * // if # of pgcard > 4, give up one card and pu ot back to deck * } * } * } */ } else // catan lose { hostPlayer.RpcAnnounce("Barbarians arrive and they defeat the force of Catan!"); int lowestContribution = 0; foreach (Player p in myPlayers._players) { int contribution = 0; foreach (Knight k in p.knights) { if (k.isActive) { contribution += k.level; } } int numOfCities = 0; foreach (Village v in p.villages) { if (v.vt == VillageType.City) { numOfCities++; } } if (numOfCities > 0 && (contribution < lowestContribution)) { lowestContribution = contribution; } } foreach (Player p in myPlayers._players) { int contribution = 0; foreach (Knight k in p.knights) { if (k.isActive) { contribution += k.level; GameObject itsVertex = k.gameObject.transform.parent.gameObject; int vertexIndex = GameObject.Find("GameBoard").GetComponent <GameBoard> ().junctions.IndexOf(itsVertex); p.CmdSetKnightActive(vertexIndex, false); } } if (contribution == lowestContribution) { int numOfCities = 0; foreach (Village v in p.villages) { if (v.vt == VillageType.City) { numOfCities++; } } if (numOfCities > 0) { hostPlayer.RpcAnnounce(p.playerName + " is raided!"); p.TargetRequestDowngradeCity(p.connectionToClient); isWaiting = true; yield return(new WaitWhile(() => isWaiting)); } else { hostPlayer.RpcAnnounce(p.playerName + " is raided, but doesn't have any city to be downgraded."); } } } } OnBarbarianPositionChanged(7); barbarianAttacked = true; } } else if (eventDie == 4) { int currentPlayerIndex = myPlayers._players.IndexOf(currentPlayer); Player p; for (int i = currentPlayerIndex; i < myPlayers._players.Count + currentPlayerIndex; i++) { if (i < myPlayers._players.Count) { p = myPlayers._players [i]; } else { p = myPlayers._players [i - myPlayers._players.Count]; } if (p.fcTradeLvl >= redDie && p.fcTradeLvl > 1) { if (tradeCardsQueue.Count > 0) { ProgressCard drawn = tradeCardsQueue.Dequeue(); p.TargetGetProgressCard(p.connectionToClient, (int)drawn.category, (int)drawn.myType); hostPlayer.CmdAnnounce(p.playerName + " gets a Trade progress card"); isWaiting = true; yield return(new WaitWhile(() => isWaiting)); } else { hostPlayer.CmdAnnounce(p.playerName + " could have got a Trade progress card, but the deck is empty."); } } } } else if (eventDie == 5) { int currentPlayerIndex = myPlayers._players.IndexOf(currentPlayer); Player p; for (int i = currentPlayerIndex; i < myPlayers._players.Count + currentPlayerIndex; i++) { if (i < myPlayers._players.Count) { p = myPlayers._players [i]; } else { p = myPlayers._players [i - myPlayers._players.Count]; } if (p.fcPoliticsLvl >= redDie && p.fcPoliticsLvl > 1) { if (politicsCardsQueue.Count > 0) { ProgressCard drawn = politicsCardsQueue.Dequeue(); p.TargetGetProgressCard(p.connectionToClient, (int)drawn.category, (int)drawn.myType); hostPlayer.CmdAnnounce(p.playerName + " gets a Politics progress card"); isWaiting = true; yield return(new WaitWhile(() => isWaiting)); } else { hostPlayer.CmdAnnounce(p.playerName + " could have got a Politics progress card, but the deck is empty."); } } } } else if (eventDie == 6) { int currentPlayerIndex = myPlayers._players.IndexOf(currentPlayer); Player p; for (int i = currentPlayerIndex; i < myPlayers._players.Count + currentPlayerIndex; i++) { if (i < myPlayers._players.Count) { p = myPlayers._players [i]; } else { p = myPlayers._players [i - myPlayers._players.Count]; } if (p.fcScienceLvl >= redDie && p.fcScienceLvl > 1) { if (scienceCardsQueue.Count > 0) { ProgressCard drawn = scienceCardsQueue.Dequeue(); p.TargetGetProgressCard(p.connectionToClient, (int)drawn.category, (int)drawn.myType); hostPlayer.CmdAnnounce(p.playerName + " gets a Science progress card"); isWaiting = true; yield return(new WaitWhile(() => isWaiting)); } else { hostPlayer.CmdAnnounce(p.playerName + " could have got a Science progress card, but the deck is empty."); } } } } // Time for yellow die and red die!! int sum = yellowDie + redDie; if (sum == 7) { if (barbarianAttacked) { foreach (Player p in myPlayers._players) { if (p.resourceSum > (p.numOfCityWall * 2 + 7)) { hostPlayer.RpcAnnounce((p.playerName + " is robbed.")); int numToDiscard = Mathf.FloorToInt((float)p.resourceSum / 2f); p.TargetRequestDiscardResources(p.connectionToClient, numToDiscard); isWaiting = true; yield return(new WaitWhile(() => isWaiting)); } } currentPlayer.TargetRequestMoveRobber(currentPlayer.connectionToClient); isWaiting = true; yield return(new WaitWhile(() => isWaiting)); } } else { GameObject robberAt = GameObject.Find("GameBoard").GetComponent <GameBoard> ().robber.transform.parent.gameObject; foreach (Player p in myPlayers._players) { bool gotResource = false; foreach (Village v in p.villages) { foreach (Hex h in v.gameObject.transform.parent.GetComponent <Vertex>().adjacentHexes) { if (h != null && h.hexNumber == sum && h.gameObject != robberAt) { ResourceType resourceType = h.Product(); int type = (int)resourceType; if (v.vt == VillageType.Settlement) { if (type >= 0 && type <= 5) { p.TargetResourceChange(p.connectionToClient, type, 1); gotResource = true; } else if (type == 8) { p.TargetRequestChooseResource(p.connectionToClient); isWaiting = true; yield return(new WaitWhile(() => isWaiting)); gotResource = true; } } else { if (type == 1 || type == 3) { p.TargetResourceChange(p.connectionToClient, type, 2); gotResource = true; } else if (type == 4) // ore { p.TargetResourceChange(p.connectionToClient, type, 1); p.TargetResourceChange(p.connectionToClient, 7, 1); gotResource = true; } else if (type == 2) // wool { p.TargetResourceChange(p.connectionToClient, type, 1); p.TargetResourceChange(p.connectionToClient, 6, 1); gotResource = true; } else if (type == 0) // lumber { p.TargetResourceChange(p.connectionToClient, type, 1); p.TargetResourceChange(p.connectionToClient, 5, 1); gotResource = true; } else if (type == 8) { p.TargetRequestChooseResource(p.connectionToClient); isWaiting = true; yield return(new WaitWhile(() => isWaiting)); p.TargetRequestChooseResource(p.connectionToClient); isWaiting = true; yield return(new WaitWhile(() => isWaiting)); gotResource = true; } } } } } if (!gotResource && p.fcScienceLvl >= 4) { p.TargetRequestChooseResource(p.connectionToClient); isWaiting = true; yield return(new WaitWhile(() => isWaiting)); } } } currentPhase = GamePhase.TurnDiceRolled; hostPlayer.TargetGiveTurn(currentPlayer.connectionToClient); isWaiting = true; yield return(new WaitWhile(() => isWaiting)); } }
// all the function is in this method public void playProgressCard(ProgressCard card) { pgCardType name = card.myType; Player localPlayer = GameObject.Find("Local Player Panel").GetComponent <Player> (); List <Player> l = GameObject.Find("panelPlayers").GetComponent <PlayerList> ()._players; GameBoard board = GameObject.Find("GameBoard").GetComponent <GameBoard> (); if (name == pgCardType.Crane) { localPlayer.isCrane = true; } else if (name == pgCardType.Engineer) { localPlayer.isEnginner = true; } else if (name == pgCardType.Irrigation) { foreach (GameObject h in board.tiles) { if (h.GetComponent <Hex> ().Product() == ResourceType.Grain) { foreach (Vertex v in h.GetComponent <Hex>().adjacentVertices) { if (v != null && v.transform.childCount > 1 && v.transform.GetChild(1).GetComponent <Village> () != null && v.transform.GetChild(1).GetComponent <Village> ().owner == localPlayer) { localPlayer.OnResourcesChanged(ResourceType.Grain, 2); break; } } } } } else if (name == pgCardType.Medicine) { localPlayer.isMedicine = true; } else if (name == pgCardType.Mining) { foreach (GameObject h in board.tiles) { if (h.GetComponent <Hex> ().Product() == ResourceType.Ore) { foreach (Vertex v in h.GetComponent <Hex>().adjacentVertices) { if (v != null && v.transform.childCount > 1 && v.transform.GetChild(1).GetComponent <Village> () != null && v.transform.GetChild(1).GetComponent <Village> ().owner == localPlayer) { localPlayer.OnResourcesChanged(ResourceType.Ore, 2); break; } } } } } else if (name == pgCardType.Printer) { localPlayer.CmdVpChange(1); } else if (name == pgCardType.Road_Building) { localPlayer.roadBuilding = 2; board.RequestPlayRoadBuildingCard(); } else if (name == pgCardType.Smith) { localPlayer.isSmith += 2; } else if (name == pgCardType.Bishop) { board.RequestBishop(); } else if (name == pgCardType.Constitution) { localPlayer.CmdVpChange(1); } else if (name == pgCardType.Deserter) { // too complicated so as Diplomat & Intrigue } else if (name == pgCardType.Saboteur) { for (int i = 0; i < l.Count; i++) { if (l [i] != localPlayer & l [i].vP >= localPlayer.vP) { localPlayer.CmdRequestDiscardResources(i, Mathf.FloorToInt(l [i].resourceSum / 2)); } } } else if (name == pgCardType.Warlord) { localPlayer.isWarLord = localPlayer.knights.Count; foreach (Knight k in localPlayer.knights) { if (!k.isActive) { localPlayer.CmdSetKnightActive(k.vertexIndex, true); // TODO resources } } } else if (name == pgCardType.Wedding) { localPlayer.CmdPlayedWeddingCard(); } else if (name == pgCardType.Master_Merchant) { foreach (Player p in l) { if (p != localPlayer) { if (p.vP > localPlayer.vP) { //to do: ui to make them choose player and which resources to take int num = 0; // THIS SHOULD BE REPLACED ResourceType chosen = 0; p.OnResourcesChanged(chosen, -num); localPlayer.OnResourcesChanged(chosen, num); localPlayer.masterMerchant = true; } } } } else if (name == pgCardType.Resource_Monopoly) { board.panelSelection.GetComponent <SelectionPanel> ().RequestResourceMonopoly(); } else if (name == pgCardType.Trade_Monopoly) { board.panelSelection.GetComponent <SelectionPanel> ().RequestTradeMonopoly(); } else if (name == pgCardType.Merchant_Fleet) { //to do: set the trade ratio to 2 for one turn localPlayer.merchantFleet = true; } else if (name == pgCardType.Commercial_Harbor) { //to do: force other players to trade 1:1 localPlayer.commercialHarbor = true; } else if (name == pgCardType.Spy) { bool hasCardsToTake = false; foreach (Player p in l) { if (p.progressCardSum > 0 && !p.isLocalPlayer) { hasCardsToTake = true; } } if (hasCardsToTake) { board.PlaySpyCard(); } else { board.panelInfo.GetComponent <InfoPanel> ().pushMessage("Other players don't have any progress cards to let you take.", null, null); return; } } else if (name == pgCardType.Merchant) { board.RequestMoveMerchant(); } else if (name == pgCardType.Inventor) { board.RequestInventorChoice(); } else if (name == pgCardType.Alchemist) { board.panelSelection.GetComponent <SelectionPanel> ().RequestDiceSelection(); localPlayer.CmdNotifyHasAlchemist(false); } localPlayer.CmdAnnounce(localPlayer.playerName + " has played a " + card.myType.ToString() + " card!"); cards.Remove(card); localPlayer.CmdDiscardProgressCard((int)card.category, (int)card.myType); }
//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); } }