public PuzzleOutput areaGeneratePuzzle(BuildingBlock buildingBlockToBind) { if (_verbose) Debug.Log("spawning Area: " + _name); if (_boundBuildingBlock != null) { if (_verbose) Debug.Log("Area already bound to another building block!"); return new PuzzleOutput(); } else { BuildingBlock.shuffle(_inputs); foreach (IAreaConnector input in _inputs) { PuzzleOutput possibleInput = input.areaGeneratePuzzle(this); if (possibleInput == null) continue; _input = input; _boundBuildingBlock = buildingBlockToBind; PuzzleOutput result = new PuzzleOutput(); result.Items.AddRange(possibleInput.Items); result.Relationships.AddRange(possibleInput.Relationships); // Add an area connection relationship here AreaConnectionRelationship connectionRelationship = input.makeConnection(this); result.Relationships.Add(connectionRelationship); return result; } return null; } }
// The function that is the official entry point to generating a puzzle with this building block public virtual PuzzleOutput generatePuzzle(string outputName, Dictionary <string, object> desiredOutputProperties) { _itemsToSpawn = new List <PuzzleItem>(); _relationshipsToSpawn = new List <IRelationship>(); _desiredOutputProperties = desiredOutputProperties; _spawnedOutput = null; if (_verbose) { Debug.Log("Generating puzzle for " + outputName); } if (!spawnFilteredOutput(outputName)) { return(null); } if (!spawnFilteredInputs(outputName)) { return(null); } // In case of success, time to create a puzzle output PuzzleOutput result = new PuzzleOutput(); result.Items = _itemsToSpawn; result.Relationships = _relationshipsToSpawn; return(result); }
public override PuzzleOutput generatePuzzle(string outputName, System.Collections.Generic.Dictionary <string, object> desiredOutputProperties) { if (_verbose) { Debug.Log(string.Format("Generating OR Block")); } if (Random.value >= 0.5f) { // Try option 1 first if (_verbose) { Debug.Log("TRYING OPTION 1"); } PuzzleOutput maybeOutput = _option1.generatePuzzle(outputName, desiredOutputProperties); if (maybeOutput != null) { _spawnedOption = _option1; return(maybeOutput); } // Next try option 2 if (_verbose) { Debug.Log("TRYING OPTION 2"); } maybeOutput = _option2.generatePuzzle(outputName, desiredOutputProperties); if (maybeOutput != null) { _spawnedOption = _option2; return(maybeOutput); } return(null); } else { // Try option 2 first if (_verbose) { Debug.Log("TRYING OPTION 2"); } PuzzleOutput maybeOutput = _option2.generatePuzzle(outputName, desiredOutputProperties); if (maybeOutput != null) { _spawnedOption = _option2; return(maybeOutput); } // Next try option 1 if (_verbose) { Debug.Log("TRYING OPTION 1"); } maybeOutput = _option1.generatePuzzle(outputName, desiredOutputProperties); if (maybeOutput != null) { _spawnedOption = _option1; return(maybeOutput); } return(null); } }
protected override bool spawnFilteredInputs(string outputName) { DBItem dbOutput = Database.Instance.getItem(outputName); // Get the possible boxes to contain our item List <string> possibleContainers = new List <string>(); if (_desiredOutputProperties.ContainsKey("fills")) { possibleContainers = new List <string>(_desiredOutputProperties["fills"] as List <string>); } else if (dbOutput.propertyExists("fills")) { possibleContainers = new List <string>(dbOutput.getProperty("fills") as List <string>); } BuildingBlock.shuffle(possibleContainers); foreach (string boxName in possibleContainers) { Dictionary <string, object> boxProperties = new Dictionary <string, object>(); boxProperties["open"] = false; boxProperties["contains"] = new List <string>() { outputName }; boxProperties["innerItemProps"] = new Dictionary <string, object>(_desiredOutputProperties); // Include the spawn index (boxProperties["innerItemProps"] as Dictionary <string, object>)["spawnIndex"] = _outputSpawnIndex; PuzzleOutput possibleInput = _containerInput.generatePuzzle(boxName, boxProperties); if (possibleInput == null) { if (_verbose) { Debug.Log(string.Format("Failed to generate unboxing puzzle with {0} as the box and {1} as the item to remove.", boxName, outputName)); } continue; } // If we officially succeed if (_verbose) { Debug.Log(string.Format("Successfully generated unboxing puzzle with {0} as the box and {1} as the item to remove.", boxName, outputName)); } _itemsToSpawn.AddRange(possibleInput.Items); _relationshipsToSpawn.AddRange(possibleInput.Relationships); // Add the insertion relationship InsertionRelationship insertionRelationship = new InsertionRelationship(outputName, _outputSpawnIndex, boxName, _containerInput.outputSpawnIndex()); _relationshipsToSpawn.Add(insertionRelationship); return(true); } if (_verbose) { Debug.Log("Failed to generate unboxing puzzle. No possible boxes worked."); } return(false); }
// The function that's called when we actually generate the puzzle. protected void onSuccess(string changeeName, string changerName, PuzzleOutput changeeInput, PuzzleOutput changerInput, string propertyName, object propertyVal) { if (_verbose) Debug.Log(string.Format("Successfully generated property change puzzle with {0} as changer and {1} as changee", changerName, changeeName)); _itemsToSpawn.AddRange(changeeInput.Items); _itemsToSpawn.AddRange(changerInput.Items); _relationshipsToSpawn.AddRange(changeeInput.Relationships); _relationshipsToSpawn.AddRange(changerInput.Relationships); PropertyChangeRelationship changeRelationship = new PropertyChangeRelationship(changeeName, _changeeInput.outputSpawnIndex(), changerName, _changerInput.outputSpawnIndex(), propertyName, propertyVal); _relationshipsToSpawn.Add(changeRelationship); }
protected void onSuccess(string outputName, string giverName, string requestName, PuzzleOutput giverInput, PuzzleOutput requestInput, string propertyName, object propertyVal) { if (_verbose) Debug.Log(string.Format("Successfully generated item request puzzle with {0} as giver and {1} as requested item and {2} as reward.", giverName, requestName, outputName)); _itemsToSpawn.AddRange(giverInput.Items); _itemsToSpawn.AddRange(requestInput.Items); _relationshipsToSpawn.AddRange(giverInput.Relationships); _relationshipsToSpawn.AddRange(requestInput.Relationships); ItemRequestRelationship requestRelationship = new ItemRequestRelationship(giverName, _requesterInput.outputSpawnIndex(), requestName, _requestedInput.outputSpawnIndex(), _spawnedOutput, propertyName, propertyVal); _relationshipsToSpawn.Add(requestRelationship); }
// The function that's called when we actually generate the puzzle. protected void onSuccess(string changeeName, string changerName, PuzzleOutput changeeInput, PuzzleOutput changerInput, string propertyName, object propertyVal) { if (_verbose) { Debug.Log(string.Format("Successfully generated property change puzzle with {0} as changer and {1} as changee", changerName, changeeName)); } _itemsToSpawn.AddRange(changeeInput.Items); _itemsToSpawn.AddRange(changerInput.Items); _relationshipsToSpawn.AddRange(changeeInput.Relationships); _relationshipsToSpawn.AddRange(changerInput.Relationships); PropertyChangeRelationship changeRelationship = new PropertyChangeRelationship(changeeName, _changeeInput.outputSpawnIndex(), changerName, _changerInput.outputSpawnIndex(), propertyName, propertyVal); _relationshipsToSpawn.Add(changeRelationship); }
protected override bool spawnFilteredInputs(string outputName) { if (!isCarryable(_keyName, _keyInput)) { if (_verbose) { Debug.Log("Failed to generate door unlock puzzle: key was not carryable."); } return(false); } // Try to generate our key PuzzleOutput possibleKeyInput = _keyInput.generatePuzzle(_keyName); if (possibleKeyInput == null) { if (_verbose) { Debug.Log("Failed to generate door unlock puzzle: key input failed"); } return(false); } // Make sure our connecting area is valid PuzzleOutput areaValidation = _connectingArea.areaGeneratePuzzle(this); if (areaValidation == null) { _keyInput.despawnItems(); if (_verbose) { Debug.Log("Failed to generate door unlock puzzle: room of origin failed"); } return(false); } if (_verbose) { Debug.Log(string.Format("Successfully generated door unlock puzzle with {0} as a key", _keyName)); } _itemsToSpawn.AddRange(possibleKeyInput.Items); _relationshipsToSpawn.AddRange(possibleKeyInput.Relationships); _itemsToSpawn.AddRange(areaValidation.Items); _relationshipsToSpawn.AddRange(areaValidation.Relationships); return(true); }
protected override bool spawnFilteredInputs(string outputName) { PuzzleOutput possibleInput = _myArea.areaGeneratePuzzle(this); if (possibleInput == null) { if (_verbose) { Debug.Log("Failed to generate Spawn Puzzle. Input Area was unable to generate."); } return(false); } _itemsToSpawn.AddRange(possibleInput.Items); _relationshipsToSpawn.AddRange(possibleInput.Relationships); (_spawnedOutput as PuzzleItem).setProperty("spawnArea", _myArea.name); return(true); }
public PuzzleOutput areaGeneratePuzzle(BuildingBlock buildingBlockToBind) { if (_verbose) { Debug.Log("spawning Area: " + _name); } if (_boundBuildingBlock != null) { if (_verbose) { Debug.Log("Area already bound to another building block!"); } return(new PuzzleOutput()); } else { BuildingBlock.shuffle(_inputs); foreach (IAreaConnector input in _inputs) { PuzzleOutput possibleInput = input.areaGeneratePuzzle(this); if (possibleInput == null) { continue; } _input = input; _boundBuildingBlock = buildingBlockToBind; PuzzleOutput result = new PuzzleOutput(); result.Items.AddRange(possibleInput.Items); result.Relationships.AddRange(possibleInput.Relationships); // Add an area connection relationship here AreaConnectionRelationship connectionRelationship = input.makeConnection(this); result.Relationships.Add(connectionRelationship); return(result); } return(null); } }
protected void onSuccess(string outputName, string giverName, string requestName, PuzzleOutput giverInput, PuzzleOutput requestInput) { onSuccess(outputName, giverName, requestName, giverInput, requestInput, null, null); }
protected bool tryToGeneratePuzzles(string changeeName, string propertyName, object propertyVal, object startingVal) { if (!Database.Instance.itemExists(changeeName)) { if (_verbose) { Debug.Log("Failed to generate property change puzzle."); Debug.Log(string.Format("WARNING: tried to generate puzzle with item that does not exist in database: {0}", changeeName)); } return(false); } DBItem dbChangee = Database.Instance.getItem(changeeName); if (!dbChangee.propertyExists(propertyName)) { if (_verbose) { Debug.Log(string.Format("Failed to generate property change puzzle. Attempted property: {0} did not exist for {1}", propertyName, changeeName)); } return(false); } List <string> possibleVals = new List <string>(dbChangee.getProperty(propertyName) as List <string>); // Now we need to iterate through all of the values instead of just a random choice. // this ensures we try all options if (propertyVal == null) { // shuffle our values BuildingBlock.shuffle(possibleVals); foreach (string maybeVal in possibleVals) { bool maybeGood = tryToGeneratePuzzles(changeeName, propertyName, maybeVal, startingVal); if (maybeGood) { return(true); } } if (_verbose) { Debug.Log(string.Format("Failed to generate property change puzzle: No desired value for property {0} worked.", propertyName)); } return(false); } // Now we need to remove the desired property from the list of posible values so we can effectively // choose a different starting value possibleVals.Remove(propertyVal as string); // Iterate through possible starting values if we don't already have on e if (startingVal == null) { if (possibleVals.Count == 0) { return(false); } BuildingBlock.shuffle(possibleVals); foreach (string maybeStartingVal in possibleVals) { bool maybeGood = tryToGeneratePuzzles(changeeName, propertyName, propertyVal, maybeStartingVal); if (maybeGood) { return(true); } } if (_verbose) { Debug.Log(string.Format("Failed to generate property change puzzle: No possible starting value for property {0} worked.", propertyName)); } return(false); } // Since we've reached this point in the function, we can assume that we have a valid changee name, property name, property value, and starting property value Dictionary <string, object> changeeStartingProp = new Dictionary <string, object>(); // Make sure all the other properties we desire are taken care of foreach (string otherName in _desiredOutputProperties.Keys) { changeeStartingProp[otherName] = _desiredOutputProperties[otherName]; } changeeStartingProp[propertyName] = startingVal; PuzzleOutput possibleChangeeInput = _changeeInput.generatePuzzle(changeeName, changeeStartingProp); if (possibleChangeeInput == null) { if (_verbose) { Debug.Log(string.Format("Failed to generate property change puzzle with {0} as the changee.", changeeName)); } _changeeInput.despawnItems(); return(false); } if (!dbChangee.propertyExists("changedby")) { if (_verbose) { Debug.Log(string.Format("Failed to generate property change puzzle with {0} as the changee. Does not possess the changedby property.")); } return(false); } // Now we choose a random changer List <string> filteredChangers = dbChangee.getProperty("changedby") as List <string>; filteredChangers = getRelevantChangers(filteredChangers, propertyName, propertyVal); // Randomly shuffle our changers BuildingBlock.shuffle(filteredChangers); foreach (string changerName in filteredChangers) { if (!areCarryable(new List <string>() { changeeName, changerName }, new List <BuildingBlock>() { _changeeInput, _changerInput })) { continue; } PuzzleOutput possibleChangerInput = _changerInput.generatePuzzle(changerName); if (possibleChangerInput == null) { if (_verbose) { Debug.Log(string.Format("Failed to generate property change puzzle with {0} as the changer", changerName)); } _changerInput.despawnItems(); } else { onSuccess(changeeName, changerName, possibleChangeeInput, possibleChangerInput, propertyName, propertyVal); return(true); } } if (_verbose) { Debug.Log(string.Format("Failed to generate property change puzzle with {0} as the changee. No changers worked.", changeeName)); } _changeeInput.despawnItems(); return(false); }
protected override bool spawnFilteredInputs(string outputName) { // First determine if our desiredProperties specifically has any items it wants to contain DBItem dbOutput = Database.Instance.getItem(outputName); List <string> possibleFillers; if (_desiredOutputProperties["contains"] != null) { possibleFillers = new List <string>(_desiredOutputProperties["contains"] as List <string>); } else if (dbOutput.propertyExists("filledby")) { possibleFillers = new List <string>(dbOutput.getProperty("filledby") as List <string>); } else { if (_verbose) { Debug.Log("Failed to generate insertion puzzle. No possible fillers worked."); } return(false); } BuildingBlock.shuffle(possibleFillers); foreach (string fillerName in possibleFillers) { if (!areCarryable(new List <string>() { outputName, fillerName }, new List <BuildingBlock>() { _containerInput, _itemToInsertInput })) { continue; } // Update the properties we're passing to our inputs Dictionary <string, object> newDesiredOutputProperties = new Dictionary <string, object>(); foreach (string key in _desiredOutputProperties.Keys) { newDesiredOutputProperties[key] = _desiredOutputProperties[key]; } // Make sure we can open our item newDesiredOutputProperties["open"] = true; if (newDesiredOutputProperties["contains"] != null) { List <string> fillerArray = new List <string>(newDesiredOutputProperties["contains"] as List <string>); fillerArray.Remove(fillerName); if (fillerArray.Count == 0) { newDesiredOutputProperties.Remove("contains"); } else { newDesiredOutputProperties["contains"] = fillerArray; } } // Now try to generate the inputs Dictionary <string, object> innerItemProps = new Dictionary <string, object>(); if (_desiredOutputProperties.ContainsKey("innerItemProps")) { innerItemProps = _desiredOutputProperties["innerItemProps"] as Dictionary <string, object>; } PuzzleOutput possibleContainerInput = _containerInput.generatePuzzle(outputName, newDesiredOutputProperties); PuzzleOutput possibleFillerInput = _itemToInsertInput.generatePuzzle(fillerName, innerItemProps); if (possibleContainerInput == null || possibleFillerInput == null) { if (_verbose) { Debug.Log(string.Format("Failed to generate insertion puzzle with {0} as the container and {1} as the filler.", outputName, fillerName)); } _containerInput.despawnItems(); _itemToInsertInput.despawnItems(); continue; } if (_verbose) { Debug.Log(string.Format("Successfully generated insertion puzzle with {0} as container and {1} as the filler.", outputName, fillerName)); } _itemsToSpawn.AddRange(possibleContainerInput.Items); _itemsToSpawn.AddRange(possibleFillerInput.Items); _relationshipsToSpawn.AddRange(possibleContainerInput.Relationships); _relationshipsToSpawn.AddRange(possibleFillerInput.Relationships); // Add an insertion relationship here InsertionRelationship insertionRelationship = new InsertionRelationship(fillerName, _itemToInsertInput.outputSpawnIndex(), outputName, _containerInput.outputSpawnIndex()); _relationshipsToSpawn.Add(insertionRelationship); return(true); } if (_verbose) { Debug.Log("Failed to generate insertion puzzle. No possible fillers worked."); } return(false); }
protected void onSuccess(string outputName, string giverName, string requestName, PuzzleOutput giverInput, PuzzleOutput requestInput, string propertyName, object propertyVal) { if (_verbose) { Debug.Log(string.Format("Successfully generated item request puzzle with {0} as giver and {1} as requested item and {2} as reward.", giverName, requestName, outputName)); } _itemsToSpawn.AddRange(giverInput.Items); _itemsToSpawn.AddRange(requestInput.Items); _relationshipsToSpawn.AddRange(giverInput.Relationships); _relationshipsToSpawn.AddRange(requestInput.Relationships); ItemRequestRelationship requestRelationship = new ItemRequestRelationship(giverName, _requesterInput.outputSpawnIndex(), requestName, _requestedInput.outputSpawnIndex(), _spawnedOutput, propertyName, propertyVal); _relationshipsToSpawn.Add(requestRelationship); }
protected void generateGame() { _relationshipMap = new Dictionary <string, Dictionary <string, IRelationship> >(); _requests = new Dictionary <string, ItemRequestRelationship>(); _areaRooms = new Dictionary <string, Room>(); _areaConnections = new Dictionary <string, List <string> >(); _lockedAreaConnections = new Dictionary <string, List <AreaConnectionRelationship> >(); _itemNames = new HashSet <string>(); _startRoom = null; _startArea = null; // Let's make a puzzle! Database.Instance.removeExtensions(); Database.Instance.addExtension(new ChangesExtension()); Database.Instance.addExtension(new ChangedbyExtension()); Database.Instance.addExtension(new ParentExtension()); Database.Instance.addExtension(new FilledbyExtension()); Database.Instance.addExtension(new MakesExtension()); Database.Instance.addExtension(new GivesExtension()); Globals.shuffle(_puzzleMaps); PuzzleOutput output = null; int puzzleI = 0; int numTries = 0; while (output == null && numTries < MAX_TRIES) { Database.Instance.clearDatabase(); DBParser.createDatabaseFromXml(new string[] { "database" }); Database.Instance.runExtensions(); BuildingBlock puzzle = PuzzleMapParser.createBuildingBlockFromXml(_puzzleMaps[puzzleI]); output = puzzle.generatePuzzle("sandwich"); puzzleI = (puzzleI + 1) % _puzzleMaps.Count; numTries++; } foreach (IRelationship rel in output.Relationships) { rel.addRelationshipToGame(this); Debug.Log(rel.ToString()); } // Now add all the relationships and items foreach (PuzzleItem item in output.Items) { spawnItem(item); } createAreaConnections(); createAuxiliaryRelationships(); // Add the player to the start room. GameObject playerObj = GameObject.Instantiate(PlayState.instance.playerPrefab) as GameObject; _player = playerObj.GetComponent <Player>(); _startRoom.addPiece(_player); }
protected override bool spawnFilteredInputs(string outputName) { DBItem rewardDBItem = Database.Instance.getItem(outputName); if (!rewardDBItem.propertyExists("givenby")) { if (_verbose) { Debug.Log("Failed to generate item request puzzle: Reward could not be result of item request"); } return(false); } List <string> workingQuestgivers = rewardDBItem.getProperty("givenby") as List <string>; List <string> filteredQuestgivers = filterQuestgivers(workingQuestgivers); if (filteredQuestgivers.Count == 0) { if (_verbose) { Debug.Log(string.Format("Failed to generate item request puzzle: no questgivers met constraints")); } return(false); } BuildingBlock.shuffle(filteredQuestgivers); foreach (string giverName in filteredQuestgivers) { PuzzleOutput possibleGiverInput = _requesterInput.generatePuzzle(giverName); if (possibleGiverInput == null) { if (_verbose) { Debug.Log(string.Format("Failed to generate item request puzzle using {0} as requester", giverName)); } _requesterInput.despawnItems(); continue; } DBItem giverDBItem = Database.Instance.getItem(giverName); if (!giverDBItem.propertyExists("requests")) { if (_verbose) { Debug.Log(string.Format("Failed to generate item request puzzle: requester {0} had no requests", giverName)); } _requesterInput.despawnItems(); continue; } List <string> requests = new List <string>(giverDBItem.getProperty("requests") as List <string>); BuildingBlock.shuffle(requests); foreach (string requestName in requests) { if (!areCarryable(new List <string>() { giverName, requestName }, new List <BuildingBlock>() { _requesterInput, _requestedInput })) { continue; } DBItem dbRequestItem = Database.Instance.getItem(requestName); if (dbRequestItem == null) { if (_verbose) { Debug.Log(string.Format("WARNING: tried to access item in database that doesn't exist: {0}", requestName)); } continue; } else if (dbRequestItem.Spawned) { if (_verbose) { Debug.Log(string.Format("failed to use {0} as a requested item. Item already spawned.", requestName)); } continue; } // Now we need to iterate through the mutable properties of the requested item List <string> propertyNames = dbRequestItem.getProperty("mutables") as List <string>; // If we don't have any mutable properties, then just go ahead and generate a normal request if (propertyNames == null || propertyNames.Count == 0) { PuzzleOutput possibleRequestInput = _requestedInput.generatePuzzle(requestName); if (possibleRequestInput == null) { if (_verbose) { Debug.Log(string.Format("Failed to generate item request puzzle with {0} as the requested item.", requestName)); } _requestedInput.despawnItems(); } else { onSuccess(outputName, giverName, requestName, possibleGiverInput, possibleRequestInput); return(true); } } else { BuildingBlock.shuffle(propertyNames); foreach (string propertyName in propertyNames) { List <string> values = dbRequestItem.getProperty(propertyName) as List <string>; if (values == null) { values = new List <string>() { null } } ; values = new List <string>(values); BuildingBlock.shuffle(values); foreach (object val in values) { Dictionary <string, object> inputDesiredProps = new Dictionary <string, object>(); inputDesiredProps[propertyName] = val; PuzzleOutput possibleRequestInput = _requestedInput.generatePuzzle(requestName, inputDesiredProps); if (possibleRequestInput == null) { _requestedInput.despawnItems(); if (_verbose) { Debug.Log(string.Format("Failed to generate item request puzzle with {0} as the requested item", requestName)); } } else { onSuccess(outputName, giverName, requestName, possibleGiverInput, possibleRequestInput, propertyName, val); return(true); } } } } } if (_verbose) { Debug.Log(string.Format("failed to generate item request puzzle with {0} as the giver. No requests worked", giverName)); } _requesterInput.despawnItems(); } if (_verbose) { Debug.Log("Failed to generate item request puzzle: No working combinations of quest giver and request worked"); } return(false); }
protected override bool spawnFilteredInputs(string outputName) { DBItem rewardDBItem = Database.Instance.getItem(outputName); if (!rewardDBItem.propertyExists("madeby")) { if (_verbose) { Debug.Log("Failed to generate combine puzzle: Reward could not be the result of combination"); } return(false); } List <KeyValuePair <string, string> > workingCombinations = rewardDBItem.getProperty("madeby") as List <KeyValuePair <string, string> >; List <KeyValuePair <string, string> > filteredCombinations = filterWorkingCombinations(workingCombinations); if (filteredCombinations.Count == 0) { if (_verbose) { Debug.Log("Failed to generate combine puzzle: No working combinations fit constraints"); } return(false); } // Randomly shuffle our working combinations BuildingBlock.shuffle(filteredCombinations); // and try each combination foreach (KeyValuePair <string, string> itemPair in filteredCombinations) { // Unpack the "Tuples" string itemName1 = itemPair.Key; string itemName2 = itemPair.Value; PuzzleOutput possibleInput1 = _input1.generatePuzzle(itemName1); PuzzleOutput possibleInput2 = _input2.generatePuzzle(itemName2); if (possibleInput1 == null || possibleInput2 == null) { if (_verbose) { Debug.Log("Failed to generate combine puzzle using " + itemName1 + " and " + itemName2); } Debug.Log(string.Format("input1: {0}, input2: {1}", possibleInput1, possibleInput2)); _input1.despawnItems(); _input2.despawnItems(); continue; } else if (!BuildingBlock.areCarryable(new List <string>() { itemName1, itemName2 }, new List <BuildingBlock>() { _input1, _input2 })) { if (_verbose) { Debug.Log("Failed to generate combine puzzle using " + itemName1 + " and " + itemName2 + " because neither item is carryable to the other item."); } _input1.despawnItems(); _input2.despawnItems(); continue; } // Success! else { if (_verbose) { Debug.Log("Successfully generated combine puzzle for " + outputName + " with " + itemName1 + " and " + itemName2); } // Add all the items spawned by our inputs _itemsToSpawn.AddRange(possibleInput1.Items); _itemsToSpawn.AddRange(possibleInput2.Items); _relationshipsToSpawn.AddRange(possibleInput1.Relationships); _relationshipsToSpawn.AddRange(possibleInput2.Relationships); // Generate the essential combine relationship CombineRelationship combine = new CombineRelationship(itemName1, _input1.outputSpawnIndex(), itemName2, _input2.outputSpawnIndex(), _spawnedOutput as PuzzleItem); _relationshipsToSpawn.Add(combine); return(true); } } if (_verbose) { Debug.Log("Failed to generate combine puzzle: no working combinations worked!"); } return(false); }