- Home /
Question by
kazchew903 · Mar 20, 2020 at 09:13 AM ·
script.tips
I'm Trying to create an Interaction system with many choices, any Guides or Tutorials will be helpful.
private void Chat(Player player)
{
canChat = false;
likability += 1;
Debug.Log("Player talked to the Cow");
}
public override List<Interaction> Interactions
{
get
{
List<Interaction> availableInteraction = new List<Interaction>();
if (canChat)
{
Interaction interaction = new Interaction("Chat", Chat);
availableInteraction.Add(interaction);
}
if (canFeed)
{
Interaction interaction = new Interaction("Feed", Feed);
availableInteraction.Add(interaction);
}
if (canMilk)
{
Interaction interaction = new Interaction("Milk", Milk);
availableInteraction.Add(interaction);
}
return availableInteraction;
}
}
public class Interaction { private string interactionName; private Action action;
public Interaction(string interactionName, Action<Player> action)
{
this.interactionName = interactionName;
this.action = action;
}
public void DoAction(Player player)
{
action?.Invoke(player);
}
public string InteractionName => interactionName;
}
Comment
Your answer

Follow this Question
Related Questions
Making an AirPlane follow mouse 1 Answer
How do I access the contents of a script from another script? 2 Answers
How can I write this code, from C# to JavaScript? 2 Answers
How can i using a break point if a gameobject have a collider after added to it ? 1 Answer
How can i make enum choice to not pause the game ? 0 Answers