Esempio n. 1
0
        public void AddShapesToPosition(IndexedPosition indexedPosition)
        {
            var parent = TableViewManager.ContainerTransform;
            var height = BlockViews.GetLength(0);
            var width  = BlockViews.GetLength(1);

            Shape = null;

            var index = 0;

            for (var i = 0; i < height; i++)
            {
                for (var j = 0; j < width; j++)
                {
                    if (BlockViews[i, j] != null)
                    {
                        BlockViews[i, j].SetParent(parent);
                        BlockViews[i, j].SetLocalPosition(new Vector3(j + indexedPosition.X, -i - indexedPosition.Y));
                        TableViewManager.BlockViews[indexedPosition.Y + i, indexedPosition.X + j] = BlockViews[i, j];
                    }
                }
            }

            BlockViews = null;
        }
Esempio n. 2
0
 public void SendTryAddShapeSignal(IndexedPosition position)
 {
     if (position.Y < 0 || position.X < 0)
     {
         return;
     }
     TryAddShapeToMapSignal.Dispatch(ShapeView.Shape, position, AddShapes);
 }
Esempio n. 3
0
            public static IndexedPosition GetPosition(int index)
            {
                IndexedPosition result;

                if (!indexes.TryGetValue(index, out result))
                {
                    result         = new IndexedPosition(index);
                    indexes[index] = result;
                }
                return(result);
            }
Esempio n. 4
0
        private bool CheckShapes(IndexedPosition position)
        {
            foreach (var shape in MapModel.Shapes)
            {
                if (CheckShape(position, shape.ShapeMatrix))
                {
                    return(true);
                }
            }

            return(false);
        }
Esempio n. 5
0
        private void OnMouseUp()
        {
            if (!_isDrag)
            {
                return;
            }

            var height = Shape.GetLength(0);
            var width  = Shape.GetLength(1);

            var topLeftShapePos = new Vector3(0.5f - width / 2f, height / 2f - 0.5f);

            var topLeftPos = TableViewManager.TopLeftAnchorPosition - topLeftShapePos;
            var yIndex     = topLeftPos.y - transform.position.y + 0.5f;
            var xIndex     = transform.position.x - topLeftPos.x + 0.5f;

            var indexedPosition = new IndexedPosition((int)yIndex, (int)xIndex);

            _isDrag = false;
            _animator.SetBool("Take", false);
            GoToCenter();

            ShapeContainer.SendTryAddShapeSignal(indexedPosition);
        }
Esempio n. 6
0
        private bool CheckShape(IndexedPosition position, bool[,] shape)
        {
            if (MapModel.Map.GetLength(0) < position.Y + shape.GetLength(0))
            {
                return(false);
            }
            if (MapModel.Map.GetLength(1) < position.X + shape.GetLength(1))
            {
                return(false);
            }

            for (var i = 0; i < shape.GetLength(0); i++)
            {
                for (var j = 0; j < shape.GetLength(1); j++)
                {
                    if (shape[i, j] && MapModel.Map[position.Y + i, position.X + j])
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
Esempio n. 7
0
 int GetOffset(IndexedPosition @from, IndexedPosition toPosition)
 {
     throw new NotImplementedException();
 }
Esempio n. 8
0
 private void AddShapes(IndexedPosition position)
 {
     ShapeView.AddShapesToPosition(position);
 }