From a9e1db4ac224b4e851051f2bf41881540167c644 Mon Sep 17 00:00:00 2001 From: Vladimir Koshevarov Date: Thu, 18 Aug 2022 14:31:33 +0300 Subject: [PATCH] monolith burger door have trigger to open a menu --- Assets/Scripts/Buildings/Building.cs | 22 +++++++++++++--------- Assets/Scripts/Buildings/Burger.cs | 23 +++++++++++++++++------ Assets/Scripts/Buildings/House.cs | 7 ++++++- 3 files changed, 36 insertions(+), 16 deletions(-) diff --git a/Assets/Scripts/Buildings/Building.cs b/Assets/Scripts/Buildings/Building.cs index 468ce1d4..2f768be0 100644 --- a/Assets/Scripts/Buildings/Building.cs +++ b/Assets/Scripts/Buildings/Building.cs @@ -6,25 +6,29 @@ namespace Assets.Scripts.Buildings { public abstract class BaseCell : MonoBehaviour { - public Dictionary OptionsList; - - protected BaseCell() - { - OptionsList = new Dictionary(); - } - - protected abstract void BuildOptionsList(); + protected string _name; + protected Dictionary _optionsList; // Start is called before the first frame update void Start() { - + _optionsList = new Dictionary(); + Initialize(); + BuildOptionsList(); } // Update is called once per frame void Update() { + + } + protected abstract void Initialize(); + protected abstract void BuildOptionsList(); + + void OnTriggerEnter(Collider other) + { + ConversationController.Instance.Change(_name, _optionsList); } } } \ No newline at end of file diff --git a/Assets/Scripts/Buildings/Burger.cs b/Assets/Scripts/Buildings/Burger.cs index faff67c9..54302cb9 100644 --- a/Assets/Scripts/Buildings/Burger.cs +++ b/Assets/Scripts/Buildings/Burger.cs @@ -1,17 +1,28 @@ using Assets.Scripts.Actions; +using UnityEngine; namespace Assets.Scripts.Buildings { public class Burger : BaseCell { + protected override void Initialize() + { + _name = "Monolith burger"; + } + protected override void BuildOptionsList() { - OptionsList.Add("Hamburgers - 83$", new Eat(null, 6, 1, 83)); - OptionsList.Add("Cheesburger - 94$", new Eat(null, 6, 1, 94)); - OptionsList.Add("Astro chicken - 131$", new Eat(null, 6, 1, 131)); - OptionsList.Add("Fries - 68$", new Eat(null, 6, 1, 68)); - OptionsList.Add("Shakes - 108$", new Eat(null, 6, 1, 108)); - OptionsList.Add("Colas - 73$", new Eat(null, 6, 1, 73)); + _optionsList.Add("Hamburgers - 83$", new Eat(null, 6, 1, 83)); + _optionsList.Add("Cheesburger - 94$", new Eat(null, 6, 1, 94)); + _optionsList.Add("Astro chicken - 131$", new Eat(null, 6, 1, 131)); + _optionsList.Add("Fries - 68$", new Eat(null, 6, 1, 68)); + _optionsList.Add("Shakes - 108$", new Eat(null, 6, 1, 108)); + _optionsList.Add("Colas - 73$", new Eat(null, 6, 1, 73)); + } + + void OnTriggerEnter(Collider other) + { + ConversationController.Instance.Change(_name, _optionsList); } } } diff --git a/Assets/Scripts/Buildings/House.cs b/Assets/Scripts/Buildings/House.cs index d9b4d736..bf3aab69 100644 --- a/Assets/Scripts/Buildings/House.cs +++ b/Assets/Scripts/Buildings/House.cs @@ -6,7 +6,12 @@ namespace Assets.Scripts.Buildings { protected override void BuildOptionsList() { - OptionsList.Add("Rest", new Relax(null, 6, 1)); + _optionsList.Add("Rest", new Relax(null, 6, 1)); + } + + protected override void Initialize() + { + throw new System.NotImplementedException(); } } }