Exemplo n.º 1
0
    /// <summary>
    /// Gets the identifier the list of cards.
    /// </summary>
    public Enums.IdTransformCard GetIdTransform(CardBehaviour paramIn)
    {
        // TODO: Create the param will be returned.
        Enums.IdTransformCard paramReturn = Enums.IdTransformCard.None;

        // TODO: Get the number of zone.
        int count = zoneCards.Length;

        // TODO: Create the list of cards.
        List <CardBehaviour> paramOut;

        // TODO: Loop to get the id.
        for (int i = 0; i < count; i++)
        {
            // TODO: Try to get the value of cards.
            if (cards.TryGetValue(Enums._IdTransformCard [(int)zoneCards[i].Id], out paramOut))
            {
                // TODO: Check if the card exists.
                if (paramOut.Contains(paramIn))
                {
                    // TODO: Get the value will be returned.
                    paramReturn = zoneCards[i].Id;

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

        // TODO: Return the value.
        return(paramReturn);
    }
Exemplo n.º 2
0
    /// <summary>
    /// Gets the next identifier of transform.
    /// </summary>
    /// <returns>The next identifier of transform.</returns>
    public Enums.IdTransformCard GetNextIDTransform(Enums.IdTransformCard id)
    {
        // TODO: Create the param will be returned.
        Enums.IdTransformCard paramReturn = Enums.IdTransformCard.None;

        // TODO: Loop to check the id.
        for (int i = 0; i < zoneCards.Length; i++)
        {
            // TODO: Check if this id equal with the id condition.
            if (zoneCards [i].Id == id)
            {
                // TODO: Check if the index of array is max.
                if (i == zoneCards.Length - 1)
                {
                    // TODO: Return the first value.
                    paramReturn = zoneCards [0].Id;
                }
                else
                {
                    // TODO: Return the next value.
                    paramReturn = zoneCards [i + 1].Id;
                }

                break;
            }
        }

        // TODO: Return the value.
        return(paramReturn);
    }
Exemplo n.º 3
0
    /// <summary>
    /// Gets the list cards.
    /// </summary>
    public List <CardBehaviour> GetTheListCards(Enums.IdTransformCard id)
    {
        // TODO: Create the list will be returned.
        List <CardBehaviour> paramReturn = new List <CardBehaviour> ();

        // TODO: Cache the key.
        string key = Enums._IdTransformCard [(int)id];

        // TODO: Check if it eixist.
        if (cards.ContainsKey(key))
        {
            // TODO: Try to get the value.
            cards.TryGetValue(key, out paramReturn);
        }

        // TODO: Check if is null.
        if (object.ReferenceEquals(paramReturn, null))
        {
            // TODO: Create the value.
            paramReturn = new List <CardBehaviour> ();
        }

        // TODO: Return the list.
        return(paramReturn);
    }
Exemplo n.º 4
0
    /// <summary>
    /// Gets the first card. From the id of card.
    /// </summary>
    public CardBehaviour GetTheFirstCard(Enums.IdTransformCard id)
    {
        // TODO: Create the value will be returned.
        CardBehaviour paramReturn = null;

        // TODO: Check if it exists.
        if (cards.ContainsKey(Enums._IdTransformCard [(int)id]))
        {
            // TODO: Create the list of cards.
            List <CardBehaviour> paramCheck;

            // TODO: Try to get the value of cards.
            if (cards.TryGetValue(Enums._IdTransformCard [(int)id], out paramCheck))
            {
                // TODO: Check if it has any card.
                if (paramCheck.Count > 0)
                {
                    // TODO: Set the value will be returned.
                    paramReturn = paramCheck [0];
                }
            }
        }

        // TODO: Return the value.
        return(paramReturn);
    }
Exemplo n.º 5
0
    /// <summary>
    /// Return true if this card exists.
    /// </summary>
    public bool IsExistsCards(Enums.IdTransformCard id, CardBehaviour paramIn)
    {
        switch (id)
        {
        case Enums.IdTransformCard.None:

            // TODO: Loop with the number of zone.
            for (int i = 0; i < zoneCards.Length; i++)
            {
                // TODO: Check if it exists.
                if (cards.ContainsKey(Enums._IdTransformCard [(int)zoneCards[i].Id]))
                {
                    // TODO: Create the list of cards.
                    List <CardBehaviour> paramOut;

                    // TODO: Try to get the value of cards.
                    if (cards.TryGetValue(Enums._IdTransformCard [(int)zoneCards[i].Id], out paramOut))
                    {
                        // TODO: Check if card exists.
                        if (paramOut.Contains(paramIn))
                        {
                            // TODO: Return the value.
                            return(true);
                        }
                    }
                }
            }

            break;

        default:
            // TODO: Check if it exists.
            if (cards.ContainsKey(Enums._IdTransformCard [(int)id]))
            {
                // TODO: Create the list of cards.
                List <CardBehaviour> paramOut;

                // TODO: Try to get the value of cards.
                if (cards.TryGetValue(Enums._IdTransformCard [(int)id], out paramOut))
                {
                    // TODO: Check if the card exists.
                    if (paramOut.Contains(paramIn))
                    {
                        // TODO: Return the value.
                        return(true);
                    }
                }
            }
            break;
        }

        // TODO: Return the value.
        return(false);
    }
Exemplo n.º 6
0
    /// <summary>
    /// Determines whether this instance is empty cards the specified id.
    /// </summary>
    /// <returns><c>true</c> if this instance is empty cards the specified id; otherwise, <c>false</c>.</returns>
    /// <param name="id">Identifier.</param>
    public bool IsEmptyCards(Enums.IdTransformCard id)
    {
        var cardFounds = GetTheListCards(id);

        // TODO: Detect condition.
        if (object.ReferenceEquals(cardFounds, null) || cardFounds.Count == 0)
        {
            return(true);
        }

        return(false);
    }
Exemplo n.º 7
0
    /// <summary>
    /// Gets the default position.
    /// </summary>
    /// <returns>The default position.</returns>
    /// <param name="id">Identifier.</param>
    public Vector3 GetDefaultPosition(Enums.IdTransformCard id)
    {
        for (int i = 0; i < zoneCards.Length; i++)
        {
            if (zoneCards[i].Id == id)
            {
                return(zoneCards[i].ZoneHandle.position);
            }
        }

        return(Contains.Vector3Zero);
    }
Exemplo n.º 8
0
    /// <summary>
    /// Gets the list of cards from the index of card in the list.
    /// </summary>
    public List <CardBehaviour> GetTheListCardsFromIndex(Enums.IdTransformCard id, CardBehaviour paramIn)
    {
        // TODO: Create the value will be returned.
        List <CardBehaviour> paramReturn = new List <CardBehaviour>();

        // TODO: Check if it exists.
        if (cards.ContainsKey(Enums._IdTransformCard [(int)id]))
        {
            // TODO: Create the list of cards.
            List <CardBehaviour> paramCheck;

            // TODO: Try to get the value of cards.
            if (cards.TryGetValue(Enums._IdTransformCard [(int)id], out paramCheck))
            {
                //TODO: Get the count of list.
                int count = paramCheck.Count;

                // TODO: Time to start getting the cards.
                bool isReadyGet = false;

                // TODO: Create the cache of cards.
                CardBehaviour cacheCard = null;

                // TODO: Loop to get the cards.
                for (int i = 0; i < count; i++)
                {
                    // TODO: Check if is not time to start getting the cards.
                    if (isReadyGet == false)
                    {
                        // TODO: Set the value to get.
                        cacheCard = paramCheck [i];

                        // TODO: Check the condition of cards.
                        if (cacheCard == paramIn)
                        {
                            isReadyGet = true;
                        }
                    }
                    else
                    {
                        // TODO: Add the value will be returned.
                        paramReturn.Add(paramCheck [i]);
                    }
                }
            }
        }

        // TODO: return the value.
        return(paramReturn);
    }
Exemplo n.º 9
0
    /// <summary>
    /// Distributes the follow cards.
    /// </summary>
    public void DistributeTheFollowCards()
    {
        // TODO: Get the list of cards follow.
        List <CardBehaviour> cardsFollow = HelperZone.Instance.GetListCards();

        // TODO: Get the count of list.
        int count = cardsFollow.Count;

        // TODO: Break the function if don't have any cards follow.
        if (count == 0)
        {
            return;
        }

        // TODO: Get the id of the list.
        Enums.IdTransformCard id = PlayingZone.Instance.GetIdTransform(this);

        // TODO: Get the parent transform.
        Transform parentFollow = PlayingZone.Instance.GetTransformCards(id);

        // TODO: Get the cache of card.
        CardBehaviour cardCache = null;

        // TODO: Loop to distribute the childs.
        for (int i = 0; i < cardsFollow.Count; i++)
        {
            // TODO: Set the cache.
            cardCache = cardsFollow [i];

            // TODO: Set the parent.
            cardCache.transform.SetParent(parentFollow);

            // TODO: Get the target position.
            cardCache.TargetPosition = Helper.GetPositionInThePlayingZone(id, Enums.Direction.Down, cardCache.IsUnlocked());


            // TODO: Set the index view.
            cardCache.transform.SetAsLastSibling();

            // TODO: Update the new card to the list.
            PlayingZone.Instance.AddTheCard(id, cardCache);

            // TODO: Unlocking the state.
            cardCache.UpdateReadyToUse(Enums.StateCard.None);
        }

        // TODO: Clear all the old cards in the list.
        HelperZone.Instance.Clear();
    }
Exemplo n.º 10
0
 /// <summary>
 /// Return the parent transform of cards.
 /// </summary>
 public Transform GetTransformCards(Enums.IdTransformCard id)
 {
     // TODO: Loop with number of zonecards.
     for (int i = 0; i < zoneCards.Length; i++)
     {
         // TODO: Check if exists any id equal with the id of condition.
         if (zoneCards[i].Id == id)
         {
             // TODO: Return the transform of zone.
             return(zoneCards[i].ZoneHandle);
         }
     }
     // TODO: Return null if can not find the transform.
     return(null);
 }
Exemplo n.º 11
0
    /// <summary>
    /// Determines whether this instance is card moving inside zone.
    /// </summary>
    public bool IsCardMovingInsideZone(Enums.IdTransformCard id, Vector3 positionTarget)
    {
        // TODO: Get the position of the last card in the list of cards.
        Vector3 positionZone = GetWorldPosition(id);

        // TODO: Check if the value is null.
        if (Contains.Vector3Null.x == positionZone.x)
        {
            // TODO: Get the default position of zone.
            positionZone = GetDefaultPosition(id);
        }

        // TODO: Return the condition.
        return(IsPositionInsideZone(positionTarget, positionZone));
    }
Exemplo n.º 12
0
    /// <summary>
    /// Determines whether this instance is the latest card unlocked.
    /// </summary>
    public bool IsLastCardUnlocked(Enums.IdTransformCard id)
    {
        // TODO: Get the last cards in the list.
        CardBehaviour cardGet = GetTheLastCard(id);

        // TODO: Check if is null.
        if (object.ReferenceEquals(cardGet, null))
        {
            // TODO: Return false if is null.
            return(false);
        }

        // TODO: Return the state of the card.
        return(cardGet.IsUnlocked());
    }
Exemplo n.º 13
0
    /// <summary>
    /// Gets the follow cards.
    /// </summary>
    public void GetTheFollowCards()
    {
        // TODO: Check if the list cards is not empty.
        if (HelperZone.Instance.GetCountCards() > 0)
        {
            // TODO: Distribute all the cards .
            DistributeTheFollowCards();
        }

        // TODO: Get the id of the list.
        Enums.IdTransformCard id = PlayingZone.Instance.GetIdTransform(this);

        // TODO: Create the list card will be follow.
        List <CardBehaviour> cardsFollow = PlayingZone.Instance.GetTheListCardsFromIndex(id, this);

        // TODO: Get the count of list.
        int count = cardsFollow.Count;

        // TODO: Break the function if don't have any cards follow.
        if (count == 0)
        {
            return;
        }

        // TODO: Get the cache of card.
        CardBehaviour cardCache = null;

        for (int i = 0; i < count; i++)
        {
            // TODO: Set the value of cache.
            cardCache = cardsFollow [i];

            // TODO: Add the card into the list.
            HelperZone.Instance.AddCardsFollow(cardCache);

            // TODO: Set the parrent follow.
            cardCache.transform.SetParent(this.transform);

            // TODO: Remove the card from the list.
            PlayingZone.Instance.RemoveTheCard(cardCache);

            if (!object.ReferenceEquals(cardCache, this))
            {
                // TODO: Locking moving.
                cardCache.UpdateReadyToUse(Enums.StateCard.Moving);
            }
        }
    }
Exemplo n.º 14
0
    /// <summary>
    /// Get the position of cards.
    /// </summary>
    public Vector3 GetWorldPosition(Enums.IdTransformCard id)
    {
        // TODO: Create the list of cards will be gotten from the Dictionary.
        List <CardBehaviour> paramOut = new List <CardBehaviour>();

        if (cards.ContainsKey(Enums._IdTransformCard [(int)id]))
        {
            if (cards.TryGetValue(Enums._IdTransformCard [(int)id], out paramOut))
            {
                if (paramOut.Count > 0)
                {
                    return(paramOut[paramOut.Count - 1].TargetPosition);
                }
            }
        }

        return(Contains.Vector3Null);
    }
Exemplo n.º 15
0
    /// <summary>
    /// Determines whether this instance is completed A list cards the specified id.
    /// </summary>
    public bool DoCompletedAListCards(Enums.IdTransformCard id)
    {
        switch (GameManager.Instance.GameType)
        {
        case Enums.GameScenes.Spider:

            // TODO: Get the cache.
            return(_SPlayingZone.DoCompletedAListCards(id));

        case Enums.GameScenes.Klondike:

            // TODO: Completed the list cards.
            return(_KPlayingZone.DoCompletedAListCards(id));
        }

        // TODO: return the value.
        return(false);
    }
Exemplo n.º 16
0
    /// <summary>
    /// Removes the card.
    /// </summary>
    /// <param name="id">Identifier.</param>
    /// <param name="paramIn">Parameter in.</param>
    public void RemoveTheCard(Enums.IdTransformCard id, CardBehaviour paramIn)
    {
        // TODO: Check if it exists.
        if (cards.ContainsKey(Enums._IdTransformCard [(int)id]))
        {
            // TODO: Create the list of cards.
            List <CardBehaviour> paramCheck;

            // TODO: Try to get the value of cards.
            if (cards.TryGetValue(Enums._IdTransformCard [(int)id], out paramCheck))
            {
                // TODO: Check if the card exists.
                if (paramCheck.Contains(paramIn))
                {
                    // TODO: Return the value.
                    paramCheck.Remove(paramIn);
                }
            }
        }
    }
Exemplo n.º 17
0
    public int GetTotalCards(Enums.IdTransformCard id)
    {
        // TODO: Create the param will be returned.
        int total = 0;

        for (int i = 0; i < zoneCards.Length; i++)
        {
            // TODO: Check the condition to get total cards.
            if (zoneCards[i].Id == id)
            {
                // TODO: Get the list cards from id.
                var cardParam = GetTheListCards(id);

                // TODO: Get the count
                total = cardParam.Count;
            }
        }

        return(total);
    }
Exemplo n.º 18
0
    /// <summary>
    /// Adds the card into the list of cards.
    /// </summary>
    public void AddTheCard(Enums.IdTransformCard id, CardBehaviour paramIn)
    {
        // TODO: Check if this card is non exists in any transform.
        if (id == Enums.IdTransformCard.None)
        {
            return;
        }

        // TODO: Check if it exists.
        if (cards.ContainsKey(Enums._IdTransformCard [(int)id]))
        {
            // TODO: Create the list of cards.
            List <CardBehaviour> paramCheck;

            // TODO: Try to get the value of cards.
            if (cards.TryGetValue(Enums._IdTransformCard [(int)id], out paramCheck))
            {
                // TODO: Check if this card exists.
                if (paramCheck.Contains(paramIn))
                {
                    // TODO: Remove the old card.
                    paramCheck.Remove(paramIn);
                }

                // TODO: Add the new card to the list.
                paramCheck.Add(paramIn);
            }
            else
            {
                // TODO: Create the new list with the new card.
                cards[Enums._IdTransformCard [(int)id]] = new List <CardBehaviour> (new CardBehaviour[] { paramIn });
            }
        }
        else
        {
            // TODO: Create the new list with the new card.
            cards.Add(Enums._IdTransformCard [(int)id], new List <CardBehaviour> (new CardBehaviour[] { paramIn }));
        }
    }
Exemplo n.º 19
0
    public void UpdateTheStateCardsInZone(Enums.IdTransformCard id)
    {
        switch (GameManager.Instance.GameType)
        {
        case Enums.GameScenes.Tripeaks:

            // TODO: Get the cache.
            _TPlayingZone.UpdateTheStateCardsInZone(id);
            break;

        case Enums.GameScenes.Spider:

            // TODO: Get the cache.
            _SPlayingZone.UpdateTheStateCardsInZone(id);
            break;

        case Enums.GameScenes.Klondike:

            // TODO: Get the cache.
            //_KPlayingZone.UpdateTheStateCardsInZone (id);
            break;
        }
    }
Exemplo n.º 20
0
        public void UpdateTheStateCardsInZone(Enums.IdTransformCard id)
        {
            // TODO: Create the list of card.
            List <CardBehaviour> paramCheck = new List <CardBehaviour> ();

            // TODO: Get the list of cards.
            paramCheck.AddRange(PlayingZone.Instance.GetTheListCards(id));

            // TODO: Get the number of cards int the list.
            int length = paramCheck.Count;

            // TODO: Create the cache of card.
            CardBehaviour cardCache;

            if (length > 0)
            {
                cardCache = paramCheck [length - 1];

                // TODO: Check if this unlocking.
                if (cardCache.IsUnlocked())
                {
                    // TODO: can move this card.
                    cardCache.UpdateReadyToUse(Enums.StateCard.None);
                }
            }

            // TODO: Loop to check.
            for (int i = length - 1; i >= 0; i--)
            {
                // TODO: Set the cache.
                cardCache = paramCheck [i];

                if (object.ReferenceEquals(cardCache, null))
                {
                    // TODO: Break the functions.
                    throw new UnityException(Contains.NullExceptions);
                }

                // TODO: Check the state of card.
                if (!cardCache.IsUnlocked())
                {
                    // TODO: Break the function if the current card is locking.
                    break;
                }

                // TODO: Check if the lenght of card is smaller than 2.
                if (length > 1)
                {
                    // TODO: Check if state of i == 0.
                    if (i > 0)
                    {
                        // TODO: Get the condition to moving card.
                        if (cardCache.GetStateCard() == Enums.StateCard.None && paramCheck [i - 1].IsUnlocked() && paramCheck [i - 1].GetProperties().GetCardValue() == cardCache.GetProperties().GetCardValue() + 1 && paramCheck [i - 1].GetProperties().GetCardType() == cardCache.GetProperties().GetCardType())
                        {
                            // TODO: can move this card.
                            paramCheck [i - 1].UpdateReadyToUse(Enums.StateCard.None);
                        }
                        else
                        {
                            // TODO: can not move this card.
                            paramCheck [i - 1].UpdateReadyToUse(Enums.StateCard.Locking);
                        }
                    }
                }
            }
        }
Exemplo n.º 21
0
        public bool DoCheckPlayingZone(bool IsMoving = true)
        {
            // TODO: Get the zone of card.
            List <int> paramGet = new List <int>();

            // TODO: Check if this moving.
            if (IsMoving)
            {
                // TODO: Get the zone's id near this.
                paramGet.AddRange(PlayingZone.Instance.GetTheIdZonesMovingInside(card.transform.position));
            }
            else
            {
                // TODO: Get all id of zones.
                paramGet.AddRange(PlayingZone.Instance.GetTheListIdZones());
            }

            // TODO: Get the old zone.
            var zoneOld = PlayingZone.Instance.GetIdTransform(card);

            for (int i = 0; i < paramGet.Count; i++)
            {
                // TODO: Get the zone of card.
                Enums.IdTransformCard zoneGet = (Enums.IdTransformCard)paramGet[i];

                // TODO: Create the point to check ready to join.
                var IsReadyToJoin = false;

                // TODO: Check if this zone is not none.
                if (zoneGet != Enums.IdTransformCard.None && zoneOld != zoneGet)
                {
                    // TODO: Get the card.
                    card.TargetBehaviour = PlayingZone.Instance.GetTheLastCard(zoneGet);

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

                    // TODO: Check if ready to join.
                    if (IsReadyToJoin)
                    {
                        // TODO: Record Data.
                        UndoSystem.Instance.Record(Enums.Zone.Play, zoneOld, card, card.IsUnlocked());

                        // TODO: Get the list cards.
                        var cardsFollow = HelperZone.Instance.GetListCards();

                        for (int j = cardsFollow.Count - 1; j > -1; j--)
                        {
                            // TODO: Record datas.
                            UndoSystem.Instance.Record(Enums.Zone.Play, zoneOld, cardsFollow[j], cardsFollow[j].IsUnlocked(), true);
                        }


                        // TODO: Remove this card.
                        PlayingZone.Instance.RemoveTheCard(zoneOld, card);

                        // TODO: Get the new position need to moving.
                        card.TargetPosition = Helper.GetPositionInThePlayingZone(zoneGet, Enums.Direction.Down, card.IsUnlocked());

                        // TODO: Moving to the new position.
                        card.Moving(card.TargetPosition, () => {
                            // TODO: Set the new of parent.
                            card.transform.SetParent(PlayingZone.Instance.GetTransformCards(zoneGet));

                            // TODO: Sort this card in the view.
                            card.transform.SetAsLastSibling();

                            // TODO: Reset all the card follow.
                            card.DistributeTheFollowCards();

                            // TODO: Check the completed of a zone.
                            if (!PlayingZone.Instance.DoCompletedAListCards(zoneGet))
                            {
                                // TODO: Unlocking the last card.
                                PlayingZone.Instance.UnlockLastCard();

                                // TODO: Update the state of all cards.
                                PlayingZone.Instance.UpdateTheStateCardsInZone(zoneGet);
                            }

                            // TODO: Update the state of cards.
                            PlayingZone.Instance.UpdateTheStateCardsInZone(zoneOld);
                        });

                        // TODO: Add this card to the new zone.
                        PlayingZone.Instance.AddTheCard(zoneGet, card);

                        // TODO: Break the functions.
                        return(true);
                    }
                }
            }

            return(false);
        }
Exemplo n.º 22
0
    public void Record(Enums.Zone zone, Enums.IdTransformCard id, CardBehaviour card, bool IsUnlock, bool IsRecordInTheLastData = false, bool IsFollowCard = true)
    {
        List <RecordDatas> datas;

        if (IsRecordInTheLastData == true)
        {
            if (recordsData.Count == 0)
            {
                // TODO: Break the function.
                return;
            }
            else
            {
                // TODO: Get the list of record.
                recordsData.TryGetValue(recordsData.Count - 1, out datas);

                if (object.ReferenceEquals(datas, null))
                {
                    datas = new List <RecordDatas>();
                }
            }
        }
        else
        {
            datas = new List <RecordDatas>();
        }

        RecordDatas data = new RecordDatas();

        // ======================================== Set the value ================================= //

        // TODO: Update the id transform.
        data.idParents = id;

        // TODO: Update the zone.
        data.zone = zone;

        // TODO: Update the state unlock.
        data.IsUnlock = IsUnlock;

        // TODO: Set the default card.
        data.cards = card;

        // TODO: set the card save.
        data.cardSave = GamePlay.Instance.cardSaveCache;

        // TODO: Set the score.
        data.score = Contains.Score;

        // TODO: Set the state follow.
        data.IsFollowCard = IsFollowCard;

        // ======================================== Ends ================================= //

        datas.Add(data);

        if (IsRecordInTheLastData)
        {
            recordsData[recordsData.Count - 1] = datas;
        }
        else
        {
            recordsData.Add(recordsData.Count, datas);
        }
    }
Exemplo n.º 23
0
		/// <summary>
		/// Determines whether this instance is completed A list cards the specified id.
		/// </summary>
		public bool DoCompletedAListCards(Enums.IdTransformCard id)
		{
			// TODO: Create the key.
			string idKey = id.ToString ();

			// TODO: Create the value will be returned.
			bool IsCompleted = false;

			// TODO: Create the list will get the cards completed.
			List < CardBehaviour > paramOut = new List<CardBehaviour> ();

			// TODO: Check the key exists.
			if (PlayingZone.Instance.cards.ContainsKey (idKey)) {

				// TODO: Create the list of cards.
				List < CardBehaviour > paramGet = null;

				// TODO: Get the list of cards from the zones.
				if (PlayingZone.Instance.cards.TryGetValue (idKey, out paramGet)) {

					// TODO: Get the number of cards.
					int count = paramGet.Count;

					// TODO: Check if the number of cards is bigger than 0.
					if (count > 0) {

						// TODO: Check if the last card is one.
						if (paramGet [count - 1].GetProperties().GetEnumCardValue() == Enums.CardVariables.One) {

							// TODO: Add the card.
							paramOut.Add (paramGet [count - 1]);

							// TODO: Set the value will be returned is true.
							IsCompleted = true;

							// Create the number of count select cards.
							int numberCount = 1;

							// TODO: Loop to check the condition.
							for (int i = count - 1; i > 0; i--) {							

								// TODO: Check if both of cards unlocked.
								if (paramGet [i - 1].IsUnlocked () && paramGet [i].IsUnlocked () && numberCount < Contains.numberCardEachType) {

									// TODO: Check if the value of two cards is difference 1 unit and has the same type of card.
									if (paramGet [i].GetValue () != paramGet [i - 1].GetValue () - 1 || paramGet [i].GetProperties ().GetCardType () != paramGet [i - 1].GetProperties ().GetCardType ()) {

										// TODO: Break the function if the condition is not right.
										IsCompleted = false;

										// TODO: Break the loop.
										break;
									}

									numberCount++;

									// TODO: Add the card.
									paramOut.Add(paramGet[i - 1]);

								} else {

									if (numberCount != Contains.numberCardEachType) {						

										// TODO: Break the function if the condition is not right.
										IsCompleted = false;
									}

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

			// TODO: Doing complete with the condition.
			if (IsCompleted) {

				// TODO: Get the number of cards.
				int count = paramOut.Count;

				// TODO: Break the function if don't enough the cards.
				if (count == 0 || paramOut [count - 1].GetValue () != (int)Enums.CardVariables.King) {

					return false;
				}

				// TODO: Get the position moving.
				Vector3 position = Helper.GetPositionInTheResultZone ( Enums.IdTransformCard.TransformCards_A, Enums.Direction.Right, true);

				// TODO: Get the transform holder.
				Transform parent = ResultZone.Instance.GetTransformCards (Enums.IdTransformCard.TransformCards_A);

				// TODO: animation
				Timing.RunCoroutine(MovingEndCards(paramOut , position , parent , ()=> {

					// TODO: Unlock the last cards.
					UnlockLastCard();

					// TODO: Update the state of cards.
					UpdateTheStateCardsInZone(id);

					// TODO: Clear the undo
					UndoSystem.Instance.Clear();

				}), Enums.Tags.GamePlaying.ToString());
			}

			// TODO: Return the value.
			return IsCompleted;
		}
Exemplo n.º 24
0
        public bool DoCheckPlayingZone(bool IsMoving = true)
        {
            // TODO: Check the condition null.
            if (object.ReferenceEquals(GamePlay.Instance.cardSaveCache, null))
            {
                // TODO: Break the  function.
                return(false);
            }

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

            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)
            {
                Enums.IdTransformCard previousId = PlayingZone.Instance.GetIdTransform(card);

                // TODO: Record undo.
                UndoSystem.Instance.Record(Enums.Zone.Play, PlayingZone.Instance.GetIdTransform(card), card, card.IsUnlocked());

                // TODO: Get the dafult transform from zone.
                Transform parentTransform = ResultZone.Instance.GetTransformCards(Enums.IdTransformCard.TransformCards_A);

                // TODO: Get the position of card from zone.
                var position = Helper.GetPositionInTheResultZone(Enums.IdTransformCard.TransformCards_A, Enums.Direction.None, true);

                // TODO: Set the target position x for the card.
                card.TargetPosition.x = position.x;

                // TODO: Set the target position y for the card.
                card.TargetPosition.y = position.y;

                // TODO: Set the target position z for the card.
                card.TargetPosition.z = position.z;
                //Debug.Log("--card.POSITION: " + card.transform.position);
                //Debug.Log("--card.TargetPosition: " + card.TargetPosition);
                // TODO: Moving the card to new position.
                card.Moving(card.TargetPosition, parentTransform, () => {
                    if (PlayingZone.Instance.IsEmptyCards(previousId))
                    {
                        Vector3 positionFind = PlayingZone.Instance.GetDefaultPosition(previousId);

                        // TODO: Get the pool.
                        var objectEmptyThing = PoolSystem.Instance.GetFromPool(Enums.PoolType.PExploise);

                        if (!object.ReferenceEquals(objectEmptyThing, null))
                        {
                            // TODO: Enable the gameobject.
                            objectEmptyThing.gameObject.SetActive(true);

                            // TODO: Set the position.
                            objectEmptyThing.transform.position = positionFind;
                        }

                        var textEmptyThing = PoolSystem.Instance.GetFromPool(Enums.PoolType.TColorText);

                        if (!object.ReferenceEquals(textEmptyThing, null))
                        {
                            // TODO: Set the position.
                            textEmptyThing.transform.position = positionFind;

                            // TODO: Get the script.
                            var scriptEmptyFind = textEmptyThing.GetComponent <TScoreDisplay>();

                            // TODO: Check the condition to show.
                            if (!object.ReferenceEquals(scriptEmptyFind, null))
                            {
                                // TODO: Display the score.
                                scriptEmptyFind.Show(Contains._ScoreResultClear);

                                // TODO: Enable the gameobject.
                                textEmptyThing.gameObject.SetActive(true);
                            }
                        }

                        // TODO: Update the score.
                        Contains.Score += Contains.ScoreResultClear;

                        // TODO: Play the completed sound.
                        SoundSystems.Instance.PlaySound(Enums.SoundIndex.Completed);
                    }

                    // TODO: Play the correct sound.
                    SoundSystems.Instance.PlaySound(Enums.SoundIndex.Correct);

                    // TODO: Get the pool.
                    var objectThing = PoolSystem.Instance.GetFromPool(Enums.PoolType.PExploise);

                    if (!object.ReferenceEquals(objectThing, null))
                    {
                        // TODO: Enable the gameobject.
                        objectThing.gameObject.SetActive(true);

                        // TODO: Set the position.
                        objectThing.transform.position = card.TargetPosition;
                    }

                    var textThing = PoolSystem.Instance.GetFromPool(Enums.PoolType.TColorText);

                    if (!object.ReferenceEquals(textThing, null))
                    {
                        // TODO: Set the position.
                        textThing.transform.position = card.TargetPosition;

                        // TODO: Get the script.
                        var scriptFind = textThing.GetComponent <TScoreDisplay>();

                        // TODO: Check the condition to show.
                        if (!object.ReferenceEquals(scriptFind, null))
                        {
                            // TODO: Display the score.
                            scriptFind.Show(Contains._ScoreResultCards);

                            // TODO: Enable the gameobject.
                            textThing.gameObject.SetActive(true);
                        }
                    }

                    // TODO: Unlock the last card.
                    PlayingZone.Instance.UnlockLastCard();

                    // TODO: Update the state of card.
                    PlayingZone.Instance.UpdateTheStateCardsInZone();

                    // TODO: Update the score.
                    Contains.Score += Contains.ScoreResultCards;

                    // TODO: Update the display score.
                    UIBehaviours.Instance.UpdateScore();
                    //GamePlay.Instance.checkAutoWin();
                    if (GamePlay.Instance.IsConditionWining())
                    {
                        // TODO: Update the state of GameOver.
                        GameManager.Instance.UpdateState(Enums.StateGame.GameOver);

                        // TODO: Showing the wining dialog.
                        DialogSystem.Instance.ShowDialogWining();

                        var fireworks = PoolSystem.Instance.GetFromPool(Enums.PoolType.Fireworks);

                        if (!object.ReferenceEquals(fireworks, null))
                        {
                            fireworks.transform.SetParent(GamePlay.Instance.transform);

                            fireworks.transform.localPosition = Contains.Vector3Zero;

                            fireworks.gameObject.SetActive(true);
                        }

                        // TODO: Save the score.
                        PlayerData.BestScore = Contains.Score;

                        // TODO: Save the best move.
                        PlayerData.BestMove = Contains.Moves;

                        // TODO: Save the best time.
                        PlayerData.BestTime = Contains.Time;

                        // TODO: Play wining music.
                        SoundSystems.Instance.PlayerMusic(Enums.MusicIndex.WinMusic);
                    }
                });

                // TODO: Remove the card from list.
                PlayingZone.Instance.RemoveTheCard(card);

                // TODO: Add the card to the list result.
                ResultZone.Instance.AddTheCard(Enums.IdTransformCard.TransformCards_A, card);

                // TODO: Set the card save.
                GamePlay.Instance.cardSaveCache = card;

                return(true);
            }

            return(false);
        }
Exemplo n.º 25
0
    /// <summary>
    /// Gets the world position in the holder cards.
    /// </summary>
    public static Vector3 GetPositionInThePlayingZone(Enums.IdTransformCard id, Enums.Direction direction, bool IsUnlocked = false, float distanceUnlocked = Contains.DistanceSortUnlockedCards, float distanceLocked = Contains.DistanceSortLockedCards)
    {
        // TODO: Create the default position will be returned.
        Vector3 position = PlayingZone.Instance.GetWorldPosition(id);

        // TODO: Check if the position is not from the any cards.
        if (position.x != Contains.Vector3Null.x)
        {
            switch (direction)
            {
            case Enums.Direction.Down:

                // TODO: Check if this card unlocked.
                if (IsUnlocked)
                {
                    // TODO: Add Position.
                    position.y -= distanceUnlocked;
                }
                else
                {
                    // TODO: Add Position.
                    position.y -= distanceLocked;
                }

                break;

            case Enums.Direction.Left:

                // TODO: Check if this card unlocked.
                if (IsUnlocked)
                {
                    // TODO: Add Position.
                    position.x -= distanceUnlocked;
                }
                else
                {
                    // TODO: Add Position.
                    position.x -= distanceLocked;
                }

                break;

            case Enums.Direction.Right:

                // TODO: Check if this card unlocked.
                if (IsUnlocked)
                {
                    // TODO: Add Position.
                    position.x += distanceUnlocked;
                }
                else
                {
                    // TODO: Add Position.
                    position.x += distanceLocked;
                }

                break;

            case Enums.Direction.Up:

                // TODO: Check if this card unlocked.
                if (IsUnlocked)
                {
                    // TODO: Add Position.
                    position.y += distanceUnlocked;
                }
                else
                {
                    // TODO: Add Position.
                    position.y += distanceLocked;
                }

                break;
            }
        }
        else
        {
            position = PlayingZone.Instance.GetDefaultPosition(id);
        }

        // TODO: Return the position.
        return(position);
    }
Exemplo n.º 26
0
        /// <summary>
        /// Drawings the game handle.
        /// </summary>
        /// <returns>The game handle.</returns>
        IEnumerator <float> DrawingGameHandle()
        {
            // TODO: Create the default card.
            CardBehaviour cardCache = null;

            // TODO: Create the default position.
            Vector3 position = Contains.Vector3Zero;

            // TODO: Create the start transform.
            Enums.IdTransformCard idTransform = Enums.IdTransformCard.TransformCards_A;

            // TODO: Get the count increase.
            int countIncrease = 0;

            // TODO: Get the lenght of cards.
            int lenght = cardsGet.Count - 1;

            // TODO: Loop 28 times to draw the cards.
            for (int i = 0; i < 28; i++)
            {
                // TODO: Check don't enough cards to use.
                if (lenght <= i)
                {
                    // TODO: Throw the exception and stop the game.
                    throw new UnityException(Contains.NullExceptions);
                }

                // TODO: Set value of card.
                cardCache = cardsGet [i];

                // TODO: Check if this card is null.
                if (cardCache == null)
                {
                    // TODO: Throw the exception and stop the game.
                    throw new UnityException(Contains.NullExceptions);
                }

                // TODO: Get the dafult transform from zone.
                Transform parentTransform = PlayingZone.Instance.GetTransformCards(idTransform);

                // TODO: Get the position of card from zone.
                position = Helper.GetPositionInThePlayingZone(idTransform, Enums.Direction.Down);

                // TODO: Set the target position x for the card.
                cardCache.TargetPosition.x = position.x;

                // TODO: Set the target position y for the card.
                cardCache.TargetPosition.y = position.y;

                // TODO: Set the target position z for the card.
                cardCache.TargetPosition.z = position.z;

                // TODO: Moving the card to new position.
                cardCache.Moving(cardCache.TargetPosition, parentTransform);
                //Debug.Log("cardCache1 -- " + cardCache.TargetPosition);

                // TODO: Adding the card to the list of cards.
                PlayingZone.Instance.AddTheCard(idTransform, cardCache);

                // TODO: Playing the sound.
                SoundSystems.Instance.PlaySound(Enums.SoundIndex.Draw);

                // TODO: Waiting until next draw.
                yield return(Timing.WaitForSeconds(Contains.DurationDraw));

                // TODO: Get the next id of transform.
                idTransform = PlayingZone.Instance.GetNextIDTransform(idTransform);

                if (idTransform == Enums.IdTransformCard.TransformCards_A)
                {
                    if (countIncrease == PlayingZone.Instance.GetLenghtZone())
                    {
                        // TODO: Break the loop.
                        break;
                    }

                    countIncrease++;

                    for (int j = 0; j < countIncrease; j++)
                    {
                        idTransform = PlayingZone.Instance.GetNextIDTransform(idTransform);
                    }
                }
            }


            // TODO: Get the next id of transform.
            idTransform = Enums.IdTransformCard.TransformCards_A;

            // TODO: Get the dafult transform from zone.
            Transform defaulTransform = HintZone.Instance.GetTransformCards(idTransform);

            // TODO: Get the position of card from zone.
            position = Helper.GetPositionInTheHintZone(idTransform, Enums.Direction.Left);

            for (int i = 28; i <= lenght; i++)
            {
                // TODO: Check don't enough cards to use.
                if (lenght < i)
                {
                    // TODO: Throw the exception and stop the game.
                    throw new UnityException(Contains.NullExceptions);
                }
                // TODO: Set value of card.
                cardCache = cardsGet [i];

                // TODO: Check if this card is null.
                if (cardCache == null)
                {
                    // TODO: Throw the exception and stop the game.
                    throw new UnityException(Contains.NullExceptions);
                }

                // TODO: Set the target position x for the card.
                cardCache.TargetPosition.x = position.x;

                // TODO: Set the target position y for the card.
                cardCache.TargetPosition.y = position.y;

                // TODO: Set the target position z for the card.
                cardCache.TargetPosition.z = position.z;

                // TODO: Moving the card to new position.
                cardCache.Moving(cardCache.TargetPosition, defaulTransform, null, true);
                //Debug.Log("cardCache2 -- " + cardCache.TargetPosition);

                // TODO: Adding the card to the list of cards.
                HintZone.Instance.AddTheCard(idTransform, cardCache);

                // TODO: Play the sound.
                SoundSystems.Instance.PlaySound(Enums.SoundIndex.Draw);

                // TODO: Waiting until next draw.
                yield return(Timing.WaitForSeconds(Contains.DurationDraw));
            }

            // TODO: Waiting until next draw.
            yield return(Timing.WaitForSeconds(Contains.DurationDraw * 2));


            // TODO: Get the next id of transform.
            idTransform = HintZone.Instance.GetNextIDTransform(idTransform);

            // TODO: Unlocking the last cards in each arrays.
            PlayingZone.Instance.UnlockLastCard();

            yield return(0f);
        }
Exemplo n.º 27
0
        protected bool DoCheckResultZone(bool IsMoving = true)
        {
            // TODO: Check start with point.
            int IsCardsFromTheCheckPoint = (int)Enums.Zone.None;

            // TODO: Get the id zone from old.
            var zoneOld = ResultZone.Instance.GetIdTransform(card);

            if (zoneOld == Enums.IdTransformCard.None)
            {
                // TODO: Get zone from hint zone.
                zoneOld = HintZone.Instance.GetIdTransform(card);

                if (zoneOld != Enums.IdTransformCard.None)
                {
                    //TODO: Record the zone.
                    IsCardsFromTheCheckPoint = (int)Enums.Zone.Hint;
                }
                else
                {
                    zoneOld = PlayingZone.Instance.GetIdTransform(card);

                    if (zoneOld != Enums.IdTransformCard.None)
                    {
                        IsCardsFromTheCheckPoint = (int)Enums.Zone.Play;
                    }
                }
            }
            else
            {
                //TODO: Record the zone.
                IsCardsFromTheCheckPoint = (int)Enums.Zone.Result;
            }

            if (IsCardsFromTheCheckPoint == (int)Enums.Zone.Play)
            {
                if (HelperZone.Instance.GetCountCards() > 0)
                {
                    // TODO: Break the function.
                    return(false);
                }
            }

            // TODO: Get the card find.
            CardBehaviour cardFind = null;

            // TODO: Get the zone of card.
            List <int> paramGet = new List <int>();

            // TODO: Check if this moving.
            if (IsMoving)
            {
                // TODO: Get the zone's id near this.
                paramGet.AddRange(ResultZone.Instance.GetTheIdZonesMovingInside(card.transform.position));
            }
            else
            {
                // TODO: Get all id of zones.
                paramGet.AddRange(ResultZone.Instance.GetTheListIdZones());
            }

            // TODO: Loop to get the best zone.

            for (int i = 0; i < paramGet.Count; i++)
            {
                // TODO: Get the zone of card.
                Enums.IdTransformCard zoneGet = (Enums.IdTransformCard)paramGet[i];

                // TODO: Create the point to check ready to join.
                var IsReadyToJoin = false;

                // TODO: Check if this zone is not none.
                if (zoneGet != Enums.IdTransformCard.None && (IsCardsFromTheCheckPoint == (int)Enums.Zone.Result && zoneOld != zoneGet || IsCardsFromTheCheckPoint != (int)Enums.Zone.Result))
                {
                    // TODO: Get the card.
                    card.TargetBehaviour = ResultZone.Instance.GetTheLastCard(zoneGet);

                    // TODO: Check if this card is not null.
                    if (!object.ReferenceEquals(card.TargetBehaviour, null))
                    {
                        // TODO: Check if this card can join with this zone.
                        if (card.IsReadyToJoinZone(card.TargetBehaviour.GetProperties(), true))
                        {
                            // TODO: Set ready.
                            IsReadyToJoin = true;
                        }
                    }
                    else
                    {
                        if (card.GetValue() == (int)Enums.CardVariables.One)
                        {
                            // TODO: Set ready.
                            IsReadyToJoin = true;
                        }
                        else
                        {
                            IsReadyToJoin = false;
                        }
                    }
                }

                // TODO: The condition free not none.
                if (IsReadyToJoin)
                {
                    switch (IsCardsFromTheCheckPoint)
                    {
                    case (int)Enums.Zone.Hint:

                        // TODO: Record Data.
                        UndoSystem.Instance.Record(Enums.Zone.Hint, zoneOld, card, card.IsUnlocked());
                        break;

                    case (int)Enums.Zone.Result:

                        // TODO: Record Data.
                        UndoSystem.Instance.Record(Enums.Zone.Result, zoneOld, card, card.IsUnlocked());
                        break;

                    case (int)Enums.Zone.Play:

                        // TODO: Record Data.
                        UndoSystem.Instance.Record(Enums.Zone.Play, zoneOld, card, card.IsUnlocked());
                        break;
                    }


                    // TODO: Get the new position need to moving.
                    card.TargetPosition = Helper.GetPositionInTheResultZone(zoneGet, Enums.Direction.None, card.IsUnlocked());

                    // TODO: Moving to the new position.
                    card.Moving(card.TargetPosition, () => {
                        // TODO: Set the new of parent.
                        card.transform.SetParent(ResultZone.Instance.GetTransformCards(zoneGet));

                        // TODO: Sort this card in the view.
                        card.transform.SetAsLastSibling();

                        if (IsCardsFromTheCheckPoint != (int)Enums.Zone.Result && IsCardsFromTheCheckPoint != (int)Enums.Zone.None)
                        {
                            // TODO: Get the pool.
                            var objectEmptyThing = PoolSystem.Instance.GetFromPool(Enums.PoolType.PExploise);

                            if (!object.ReferenceEquals(objectEmptyThing, null))
                            {
                                // TODO: Enable the gameobject.
                                objectEmptyThing.gameObject.SetActive(true);

                                // TODO: Set the position.
                                objectEmptyThing.transform.position = card.TargetPosition;
                            }

                            var textThing = PoolSystem.Instance.GetFromPool(Enums.PoolType.TColorText);

                            if (!object.ReferenceEquals(textThing, null))
                            {
                                // TODO: Set the position.
                                textThing.transform.position = card.TargetPosition;

                                // TODO: Get the script.
                                var scriptFind = textThing.GetComponent <TScoreDisplay>();

                                // TODO: Check the condition to show.
                                if (!object.ReferenceEquals(scriptFind, null))
                                {
                                    Helper.StringBulding.Clear();

                                    // TODO: Append the string.
                                    Helper.StringBulding.Append(Contains.ScoreResultCards + Contains.ScoreResultCards * HelperZone.Instance.GetCountCards());

                                    // TODO: Display the score.
                                    scriptFind.Show(Helper.StringBulding.ToString());

                                    // TODO: Enable the gameobject.
                                    textThing.gameObject.SetActive(true);
                                }
                            }

                            // TODO: Update the score.
                            Contains.Score += Contains.ScoreResultCards + Contains.ScoreResultCards * HelperZone.Instance.GetCountCards();

                            // TODO: Update display score.
                            UIBehaviours.Instance.UpdateScore();
                        }

                        // TODO: Unlocking the last card.
                        PlayingZone.Instance.UnlockLastCard();

                        // TODO: Update the state of all cards.
                        PlayingZone.Instance.UpdateTheStateCardsInZone(zoneOld);
                    });

                    switch (IsCardsFromTheCheckPoint)
                    {
                    case (int)Enums.Zone.Hint:

                        // TODO: Remove this card from zone old.
                        HintZone.Instance.RemoveTheCard(zoneOld, card);

                        // TODO: Sort the cards of hint zone.
                        Helper.SortCards(HintZone.Instance.GetTheListCards(Enums.IdTransformCard.TransformCards_B), Enums.Direction.Right, HintZone.Instance.GetDefaultPosition(Enums.IdTransformCard.TransformCards_B), 3);

                        break;

                    case (int)Enums.Zone.Result:

                        // TODO: Remove this card.
                        ResultZone.Instance.RemoveTheCard(zoneOld, card);
                        break;

                    case (int)Enums.Zone.Play:

                        // TODO: Remove from zone old.
                        PlayingZone.Instance.RemoveTheCard(zoneOld, card);
                        break;
                    }

                    // TODO: Add this card to the new zone.
                    ResultZone.Instance.AddTheCard(zoneGet, card);

                    return(true);
                }
            }
            // TODO: Break the function.
            return(false);
        }
Exemplo n.º 28
0
        public bool DoCheckPlayingZone(bool IsMoving = true)
        {
            // TODO: Check the condition return.
            if (DoCheckResultZone(IsMoving))
            {
                //GamePlay.Instance.checkAutoWin();

                // TODO: Check the condition wining.
                if (GamePlay.Instance.IsConditionWining())
                {
                    // TODO: Update the state of GameOver.
                    GameManager.Instance.UpdateState(Enums.StateGame.GameOver);

                    // TODO: Showing the wining dialog.
                    DialogSystem.Instance.ShowDialogWining();

                    var fireworks = PoolSystem.Instance.GetFromPool(Enums.PoolType.Fireworks);

                    if (!object.ReferenceEquals(fireworks, null))
                    {
                        fireworks.transform.SetParent(GamePlay.Instance.transform);

                        fireworks.transform.localPosition = Contains.Vector3Zero;

                        fireworks.gameObject.SetActive(true);
                    }

                    // TODO: Save the score.
                    PlayerData.BestScore = Contains.Score;

                    // TODO: Save the best move.
                    PlayerData.BestMove = Contains.Moves;

                    // TODO: Save the best time.
                    PlayerData.BestTime = Contains.Time;

                    // TODO: Play wining music.
                    SoundSystems.Instance.PlayerMusic(Enums.MusicIndex.WinMusic);
                }

                // TODO: Break the function.
                return(true);
            }


            // TODO: Check start with point.
            int CardsFromTheCheckPoint = (int)Enums.Zone.None;

            // TODO: Get the old zone.
            var zoneOld = PlayingZone.Instance.GetIdTransform(card);

            // TODO: Get state zone from old zone.
            if (zoneOld == Enums.IdTransformCard.None)
            {
                zoneOld = HintZone.Instance.GetIdTransform(card);

                if (zoneOld == Enums.IdTransformCard.None)
                {
                    // TODO: Get the id transform.
                    zoneOld = ResultZone.Instance.GetIdTransform(card);


                    if (zoneOld == Enums.IdTransformCard.None)
                    {
                    }
                    else
                    {
                        CardsFromTheCheckPoint = (int)Enums.Zone.Result;
                    }
                }
                else
                {
                    CardsFromTheCheckPoint = (int)Enums.Zone.Hint;
                }
            }
            else
            {
                CardsFromTheCheckPoint = (int)Enums.Zone.Play;
            }

            // TODO: Get the zone of card.
            List <int> paramGet = new List <int>();

            // TODO: Check if this moving.
            if (IsMoving)
            {
                // TODO: Get the zone's id near this.
                paramGet.AddRange(PlayingZone.Instance.GetTheIdZonesMovingInside(card.transform.position));
            }
            else
            {
                // TODO: Get all id of zones.
                paramGet.AddRange(PlayingZone.Instance.GetTheListIdZones());
            }

            for (int i = 0; i < paramGet.Count; i++)
            {
                // TODO: Get the zone of card.
                Enums.IdTransformCard zoneGet = (Enums.IdTransformCard)paramGet[i];

                // TODO: Create the point to check ready to join.
                var IsReadyToJoin = false;

                // TODO: Check if this zone is not none.
                if (zoneGet != Enums.IdTransformCard.None && (CardsFromTheCheckPoint == (int)Enums.Zone.Play && zoneOld != zoneGet || CardsFromTheCheckPoint != (int)Enums.Zone.Play))
                {
                    // TODO: Get the card.
                    card.TargetBehaviour = PlayingZone.Instance.GetTheLastCard(zoneGet);

                    // TODO: Check if this card is not null.
                    if (!object.ReferenceEquals(card.TargetBehaviour, null))
                    {
                        // TODO: Check if this card can join with this zone.
                        if (card.IsReadyToJoinZone(card.TargetBehaviour.GetProperties(), false, GameManager.Instance.GetModeGame() == Enums.ModeGame.Easy))
                        {
                            // TODO: Set ready.
                            IsReadyToJoin = true;
                        }
                    }
                    else
                    {
                        if (card.GetValue() == (int)Enums.CardVariables.King)
                        {
                            // TODO: Set ready.
                            IsReadyToJoin = true;
                        }
                        else
                        {
                            IsReadyToJoin = false;
                        }
                    }

                    // TODO: Check if ready to join.
                    if (IsReadyToJoin)
                    {
                        switch (CardsFromTheCheckPoint)
                        {
                        case (int)Enums.Zone.Play:

                            // TODO: Record Data.
                            UndoSystem.Instance.Record(Enums.Zone.Play, zoneOld, card, card.IsUnlocked());
                            break;

                        case (int)Enums.Zone.Hint:

                            // TODO: Record Data.
                            UndoSystem.Instance.Record(Enums.Zone.Hint, zoneOld, card, card.IsUnlocked());
                            break;

                        case (int)Enums.Zone.Result:


                            // TODO: Record Data.
                            UndoSystem.Instance.Record(Enums.Zone.Result, zoneOld, card, card.IsUnlocked());
                            break;
                        }


                        // TODO: Get the list cards.
                        var cardsFollow = HelperZone.Instance.GetListCards();

                        // TODO: Check start with point.
                        bool IsReadyGetPoint = true;

                        for (int j = cardsFollow.Count - 1; j > -1; j--)
                        {
                            switch (CardsFromTheCheckPoint)
                            {
                            case (int)Enums.Zone.Play:

                                // TODO: Record datas.
                                UndoSystem.Instance.Record(Enums.Zone.Play, zoneOld, cardsFollow[j], cardsFollow[j].IsUnlocked(), true);
                                break;

                            case (int)Enums.Zone.Hint:

                                // TODO: Record datas.
                                UndoSystem.Instance.Record(Enums.Zone.Hint, zoneOld, cardsFollow[j], cardsFollow[j].IsUnlocked(), true);
                                break;

                            case (int)Enums.Zone.Result:

                                // TODO: Record datas.
                                UndoSystem.Instance.Record(Enums.Zone.Result, zoneOld, cardsFollow[j], cardsFollow[j].IsUnlocked(), true);
                                break;
                            }
                        }

                        switch (CardsFromTheCheckPoint)
                        {
                        case (int)Enums.Zone.Play:


                            // TODO: Remove this card.
                            PlayingZone.Instance.RemoveTheCard(zoneOld, card);
                            break;

                        case (int)Enums.Zone.Hint:

                            // TODO: Remove this card.
                            HintZone.Instance.RemoveTheCard(zoneOld, card);
                            break;

                        case (int)Enums.Zone.Result:

                            // TODO: Remove this card.
                            ResultZone.Instance.RemoveTheCard(zoneOld, card);
                            break;
                        }

                        // TODO: Get the new position need to moving.
                        card.TargetPosition = Helper.GetPositionInThePlayingZone(zoneGet, Enums.Direction.Down, card.IsUnlocked());
                        //Debug.Log("qq -- " + card.TargetPosition);

                        // TODO: Moving to the new position.
                        card.Moving(card.TargetPosition, () => {
                            // TODO: Set the new of parent.
                            card.transform.SetParent(PlayingZone.Instance.GetTransformCards(zoneGet));

                            // TODO: Sort this card in the view.
                            card.transform.SetAsLastSibling();

                            if (IsReadyGetPoint)
                            {
                                if (CardsFromTheCheckPoint == (int)Enums.Zone.Result)
                                {
                                    var textThing = PoolSystem.Instance.GetFromPool(Enums.PoolType.TColorText);

                                    if (!object.ReferenceEquals(textThing, null))
                                    {
                                        // TODO: Set the position.
                                        textThing.transform.position = card.TargetPosition;

                                        // TODO: Get the script.
                                        var scriptFind = textThing.GetComponent <TScoreDisplay>();

                                        // TODO: Check the condition to show.
                                        if (!object.ReferenceEquals(scriptFind, null))
                                        {
                                            Helper.StringBulding.Clear();

                                            // TODO: Append the string.
                                            Helper.StringBulding.Append("-").Append(Contains.ScoreResultCards);

                                            // TODO: Display the score.
                                            scriptFind.Show(Helper.StringBulding.ToString());

                                            // TODO: Enable the gameobject.
                                            textThing.gameObject.SetActive(true);
                                        }
                                    }

                                    // TODO: Update the score.
                                    Contains.Score -= Contains.ScoreResultCards;
                                }

                                // TODO: Update display score.
                                UIBehaviours.Instance.UpdateScore();
                            }

                            // TODO: Reset all the card follow.
                            card.DistributeTheFollowCards();

                            switch (CardsFromTheCheckPoint)
                            {
                            case (int)Enums.Zone.Play:

                                // TODO: Unlock the last card.
                                PlayingZone.Instance.UnlockLastCard();

                                // TODO: Update the state of cards.
                                PlayingZone.Instance.UpdateTheStateCardsInZone(zoneOld);
                                break;
                            }
                        });

                        // TODO: Add this card to the new zone.
                        PlayingZone.Instance.AddTheCard(zoneGet, card);

                        // TODO: Break the functions.
                        return(true);
                    }
                }
            }

            return(false);
        }
Exemplo n.º 29
0
        /// <summary>
        /// Draws the cards.
        /// </summary>
        IEnumerator <float> _DrawCards(int numberCards)
        {
            // TODO: reset the undo.
            UndoSystem.Instance.Clear();

            // TODO: Get the list Cards from the zone.
            List <CardBehaviour> paramIn = HintZone.Instance.GetTheListCards(Enums.IdTransformCard.TransformCards_A);

            // TODO: Count the number of cards.
            int length = paramIn.Count;

            // TODO: Create the start transform.
            Enums.IdTransformCard idTransform = Enums.IdTransformCard.TransformCards_A;

            // TODO: Get the limit of cards will be drawn.
            int limit = Mathf.Clamp(length - Contains.numberColumn, 0, int.MaxValue);

            // TODO: Create the cache.
            CardBehaviour cardCache;

            // TODO: Create the cache of position.
            Vector3 position = Contains.Vector3Zero;

            // TODO: Loop to get the cards.
            for (int i = length - 1; i >= limit; i--)
            {
                // TODO: Set value of card.
                cardCache = paramIn [i];

                // TODO: Check if this card is null.
                if (cardCache == null)
                {
                    // TODO: Throw the exception and stop the game.
                    throw new UnityException(Contains.NullExceptions);
                }

                // TODO: Get the dafult transform from zone.
                Transform parentTransform = PlayingZone.Instance.GetTransformCards(idTransform);

                // TODO: Get the position of card from zone.
                position = Helper.GetPositionInThePlayingZone(idTransform, Enums.Direction.Down, PlayingZone.Instance.IsLastCardUnlocked(idTransform));

                // TODO: Set the target position x for the card.
                cardCache.TargetPosition.x = position.x;

                // TODO: Set the target position y for the card.
                cardCache.TargetPosition.y = position.y;

                // TODO: Set the target position z for the card.
                cardCache.TargetPosition.z = position.z;

                // TODO: Moving the card to new position.
                cardCache.Moving(cardCache.TargetPosition, parentTransform);

                // TODO: Adding the card to the list of cards.
                PlayingZone.Instance.AddTheCard(idTransform, cardCache);

                // TODO: Playing the sound.
                SoundSystems.Instance.PlaySound(Enums.SoundIndex.Draw);

                // TODO: Remove the cards from the list.
                HintZone.Instance.RemoveTheCard(cardCache);

                // TODO: Waiting until next draw.
                yield return(Timing.WaitForSeconds(Contains.DurationDraw));

                // TODO: Get the next id of transform.
                idTransform = PlayingZone.Instance.GetNextIDTransform(idTransform);
            }

            // TODO: Unlocking the last cards in each arrays.
            PlayingZone.Instance.UnlockLastCard();

            // TODO: update the state of all cards.
            PlayingZone.Instance.UpdateTheStateCardsInZone();

            yield return(0f);

            // TODO: Check the current state of game.
            if (GameManager.Instance.GetStateGame() == Enums.StateGame.Drawing)
            {
                // TODO: Update the current state.
                GameManager.Instance.UpdateState(Enums.StateGame.Playing);
            }
        }