Esempio n. 1
0
 public virtual void Update()
 {
     if (!GridHasEmpty())
     {
         if (matchManager.GridHasMatch())
         {
             matchManager.RemoveMatches();
         }
         else
         {
             inputManager.SelectToken();
         }
     }
     else
     {
         if (!moveTokenManager.move)
         {
             moveTokenManager.SetupTokenMove();
         }
         if (!moveTokenManager.MoveTokensToFillEmptySpaces())
         {
             repopulateManager.AddNewTokensToRepopulateGrid();
         }
     }
 }
    public virtual void Update()
    {
        //every frame, check whether the grid is full of tokens.

        if (!GridHasEmpty())
        {
            //if the grid is full of tokens and has matches, remove them.
            if (matchManager.GridHasMatch())
            {
                matchManager.RemoveMatches();
            }
            else
            {
                //if the grid is full and there are no matches, wait for the player to make a move (and look for it in InputManager)
                inputManager.SelectToken();
            }
        }
        else
        {
            if (!moveTokenManager.move)
            {
                //if the icons are currently moving, set them up to move and leave it be
                moveTokenManager.SetupTokenMove();
            }
            if (!moveTokenManager.MoveTokensToFillEmptySpaces())
            {
                //if the MoveTokenManager hasn't added any tokens to the grid
                //tell Repopulate Script to add new tokens
                repopulateManager.AddNewTokensToRepopulateGrid();
            }
        }
    }
Esempio n. 3
0
 public virtual void Update()
 {
     if (!GridHasEmpty())                  //if grid is fully populated
     {
         if (matchManager.GridHasMatch())  //if there are matches
         {
             matchManager.RemoveMatches(); //remove the matches
         }
         else
         {
             inputManager.SelectToken();                 //allow token to be selected
         }
     }
     else                                                      //if grid not fully populated
     {
         if (!moveTokenManager.move)                           //if token movement is false
         {
             moveTokenManager.SetupTokenMove();                //set it true so they can fill empty space
         }
         if (!moveTokenManager.MoveTokensToFillEmptySpaces())  //if is false
         {
             repopulateManager.AddNewTokensToRepopulateGrid(); //and there are still free spaces, allow it to populate
         }
     }
 }
    public virtual void Update()
    {
        if (!GridHasEmpty())                  //if the grid has no empty spots
        {
            if (matchManager.GridHasMatch())  //check if it has a match or not
            {
                matchManager.RemoveMatches(); //remove the matches if it has
            }
            else
            {
                inputManager.SelectToken();                 //let manager check to see if we clicked on a token
            }
        }

        else
        {
            if (!moveTokenManager.move)
            {
                moveTokenManager.SetupTokenMove();
            }
            if (!moveTokenManager.MoveTokensToFillEmptySpaces())
            {
                repopulateManager.AddNewTokensToRepopulateGrid();
            }
        }
    }
    public virtual void Update()
    {
        //update moves left
        movesText.text = "Moves Left: " + MovesLeft;
        //update your score
        playerScoreText.text = "Your Score: " + PlayerScore;
        //update their score
        opponentScoreText.text = "Their Score: " + OpponentScore;

        switch (currentState)
        {
        case GameState.BoardSettled:
            if (isPlayersTurn)
            {
                currentState = GameState.PlayerMakingMove;
            }
            else
            {
                currentState = GameState.OpponentMakingMove;
            }
            break;

        case GameState.PlayerMakingMove:
            inputManager.SelectToken();
            if (matchManager.GridHasMatch())
            {
                //isPlayersTurn = false;
                movesLeft--;
                currentState = GameState.RemovingMatches;
            }
            break;

        case GameState.OpponentMakingMove:
            StartCoroutine(opponentController.OpponentMove());
            currentState = GameState.CheckingMatch;
            break;

        case GameState.CheckingMatch:
            if (matchManager.GridHasMatch())
            {
                //isPlayersTurn = true;
                currentState = GameState.RemovingMatches;
            }
            else if (!moveTokenManager.move)
            {
                currentState = GameState.OpponentMakingMove;
            }
            break;

        case GameState.RemovingMatches:
            matchManager.RemoveMatches();
            if (GridHasEmpty() && !moveTokenManager.MoveTokensToFillEmptySpaces())
            {
                currentState = GameState.FillingBoard;
            }
            break;

        case GameState.FillingBoard:
            if (!moveTokenManager.move)
            {
                moveTokenManager.SetupTokenMove();
            }
            if (!moveTokenManager.MoveTokensToFillEmptySpaces())
            {
                repopulateManager.AddNewTokensToRepopulateGrid();
            }
            if (matchManager.GridHasMatch())
            {
                currentState = GameState.RemovingMatches;
            }
            if (!GridHasEmpty() && !matchManager.GridHasMatch())
            {
                isPlayersTurn = !isPlayersTurn;
                currentState  = GameState.BoardSettled;
            }
            break;
        }

        if (Input.GetKey(KeyCode.R))
        {
            SceneManager.LoadScene(0);
        }

        if (MovesLeft <= 0 && !moveTokenManager.move)
        {
            GameOver();
        }
    }
Esempio n. 6
0
    public virtual void Update()
    {
        if (!PlayerLost)
        {
            timer += Time.deltaTime;

            //check to see if the game is over
            if (!music.isPlaying && !gameOver)
            {
                gameOver = GameOver(SUCCESS_MARKER);
                return;
            }

            //each beat, check for matches
            if (!GridHasEmpty() && timer >= timeBetweenBeats)
            {
                if (matchManager.GridHasMatch())
                {
                    matchManager.RemoveMatches();
                    numberManager.ScorePoints();

                    //check to see if the game is over
                }
            }
            else if (!GridHasEmpty())
            {
                inputManager.SelectToken();                 //if not on the beat, allow the player to make selections
            }

            //if there are empty spaces, tokens need to move
            if (GridHasEmpty())
            {
                if (!moveTokenManager.move)
                {
                    //if the icons are currently moving, set them up to move and leave it be
                    moveTokenManager.SetupTokenMove();
                }
                if (!moveTokenManager.MoveTokensToFillEmptySpaces())
                {
                    //if the MoveTokenManager hasn't added any tokens to the grid
                    //tell Repopulate Script to add new tokens
                    repopulateManager.AddNewTokensToRepopulateGrid();
                }
            }

            //keep on the beat
            if (timer >= timeBetweenBeats)
            {
                timer = 0.0f;
            }
        }
        else if (PlayerLost)
        {
            failTimer       += Time.deltaTime;
            healthText.color = failColor;

            if (failTimer >= failGameEndDelay)
            {
                GameOver(FAIL_MARKER);
            }
        }

        //every frame, check whether the grid is full of tokens.

//		if(!GridHasEmpty()){
//			//if the grid is full of tokens and has matches, remove them.
//			if(matchManager.GridHasMatch()){
//				matchManager.RemoveMatches();
//			} else {
//				//if the grid is full and there are no matches, wait for the player to make a move (and look for it in InputManager)
//				inputManager.SelectToken();
//			}
//
//		} else {
//			if(!moveTokenManager.move){
//				//if the icons are currently moving, set them up to move and leave it be
//				moveTokenManager.SetupTokenMove();
//			}
//			if(!moveTokenManager.MoveTokensToFillEmptySpaces()){
//				//if the MoveTokenManager hasn't added any tokens to the grid
//				//tell Repopulate Script to add new tokens
//				repopulateManager.AddNewTokensToRepopulateGrid();
//			}
//		}
    }