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 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; }); }); } }