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); }
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); }
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); }