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); }
/// <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); }
/// <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); }
void Start() { rigidBody = GetComponent <Rigidbody>(); blockCommunication = GetComponent <BlockCommunication>(); }