예제 #1
0
        /// <summary>
        /// Creates a "placed" block.
        /// </summary>
        public static PlacedSingleBlock MakeSinglePlaced(Transform parent, SingleBlockInfo info, byte rotation, BlockPosition position)
        {
            GameObject        block     = InstantiatePrefab(parent, info, rotation, position);
            PlacedSingleBlock component = block.AddComponent <PlacedSingleBlock>();

            component.Initialize(info, position, rotation);
            return(component);
        }
예제 #2
0
        private void RemoveBlock(IPlacedBlock block)
        {
            RealBlockCount--;
            if (block.Position.Equals(_mainframePosition))
            {
                _mainframePosition = null;
            }
            else if (SystemFactory.IsActiveSystem(block.Type))
            {
                _activeSystemPresent = false;
            }
            else if (SystemFactory.GetWeaponType(block.Type) != WeaponSystem.Type.None)
            {
                if (--_weaponCount == 0)
                {
                    _weaponType = WeaponSystem.Type.None;
                }
            }

            PlacedSingleBlock single = block as PlacedSingleBlock;

            if (single != null)
            {
                Destroy(single.gameObject);
                _blocks.Remove(single.Position);
                return;
            }

            PlacedMultiBlockParent parent = block as PlacedMultiBlockParent;

            if (parent == null)
            {
                parent = ((PlacedMultiBlockPart)block).Parent;
            }

            Destroy(parent.gameObject);
            Assert.IsTrue(_blocks.Remove(parent.Position), "The parent of the multi block is not present.");
            foreach (PlacedMultiBlockPart part in parent.Parts)
            {
                Assert.IsTrue(_blocks.Remove(part.Position), "A part of the multi block is not present.");
            }
        }