/// <summary> /// Auto complete actions in coroutine. /// </summary> private IEnumerator CompleteCoroutine() { IsAutoCompleteActive = true; HintComponent.UpdateAvailableForAutoCompleteCards(); while (HintComponent.IsHasHint()) { HintComponent.HintAndSet(HintSetTransitionTime); yield return(new WaitWhile(() => HintComponent.IsHintProcess)); } IsAutoCompleteActive = false; HintComponent.UpdateAvailableForDragCards(); }
/// <summary> /// Call after each step. /// </summary> public void ActionAfterEachStep() { if (!_isUserMadeFirstMove) { _isUserMadeFirstMove = true; } SetPackDeckBg(); GameManagerComponent.CardMove(); if (AutoCompleteComponent.IsAutoCompleteActive) { HintManagerComponent.UpdateAvailableForAutoCompleteCards(); } else { HintManagerComponent.UpdateAvailableForDragCards(); } CheckWinGame(); CheckActivateAutoComplete(); }
/// <summary> /// Action of Undo all decks/cards states. /// </summary> public void Undo() { if (StatesData.States.Count > 0) { //if undos are countable and there are undos to be used, subtract the undo and update the text if (IsCountable && _availableUndoCounts > 0) { _availableUndoCounts--; gameUndoCount++; _undoAvailableCountsText.text = _availableUndoCounts.ToString(); } //else if undos are countable and there are no remaining undos, trigger an ad to reset the undo count else if (IsCountable && _availableUndoCounts == 0) { //_gameMgrComponent.OnClickGetUndoAdsBtn(); //if the Player doesn't have any more undos, trigger an ad to get more if (_adsComponent.adsActive == true) { _adsComponent.ShowAd("refillUndos"); return; } else { return; } } _hintComponent.IsHintWasUsed = false; _cardLogicComponent.IsNeedResetPack = false; //go through each card in the alldeckarray(master of all cards) for (int i = 0; i < _cardLogicComponent.AllDeckArray.Length; i++) { //_cardLogicComponent.faceDownCardsCount = 0; //assign deck to the all deck array, so all cards Deck deck = _cardLogicComponent.AllDeckArray[i]; //assign the deck record to the current state -1, so the previous state DeckRecord deckRecord = StatesData.States[StatesData.States.Count - 1].DecksRecord[i]; //assign deck's card list to the deckRecord cards list of the previous state deck.CardsArray = new List <Card>(deckRecord.Cards); for (int j = 0; j < deckRecord.CardsRecord.Count; j++) { Card card = deck.CardsArray[j]; CardRecord cardRecord = deckRecord.CardsRecord[j]; card.CardType = cardRecord.CardType; card.CardNumber = cardRecord.CardNumber; card.Number = cardRecord.Number; card.CardStatus = cardRecord.CardStatus; card.CardColor = cardRecord.CardColor; card.IsDraggable = cardRecord.IsDraggable; card.IndexZ = cardRecord.IndexZ; card.Deck = cardRecord.Deck; card.transform.localPosition = cardRecord.Position; card.transform.SetSiblingIndex(cardRecord.SiblingIndex); card.isFaceDown = cardRecord.IsFaceDown; //if (card.isFaceDown == true) //{ // _cardLogicComponent.faceDownCardsCount++; //} } //_cardLogicComponent.faceDownCardsCount = deckRecord.faceDownCardsCount; deck.UpdateCardsPosition(false); } _cardLogicComponent.faceDownCardsCount = 0; for (int k = 0; k < _cardLogicComponent.CardsArray.Length; k++) { Card card = _cardLogicComponent.CardsArray[k]; if (card.isFaceDown == true) { _cardLogicComponent.faceDownCardsCount++; } } //_gameMgrComponent._scoreCount = StatesData.States[StatesData.States.Count - 1].Score; _hintComponent.UpdateAvailableForDragCards(); _cardLogicComponent.GameManagerComponent.CardMove(); StatesData.States.RemoveAt(StatesData.States.Count - 1); ActivateUndoButton(); } }