Beispiel #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;
        }
    }
Beispiel #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;
    }
Beispiel #3
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;
    }