void SetCardSprite(CardStruct card) { string spName = ""; ENUM_CARD_TYPE cardType = (ENUM_CARD_TYPE)card.CardType; ENUM_CARD_COLOR cardColor = (ENUM_CARD_COLOR)card.CardColor; switch (cardType) { case ENUM_CARD_TYPE.NONE: break; case ENUM_CARD_TYPE.NUMBER: case ENUM_CARD_TYPE.STOP: case ENUM_CARD_TYPE.FLIP: case ENUM_CARD_TYPE.DRAW2: spName = Utils.GetCardTypeNameWithType(cardType) + "_" + Utils.GetColorNameWithType(cardColor); break; case ENUM_CARD_TYPE.WILD: case ENUM_CARD_TYPE.WILD_DRAW4: spName = Utils.GetCardTypeNameWithType(cardType); break; default: break; } _bg.spriteName = spName; }
public override bool CanPlayCard(Card lastCard) { ENUM_CARD_TYPE CardColor = (ENUM_CARD_TYPE)MyCardStruct.CardType; ENUM_CARD_TYPE LastCardColor = (ENUM_CARD_TYPE)lastCard.MyCardStruct.CardType; /* * switch ((ENUM_CARD_TYPE)lastCard.MyCardStruct.CardType) * { * case ENUM_CARD_TYPE.NONE: * break; * case ENUM_CARD_TYPE.NUMBER: * if (CardColor == LastCardColor) return true; * break; * case ENUM_CARD_TYPE.PASS: * if (!lastCard.HasEffect) return true; * break; * case ENUM_CARD_TYPE.FLIP: * if (!lastCard.HasEffect) return true; * break; * case ENUM_CARD_TYPE.DRAWTWO: * if (!lastCard.HasEffect && LastCardColor == CardColor) return true; * break; * case ENUM_CARD_TYPE.WILD: * if (!lastCard.HasEffect && LastCardColor == CardColor) return true; * break; * default: * break; * } */ return(base.CanPlayCard(lastCard)); }
public static T Create <T>(ENUM_CARD_TYPE type) where T : Card { Card t = null; switch (type) { case ENUM_CARD_TYPE.NONE: break; case ENUM_CARD_TYPE.NUMBER: t = new Card_Number(); break; case ENUM_CARD_TYPE.STOP: t = new Card_Stop(); break; case ENUM_CARD_TYPE.FLIP: t = new Card_Flip(); break; case ENUM_CARD_TYPE.DRAW2: t = new Card_DrawTwo(); break; case ENUM_CARD_TYPE.WILD: t = new Card_Wild(); break; case ENUM_CARD_TYPE.WILD_DRAW4: t = new Card_Wild4(); break; default: break; } return(t as T); }
public static string GetCardTypeNameWithType(ENUM_CARD_TYPE type) { string colorstring = ""; switch (type) { case ENUM_CARD_TYPE.NONE: break; case ENUM_CARD_TYPE.NUMBER: colorstring = "numb"; break; case ENUM_CARD_TYPE.STOP: colorstring = "stop"; break; case ENUM_CARD_TYPE.FLIP: colorstring = "flip"; break; case ENUM_CARD_TYPE.DRAW2: colorstring = "draw2"; break; case ENUM_CARD_TYPE.WILD: colorstring = "wild"; break; case ENUM_CARD_TYPE.WILD_DRAW4: colorstring = "wild_draw4"; break; default: break; } return(colorstring); }