private GameObject SelectPrefab(PlayerCardType type) { if (type is CombatCardType) { return(combatCardPrefab); } else if (type is ActionFoodCardType) { return(actionFoodCardPrefab); } else if (type is ActionLearningCardType) { return(actionLearningCardPrefab); } else if (type is ActionConditionCardType) { return(actionConditionCardPrefab); } else if (type is ActionCardType) { return(actionCardPrefab); } else { throw new Exception("There is no prefab for this card type!"); } }
public LearningPoolPlayerCard InstantiateLearningPoolCard(PlayerCardType type) { var prefab = SelectPrefab(type); var instance = Instantiate(prefab); var playerCard = instance.GetComponent <PlayerCard>(); playerCard.Type = type; playerCard.UpdateText(); playerCard.UpdateCardImage(); return(instance.AddComponent <LearningPoolPlayerCard>()); }
/// <summary> /// returns a random card type from the database, with the given PlayerCardType, that is neither modded nor a token /// </summary> /// <param name="type">card type (tower, spell, etc.) to return</param> /// <returns>the located type</returns> public PlayerCardData getRandomCardType(PlayerCardType type) { //get a subset of the type list IEnumerable <PlayerCardData> typeOptions = types.cardTypes.Where(pcd => (pcd.cardType == type) && (pcd.isModded == false) && (pcd.isToken == false)); //get random index int index = Random.Range(0, typeOptions.Count()); //return card at that index return(typeOptions.ElementAt(index)); }
public void UpdateText(PlayerCardType type) { if (type is ActionCardType) { GetComponent <Text>().text = (type as ActionCardType).ActionCost.ToString(); } else { throw new Exception("ActionPlayerCardText is not compatible with non-action card type!"); } }
/// <summary> /// attempts to draw a card of the given type. If this is possible, then that card is removed from the deck and returned as though it were drawn normally /// if such a card does not exist, does nothing and returns null /// </summary> /// <param name="cardType">the type of PlayerCard to draw</param> /// <returns>the PlayerCard drawn, if found, or null if not</returns> public PlayerCard?DrawCardType(PlayerCardType cardType) { //finds the first card of the correct type foreach (PlayerCard c in currentDeck) { if (c.data.cardType != cardType) { continue; } //card found. remove it from the list and return it currentDeck.Remove(c); return(c); } //card was not found. return(null); }
public void UpdateText(PlayerCardType type) { GetComponent <Text>().text = type.GetText(); }
public void UpdateText(PlayerCardType type) { GetComponent <Text>().text = type.LearningCost.ToString(); }