private void Start() { cardsId = Enumerable.Range(0, allCard.Count).ToList(); cardsId = ShuffleList(cardsId); //Setting up all the cards for (int i = 0; i < allCard.Count; i++) { allCard[i].SetCardData(cardsData[cardsId[i]]); allCard[i].onLockCard = true; } playerCards = new List <CardModel>(); botCards = new List <CardModel>(); //Initialize the game parameter gamePhase = 0; playerCardsNb = 0; botCardsNb = 0; currentTurn = 0; playerScore = 0; botScore = 0; onCardClicked = null; battleCD = -1; view.OpenIngameUI(); view.UpdateScore(0, 0); view.UpdateNotification("Please wait..."); view.goPlayAgain.onClick.AddListener(ReplayGame); view.goQuit.onClick.AddListener(QuitGame); StartCoroutine(ShuffleTheDeckAnimation()); }
IEnumerator ShuffleTheDeckAnimation() { yield return(new WaitForSeconds(1)); //Debug.Log("Shuffle"); //Gather all cards foreach (CardModel c in allCard) { c.MoveCard(centerPlatePos.position, centerPlatePos.localScale); } yield return(new WaitForSeconds(2)); for (int i = 0; i < allCard.Count; i++) { allCard[i].MoveCard(plateCardPos[i].position, plateCardPos[i].localScale); } yield return(new WaitForSeconds(2)); for (int i = 0; i < allCard.Count; i++) { allCard[i].onLockCard = false; } gamePhase = 1; onCardClicked += AddToPlayerHand; view.UpdateNotification("Please pick up 5 cards"); }
void StartGame() { gamePhase = 2; view.UpdateNotification("Game Start..."); SummonCard(botCards[0]); //Add the summon card event for the cards onCardClicked = null; onCardClicked += SummonCard; //Free the card so it can be clicked LockTheCardTrigger(false); }
//Phase 1: picking up card void AddToPlayerHand(CardModel card) { if (playerCardsNb < 5) { card.MoveCard(playerCardPos[playerCardsNb].position, playerCardPos[playerCardsNb].localScale); card.onLockCard = true; card.teamID = 1; playerCards.Add(card); card.ToFaceUp(); allCard.Remove(card); //The player already pickup all cards-> all the reaminng card belong to bot if (playerCardsNb == 4) { onCardClicked = null; StartCoroutine(BotPickingCard()); } else { playerCardsNb++; } } }