示例#1
0
    /// <summary>
    /// The method to tell the tiles to switch places when swiped.
    /// </summary>
    /// <param name="rock1">The first rock</param>
    /// <param name="rock2">The second rock</param>
    /// <param name="newMove">If the tiles are not reverting back to place</param>
    public void MoveTiles(GameObject rock1, GameObject rock2, bool newMove)
    {
        Rock rocker1 = rock1.GetComponent <Rock>();
        Rock rocker2 = rock2.GetComponent <Rock>();

        //Debug.Log(posRock1[0] + " " + posRock1[1]);

        int[] posRock1 = rocker1.GetPos();
        rocker1.SetPos(rocker2.GetPos());
        rocker2.SetPos(posRock1);


        rocker1.ChangeParent(FindParent(rocker1.GetPos()[0]));
        rocker2.ChangeParent(FindParent(rocker2.GetPos()[0]));

        gameField[rocker1.pos[0], rocker1.pos[1]] = rock1;
        gameField[rocker2.pos[0], rocker2.pos[1]] = rock2;

        if (newMove)
        {
            //Debug.Log("Calling to check matches");
            _camera.GetComponent <CameraManager>()
            .PlaySound(_movementAudio, GameManager._soundVolume, usePitchVariance: true);
            gameObject.GetComponent <MatchChecker>().MatchCheck(rock1, rock2);
        }
    }