Esempio n. 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);
        }
Esempio n. 2
0
File: Tile.cs Progetto: crener/2048
        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();
        }
Esempio n. 3
0
File: Tile.cs Progetto: crener/2048
        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;
        }
Esempio n. 4
0
File: Tile.cs Progetto: crener/2048
        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;
        }
Esempio n. 5
0
 public TileState()
 {
     grid   = new BoardPos(-1, -1);
     Points = -1;
 }
Esempio n. 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]);
        }
Esempio n. 7
0
 public TileValue(int val, BoardPos grid)
 {
     Val  = val;
     Grid = grid;
 }