Exemplo n.º 1
0
 public virtual void SetUp(TetroMovement movement)
 {
     this.movement = movement;
     tetro         = movement.Tetro;
     tiles         = tetro.Tiles;
     grid          = movement.Grid;
     settings      = movement.Settings;
 }
Exemplo n.º 2
0
        private void SetTexture(TetroGrid grid)
        {
            Theme theme = grid.TetroSettings.Theme;

            texture.sprite         = theme.Sprite;
            texture.color          = theme.Color;
            texture.type           = Image.Type.Simple;
            texture.preserveAspect = true;
        }
Exemplo n.º 3
0
        private void OnDie()
        {
            TetroGrid grid = FindObjectOfType <TetroGrid>();

            foreach (Tile tile in activeCoinPositions)
            {
                grid.SetCellCoin(tile.transform.position);
            }
        }
Exemplo n.º 4
0
        public void MoveDown(TetroGrid grid, Cell cell, Vector2 startPos, int distance)
        {
            this.grid    = grid;
            sprite.color = cell.GetColor();
            SetTexture(grid);
            transform.position = startPos;
            ActiveCell state = (ActiveCell)cell.CurrentState;

            coinImage.SetActive(state.HasCoin);

            Vector2 endPos = grid.GetCellPosAt(new Vector2(startPos.x, startPos.y - distance));

            StartCoroutine(LerpDown(startPos, endPos, ReturnToPool));
        }
Exemplo n.º 5
0
        /// <summary>
        /// Checks whether the cell on the side "side" is empty. If it is, return true. Otherwise, return false.
        /// </summary>
        /// <param name="grid">The grid to check with.</param>
        /// <param name="side">The side of the tile to check.</param>
        /// <returns></returns>
        public bool CanMove(TetroGrid grid, Side side)
        {
            switch (side)
            {
            case Side.Right:
                return(grid.IsCellEmpty(grid.GetCellPosRight(transform.position)));

            case Side.Left:
                return(grid.IsCellEmpty(grid.GetCellPosLeft(transform.position)));

            case Side.Down:
                return(grid.IsCellEmpty(grid.GetCellPosBelow(transform.position)));
            }
            return(false);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Checks whether the cell on the side "side" is empty with the given offset. If it is, return true. Otherwise, return false.
        /// </summary>
        /// <param name="grid">The grid to check with.</param>
        /// <param name="side">The side of the tile to check.</param>
        /// <param name="offset">The offset to apply.</param>
        /// <returns></returns>
        public bool CanMove(TetroGrid grid, Side side, Vector3 offset)
        {
            Vector3 pos = transform.position + offset;

            switch (side)
            {
            case Side.Right:
                return(grid.IsCellEmpty(grid.GetCellPosRight(pos)));

            case Side.Left:
                return(grid.IsCellEmpty(grid.GetCellPosLeft(pos)));

            case Side.Down:
                return(grid.IsCellEmpty(grid.GetCellPosBelow(pos)));
            }
            return(false);
        }
Exemplo n.º 7
0
 public void SetGrid(TetroGrid grid, int x, int y)
 {
     this.Grid = grid;
     X         = x;
     Y         = y;
 }
Exemplo n.º 8
0
 private void Awake()
 {
     grid = FindObjectOfType <TetroGrid>();
 }