Пример #1
0
        private void PlaceEmptyTile(BoardPos grid, Vector2 ui)
        {
            Tile tile = BoardBuilder.spareTiles.GetObject();

            tile.transform.SetAsFirstSibling();
            tile.setEmpty(grid, ui, emptyTileColor);
            tile.gameObject.SetActive(true);

            AddNewTile(tile);
        }
Пример #2
0
        public void setEmpty(BoardPos gridPos, Vector2 worldPos, Color colour)
        {
            setEmpty(colour);
            GridPosition       = gridPos;
            transform.position = new Vector3(worldPos.x, worldPos.y, -1f);

            moving  = false;
            merging = false;
            FinishSpawning();
        }
Пример #3
0
        public void MoveTile(BoardPos gridLocation, Vector2 uiLocation, float speed, Tile hide)
        {
            GridPosition = gridLocation;

            FinishMoving();
            FinishSpawning();

            start      = trans.position;
            end        = uiLocation;
            this.speed = speed;
            passed     = 0f;
            hidden     = hide;
            moving     = true;
        }
Пример #4
0
        internal void MergeTile(BoardPos moveGridLocation, Vector2 moveUiLocation, float movementSpeed, Tile replace, Color styleColor, Color textColor)
        {
            GridPosition = moveGridLocation;

            FinishMoving();
            FinishSpawning();

            start      = trans.position;
            end        = moveUiLocation;
            speed      = movementSpeed;
            passed     = 0f;
            hidden     = replace;
            imgColour  = styleColor;
            textColour = textColor;

            moving  = true;
            merging = true;
        }
Пример #5
0
 public TileState()
 {
     grid   = new BoardPos(-1, -1);
     Points = -1;
 }
Пример #6
0
        private Tile FindEmptyEdgeTile(Direction edge)
        {
            Profiler.BeginSample("Find Edge Tile");

            List <Tile> validPositions = new List <Tile>();
            int         returnTile     = 0;

            if (edge == Direction.Up || edge == Direction.Down)
            {
                int y = -1;
                Profiler.BeginSample("X Search");

                if (edge == Direction.Up)
                {
                    y = 0;
                }
                else if (edge == Direction.Down)
                {
                    y = boardSize.Y - 1;
                }

                //figure out which tiles are free
                BoardPos pos = new BoardPos(-1, y);
                for (int i = 0; i < boardSize.X; i++)
                {
                    pos.X = i;
                    if (tilePositions[pos].Value == -1)
                    {
                        validPositions.Add(tilePositions[pos]);
                    }
                }

                returnTile = Random.Range(0, validPositions.Count - 1);
                Profiler.EndSample();
            }

            if (edge == Direction.Left || edge == Direction.Right)
            {
                int x = -1;
                Profiler.BeginSample("Y Search");

                if (edge == Direction.Left)
                {
                    x = 0;
                }
                else if (edge == Direction.Right)
                {
                    x = boardSize.X - 1;
                }

                //figure out which tiles are free
                BoardPos pos = new BoardPos(x, -1);
                for (int i = 0; i < boardSize.Y; i++)
                {
                    pos.Y = i;
                    if (tilePositions[pos].Value == -1)
                    {
                        validPositions.Add(tilePositions[pos]);
                    }
                }

                returnTile = Random.Range(0, validPositions.Count - 1);
                Profiler.EndSample();
            }

            Profiler.EndSample();
            return(validPositions[returnTile]);
        }
Пример #7
0
 public TileValue(int val, BoardPos grid)
 {
     Val  = val;
     Grid = grid;
 }