Exemple #1
0
    public IEnumerator CheckMoveCo()
    {
        yield return(new WaitForSeconds(.3f));

        if (otherDot != null)
        {
            if (!isMatched && !otherDot.GetComponent <Gems>().isMatched)
            {
                otherDot.GetComponent <Gems>().row    = row;
                otherDot.GetComponent <Gems>().column = column;
                row    = previousRow;
                column = previousColumn;
                yield return(new WaitForSeconds(.3f));

                board.currentState = GameState.move;
            }
            else
            {
                if (endGameManager != null)
                {
                    if (endGameManager.requirements.gameType == GameType.Moves)
                    {
                        endGameManager.DecreaseCounterValue();
                    }
                }
                board.DestroyMatches();
            }
            otherDot = null;
        }
    }
    public IEnumerator CheckMoveCo()
    {
        yield return(new WaitForSeconds(.5f));

        if (otherCake != null)
        {
            if (!isMatched && !otherCake.GetComponent <Cake>().isMatched)
            {
                otherCake.GetComponent <Cake>().row    = row;
                otherCake.GetComponent <Cake>().column = column;
                row    = previousRow;
                column = previousColumn;
                yield return(new WaitForSeconds(.5f));

                board.currentState = GameState.move;
            }
            else
            {
                if (endGameManager != null)
                {
                    if (endGameManager.requirement.gameType == GameType.Move)
                    {
                        endGameManager.DecreaseCounterValue(findMaches.currentMatches.Count);
                    }
                }
                board.DestroyMatches();
            }
            //otherCake = null;
        }
    }
    public IEnumerator CheckMoveCo()
    {
        // if the current tile or other tile is a colour bomb - do the thing
        if (isColourBomb)
        {
            // This piece is a colour bomb and other piece is colour to destroy
            findMatches.MatchPiecesOfColour(otherShapeTile.tag);
            isMatched = true;
        }
        else if (otherShapeTile.GetComponent <ShapeTile>().isColourBomb)
        {
            // The other tile is a colour bomb, and this piece is the colour to destroy
            findMatches.MatchPiecesOfColour(this.gameObject.tag);
            otherShapeTile.GetComponent <ShapeTile>().isMatched = true;
        }

        // Wait for 5 seconds
        yield return(new WaitForSeconds(.2f));

        // Check to see if this Shape or another is matched
        if (otherShapeTile != null)
        {
            // if our current shape tile AND the other shape tile isn't matched - do the thing
            if (!isMatched && !otherShapeTile.GetComponent <ShapeTile>().isMatched)
            {
                // Set the other shape tiles position to this tiles position
                otherShapeTile.GetComponent <ShapeTile>().row    = row;
                otherShapeTile.GetComponent <ShapeTile>().column = column;
                // Set this tiles row and tile position to its previous position
                row    = previousRow;
                column = previousColumn;
                // Wait for half a second, then set the game state to move
                yield return(new WaitForSeconds(.2f));

                board.currentTile  = null;
                board.currentState = GameState.move;
            }
            else
            {
                // If the endGameManager was assigned
                if (endGameManager != null)
                {
                    // If the game type is Moves
                    if (endGameManager.requirements.gameType == GameType.Moves)
                    {
                        // Decrease counter
                        endGameManager.DecreaseCounterValue();
                    }
                }
                board.DestroyMatches();
            }
            //otherShapeTile = null;
        }
    }
Exemple #4
0
    public IEnumerator CheckMoveCo()
    {
        if (isColorBomb)
        {
            //La pièce actuelle est la color bomb et l'autre est celle ayant la couleur à détruire
            findMatches.MatchPiecesOfColor(otherDot.tag);
            isMatched = true;
        }
        else if (otherDot.GetComponent <Dot>().isColorBomb)
        {
            //L'autre pièce est la color bomb et la pièce actuelle est celle ayant la couleur à détruire
            findMatches.MatchPiecesOfColor(this.gameObject.tag);
            otherDot.GetComponent <Dot>().isMatched = true;
        }
        yield return(new WaitForSeconds(.5f));

        if (otherDot != null)
        {
            //Si les deux dot qu'on veut échanger ne forme pas trois mêmes dots consécutives, on les remets à leurs places (on ne les échange pas)
            if (!isMatched && !otherDot.GetComponent <Dot>().isMatched)
            {
                otherDot.GetComponent <Dot>().row    = row;
                otherDot.GetComponent <Dot>().column = column;
                row    = previousRow;
                column = previousColumn;
                yield return(new WaitForSeconds(.5f));

                board.currentDot   = null;
                board.currentState = GameState.move;
            }
            else
            {
                if (endGameManager != null)
                {
                    //vérifier si la condition d'arret du jeu est le nb de mouvements ou le temps
                    if (endGameManager.requirements.gameType == GameType.Moves)
                    {
                        endGameManager.DecreaseCounterValue();
                    }
                }
                board.DistroyMatches();
            }

            //otherDot = null;
        }
    }
Exemple #5
0
        private IEnumerator CheckMoveCoroutine()
        {
            if (isColorBomb)
            {
                //this piece is a color bomb and the other piece is the color to destroy
                findMatches.MatchPiecesOfColor(gameObject.tag);
                nextDot.GetComponent <Element>().isMatched = true;
            }
            else if (nextDot.GetComponent <Element>().isColorBomb)
            {
                //the other piece is the color bomb and this piece has the color to destroy
                findMatches.MatchPiecesOfColor(nextDot.tag);
                isMatched = true;
            }

            //todo убрать задержки
            yield return(new WaitForSeconds(.5f));

            if (nextDot != null)
            {
                var nextDotComponent = nextDot.GetComponent <Element>();
                if (!isMatched && !nextDotComponent.isMatched)
                {
                    nextDotComponent.row    = row;
                    nextDotComponent.column = column;
                    row    = previousRow;
                    column = previousColumn;
                    //todo убрать задержки
                    yield return(new WaitForSeconds(.5f));

                    board.currentElement = null;
                    board.currentState   = GameState.MOVE;
                }
                else
                {
                    if (endGameManager != null)
                    {
                        if (endGameManager.requirementState.levelLimitationType == LevelLimitationType.MOVES)
                        {
                            endGameManager.DecreaseCounterValue();
                        }
                    }
                    board.DestroyMatches();
                }
            }
        }
Exemple #6
0
    //Diğer kodlarla eş zamanda ve şartlar sağlanana kadar çalışan bir metotdur (corutine). Şartlar sağlandığında ise, yani hexi hareket ettirdiğimiz yerde eşleşme yoksa, hex hareket ettirildiği yere geri döner.
    public IEnumerator CheckMoveCo()
    {
        if (isColorBomb)
        {
            //Bu parça renk bombasıdır ve diğer parça da yok edilecek olan renktir.
            findMatches.MatchPiecesOfColor(otherHex.tag);
            isMatched = true;
        }
        else if (otherHex.GetComponent <Hex>().isColorBomb)
        {
            //Diğer parça renk bombasıdır ve bu parça da yok edilecek olan renktir.
            findMatches.MatchPiecesOfColor(this.gameObject.tag);
            otherHex.GetComponent <Hex>().isMatched = true;
        }

        yield return(new WaitForSeconds(.5f));

        if (otherHex != null)
        {
            if (!isMatched && !otherHex.GetComponent <Hex>().isMatched)
            {
                otherHex.GetComponent <Hex>().column = column;
                otherHex.GetComponent <Hex>().row    = row;
                row    = previousRow;
                column = previousColumn;

                yield return(new WaitForSeconds(.5f));

                board.currentHex   = null;
                board.currentState = GameState.move;
            }
            else
            {
                if (endGameManager != null)
                {
                    if (endGameManager.requirements.gameType == GameType.Moves)
                    {
                        endGameManager.DecreaseCounterValue();
                    }
                }
                board.DestrowMatches();
            }
            //otherHex = null;
        }
    }
Exemple #7
0
    public IEnumerator CheckMoveCo()
    {
        if (isColorBomb)
        {
            //this piece is color bomb and the other pieces are color to destroy
            findMatches.MatchPiecesOfColor(otherDot.tag);
            isMatched = true;
        }
        else if (otherDot.GetComponent <Dot>().isColorBomb)
        {
            //the other piece is a color bomb and this piece has the color to destroy
            findMatches.MatchPiecesOfColor(this.gameObject.tag);
            otherDot.GetComponent <Dot>().isMatched = true;
        }
        yield return(new WaitForSeconds(.5f));

        if (otherDot != null)
        {
            if (!isMatched && !otherDot.GetComponent <Dot>().isMatched)
            {
                otherDot.GetComponent <Dot>().row    = row;
                otherDot.GetComponent <Dot>().column = column;
                row    = previousRow;
                column = previousColumn;
                yield return(new WaitForSeconds(.5f));

                board.currentDot   = null;
                board.currentState = GameState.move;
            }
            else
            {
                if (endGameManager != null)
                {
                    if (endGameManager.requirements.gameType == GameType.Moves)
                    {
                        endGameManager.DecreaseCounterValue();
                    }
                }


                StartCoroutine(board.DestroyMatches());
            }
            //otherDot = null;
        }
    }
Exemple #8
0
    public IEnumerator CheckMoveCo() //карантин,если не сходятся цвета, то возврат напредыдущую позицию
    {
        if (isColorBomb)             //взрывы по цвету
        {
            //этот кусок - цветная бомба, а другой - цвет, который нужно уничтожить
            findMatches.MatchPiecesOfColor(otherCircle.tag);
            isMatched = true;
        }
        else if (otherCircle.GetComponent <Circle>().isColorBomb)
        {
            //другая часть - цветная бомба, и эта часть имеет цвет, чтобы разрушить
            findMatches.MatchPiecesOfColor(this.gameObject.tag);
            otherCircle.GetComponent <Circle>().isMatched = true;
        }

        yield return(new WaitForSeconds(0.5f)); //задержка на возвращение на предыдущее место, если не сошлись цвета

        if (otherCircle != null)
        {
            if (!isMatched && !otherCircle.GetComponent <Circle>().isMatched)
            {
                otherCircle.GetComponent <Circle>().row    = row;
                otherCircle.GetComponent <Circle>().column = column;
                row    = previousRow;
                column = previousColumns;
                yield return(new WaitForSeconds(0.5f));//запрет на ход - задержка для возврата кругов на исходные места если не совпали

                board.currentCircle = null;
                board.currentState  = GameState.move;
            }
            else
            {
                if (endGameManager != null)
                {
                    if (endGameManager.requirements.gameType == GameType.Moves)
                    {
                        endGameManager.DecreaseCounterValue();
                    }
                }
                board.DestroyMatches();
            }
            //otherCircle = null;
        }
    }
Exemple #9
0
    }//MovePiece Method

    public IEnumerator CheckIsMatch()
    {
        if (isColorBomb)//this piece is colorbomb, and other piece of same color to Destory
        {
            matchFinder.MatchPiecesOfColor(otherDot.tag);
            isMatched = true;
        }
        else if (otherDot.GetComponent <Dots>().isColorBomb)//other piece is colorbomb, and this piece of same color to Destory
        {
            matchFinder.MatchPiecesOfColor(this.gameObject.tag);
            otherDot.GetComponent <Dots>().isMatched = true;
        }
        yield return(new WaitForSeconds(.5f));

        if (otherDot != null)
        {
            if (!otherDot.GetComponent <Dots>().isMatched&& !isMatched)
            {
                otherDot.GetComponent <Dots>().row    = row;
                otherDot.GetComponent <Dots>().column = column;
                row             = previousRow;
                column          = previousColumn;
                board.playState = PlayState.Move;
                // board.currentDot = null;
            }
            else
            {
                if (endGameManager != null)
                {
                    if (endGameManager.requirements.gameType == GameType.Moves)
                    {
                        endGameManager.DecreaseCounterValue();
                    }
                }
                board.DestoryMatch();
            }
        }
        else
        {
            board.playState = PlayState.Move;
        }
    }
Exemple #10
0
    public IEnumerator CheckMoveCoroutine()
    {
        if (isColorBomb)
        {
            findMatches.MatchesPiecesOfColor(otherDot.tag);
            isMatched = true;
        }
        else if (otherDot.GetComponent <Dot>().isColorBomb)
        {
            findMatches.MatchesPiecesOfColor(this.gameObject.tag);
            otherDot.GetComponent <Dot>().isMatched = true;
        }

        board.currentDot = this;
        yield return(new WaitForSeconds(board.refillDelay));

        if (otherDot != null)
        {
            if (!isMatched && !otherDot.GetComponent <Dot>().isMatched)
            {
                otherDot.GetComponent <Dot>().row    = row;
                otherDot.GetComponent <Dot>().column = column;
                row    = originalRow;
                column = originalColumn;
                yield return(new WaitForSeconds(board.refillDelay));

                board.currentDot       = null;
                board.currentGameState = GameState.move;
            }
            else
            {
                if (endGameManager != null)
                {
                    if (endGameManager.requirements.gameType == GameType.Moves)
                    {
                        endGameManager.DecreaseCounterValue();
                    }
                }
                board.DestroyMatches();
            }
        }
    }
Exemple #11
0
    public IEnumerator CheckMoveCo()
    {
        if (isColourBomb)
        {
            //This piece is colour explosion, other piece colour to destroy
            findMatches.MatchPiecesOfColour(otherDot.tag);
            isMatched = true;
            moveToMatchCounter++;
        }
        else if (otherDot.GetComponent <Dot>().isColourBomb)
        {
            // The other piece is a color bomb, this piece has colour to destroy
            findMatches.MatchPiecesOfColour(this.gameObject.tag);
            otherDot.GetComponent <Dot>().isMatched = true;
            moveToMatchCounter++;
        }

        yield return(new WaitForSeconds(.5f));

        if (otherDot != null)
        {
            if (!isMatched && !otherDot.GetComponent <Dot>().isMatched)
            {
                otherDot.GetComponent <Dot>().row    = row;
                otherDot.GetComponent <Dot>().column = column;
                row    = previousRow;
                column = previousColumn;


                audioSource.enabled = true;

                if (!audioSource.isPlaying)
                {
                    audioSource.clip = wrong;
                    audioSource.Play();
                }

                if (board.AllJuice == true || board.someJuice == true)
                {
                    shake.TriggerShake();
                }

                wrongMoveCounter++;

                yield return(new WaitForSeconds(.5f));

                board.currentDot   = null;
                board.currentState = GameState.move;
            }
            else
            {
                if (endGameManager != null)
                {
                    if (endGameManager.requirements.gameType == GameType.Moves)
                    {
                        endGameManager.DecreaseCounterValue();
                    }
                }

                board.DestroyMatches();
            }
        }
    }