Exemplo n.º 1
0
        private List <ConnectedBlockSerialized> GetConnectedBlocks(BlockCommunication blockCommunication)
        {
            List <ConnectedBlockSerialized> Guids = new List <ConnectedBlockSerialized>();

            foreach (BlockContainer container in blockCommunication.ConnectedBlocks)
            {
                Guids.Add(new ConnectedBlockSerialized(container));
            }
            return(Guids);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Removes a Block by guid from the list and the Scene, clearing everyting
        /// </summary>
        /// <param name="guid"></param>
        public void RemoveBlock(Guid guid)
        {
            BlockCommunication blockCommunication = GetBlockByGuid(guid).GetComponent <BlockCommunication>();

            //Clear the connection to other Blocks
            blockCommunication.RemoveAllBlockConnections();

            //Destroies the GameObject
            Destroy(GetBlockByGuid(guid));

            //Removes the Dictonary Entry
            exsistingBlocksInGame.Remove(guid);

            //Removes the History Entry
            RemoveEntryFromHistory(guid);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Get all CollisionObjects that are Occupied but not connected to a Block
        /// </summary>
        /// <returns>Not connected CollisionObjects</returns>
        public List <CollisionObject> GetCollidingObjects()
        {
            BlockCommunication blockCommunication = GetComponentInParent <BlockCommunication>();

            //fix any case where a connection wasn't caught
            foreach (CollisionObject collisionObject in colliderDictionary.Values)
            {
                //If the other Block is not connected according to the Tap- or GrooveHandler but is in the List of ConnectedBlock, fix the issue
                if (!collisionObject.IsConnected && collisionObject.CollidedBlock != null && blockCommunication.ConnectedBlocks.Exists(blockContainer => blockContainer.GetHashCode() == collisionObject.GetHashCode()))
                {
                    collisionObject.IsConnected = true;
                }
            }

            List <CollisionObject> collisionList = new List <CollisionObject>(colliderDictionary.Values);

            collisionList.RemoveAll(collision => collision.CollidedBlock == null || collision.IsConnected);
            return(collisionList);
        }
Exemplo n.º 4
0
 void Start()
 {
     rigidBody          = GetComponent <Rigidbody>();
     blockCommunication = GetComponent <BlockCommunication>();
 }