Exemplo n.º 1
0
    public void OnLetterSelected(GameObject tile)
    //public void InputRegistered(LetterTileController tile)
    {
        LetterTileController lt = tile.GetComponent <LetterTileController>();

        if (lt.isSelectable)
        {
            EventManager.TriggerEvent("ValidLetterSelected", tile);
            AddLetter(lt);

            //After letting letters set themselves, deselect those already chosen
            foreach (LetterTileController l in selectedTiles)
            {
                l.MakeSelectable(false);
            }
        }
        else
        {
            EventManager.TriggerEvent("InvalidLetterLocation", tile);
        }

        //if (selectedTiles.Contains(lt))
        //{
        //  ClearWords();
        //}
    }
    //private void Shrink()
    //{
    //  iTween.ScaleTo(gameObject, iTween.Hash("x", 1.0f, "y", 1.0f, "time", 0.5f, "oncomplete", "Grow"));
    //}

    private void OnValidLetterSelected(GameObject tile)
    {
        LetterTileController lt = tile.GetComponent <LetterTileController>();

        MakeCurrent(tile == gameObject);                                                                                                            //Sets Current tile animation if this is current, turns it off if not
        MakeSelectable(tile != gameObject && (Math.Abs(lt.gridPositionX - gridPositionX) <= 1 && Math.Abs(lt.gridPositionY - gridPositionY) <= 1)); //Sets surround tiles to selectable
    }
Exemplo n.º 3
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);
    }
Exemplo n.º 4
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();
    }
Exemplo n.º 5
0
 public void AddLetter(LetterTileController lt)
 {
     currentWordText.text += lt.letter;
     selectedTiles.Add(lt);
 }