Exemplo n.º 1
0
    //draw one tile from the bag
    public void TakeOneTile()
    {
        Debug.Log("taking one tile");

        if (hand.Length < xyz.Length)
        {
            //creates new hand object
            GameObject[] nhand = new GameObject[hand.Length + 1];
            //copies each tile into the new hand
            for (int i = 0; i < hand.Length; i++)
            {
                nhand[i] = hand[i];
            }
            //puts a new tile into new empty spot in the new hand
            nhand[nhand.Length - 1] = tileDistributor.DealTile();             //has problem when there is only one tile in the bag
            //places the new tile
            nhand[nhand.Length - 1].transform.position = new Vector3(xyz[nhand.Length - 1, 0], xyz[nhand.Length - 1, 1], xyz[nhand.Length - 1, 2]);
            //sets starting position of the new tile
            Tile tile = nhand[nhand.Length - 1].GetComponent(typeof(Tile)) as Tile;
            tile.SetStartPosition(new Vector3(xyz[nhand.Length - 1, 0], xyz[nhand.Length - 1, 1], xyz[nhand.Length - 1, 2]));

            //replace previous hand with new hand
            hand = nhand;
        }
        else
        {
            Debug.LogError("Hand is too large. Cannot draw tile");
        }
    }
Exemplo n.º 2
0
    void Start()
    {
        hand            = new GameObject[18]; //change back to 18
        tileDistributor = TileDistributor.Instance();

        //modal planel and options
        modalPanel        = ModalPanel.Instance();
        okayErrorAction   = new UnityAction(ModalPanelErrorOkayAction);
        dealOneTileAction = new UnityAction(TakeOneTile);
        returnTilesAction = new UnityAction(ReturnTilesAction);

        //fill hand randomly
        for (int i = 0; i < hand.Length; i++)
        {
            hand[i] = tileDistributor.DealTile();
        }

        /*use the following to deal a specific hand
         * hand[0] = tileDistributor.DealSpecificTile('M');
         * hand[1] = tileDistributor.DealSpecificTile('E');
         * hand[2] = tileDistributor.DealSpecificTile('L');
         * hand[3] = tileDistributor.DealSpecificTile('T');
         * hand[4] = tileDistributor.DealSpecificTile('S');
         * hand[5] = tileDistributor.DealSpecificTile('P');
         * hand[6] = tileDistributor.DealSpecificTile('U');
         * hand[7] = tileDistributor.DealSpecificTile('N');
         * hand[8] = tileDistributor.DealSpecificTile('Q');
         * hand[9] = tileDistributor.DealSpecificTile('I');
         * hand[10] = tileDistributor.DealSpecificTile('E');
         * hand[11] = tileDistributor.DealSpecificTile('T');
         * hand[12] = tileDistributor.DealSpecificTile('E');
         * hand[13] = tileDistributor.DealSpecificTile('R');
         * hand[14] = tileDistributor.DealSpecificTile('B');
         * hand[15] = tileDistributor.DealSpecificTile('A');
         * hand[16] = tileDistributor.DealSpecificTile('R');
         * hand[17] = tileDistributor.DealSpecificTile('L');
         * hand[18] = tileDistributor.DealSpecificTile('A');
         * hand[19] = tileDistributor.DealSpecificTile('C');
         * hand[20] = tileDistributor.DealSpecificTile('K');
         * hand[21] = tileDistributor.DealSpecificTile('D');
         * hand[22] = tileDistributor.DealSpecificTile('N');
         * hand[23] = tileDistributor.DealSpecificTile('O');
         * hand[24] = tileDistributor.DealSpecificTile('D');
         * hand[25] = tileDistributor.DealSpecificTile('S');
         * hand[26] = tileDistributor.DealSpecificTile('O');
         * hand[27] = tileDistributor.DealSpecificTile('W');
         *
         */


        //get boardchecker component
        boardChecker = gameObject.GetComponent(typeof(BoardChecker)) as BoardChecker;
        PlaceHand();
        GetCells();
    }
Exemplo n.º 3
0
    void Start()
    {
        hand            = new GameObject[21];
        tileDistributor = TileDistributor.Instance();

        modalPanel        = ModalPanel.Instance();
        okayErrorAction   = new UnityAction(ModalPanelErrorOkayAction);
        dealOneTileAction = new UnityAction(TakeOneTile);

        for (int i = 0; i < hand.Length; i++)
        {
            hand[i] = tileDistributor.DealTile();
        }

        boardChecker = gameObject.GetComponent(typeof(BoardChecker)) as BoardChecker;
        PlaceHand();
        GetCells();
    }
Exemplo n.º 4
0
    public void TakeOneTile()
    {
        Debug.Log("taking one tile");
        if (hand.Length < xyz.Length)
        {
            GameObject[] nhand = new GameObject[hand.Length + 1];
            for (int i = 0; i < hand.Length; i++)
            {
                nhand[i] = hand[i];
            }
            nhand[nhand.Length - 1] = tileDistributor.DealTile();
            nhand[nhand.Length - 1].transform.position = new Vector3(xyz[nhand.Length - 1, 0], xyz[nhand.Length - 1, 1], xyz[nhand.Length - 1, 2]);
            Tile tile = nhand[nhand.Length - 1].GetComponent(typeof(Tile)) as Tile;
            tile.SetStartPosition(new Vector2(xyz[nhand.Length - 1, 0], xyz[nhand.Length - 1, 1]));

            //replace previous hand with new hand
            hand = nhand;
        }
        else
        {
            Debug.LogError("Hand is too large. Cannot draw tile");
        }
    }