public virtual void SetUp(TetroMovement movement)
 {
     this.movement = movement;
     tetro         = movement.Tetro;
     tiles         = tetro.Tiles;
     grid          = movement.Grid;
     settings      = movement.Settings;
 }
Esempio 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;
        }
Esempio n. 3
0
        private void OnDie()
        {
            TetroGrid grid = FindObjectOfType <TetroGrid>();

            foreach (Tile tile in activeCoinPositions)
            {
                grid.SetCellCoin(tile.transform.position);
            }
        }
Esempio 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));
        }
Esempio 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);
        }
Esempio 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);
        }
Esempio n. 7
0
 public void SetGrid(TetroGrid grid, int x, int y)
 {
     this.Grid = grid;
     X         = x;
     Y         = y;
 }
Esempio n. 8
0
 private void Awake()
 {
     grid = FindObjectOfType <TetroGrid>();
 }