示例#1
0
    public LetterTileController CreateLetterTile(char letter, int x, int y)
    {
        float newX = ((x + _currentLeftSideOfGrid) * xStepSize) + xLeftGoalLine;
        float newY = (y * yStepSize) + yOffsetScreenBottom;
        LetterTileController lt = Instantiate(letterTilePrefab, new Vector3(newX, newY, 0), transform.rotation) as LetterTileController;

        lt.transform.position.Set(newX, newY, 0);
        lt.SetLetterTileLetter(letter);
        lt.SetLetterTilePositionX(x);
        lt.SetLetterTilePositionY(y);
        //lt.MakeSelectable((x + game.currentLeftSideOffset) <= game.currentLineOfScrimmage); //Letter is selectable if x is left of current line of scrimmage?
        //lt.game = game;
        return(lt);
    }
示例#2
0
    //Handles moving a letter in the visible grid (and the characters in the full grid) and sets
    //it up to move (doesn't actually move current letter, though)
    private void MoveLetterToEndOfVisibleGrid(LetterTileController currentLetter)
    {
        int col = currentLetter.gridPositionX; //These coordinates are for visible grid, relative to 0,0
        int row = currentLetter.gridPositionY;
        LetterTileController visLetter;

        try {
            for (int i = col; i < xVisibleGridSize; i++)
            {
                //Move letter from next spot in full letter grid to current
                fullLetterGrid[i + game.currentLeftSideOffset, row] = fullLetterGrid[i + game.currentLeftSideOffset + 1, row];

                //When in visible letter grid, do the same
                if (i < xVisibleGridSize - 1)
                {
                    visLetter = visibleLetterGrid[i, row] = visibleLetterGrid[i + 1, row];
                    visLetter.SetLetterTilePositionX(i);
                    visLetter.SetToMoveToNewXPosition(((i + game.currentLeftSideOffset) * xStepSize) + xLeftGoalLine);
                }
                //Until the last space, when the current letter is placed there
                else if (i == xVisibleGridSize - 1)
                {
                    visibleLetterGrid[i, row] = currentLetter;
                    currentLetter.SetLetterTileLetter(fullLetterGrid[i + game.currentLeftSideOffset, row]);
                    currentLetter.SetLetterTilePositionX(i);
                    currentLetter.SetToMoveToNewXPosition(((xVisibleGridSize + game.currentLeftSideOffset - 1) * xStepSize) + xLeftGoalLine);
                }
            }
        }
        catch (Exception e)
        {
            Debug.Log(e.ToString());
        }

        //Put a new letter in the space just past the visible grid (need to ensure full grid is always one larger than visible grid can go)
        fullLetterGrid[xVisibleGridSize + game.currentLeftSideOffset, row] = GenerateLetter();
    }