示例#1
0
        public Vector2[] GetRotationPositions(int index)
        {
            index = Mathf.Clamp(index, 0, data.TilePositions.GetLength(0)); // Just in case "index" is out of bounds

            Vector2[] temp = data.GetPositions(index);
            for (int i = 0; i < temp.Length; i++)
            {
                temp[i] = temp[i] + grid.GetCellPosAt(transform.position);
            }
            return(temp);
        }
示例#2
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));
        }
        protected void Snap(SnapAxis axis)
        {
            Vector2 cellPos = grid.GetCellPosAt(transform.position);
            Vector2 newPos  = transform.position;

            switch (axis)
            {
            case SnapAxis.X:
                newPos = new Vector2(cellPos.x, transform.position.y);
                break;

            case SnapAxis.Y:
                newPos = new Vector2(transform.position.x, cellPos.y);
                break;

            case SnapAxis.Both:
                newPos = cellPos;
                break;
            }
            transform.position = newPos;
        }