示例#1
0
    //when a lighting cell is clicked, it will use this method to allow the currHoodle jump to it
    //destPos is the position of the chosen cell
    //row and col are the coordiantes of chosen cell
    public void LetMove(Vector3 destPos, int row, int col)
    {
        if (currHoodle != null) {
            BoardCells[(int)currHoodle.GetOnBoardPos()[0], (int)currHoodle.GetOnBoardPos()[1]].cellOccupied = false;
            BoardCells[row, col].cellOccupied = true;
            int playerNum = translatePlayer(currHoodle.tag.ToString());
            if(playerNum == BoardCells[row,col].occupyingPlayer) {
                ++arrivalCounters[playerNum];
                if(arrivalCounters[playerNum] == 15)
                    gameManager.Win(currHoodle.tag.ToString());
            }
            if(playerNum == BoardCells[(int)currHoodle.GetOnBoardPos()[0], (int)currHoodle.GetOnBoardPos()[1]].occupyingPlayer)
                --arrivalCounters[playerNum];
            currHoodle.SetCoordinate(row, col);

            //send movements according to the bounce queue
            while(BoardCells[row, col].bounceQueue.Count > 0){
                int[] nextPos = (int[])BoardCells[row, col].bounceQueue.Dequeue();
                Vector2 twodPos = BoardCells[nextPos[0], nextPos[1]].cellPos;
                currHoodle.moveQueue.Enqueue(new Vector3(twodPos.x, 0, twodPos.y));
            }
            turnOffAllPoss();
            currHoodle.NotifyMove();
            currHoodle.ResumeState();
            currHoodle = null;
        }
    }
示例#2
0
    //a hoodle calls this method to place itself on the board
    public void Occupy(HoodleMove hoodle)
    {
        Vector2 hoodlePos = new Vector2(hoodle.GetTransformPos().x, hoodle.GetTransformPos().z);
        float   x = 100;
        int     y = 0, z = 0;
        Vector2 tmp = new Vector2(0, 0);

        //find a cell to place the hoodle
        for (int i = 0; i < 17; ++i)
        {
            for (int j = 0; j < 17; ++j)
            {
                if (BoardCells[i, j] != null &&
                    (hoodlePos - BoardCells [i, j].cellPos).magnitude < x &&
                    !BoardCells[i, j].cellOccupied)
                {
                    x   = (hoodlePos - BoardCells [i, j].cellPos).magnitude;
                    y   = i;
                    z   = j;
                    tmp = BoardCells[i, j].cellPos;
                }
            }
        }
        BoardCells [16 - y, 16 - z].occupyingPlayer = translatePlayer(hoodle.tag.ToString());
        hoodle.SetCoordinate(y, z);
        hoodle.SetPos(BoardCells [y, z].cellPos);
        BoardCells [y, z].cellOccupied = true;
    }
示例#3
0
    //when a lighting cell is clicked, it will use this method to allow the currHoodle jump to it
    //destPos is the position of the chosen cell
    //row and col are the coordiantes of chosen cell
    public void LetMove(Vector3 destPos, int row, int col)
    {
        if (currHoodle != null)
        {
            BoardCells[(int)currHoodle.GetOnBoardPos()[0], (int)currHoodle.GetOnBoardPos()[1]].cellOccupied = false;
            BoardCells[row, col].cellOccupied = true;
            int playerNum = translatePlayer(currHoodle.tag.ToString());
            if (playerNum == BoardCells[row, col].occupyingPlayer)
            {
                ++arrivalCounters[playerNum];
                if (arrivalCounters[playerNum] == 15)
                {
                    gameManager.Win(currHoodle.tag.ToString());
                }
            }
            if (playerNum == BoardCells[(int)currHoodle.GetOnBoardPos()[0], (int)currHoodle.GetOnBoardPos()[1]].occupyingPlayer)
            {
                --arrivalCounters[playerNum];
            }
            currHoodle.SetCoordinate(row, col);

            //send movements according to the bounce queue
            while (BoardCells[row, col].bounceQueue.Count > 0)
            {
                int[]   nextPos = (int[])BoardCells[row, col].bounceQueue.Dequeue();
                Vector2 twodPos = BoardCells[nextPos[0], nextPos[1]].cellPos;
                currHoodle.moveQueue.Enqueue(new Vector3(twodPos.x, 0, twodPos.y));
            }
            turnOffAllPoss();
            currHoodle.NotifyMove();
            currHoodle.ResumeState();
            currHoodle = null;
        }
    }
示例#4
0
    override public void Link()
    {
        board       = GameObject.FindGameObjectWithTag("HoldBoard").GetComponent <Board>();
        gameManager = GameObject.FindGameObjectWithTag("PlayBoard").GetComponent <GameManager>();

        hoodles     = GameObject.FindGameObjectsWithTag("Player" + color);
        hoodleMoves = new HoodleMove[10];
        for (int i = 0; i < hoodles.Length; ++i)
        {
            hoodleMoves[i]       = hoodles[i].GetComponent <HoodleMove>();
            hoodleMoves[i].owner = playerNumber;
        }

        cameras[0].GetComponent <Camera>().enabled = false;
        cameras[1].GetComponent <Camera>().enabled = false;
    }
示例#5
0
 //when a hoodle is chosen, it uses this method to send request to the board for changing the currHoodle to itself
 public bool UpDateCurrHoodle(HoodleMove newCurr)
 {
     if (newCurr.tag.ToString() == colorList [currPlayer])
     {
         if (currHoodle != null && newCurr != null)
         {
             currHoodle.ResumeState();
         }
         currHoodle = newCurr;
         turnOffAllPoss();
         if (currHoodle != null)
         {
             //search for all reachable cells
             SearchMovable(currHoodle.GetOnBoardPos());
         }
         return(true);
     }
     return(false);
 }
	override public void Link()
	{
		hoodles = GameObject.FindGameObjectsWithTag("Player" + color);
		hoodleMoves = new HoodleMove[10];
		for (int i = 0; i < hoodles.Length; ++i) {
			hoodleMoves[i] = hoodles[i].GetComponent<HoodleMove>();
            hoodleMoves[i].owner = playerNumber;
		}
		
		currentCameraNum = 0;
		currentCamera = cameras[currentCameraNum].GetComponent<Camera>();
		cameras[0].GetComponent<Camera>().enabled = false;
		cameras[1].GetComponent<Camera>().enabled = false;

        gameManager = GameObject.FindGameObjectWithTag("PlayBoard").GetComponent<GameManager>();

        isTheFirstTry = true;
        theFirstHoodleCoordinateX = -1;
        theFirstHoodleCoordinateY = -1;
	}
示例#7
0
    override public void Link()
    {
        hoodles     = GameObject.FindGameObjectsWithTag("Player" + color);
        hoodleMoves = new HoodleMove[10];
        for (int i = 0; i < hoodles.Length; ++i)
        {
            hoodleMoves[i]       = hoodles[i].GetComponent <HoodleMove>();
            hoodleMoves[i].owner = playerNumber;
        }

        currentCameraNum = 0;
        currentCamera    = cameras[currentCameraNum].GetComponent <Camera>();
        cameras[0].GetComponent <Camera>().enabled = false;
        cameras[1].GetComponent <Camera>().enabled = false;

        gameManager = GameObject.FindGameObjectWithTag("PlayBoard").GetComponent <GameManager>();

        isTheFirstTry             = true;
        theFirstHoodleCoordinateX = -1;
        theFirstHoodleCoordinateY = -1;
    }
示例#8
0
    //a hoodle calls this method to place itself on the board
    public void Occupy(HoodleMove hoodle)
    {
        Vector2 hoodlePos = new Vector2 (hoodle.GetTransformPos ().x, hoodle.GetTransformPos ().z);
        float x = 100;
        int y = 0, z = 0;
        Vector2 tmp = new Vector2 (0, 0);

        //find a cell to place the hoodle
        for (int i = 0; i < 17; ++i)
            for (int j = 0; j < 17; ++j) {
                if(BoardCells[i, j] != null &&
               		(hoodlePos - BoardCells [i, j].cellPos).magnitude < x &&
               		!BoardCells[i, j].cellOccupied) {
                    x = (hoodlePos - BoardCells [i, j].cellPos).magnitude;
                    y = i;
                    z = j;
                    tmp = BoardCells[i, j].cellPos;
                }
            }
        BoardCells [16 - y, 16 - z].occupyingPlayer = translatePlayer (hoodle.tag.ToString ());
        hoodle.SetCoordinate (y, z);
        hoodle.SetPos (BoardCells [y, z].cellPos);
        BoardCells [y, z].cellOccupied = true;
    }
示例#9
0
 //when a hoodle is chosen, it uses this method to send request to the board for changing the currHoodle to itself
 public bool UpDateCurrHoodle(HoodleMove newCurr)
 {
     if (newCurr.tag.ToString() == colorList [currPlayer]) {
         if (currHoodle != null && newCurr != null)
             currHoodle.ResumeState ();
         currHoodle = newCurr;
         turnOffAllPoss ();
         if (currHoodle != null) {
             //search for all reachable cells
             SearchMovable (currHoodle.GetOnBoardPos ());
         }
         return true;
     }
     return false;
 }
示例#10
0
    override public void Link()
    {
        board = GameObject.FindGameObjectWithTag("HoldBoard").GetComponent<Board>();
        gameManager = GameObject.FindGameObjectWithTag("PlayBoard").GetComponent<GameManager>();

        hoodles = GameObject.FindGameObjectsWithTag("Player" + color);
        hoodleMoves = new HoodleMove[10];
        for (int i = 0; i < hoodles.Length; ++i) {
            hoodleMoves[i] = hoodles[i].GetComponent<HoodleMove>();
            hoodleMoves[i].owner = playerNumber;
        }

        cameras[0].GetComponent<Camera>().enabled = false;
        cameras[1].GetComponent<Camera>().enabled = false;
    }