- Home /
Combine items in inventory (a la LucasArts)
I guess this is more trying to figure out the best way to think about the problem.
I'm halfway through a project where the character can combine items with each other. Each combination, if possible results in a different reaction from the character and a unique result (sometimes a new object, sometimes changes on the original object etc)
If the combination is impossible the character can say the generic "Not sure how to do that" or sometimes a more specific reply about why its impossible to combine the 2 objects.
The way I do it so far is compare if the names of the objects are "acceptable" using a generic list
combinationsList.Add("Ambien Pills, Mug with tea satchet");
combinationsList.Add("Ambien Pills, Mug with cold water");
combinationsList.Add("Ambien Pills, Mug with hot water");
combinationsList.Add("Ambien Pills, Mug with sleeping pills");
If the combination is in the list then sort the result between the two objects:
if (x.basicProperties.objName == "Ambien Pills"){
//Mug
if (y.basicProperties.objName == "Mug"){
playerInteractions.SaySingleThought("Added a couple of pills to the mug.");
audio.PlayClipAtPoint(x.customAudioClip01, x.transform.position);
y.basicProperties.objName = "Mug with sleeping pills";
y.basicProperties.lookAtDescription = "It has a couple of sleeping pills.";
}
//Mug with tea satchet
else if (y.basicProperties.objName == "Mug with tea satchet"){
playerInteractions.SaySingleThought("Added a couple of pills to the mug.");
audio.PlayClipAtPoint(x.customAudioClip01, x.transform.position);
y.basicProperties.objName = "Mug with tea satchet and sleeping pills";
y.basicProperties.lookAtDescription = "A mug with sleeping pills and a tea satchet.";
}
This is doing exactly what I need but I think it will get messy once I have a lot of objects.
After thinking a while this is how I think I should do it:
Each object adds himself to an array
In the editor, per object, I have the option to "add" objects" that I want the selected object to interact with (like a drop down list from the array I created).
Once I added a object combination to the selected object I can write the custom code that will be executed when the combination happens.
This way I could just select an object to see what are the current valid combinations and quickly add more.
Now I don't know how I go about doing the drop down list from the array in the editor. And how would I be able to write custom code in the editor that will run in game for each interaction?
Hope the question is clear, thanks in advance!
Your answer
Follow this Question
Related Questions
stack by quanity...? C# 2 Answers
Database error updating inventory 0 Answers
Inventory armor wielding proplem,How to convert from derived to base 1 Answer
Pickable items; Editor vs Savegame 2 Answers
Equipting a Item/Weapon 1 Answer