Vector2 exchangeGridPos2;                    //The position of exchangeToken2 in the scene.

    public virtual void Start()
    {
        gameManager      = GetComponent <GameManagerScript>();  //Set the gameManager variable to the GameManagerScript component on the GameObject.
        matchManager     = GetComponent <MatchManagerScript>(); //Set the matchManager variable to the MatchManagerScript component on the GameObject.
        lerpPercent      = 0;                                   //Reset the lerp percentage to 0 so that tokens don't move until the right time.
        repopulateScript = GetComponent <RepopulateScript>();
    }
    /// <summary>
    /// This function is used to animate tokens moving into empty spaces after making a match.
    /// </summary>
    /// <param name="startGridX"></param>
    /// <param name="startGridY"></param>
    /// <param name="endGridX"></param>
    /// <param name="endGridY"></param>
    /// <param name="token"></param>
    public virtual void MoveTokenToEmptyPos(int startGridX, int startGridY,
                                            int endGridX, int endGridY,
                                            GameObject token)
    {
        /*
         * The next two lines set references to the locations we're using to move the tokens.
         * startPos is set to the place where a token is coming from
         * endPos is set to the empty space's location
         *
         * The positions are converted into grid positions by gameManager.GetWorldPositionFromGridPosition.
         */
        Vector3 startPos = gameManager.GetWorldPositionFromGridPosition(startGridX, startGridY);
        Vector3 endPos   = gameManager.GetWorldPositionFromGridPosition(endGridX, endGridY);

        Vector3 pos = Vector3.Lerp(startPos, endPos, lerpPercent);

        token.transform.position = pos;

        if (lerpPercent == 1) //If the lerp percentage is complete
        {
            /*
             * Swap the valid token with the empty space.
             */
            gameManager.gridArray[endGridX, endGridY]     = token;
            gameManager.gridArray[startGridX, startGridY] = null;

            RepopulateScript repopulateScript = GetComponent <RepopulateScript>();
            repopulateScript.AddNewTokensToRepopulateGrid();
        }
    }
Example #3
0
 //can be overridden
 public virtual void Start()
 {
     tokenTypes = (Object[])Resources.LoadAll("_Core/Tokens/"); //grabbing prefabs
     gridArray  = new GameObject[gridWidth, gridHeight];        //creating the grid
     MakeGrid();                                                //populating the grid
     matchManager      = GetComponent <MatchManagerScript>();   //assigning scripts to variables
     inputManager      = GetComponent <InputManagerScript>();
     repopulateManager = GetComponent <RepopulateScript>();
     moveTokenManager  = GetComponent <MoveTokensScript>();
 }
Example #4
0
 public virtual void Start()
 {
     tokenTypes = (Object[])Resources.LoadAll("_Core/Tokens/");
     gridArray  = new GameObject[gridWidth, gridHeight];
     MakeGrid();
     matchManager      = GetComponent <MatchManagerScript>();
     inputManager      = GetComponent <InputManagerScript>();
     repopulateManager = GetComponent <RepopulateScript>();
     moveTokenManager  = GetComponent <MoveTokensScript>();
 }
 public virtual void Start()
 {
     //load the tokens, make the grid, and create references to the other scripts
     tokenTypes = (Object[])Resources.LoadAll("Tokens/");
     gridArray  = new GameObject[gridWidth, gridHeight];
     MakeGrid();
     matchManager      = GetComponent <MatchManagerScript>();
     inputManager      = GetComponent <InputManagerScript>();
     repopulateManager = GetComponent <RepopulateScript>();
     moveTokenManager  = GetComponent <MoveTokensScript>();
 }
Example #6
0
    public virtual void Start()
    {
        tokenTypes = Resources.LoadAll("Tokens/");
        gridArray  = new GameObject[gridWidth, gridHeight];
        MakeGrid();

        matchManager = GetComponent <MatchManagerScript>();
        Debug.Assert(matchManager != null, "Attach a match manager to this object.");

        inputManager      = GetComponent <InputManagerScript>();
        repopulateManager = GetComponent <RepopulateScript>();
        moveTokenManager  = GetComponent <MoveTokensScript>();
    }
Example #7
0
 public virtual void Awake()
 {
     tokenTypes        = (UnityEngine.Object[])Resources.LoadAll("Tokens/");
     noteSprites       = Resources.LoadAll <Sprite>("Sprites/Note sprites");
     gridArray         = new GameObject[gridWidth, gridHeight];
     matchManager      = GetComponent <MatchManagerScript>();
     inputManager      = GetComponent <InputManagerScript>();
     repopulateManager = GetComponent <RepopulateScript>();
     moveTokenManager  = GetComponent <MoveTokensScript>();
     numberManager     = GetComponent <NumberManager>();
     stringGraphic     = Resources.Load("String") as GameObject;
     timeBetweenBeats  = 60.0f / bpm;
     music             = GameObject.Find(SPEAKER_OBJ).GetComponent <AudioSource>();
     healthText        = transform.root.Find(UI_CANVAS).Find(HEALTH_TEXT).GetComponent <Text>();
     MakeGrid();
     ChangeGridDuplicates();
 }
Example #8
0
 public virtual void Start()
 {
     //load the tokens, make the grid, and create references to the other scripts
     tokenTypes        = (UnityEngine.Object[])Resources.LoadAll("Tokens/");
     dummySprites      = Resources.LoadAll <Sprite>("Sprites/Dummy sprites");
     gridArray         = new GameObject[gridWidth, gridHeight];
     matchManager      = GetComponent <MatchManagerScript>();
     inputManager      = GetComponent <InputManagerScript>();
     repopulateManager = GetComponent <RepopulateScript>();
     moveTokenManager  = GetComponent <MoveTokensScript>();
     scoreManager      = transform.root.Find("Score canvas").Find("Score").GetComponent <ScoreManager>();
     stringGraphic     = Resources.Load("String") as GameObject;
     MakeGrid();
     ChangeGridDuplicates();
     SceneManager.LoadScene(INSTRUCTION_SCENE_NAME, LoadSceneMode.Additive);
     winLoseManager     = GetComponent <WinLoseManager>();
     chordsRemaining    = transform.root.Find(SCORE_CANVAS).Find(CHORDS_REMAINING).GetComponent <Text>();
     ChordsPlayed       = 0;   //set the text correctly at the start of the game
     scoreRequired      = transform.root.Find(SCORE_CANVAS).Find(SCORE_REQUIRED).GetComponent <Text>();
     scoreRequired.text = winLoseManager.ScoreToWin + " to win";
 }
    public virtual void Start()
    {
        _tokenTypes = Resources.LoadAll("ChessPieces/");
        gridArray   = new GameObject[gridWidth, gridHeight];
        MakeGrid();

        if (playerColor == ChessPiece.PieceColor.Black)
        {
            opponentColor = ChessPiece.PieceColor.White;
        }
        else
        {
            opponentColor = ChessPiece.PieceColor.Black;
        }

        matchManager       = GetComponent <MatchManagerScript>();
        inputManager       = GetComponent <InputManagerScript>();
        repopulateManager  = GetComponent <RepopulateScript>();
        moveTokenManager   = GetComponent <MoveTokensScript>();
        opponentController = GetComponent <OpponentController>();
    }
    public static RepopulateScript instance;     //ADDED this

    //protected GameManagerScript gameManager;

    //ADDED this
    public void Awake()
    {
        instance = this;
    }