Exemplo n.º 1
0
        void AddBlock(Vector2 position, VFXModelDescriptor <VFXBlock> descriptor)
        {
            int blockIndex = -1;

            var blocks = m_BlockContainer.Query().OfType <VFXBlockUI>().ToList();

            for (int i = 0; i < blocks.Count; ++i)
            {
                Rect worldBounds = blocks[i].worldBound;
                if (worldBounds.Contains(position))
                {
                    if (position.y > worldBounds.center.y)
                    {
                        blockIndex = i + 1;
                    }
                    else
                    {
                        blockIndex = i;
                    }
                    break;
                }
            }

            using (var growContext = new GrowContext(this))
            {
                controller.AddBlock(blockIndex, descriptor.CreateInstance(), true /* freshly created block, should init space */);
            }
        }
Exemplo n.º 2
0
        public void BlocksDropped(int blockIndex, IEnumerable <VFXBlockUI> draggedBlocks, bool copy)
        {
            HashSet <VFXContextController> contexts = new HashSet <VFXContextController>();

            foreach (var draggedBlock in draggedBlocks)
            {
                contexts.Add(draggedBlock.context.controller);
            }

            using (var growContext = new GrowContext(this))
            {
                controller.BlocksDropped(blockIndex, draggedBlocks.Select(t => t.controller), copy);

                foreach (var context in contexts)
                {
                    context.ApplyChanges();
                }
            }
        }