コード例 #1
0
    public IEnumerator autoWinCoroutine()
    {
        bool flag    = true;
        int  counter = 0;

        while (flag)
        {
            Debug.Log(counter);
            HintValueDisplay hint = PlayingZone.Instance.GetHint();
            if (hint.cardDisplay == null)
            {
                hint = HintZone.Instance.GetHint();
            }
            if (hint.cardDisplay == null)
            {
                //flag = false;
                Debug.Log("hint.cardDisplay");
                Debug.Log(hint.cardDisplay == null);

                //break;
            }
            else
            {
                hint.cardDisplay.cardClick();
            }

            Debug.Log("IsConditionWining(): " + (IsConditionWining()));
            if (IsConditionWining())
            {
                flag = false;
            }
            Debug.Log("!IsHintAvailable(false): " + (!IsHintAvailable(false)));
            if (!IsHintAvailable(false))
            {
                EventSystem.Instance.DrawHintCards();
                //flag = false;
            }
            counter++;
            Debug.Log("counter > 1000: " + (counter > 1000));
            if (counter > 1000)
            {
                flag = false;
            }
            Debug.Log("flag: " + flag);
            Debug.Log("time: " + Time.timeScale);
            yield return(new WaitForSeconds(0.1f));
        }

        //chechAutoWin();

        /*
         * HintValueDisplay hint =  PlayingZone.Instance.GetHint();
         * if (hint.cardDisplay == null ) hint = HintZone.Instance.GetHint();
         * hint.cardDisplay.cardClick();
         */
    }
コード例 #2
0
        public HintValueDisplay GetHint()
        {
            // TODO: Create the param will be returned.
            HintValueDisplay paramReturn = new HintValueDisplay();

            // TODO: Get the last cards.
            CardBehaviour lastCard = HintZone.Instance.GetTheLastCard(Enums.IdTransformCard.TransformCards_A);

            // TODO: Check null.
            if (!object.ReferenceEquals(lastCard, null))
            {
                // TODO: set the card.
                paramReturn.cardDisplay = lastCard;

                // TODO: Get the position.
                paramReturn.positionTarget = lastCard.TargetPosition;
            }

            // TODO: Return the value.
            return(paramReturn);
        }
コード例 #3
0
ファイル: _PlayingZone.cs プロジェクト: Tetta/Solitaire
        public HintValueDisplay GetHint()
        {
            // TODO: Create the list will be returned.
            HintValueDisplay paramOut = new HintValueDisplay();

            // TODO: Check the condition null.
            if (object.ReferenceEquals(GamePlay.Instance.cardSaveCache, null))
            {
                // TODO: Return the value.
                return(paramOut);
            }

            // TODO: Create the lenght of cards.
            int lenght = PlayingZone.Instance.zoneCards.Length;

            // TODO: Loop to check.
            for (int i = 0; i < lenght; i++)
            {
                // TODO: Create the cache to check the cards.
                var card = PlayingZone.Instance.GetTheLastCard(PlayingZone.Instance.zoneCards[i].Id);

                // TODO: Get the card save.
                var cardSave = GamePlay.Instance.cardSaveCache;

                // TODO: Check if the list cards is empty or null.
                if (object.ReferenceEquals(card, null))
                {
                    // TODO: next to another.
                    continue;
                }

                bool IsReadyAnotherCondition = true;
                bool IsReadyKingCondition    = false;

                if (card.GetEnumsCard() == Enums.CardVariables.King && cardSave.GetEnumsCard() == Enums.CardVariables.One || card.GetEnumsCard() == Enums.CardVariables.One && cardSave.GetEnumsCard() == Enums.CardVariables.King)
                {
                    // TODO: Set the another condition.
                    IsReadyKingCondition = true;
                }

                switch (GameManager.Instance.GetModeGame())
                {
                case Enums.ModeGame.Hard:

                    if (card.GetTypeCards() != cardSave.GetTypeCards())
                    {
                        // TODO: Set the another condition.
                        IsReadyAnotherCondition = false;
                    }

                    break;

                case Enums.ModeGame.Medium:

                    if (!card.IsSameColorCard(cardSave.GetTypeCards()))
                    {
                        // TODO: Set the another condition.
                        IsReadyAnotherCondition = false;
                    }

                    break;
                }

                if ((cardSave.GetValue() + 1 == card.GetValue() || cardSave.GetValue() - 1 == card.GetValue()) && IsReadyAnotherCondition || IsReadyKingCondition && IsReadyAnotherCondition)
                {
                    // TODO: Set the card display.
                    paramOut.cardDisplay = card;

                    // TODO: Set the target position.
                    paramOut.positionTarget = cardSave.TargetPosition;

                    // TODO: break the state check
                    break;
                }
            }

            // TODO: Return the list.
            return(paramOut);
        }
コード例 #4
0
ファイル: _PlayingZone.cs プロジェクト: Tetta/Solitaire
		public HintValueDisplay GetHint()
		{
			// TODO: Create the list will be returned.
			HintValueDisplay paramOut = new HintValueDisplay();

			// TODO: Create the lenght of cards.
			int lenght = PlayingZone.Instance.zoneCards.Length;

			// TODO: Create the flag, the condition to check moving cards.
			bool IsReadyToCheck = false;

			// TODO: Loop to check.
			for ( int i = 0; i < lenght; i++ )
			{
				// TODO: the condition to break the function.
				if (IsReadyToCheck)
				{
					// TODO: Break the function.
					break;
				}

				// TODO: Create the cache to check the cards.
				var paramCheck = new List<CardBehaviour>(PlayingZone.Instance.GetTheListCards(PlayingZone.Instance.zoneCards[i].Id));

				// TODO: Check if the list cards is empty or null.
				if ( object.ReferenceEquals ( paramCheck , null ) || paramCheck.Count == 0)
				{
					// TODO: next to another.
					continue;
				}        

				// TODO: Create the count of list.
				int count = paramCheck.Count;

				// ====================================== DOING HINT WITH RESULT ZONE =================================== //

				if (count > 0) {		

					// TODO: Get the list of id.
					var zoneCards = ResultZone.Instance.GetTheListIdZones ();

					// TODO: Get the cache of card from Result zone.
					CardBehaviour cardParamFromResultZone = null;

					for (int j = 0; j < zoneCards.Count; j++) {

						// TODO: Get the last card in playing zone.
						cardParamFromResultZone = ResultZone.Instance.GetTheLastCard ((Enums.IdTransformCard)zoneCards [j]);

						// TODO: Get the condition null.
						if (!object.ReferenceEquals (cardParamFromResultZone, null)) {

							// TODO: Check the condition to join.
							if (paramCheck [count - 1].IsReadyToJoinZone (cardParamFromResultZone.GetProperties (), true)) {

								// TODO: Set the card will be displayed.
								paramOut.cardDisplay = paramCheck [count - 1];

								// TODO: Get the new position need to moving.
								paramOut.positionTarget = cardParamFromResultZone.TargetPosition;

								// TODO: Return the value.
								return paramOut;
							}
						} else {
						
							if (paramCheck [count - 1].GetValue () == (int)Enums.CardVariables.One) {

								// TODO: Set the card will be displayed.
								paramOut.cardDisplay = paramCheck [count - 1];

								// TODO: Get the new position need to moving.
								paramOut.positionTarget = Helper.GetPositionInTheResultZone ((Enums.IdTransformCard)zoneCards [j] , Enums.Direction.None , true );

								// TODO: Return the value.
								return paramOut;
							}
						}
					}		
				}

				// ====================================== DOING HINT WITH PLAYING ZONE =================================== //

				// TODO: Loop to get the cards.
				for ( int j = 0; j < count ; j ++ )
				{
					// TODO: the condition to break the function.
					if (IsReadyToCheck)
					{
						// TODO: Break the function.
						break;
					}

					// TODO: Create the cache of cards.
					var cardParam = paramCheck[j];

					// TODO: Check if the card is lock break.
					if (cardParam.IsUnlocked() == false || cardParam.GetStateCard() != Enums.StateCard.None)
					{
						continue;
					}            

					for ( int  h =  0;  h < lenght; h++ )
					{
						// TODO: Check if id is the same.
						if ( PlayingZone.Instance.zoneCards[h].Id == PlayingZone.Instance.zoneCards[i].Id)
						{
							continue;
						}

						// TODO: the condition to join.
						var IsReadyToJoin = false;

						// TODO: Get the card.
						var TargetBehaviour = PlayingZone.Instance.GetTheLastCard(PlayingZone.Instance.zoneCards[h].Id);

						// TODO: Check if this card is not null.
						if (!object.ReferenceEquals(TargetBehaviour, null))
						{
							// TODO: Check if this card can join with this zone.
							if (cardParam.IsReadyToJoinZone (TargetBehaviour.GetProperties (), false , GameManager.Instance.GetModeGame() == Enums.ModeGame.Easy )) {

								// TODO: Set ready.
								IsReadyToJoin = true;						
							}
						}
						else
						{
							if (cardParam.GetValue () == (int)Enums.CardVariables.King && !object.ReferenceEquals ( PlayingZone.Instance.GetTheFirstCard (cardParam) , cardParam)) {
								// TODO: Set ready.
								IsReadyToJoin = true;
							} else {

								IsReadyToJoin = false;
							}
						}

						if ( IsReadyToJoin )
						{
							// TODO: Set the card will be displayed.
							paramOut.cardDisplay = cardParam;

							// TODO: Get the new position need to moving.
							paramOut.positionTarget =  Helper.GetPositionInThePlayingZone( PlayingZone.Instance.zoneCards[h].Id, Enums.Direction.Down, cardParam.IsUnlocked());

							// TODO: Break the flags.
							IsReadyToCheck = true;

							// TODO: Break the function.
							break;
						}
					}

					// TODO: Break the function.
					break;
				}
			}

			// TODO: Return the list.
			return paramOut;
		}
コード例 #5
0
        public CardBehaviour GetHint2()
        {
            //first

            // TODO: Create the param will be returned.
            HintValueDisplay paramReturn = new HintValueDisplay();

            // ============================================ LAST CARD FROM B ==================================== //

            // TODO: Get the last cards.
            CardBehaviour lastCard = HintZone.Instance.GetTheLastCard(Enums.IdTransformCard.TransformCards_B);

            var isReadyToJoin = false;

            // TODO: Get the target position.
            var positionTarget = Contains.Vector3Zero;

            // ============================================ DOING LAST CARD WITH RESULT ZONE ==================== //
            if (!object.ReferenceEquals(lastCard, null))
            {
                // TODO: Get the list of id.
                var zoneCards = ResultZone.Instance.GetTheListIdZones();

                // TODO: Get the cache of card from Result zone.
                CardBehaviour cardParamFromResultZone = null;

                for (int i = 0; i < zoneCards.Count; i++)
                {
                    // TODO: Get the last card in playing zone.
                    cardParamFromResultZone = ResultZone.Instance.GetTheLastCard((Enums.IdTransformCard)zoneCards[i]);

                    // TODO: Get the condition null.
                    if (!object.ReferenceEquals(cardParamFromResultZone, null))
                    {
                        // TODO: Check the condition to join.
                        if (lastCard.IsReadyToJoinZone(cardParamFromResultZone.GetProperties(), true))
                        {
                            isReadyToJoin = true;

                            // TODO: Get the default position.
                            positionTarget = cardParamFromResultZone.TargetPosition;
                            return(lastCard);

                            break;
                        }
                    }
                    else
                    {
                        if (lastCard.GetValue() == (int)Enums.CardVariables.One)
                        {
                            isReadyToJoin = true;

                            // TODO: Get the default position.
                            positionTarget = Helper.GetPositionInTheResultZone((Enums.IdTransformCard)zoneCards[i], Enums.Direction.None, true);
                            return(lastCard);

                            break;
                        }
                    }
                }
            }

            // =========================================== DOING LAST CARD WITH PLAYING ZONE ==================== //

            if (!object.ReferenceEquals(lastCard, null) && isReadyToJoin == false)
            {
                // TODO: Get the list of cards.
                var zoneCards = PlayingZone.Instance.GetTheListIdZones();

                // TODO: Get the cache of card from playing zone.
                CardBehaviour cardParamFromPlayingZone = null;

                for (int i = 0; i < zoneCards.Count; i++)
                {
                    // TODO: Get the last card in playing zone.
                    cardParamFromPlayingZone = PlayingZone.Instance.GetTheLastCard((Enums.IdTransformCard)zoneCards[i]);

                    // TODO: Get the condition null.
                    if (!object.ReferenceEquals(cardParamFromPlayingZone, null))
                    {
                        // TODO: Check the condition to join.
                        if (lastCard.IsReadyToJoinZone(cardParamFromPlayingZone.GetProperties(), false, GameManager.Instance.GetModeGame() == Enums.ModeGame.Easy))
                        {
                            isReadyToJoin = true;

                            // TODO: Get the default position.
                            positionTarget = cardParamFromPlayingZone.TargetPosition;
                            return(lastCard);

                            break;
                        }
                    }
                    else
                    {
                        if (lastCard.GetValue() == (int)Enums.CardVariables.King)
                        {
                            isReadyToJoin = true;

                            // TODO: Get the default position.
                            positionTarget = Helper.GetPositionInThePlayingZone((Enums.IdTransformCard)zoneCards[i], Enums.Direction.None, true);
                            return(lastCard);

                            break;
                        }
                    }
                }
            }

            // ============================================ LAST CARD FROM A ==================================== //

            //----------------------------------------------------------------------------------
            // TODO: Create the param will be returned.
            paramReturn = new HintValueDisplay();

            // ============================================ LAST CARD FROM B ==================================== //
            lastCard = HintZone.Instance.GetTheLastCard(Enums.IdTransformCard.TransformCards_B);

            // TODO: Get the last cards.

            var arrayCards = HintZone.Instance.GetTheListCards(Enums.IdTransformCard.TransformCards_A);

            foreach (CardBehaviour card in arrayCards)
            {
                lastCard = card;

                isReadyToJoin = false;

                // TODO: Get the target position.
                positionTarget = Contains.Vector3Zero;

                // ============================================ DOING LAST CARD WITH RESULT ZONE ==================== //
                if (!object.ReferenceEquals(lastCard, null))
                {
                    // TODO: Get the list of id.
                    var zoneCards = ResultZone.Instance.GetTheListIdZones();

                    // TODO: Get the cache of card from Result zone.
                    CardBehaviour cardParamFromResultZone = null;

                    for (int i = 0; i < zoneCards.Count; i++)
                    {
                        // TODO: Get the last card in playing zone.
                        cardParamFromResultZone = ResultZone.Instance.GetTheLastCard((Enums.IdTransformCard)zoneCards[i]);

                        // TODO: Get the condition null.
                        if (!object.ReferenceEquals(cardParamFromResultZone, null))
                        {
                            // TODO: Check the condition to join.
                            if (lastCard.IsReadyToJoinZone(cardParamFromResultZone.GetProperties(), true))
                            {
                                isReadyToJoin = true;

                                // TODO: Get the default position.
                                positionTarget = cardParamFromResultZone.TargetPosition;
                                return(lastCard);

                                break;
                            }
                        }
                        else
                        {
                            if (lastCard.GetValue() == (int)Enums.CardVariables.One)
                            {
                                isReadyToJoin = true;

                                // TODO: Get the default position.
                                positionTarget = Helper.GetPositionInTheResultZone((Enums.IdTransformCard)zoneCards[i], Enums.Direction.None, true);
                                return(lastCard);

                                break;
                            }
                        }
                    }
                }

                // =========================================== DOING LAST CARD WITH PLAYING ZONE ==================== //

                if (!object.ReferenceEquals(lastCard, null) && isReadyToJoin == false)
                {
                    // TODO: Get the list of cards.
                    var zoneCards = PlayingZone.Instance.GetTheListIdZones();

                    // TODO: Get the cache of card from playing zone.
                    CardBehaviour cardParamFromPlayingZone = null;

                    for (int i = 0; i < zoneCards.Count; i++)
                    {
                        // TODO: Get the last card in playing zone.
                        cardParamFromPlayingZone = PlayingZone.Instance.GetTheLastCard((Enums.IdTransformCard)zoneCards[i]);

                        // TODO: Get the condition null.
                        if (!object.ReferenceEquals(cardParamFromPlayingZone, null))
                        {
                            // TODO: Check the condition to join.
                            if (lastCard.IsReadyToJoinZone(cardParamFromPlayingZone.GetProperties(), false, GameManager.Instance.GetModeGame() == Enums.ModeGame.Easy))
                            {
                                isReadyToJoin = true;

                                // TODO: Get the default position.
                                positionTarget = cardParamFromPlayingZone.TargetPosition;
                                return(lastCard);

                                break;
                            }
                        }
                        else
                        {
                            if (lastCard.GetValue() == (int)Enums.CardVariables.King)
                            {
                                isReadyToJoin = true;

                                // TODO: Get the default position.
                                positionTarget = Helper.GetPositionInThePlayingZone((Enums.IdTransformCard)zoneCards[i], Enums.Direction.None, true);
                                return(lastCard);

                                break;
                            }
                        }
                    }
                }

                // ============================================ LAST CARD FROM A ==================================== //
            }

            arrayCards = HintZone.Instance.GetTheListCards(Enums.IdTransformCard.TransformCards_B);
            foreach (CardBehaviour card in arrayCards)
            {
                lastCard = card;

                isReadyToJoin = false;

                // TODO: Get the target position.
                positionTarget = Contains.Vector3Zero;

                // ============================================ DOING LAST CARD WITH RESULT ZONE ==================== //
                if (!object.ReferenceEquals(lastCard, null))
                {
                    // TODO: Get the list of id.
                    var zoneCards = ResultZone.Instance.GetTheListIdZones();

                    // TODO: Get the cache of card from Result zone.
                    CardBehaviour cardParamFromResultZone = null;

                    for (int i = 0; i < zoneCards.Count; i++)
                    {
                        // TODO: Get the last card in playing zone.
                        cardParamFromResultZone = ResultZone.Instance.GetTheLastCard((Enums.IdTransformCard)zoneCards[i]);

                        // TODO: Get the condition null.
                        if (!object.ReferenceEquals(cardParamFromResultZone, null))
                        {
                            // TODO: Check the condition to join.
                            if (lastCard.IsReadyToJoinZone(cardParamFromResultZone.GetProperties(), true))
                            {
                                isReadyToJoin = true;

                                // TODO: Get the default position.
                                positionTarget = cardParamFromResultZone.TargetPosition;
                                return(lastCard);

                                break;
                            }
                        }
                        else
                        {
                            if (lastCard.GetValue() == (int)Enums.CardVariables.One)
                            {
                                isReadyToJoin = true;

                                // TODO: Get the default position.
                                positionTarget = Helper.GetPositionInTheResultZone((Enums.IdTransformCard)zoneCards[i], Enums.Direction.None, true);
                                return(lastCard);

                                break;
                            }
                        }
                    }
                }

                // =========================================== DOING LAST CARD WITH PLAYING ZONE ==================== //

                if (!object.ReferenceEquals(lastCard, null) && isReadyToJoin == false)
                {
                    // TODO: Get the list of cards.
                    var zoneCards = PlayingZone.Instance.GetTheListIdZones();

                    // TODO: Get the cache of card from playing zone.
                    CardBehaviour cardParamFromPlayingZone = null;

                    for (int i = 0; i < zoneCards.Count; i++)
                    {
                        // TODO: Get the last card in playing zone.
                        cardParamFromPlayingZone = PlayingZone.Instance.GetTheLastCard((Enums.IdTransformCard)zoneCards[i]);

                        // TODO: Get the condition null.
                        if (!object.ReferenceEquals(cardParamFromPlayingZone, null))
                        {
                            // TODO: Check the condition to join.
                            if (lastCard.IsReadyToJoinZone(cardParamFromPlayingZone.GetProperties(), false, GameManager.Instance.GetModeGame() == Enums.ModeGame.Easy))
                            {
                                isReadyToJoin = true;

                                // TODO: Get the default position.
                                positionTarget = cardParamFromPlayingZone.TargetPosition;
                                return(lastCard);

                                break;
                            }
                        }
                        else
                        {
                            if (lastCard.GetValue() == (int)Enums.CardVariables.King)
                            {
                                isReadyToJoin = true;

                                // TODO: Get the default position.
                                positionTarget = Helper.GetPositionInThePlayingZone((Enums.IdTransformCard)zoneCards[i], Enums.Direction.None, true);
                                return(lastCard);

                                break;
                            }
                        }
                    }
                }

                // ============================================ LAST CARD FROM A ==================================== //
            }



            return(null);
        }
コード例 #6
0
ファイル: _PlayingZone.cs プロジェクト: Tetta/Solitaire
        public HintValueDisplay GetHint()
        {
            // TODO: Create the list will be returned.
            HintValueDisplay paramOut = new HintValueDisplay();

            // TODO: Create the lenght of cards.
            int lenght = PlayingZone.Instance.zoneCards.Length;

            // TODO: Create the flag, the condition to check moving cards.
            bool IsReadyToCheck = false;

            // TODO: Loop to check.
            for (int i = 0; i < lenght; i++)
            {
                // TODO: the condition to break the function.
                if (IsReadyToCheck)
                {
                    // TODO: Break the function.
                    break;
                }

                // TODO: Create the cache to check the cards.
                var paramCheck = new List <CardBehaviour>(PlayingZone.Instance.GetTheListCards(PlayingZone.Instance.zoneCards[i].Id));

                // TODO: Check if the list cards is empty or null.
                if (object.ReferenceEquals(paramCheck, null) || paramCheck.Count == 0)
                {
                    // TODO: next to another.
                    continue;
                }

                // TODO: Create the count of list.
                int count = paramCheck.Count;

                // TODO: Loop to get the cards.
                for (int j = 0; j < count; j++)
                {
                    // TODO: the condition to break the function.
                    if (IsReadyToCheck)
                    {
                        // TODO: Break the function.
                        break;
                    }

                    // TODO: Create the cache of cards.
                    var cardParam = paramCheck[j];

                    // TODO: Check if the card is lock break.
                    if (cardParam.IsUnlocked() == false || cardParam.GetStateCard() != Enums.StateCard.None)
                    {
                        continue;
                    }

                    for (int h = 0; h < lenght; h++)
                    {
                        // TODO: Check if id is the same.
                        if (PlayingZone.Instance.zoneCards[h].Id == PlayingZone.Instance.zoneCards[i].Id)
                        {
                            continue;
                        }

                        // TODO: the condition to join.
                        var IsReadyToJoin = false;

                        // TODO: Get the card.
                        var TargetBehaviour = PlayingZone.Instance.GetTheLastCard(PlayingZone.Instance.zoneCards[h].Id);

                        // TODO: Check if this card is not null.
                        if (!object.ReferenceEquals(TargetBehaviour, null))
                        {
                            // TODO: Check if this card can join with this zone.
                            if (cardParam.IsReadyToJoinZone(TargetBehaviour.GetProperties()))
                            {
                                // TODO: Set ready.
                                IsReadyToJoin = true;
                            }
                        }
                        else
                        {
                            if (j != 0)
                            {
                                // TODO: Set ready.
                                IsReadyToJoin = true;
                            }
                        }

                        if (IsReadyToJoin)
                        {
                            // TODO: Set the card will be displayed.
                            paramOut.cardDisplay = cardParam;

                            // TODO: Get the new position need to moving.
                            paramOut.positionTarget = Helper.GetPositionInThePlayingZone(PlayingZone.Instance.zoneCards[h].Id, Enums.Direction.Down, cardParam.IsUnlocked());

                            // TODO: Break the flags.
                            IsReadyToCheck = true;

                            // TODO: Break the function.
                            break;
                        }
                    }

                    // TODO: Break the function.
                    break;
                }
            }

            // TODO: Return the list.
            return(paramOut);
        }