public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info) { if (front == null) { front = Array.Find(CardManager.instance.cardImages, x => x.name == "card_" + value + "_" + cardType.ToString()); } if (showFront && sr.sprite != front) { sr.sprite = front; } else if (!showFront && sr.sprite != back) { sr.sprite = back; } if (stream.IsWriting) { stream.SendNext(cardType); stream.SendNext(cardColor); stream.SendNext(value); stream.SendNext(showFront); stream.SendNext(isDouble); } else if (stream.IsReading) { cardType = (Enums.CardType)stream.ReceiveNext(); cardColor = (Enums.CardColor)stream.ReceiveNext(); value = (int)stream.ReceiveNext(); showFront = (bool)stream.ReceiveNext(); isDouble = (bool)stream.ReceiveNext(); } }
/// <summary> /// Determines whether this instance is same color card the specified anotherCard. /// </summary> /// <returns><c>true</c> if this instance is same color card the specified anotherCard; otherwise, <c>false</c>.</returns> /// <param name="anotherCard">Another card.</param> public bool IsSameColorCard(Enums.CardType anotherCard) { var cardType = GetTypeCards(); return((anotherCard == Enums.CardType.Diamond || anotherCard == Enums.CardType.Heart) && (cardType == Enums.CardType.Heart || cardType == Enums.CardType.Diamond) || (anotherCard == Enums.CardType.Club || anotherCard == Enums.CardType.Spade) && (cardType == Enums.CardType.Club || cardType == Enums.CardType.Spade)); }
public IEnumerable <IPlayableCard> GetStartingGamesCards(Enums.CardType cardType) { //TODO: change to factory query method switch (cardType) { case Enums.CardType.Person: var personResponse = _mediator.Send(request: new GetStartPersonsCardRequestModel()); return(personResponse.Result.Cards); case Enums.CardType.Spaceship: var spaceshipResponse = _mediator.Send(request: new GetStartSpaceshipCardRequestModel()); return(spaceshipResponse.Result.Cards); default: throw new NotImplementedException($"{cardType} is not implemented for starting game."); } }
/// <summary> /// Create a new simple card. /// </summary> /// <param name="cardId">The card id.</param> /// <param name="name">The card name.</param> /// <param name="text">The card text.</param> /// <param name="manaCost">The mana cost of the card.</param> /// <param name="cardSet">The set the card belongs to.</param> /// <param name="cardType">The type of the card.</param> /// <param name="heroClass">The hero class the card belongs to.</param> /// <param name="rarity">The card rarity.</param> protected SimpleCard( string cardId, string name, string text, int manaCost, Enums.CardSet cardSet, Enums.CardType cardType, Enums.HeroClass heroClass, Enums.CardRarity rarity) { CardId = cardId; Name = name; Text = text; ManaCost = manaCost; CardSet = cardSet; CardType = cardType; HeroClass = heroClass; Rarity = rarity; }
/// <summary> /// Gets the color of the cards. /// </summary> /// <returns>The cards color.</returns> /// <param name="type">Type.</param> /// <param name="numberLoad">Number load.</param> public List <CardBehaviour> GetCardsColor(Enums.CardType type) { // TODO: Create default list to return. List <CardBehaviour> paramReturn = new List <CardBehaviour> (); // TODO: Count the items. int count = ItemProperties.Count; if (type == Enums.CardType.None) { paramReturn.AddRange(ItemProperties); } else { // TODO: Create the cache of card. CardBehaviour paramCache; // TODO: Loop and check with the conditions. for (int i = 0; i < count; i++) { // TODO: Set the cache with the value of items. paramCache = ItemProperties [i]; if (paramCache == null) { print("Yes"); continue; } // TODO: Check the condition to get this card. if (paramCache.GetTypeCards() == type && !paramReturn.Exists(x => x.GetValue() == paramCache.GetValue())) { // TODO: Add the card to params Return. paramReturn.Add(paramCache); // TODO: Break the loop if paramReturn enough 13 cards. if (paramReturn.Count > 12) { break; } } } } //TODO: Check the number of paramReturn equal 13. //Debug.Log("paramReturn " +paramReturn.Count); if (paramReturn.Count > 12) { // TODO: Loop and remove all cards. for (int i = 0; i < paramReturn.Count; i++) { // TODO: remove this item out of List Cards. ItemProperties.Remove(paramReturn [i]); } } else { // TODO: clear the param return if don't enough cards. paramReturn.Clear(); } // TODO: Return the list of cards. return(paramReturn); }
/// <summary> /// Init this instance. /// </summary> protected void Init() { Debug.Log("Klondike init: " + GameManager.Instance.GetModeGame()); // TODO: Create the default list will get the cards. List <CardBehaviour> paramGet = new List <CardBehaviour>(); // TODO: Check the current of mode. switch (GameManager.Instance.GetModeGame()) { case Enums.ModeGame.Easy: // TODO: Random color of cards for 1 suit. Enums.CardType type = (Enums.CardType)Random.Range((int)Enums.CardType.Club, (int)Enums.CardType.Spade + 1); // TODO: Loop 8 times and get the cards. for (int i = 0; i < 4; i++) { // TODO: Clear the old of cards in the list. paramGet.Clear(); // TODO: Get the cards from the pool. paramGet.AddRange(PoolSystem.Instance.GetCardsColor(type)); // TODO: Check the number of cards from list. if (paramGet.Count > 0) { // TODO: Add the list of cards from the pool. cardsGet.AddRange(paramGet); } else { // TODO: Show the error if we don't have enough the cards to start the game. throw new UnityException("We don't have enough the cards to start the game."); } } break; case Enums.ModeGame.Medium: // TODO: Create enum of Card. Enums.CardType type_Black; // TODO: Random value. if (Random.Range(0, 2) == 1) { // TODO: Set type of card is club. type_Black = Enums.CardType.Club; } else { // TODO: Set type of card is Spade. type_Black = Enums.CardType.Spade; } // TODO: Create enum of Card. Enums.CardType type_Red; // TODO: Random value. if (Random.Range(0, 2) == 1) { // TODO: Set type of card is Heart. type_Red = Enums.CardType.Heart; } else { // TODO: Set type of card is Diamond. type_Red = Enums.CardType.Diamond; } //TODO: Loop 4 times to get the cards. for (int i = 0; i < 2; i++) { // TODO: Clear the old of cards in the list. paramGet.Clear(); // TODO: Get the cards from the pool. paramGet.AddRange(PoolSystem.Instance.GetCardsColor(type_Black)); // TODO: Check the number of cards from list. if (paramGet.Count > 0) { // TODO: Add the list of cards from the pool. cardsGet.AddRange(paramGet); } else { // TODO: Show the error if we don't have enough the cards to start the game. throw new UnityException("We don't have enough the cards to start the game."); } } // TODO: Loop 4 times to get the cards. for (int i = 0; i < 2; i++) { // TODO: Clear the old of cards in the list. paramGet.Clear(); // TODO: Get the cards from the pool. paramGet.AddRange(PoolSystem.Instance.GetCardsColor(type_Red)); // TODO: Check the number of cards from list. if (paramGet.Count > 0) { // TODO: Add the list of cards from the pool. cardsGet.AddRange(paramGet); } else { // TODO: Show the error if we don't have enough the cards to start the game. throw new UnityException("We don't have enough the cards to start the game."); } } break; case Enums.ModeGame.Hard: // TODO: Clear the old of cards in the list. paramGet.Clear(); // TODO: Get the cards from the pool. paramGet.AddRange(PoolSystem.Instance.GetCardsColor(Enums.CardType.Club)); // TODO: Check the number of cards from list. if (paramGet.Count > 0) { // TODO: Add the list of cards from the pool. cardsGet.AddRange(paramGet); } else { // TODO: Show the error if we don't have enough the cards to start the game. throw new UnityException("We don't have enough the cards to start the game."); } // TODO: Clear the old of cards in the list. paramGet.Clear(); // TODO: Get the cards from the pool. paramGet.AddRange(PoolSystem.Instance.GetCardsColor(Enums.CardType.Heart)); // TODO: Check the number of cards from list. if (paramGet.Count > 0) { // TODO: Add the list of cards from the pool. cardsGet.AddRange(paramGet); } else { // TODO: Show the error if we don't have enough the cards to start the game. throw new UnityException("We don't have enough the cards to start the game."); } // TODO: Clear the old of cards in the list. paramGet.Clear(); // TODO: Get the cards from the pool. paramGet.AddRange(PoolSystem.Instance.GetCardsColor(Enums.CardType.Spade)); // TODO: Check the number of cards from list. if (paramGet.Count > 0) { // TODO: Add the list of cards from the pool. cardsGet.AddRange(paramGet); } else { // TODO: Show the error if we don't have enough the cards to start the game. throw new UnityException("We don't have enough the cards to start the game."); } // TODO: Clear the old of cards in the list. paramGet.Clear(); // TODO: Get the cards from the pool. paramGet.AddRange(PoolSystem.Instance.GetCardsColor(Enums.CardType.Diamond)); // TODO: Check the number of cards from list. if (paramGet.Count > 0) { // TODO: Add the list of cards from the pool. cardsGet.AddRange(paramGet); } else { // TODO: Show the error if we don't have enough the cards to start the game. throw new UnityException("We don't have enough the cards to start the game."); } break; } // TODO: Get the total of cards in the list. int count = cardsGet.Count; // TODO: Create the cache of card. CardBehaviour paramCache; // TODO: Loop and set the item's properties. for (int i = 0; i < cardsGet.Count; i++) { // TODO: Set the default of card with the list cards. paramCache = cardsGet[i]; // TODO: Set the defautl of transform parent. paramCache.transform.SetParent(GamePlay.Instance.TDrawCards); // TODO: Set the default of scale. paramCache.transform.localScale = Vector3.one; // TODO: Set the default of position. paramCache.transform.localPosition = Vector3.zero; paramCache.ResetCards(); if (paramCache.gameObject.activeSelf == false) { paramCache.gameObject.SetActive(true); } } }
/// <summary> /// Create a new empty card base sheet with a specified card type. /// </summary> /// <param name="cardType">The card type.</param> internal CardSheetBase(Enums.CardType cardType) { CardType = cardType; }