start to change action system

This commit is contained in:
Vladimir Koshevarov
2022-08-18 16:07:06 +03:00
parent a9e1db4ac2
commit 9366aa479c
11 changed files with 31 additions and 49 deletions
@@ -10,6 +10,7 @@ public class ConversationChangeEvent : UnityEvent<BaseAction> { }
public class ChoiceController : MonoBehaviour
{
public PlayerController playerController;
public KeyValuePair<string, BaseAction> _option;
public ConversationChangeEvent conversationChangeEvent;
// Update is called once per frame
@@ -41,6 +42,7 @@ public class ChoiceController : MonoBehaviour
public void MakeChoice()
{
playerController.TryBuyAction(_option.Value);
conversationChangeEvent.Invoke(_option.Value);
}
}
@@ -11,16 +11,14 @@ public class ConversationController : MonoBehaviour
public TextMeshProUGUI _title;
[SerializeField]
public Button _choiceButton;
[SerializeField]
private Button _closeBtn;
public ConversationChangeEvent conversationChangeEvent;
private List<ChoiceController> choiceControllers = new();
public static ConversationController Instance { get; private set; }
private void Awake()
{
Instance = this;
Hide();
}
@@ -35,17 +33,14 @@ public class ConversationController : MonoBehaviour
ChoiceController c = ChoiceController.AddChoiceButton(_choiceButton, options.ElementAt(count), count);
choiceControllers.Add(c);
}
_closeBtn.onClick.AddListener(() =>
{
Hide();
});
StopAllCoroutines();
Time.timeScale = 0;
_choiceButton.gameObject.SetActive(false);
}
private void RemoveChoices()
{
foreach (ChoiceController c in choiceControllers)
@@ -1,5 +1,3 @@
using Assets.Scripts.Actions;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
@@ -22,19 +20,7 @@ public class TestingQuestionDialog : MonoBehaviour
});
}
if (Input.GetKeyDown(KeyCode.Space))
{
Dictionary<string, BaseAction> optionsList = new Dictionary<string, BaseAction>
{
{ "Hamburgers - 83$", new Eat(null, 6, 1, 83) },
{ "Cheesburger - 94$", new Eat(null, 6, 1, 94) },
{ "Astro chicken - 131$", new Eat(null, 6, 1, 131) },
{ "Fries - 68$", new Eat(null, 6, 1, 68) },
{ "Shakes - 108$", new Eat(null, 6, 1, 108) },
{ "Colas - 73$", new Eat(null, 6, 1, 73) }
};
ConversationController.Instance.Change("Monolith burger", optionsList);
}
}