CleanupCode add eating
This commit is contained in:
@@ -1863,7 +1863,7 @@ PrefabInstance:
|
||||
- target: {fileID: 808129671576928264, guid: 8939548f67eb43c4fa321f112c45f83b,
|
||||
type: 3}
|
||||
propertyPath: m_AnchoredPosition.x
|
||||
value: 0
|
||||
value: 20
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 808129671576928264, guid: 8939548f67eb43c4fa321f112c45f83b,
|
||||
type: 3}
|
||||
@@ -1888,7 +1888,7 @@ PrefabInstance:
|
||||
- target: {fileID: 896272491191485165, guid: 8939548f67eb43c4fa321f112c45f83b,
|
||||
type: 3}
|
||||
propertyPath: m_AnchoredPosition.x
|
||||
value: 0
|
||||
value: 182.005
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 896272491191485165, guid: 8939548f67eb43c4fa321f112c45f83b,
|
||||
type: 3}
|
||||
@@ -2013,22 +2013,22 @@ PrefabInstance:
|
||||
- target: {fileID: 4307980429506515175, guid: 8939548f67eb43c4fa321f112c45f83b,
|
||||
type: 3}
|
||||
propertyPath: m_AnchorMax.y
|
||||
value: 0
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4307980429506515175, guid: 8939548f67eb43c4fa321f112c45f83b,
|
||||
type: 3}
|
||||
propertyPath: m_AnchorMin.y
|
||||
value: 0
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4307980429506515175, guid: 8939548f67eb43c4fa321f112c45f83b,
|
||||
type: 3}
|
||||
propertyPath: m_AnchoredPosition.x
|
||||
value: 0
|
||||
value: 250
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4307980429506515175, guid: 8939548f67eb43c4fa321f112c45f83b,
|
||||
type: 3}
|
||||
propertyPath: m_AnchoredPosition.y
|
||||
value: 0
|
||||
value: -90
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4537241548631189332, guid: 8939548f67eb43c4fa321f112c45f83b,
|
||||
type: 3}
|
||||
@@ -2123,7 +2123,7 @@ PrefabInstance:
|
||||
- target: {fileID: 6551138445549304010, guid: 8939548f67eb43c4fa321f112c45f83b,
|
||||
type: 3}
|
||||
propertyPath: m_AnchoredPosition.x
|
||||
value: 0
|
||||
value: 182.005
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 6551138445549304010, guid: 8939548f67eb43c4fa321f112c45f83b,
|
||||
type: 3}
|
||||
@@ -2248,7 +2248,7 @@ PrefabInstance:
|
||||
- target: {fileID: 7883991513978601488, guid: 8939548f67eb43c4fa321f112c45f83b,
|
||||
type: 3}
|
||||
propertyPath: m_AnchoredPosition.x
|
||||
value: 0
|
||||
value: 182.005
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7883991513978601488, guid: 8939548f67eb43c4fa321f112c45f83b,
|
||||
type: 3}
|
||||
@@ -2268,12 +2268,12 @@ PrefabInstance:
|
||||
- target: {fileID: 7949779033593405736, guid: 8939548f67eb43c4fa321f112c45f83b,
|
||||
type: 3}
|
||||
propertyPath: m_SizeDelta.x
|
||||
value: 0
|
||||
value: 364.01
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7949779033593405736, guid: 8939548f67eb43c4fa321f112c45f83b,
|
||||
type: 3}
|
||||
propertyPath: m_AnchoredPosition.x
|
||||
value: 0
|
||||
value: 182.005
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7949779033593405736, guid: 8939548f67eb43c4fa321f112c45f83b,
|
||||
type: 3}
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2e8ace0e753f18d41ae7374b31260efd
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,16 +0,0 @@
|
||||
namespace Assets.Scripts.Actions
|
||||
{
|
||||
public abstract class BaseAction
|
||||
{
|
||||
protected int DurationInTicks { get; }
|
||||
protected int ElapsedTicks { get; }
|
||||
|
||||
protected BaseAction(int durationTicks)
|
||||
{
|
||||
DurationInTicks = durationTicks;
|
||||
}
|
||||
|
||||
public abstract void ApplyAction(Player playerController);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e13454be9a4755a4cb902ce4492c0d47
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,27 +0,0 @@
|
||||
using Assets.Scripts.Actions.Interfaces;
|
||||
|
||||
namespace Assets.Scripts.Actions
|
||||
{
|
||||
public class Eat : IPlayerAction, ISellable
|
||||
{
|
||||
public decimal Price { get; private set; }
|
||||
|
||||
public string Name { get; private set; }
|
||||
|
||||
public string Description => $"{Name} - {Price}$";
|
||||
private int _energy;
|
||||
|
||||
public Eat(string name, int energy, decimal price)
|
||||
{
|
||||
Name = name;
|
||||
Price = price;
|
||||
_energy = energy;
|
||||
}
|
||||
|
||||
|
||||
public void ApplyAction(Player playerController)
|
||||
{
|
||||
playerController.Stats[StatsId.Food].increase(_energy);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 88b69afebf64e464981dc504941a0887
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 75ecd68a88c4c904393604b692b01a43
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,20 +0,0 @@
|
||||
namespace Assets.Scripts.Actions.Interfaces
|
||||
{
|
||||
public enum JobId { Unemployed, HotDogs };
|
||||
public interface IPlayerAction
|
||||
{
|
||||
public string Description { get; }
|
||||
public void ApplyAction(Player player);
|
||||
}
|
||||
|
||||
public interface ISellable
|
||||
{
|
||||
public decimal Price { get; }
|
||||
}
|
||||
|
||||
public interface IWorkPlace
|
||||
{
|
||||
public JobId JobID { get; }
|
||||
public decimal Sallary { get; }
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5b7ba6deb189bc44ca6f628a799c8667
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,23 +0,0 @@
|
||||
using Assets.Scripts.Actions.Interfaces;
|
||||
|
||||
namespace Assets.Scripts.Actions
|
||||
{
|
||||
public class JobPosition : IPlayerAction, IWorkPlace
|
||||
{
|
||||
public string Description => $"{_position} - {Sallary}$ per hour";
|
||||
public decimal Sallary { get; private set; }
|
||||
public JobId JobID { get; private set; }
|
||||
|
||||
|
||||
private string _position;
|
||||
|
||||
public JobPosition(string position, decimal sallary, JobId jobId)
|
||||
{
|
||||
_position = position;
|
||||
Sallary = sallary;
|
||||
}
|
||||
public void ApplyAction(Player playerController)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 80cfc634ca94f1e4fa1726ca19eab626
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 46382eb4a7b5812458ddf7287b5a65ff
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cdd8a9c61eebf384796c7c94453d3255
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,36 +0,0 @@
|
||||
using Assets.Scripts.Actions.Interfaces;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Assets.Scripts.Buildings
|
||||
{
|
||||
public abstract class BaseCell : MonoBehaviour
|
||||
{
|
||||
protected string _name;
|
||||
protected List<IPlayerAction> _optionsList;
|
||||
[SerializeField]
|
||||
private ConversationController _conversationController;
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
_optionsList = new List<IPlayerAction>();
|
||||
Initialize();
|
||||
BuildOptionsList();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
protected abstract void Initialize();
|
||||
protected abstract void BuildOptionsList();
|
||||
|
||||
void OnTriggerEnter(Collider other)
|
||||
{
|
||||
_conversationController.Change(_name, _optionsList);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8087167db9f5271408218993b0473a69
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,21 +0,0 @@
|
||||
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(6, 10, 83));
|
||||
//_optionsList.Add("Cheesburger - 94$", new Eat(6, 1, 94));
|
||||
//_optionsList.Add("Astro chicken - 131$", new Eat(6, 1, 131));
|
||||
//_optionsList.Add("Fries - 68$", new Eat(6, 1, 68));
|
||||
//_optionsList.Add("Shakes - 108$", new Eat(6, 1, 108));
|
||||
//_optionsList.Add("Colas - 73$", new Eat(6, 1, 73));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 61bf941dbcbd36f48bdd8f30b1b6c1f0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,19 +0,0 @@
|
||||
using Assets.Scripts.Actions;
|
||||
|
||||
namespace Assets.Scripts.Buildings
|
||||
{
|
||||
public class HotDogs : BaseCell
|
||||
{
|
||||
protected override void Initialize()
|
||||
{
|
||||
_name = "Hot dogs";
|
||||
}
|
||||
|
||||
protected override void BuildOptionsList()
|
||||
{
|
||||
_optionsList.Add(new Eat("Hot Dog", 15, 20));
|
||||
_optionsList.Add(new Eat("Cola", 10, 10));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 60f522567c8014c40a76002f2dc8e2e4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,15 +0,0 @@
|
||||
namespace Assets.Scripts.Buildings
|
||||
{
|
||||
public class House : BaseCell
|
||||
{
|
||||
protected override void BuildOptionsList()
|
||||
{
|
||||
//_optionsList.Add(new Relax("Rest", 6, 1));
|
||||
}
|
||||
|
||||
protected override void Initialize()
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1a4df4c0f11d1a043b36f4ea6a31e4d7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,19 +0,0 @@
|
||||
using Assets.Scripts.Actions;
|
||||
using Assets.Scripts.Actions.Interfaces;
|
||||
|
||||
namespace Assets.Scripts.Buildings
|
||||
{
|
||||
public class JobAgency : BaseCell
|
||||
{
|
||||
protected override void Initialize()
|
||||
{
|
||||
_name = "Job Agency";
|
||||
}
|
||||
|
||||
protected override void BuildOptionsList()
|
||||
{
|
||||
_optionsList.Add(new JobPosition("Hot Dogs sailer ", 20, JobId.HotDogs));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 16925e4f4154a004dadcfa7300af1bbe
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,45 +1,44 @@
|
||||
using Assets.Scripts.Actions.Interfaces;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.UI;
|
||||
//using TMPro;
|
||||
//using UnityEngine;
|
||||
//using UnityEngine.Events;
|
||||
//using UnityEngine.UI;
|
||||
|
||||
[System.Serializable]
|
||||
public class ConversationChangeEvent : UnityEvent<IPlayerAction> { }
|
||||
//[System.Serializable]
|
||||
//public class ConversationChangeEvent : UnityEvent<IPlayerAction> { }
|
||||
|
||||
public class ChoiceController : MonoBehaviour
|
||||
{
|
||||
public IPlayerAction _option;
|
||||
public ConversationChangeEvent conversationChangeEvent;
|
||||
// Update is called once per frame
|
||||
public static ChoiceController AddChoiceButton(Button choiceButtonTemplate, IPlayerAction option, int index)
|
||||
{
|
||||
int buttonSpacing = -50;
|
||||
//public class ChoiceController : MonoBehaviour
|
||||
//{
|
||||
// public IPlayerAction _option;
|
||||
// public ConversationChangeEvent conversationChangeEvent;
|
||||
// // Update is called once per frame
|
||||
// public static ChoiceController AddChoiceButton(Button choiceButtonTemplate, IPlayerAction option, int index)
|
||||
// {
|
||||
// int buttonSpacing = -50;
|
||||
|
||||
Button button = Instantiate(choiceButtonTemplate);
|
||||
// Button button = Instantiate(choiceButtonTemplate);
|
||||
|
||||
button.transform.SetParent(choiceButtonTemplate.transform.parent);
|
||||
button.transform.localScale = Vector3.one;
|
||||
button.transform.localPosition = choiceButtonTemplate.transform.localPosition + new Vector3(0, index * buttonSpacing, 0);
|
||||
button.name = option.Description;
|
||||
button.gameObject.SetActive(true);
|
||||
ChoiceController choiceController = button.GetComponent<ChoiceController>();
|
||||
choiceController._option = option;
|
||||
return choiceController;
|
||||
}
|
||||
// button.transform.SetParent(choiceButtonTemplate.transform.parent);
|
||||
// button.transform.localScale = Vector3.one;
|
||||
// button.transform.localPosition = choiceButtonTemplate.transform.localPosition + new Vector3(0, index * buttonSpacing, 0);
|
||||
// button.name = option.Description;
|
||||
// button.gameObject.SetActive(true);
|
||||
// ChoiceController choiceController = button.GetComponent<ChoiceController>();
|
||||
// choiceController._option = option;
|
||||
// return choiceController;
|
||||
// }
|
||||
|
||||
private void Start()
|
||||
{
|
||||
if (conversationChangeEvent == null)
|
||||
conversationChangeEvent = new ConversationChangeEvent();
|
||||
var btn = GetComponent<Button>();
|
||||
// private void Start()
|
||||
// {
|
||||
// if (conversationChangeEvent == null)
|
||||
// conversationChangeEvent = new ConversationChangeEvent();
|
||||
// var btn = GetComponent<Button>();
|
||||
|
||||
var txt = btn.GetComponentInChildren<TextMeshProUGUI>();
|
||||
txt.text = _option.Description;
|
||||
}
|
||||
// var txt = btn.GetComponentInChildren<TextMeshProUGUI>();
|
||||
// txt.text = _option.Description;
|
||||
// }
|
||||
|
||||
public void MakeChoice()
|
||||
{
|
||||
conversationChangeEvent.Invoke(_option);
|
||||
}
|
||||
}
|
||||
// public void MakeChoice()
|
||||
// {
|
||||
// conversationChangeEvent.Invoke(_option);
|
||||
// }
|
||||
//}
|
||||
|
||||
@@ -1,88 +1,88 @@
|
||||
using Assets.Scripts.Actions.Interfaces;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
//using Assets.Scripts.Actions.Interfaces;
|
||||
//using System.Collections.Generic;
|
||||
//using System.Linq;
|
||||
//using TMPro;
|
||||
//using UnityEngine;
|
||||
//using UnityEngine.UI;
|
||||
|
||||
public class ConversationController : MonoBehaviour
|
||||
{
|
||||
[SerializeField] public TextMeshProUGUI _title;
|
||||
[SerializeField] public Button _choiceButton;
|
||||
[SerializeField] private Button _btnApply;
|
||||
[SerializeField] private Button _btnClose;
|
||||
//public class ConversationController : MonoBehaviour
|
||||
//{
|
||||
// [SerializeField] public TextMeshProUGUI _title;
|
||||
// [SerializeField] public Button _choiceButton;
|
||||
// [SerializeField] private Button _btnApply;
|
||||
// [SerializeField] private Button _btnClose;
|
||||
|
||||
public ConversationChangeEvent conversationChangeEvent;
|
||||
private List<ChoiceController> choiceControllers = new();
|
||||
// public ConversationChangeEvent conversationChangeEvent;
|
||||
// private List<ChoiceController> choiceControllers = new();
|
||||
|
||||
private IPlayerAction _selectedAction = null;
|
||||
// private IPlayerAction _selectedAction = null;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
Hide();
|
||||
}
|
||||
// private void Awake()
|
||||
// {
|
||||
// Hide();
|
||||
// }
|
||||
|
||||
public void Change(string title, List<IPlayerAction> options)
|
||||
{
|
||||
_btnApply.interactable = false;
|
||||
// public void Change(string title, List<IPlayerAction> options)
|
||||
// {
|
||||
// _btnApply.interactable = false;
|
||||
|
||||
_btnClose.onClick.AddListener(() =>
|
||||
{
|
||||
Hide();
|
||||
});
|
||||
// _btnClose.onClick.AddListener(() =>
|
||||
// {
|
||||
// Hide();
|
||||
// });
|
||||
|
||||
_btnApply.onClick.AddListener(() =>
|
||||
{
|
||||
ApplyActionOnPlayer(_selectedAction);
|
||||
});
|
||||
// _btnApply.onClick.AddListener(() =>
|
||||
// {
|
||||
// ApplyActionOnPlayer(_selectedAction);
|
||||
// });
|
||||
|
||||
//Player.Instance.allowMovement = false;
|
||||
RemoveChoices();
|
||||
_title.text = title;
|
||||
gameObject.SetActive(true);
|
||||
// //Player.Instance.allowMovement = false;
|
||||
// RemoveChoices();
|
||||
// _title.text = title;
|
||||
// gameObject.SetActive(true);
|
||||
|
||||
for (var count = 0; count < options.Count; count++)
|
||||
{
|
||||
ChoiceController c = ChoiceController.AddChoiceButton(_choiceButton, options.ElementAt(count), count);
|
||||
c.conversationChangeEvent.AddListener(SelectAction);
|
||||
choiceControllers.Add(c);
|
||||
}
|
||||
// for (var count = 0; count < options.Count; count++)
|
||||
// {
|
||||
// ChoiceController c = ChoiceController.AddChoiceButton(_choiceButton, options.ElementAt(count), count);
|
||||
// c.conversationChangeEvent.AddListener(SelectAction);
|
||||
// choiceControllers.Add(c);
|
||||
// }
|
||||
|
||||
StopAllCoroutines();
|
||||
// StopAllCoroutines();
|
||||
|
||||
Time.timeScale = 0;
|
||||
_choiceButton.gameObject.SetActive(false);
|
||||
}
|
||||
// Time.timeScale = 0;
|
||||
// _choiceButton.gameObject.SetActive(false);
|
||||
// }
|
||||
|
||||
private void SelectAction(IPlayerAction action)
|
||||
{
|
||||
_selectedAction = action;
|
||||
if (action is ISellable)
|
||||
{
|
||||
// _btnApply.interactable = Player.Instance.Stats[StatsId.Money].Value >= (action as ISellable).Price;
|
||||
}
|
||||
}
|
||||
// private void SelectAction(IPlayerAction action)
|
||||
// {
|
||||
// _selectedAction = action;
|
||||
// if (action is ISellable)
|
||||
// {
|
||||
// // _btnApply.interactable = Player.Instance.Stats[StatsId.Money].Value >= (action as ISellable).Price;
|
||||
// }
|
||||
// }
|
||||
|
||||
private void ApplyActionOnPlayer(IPlayerAction action)
|
||||
{
|
||||
//if (action is ISellable)
|
||||
// Player.Instance.BuyAction(action);
|
||||
}
|
||||
private void RemoveChoices()
|
||||
{
|
||||
foreach (ChoiceController c in choiceControllers)
|
||||
{
|
||||
c.conversationChangeEvent.RemoveAllListeners();
|
||||
Destroy(c.gameObject);
|
||||
}
|
||||
choiceControllers.Clear();
|
||||
}
|
||||
// private void ApplyActionOnPlayer(IPlayerAction action)
|
||||
// {
|
||||
// //if (action is ISellable)
|
||||
// // Player.Instance.BuyAction(action);
|
||||
// }
|
||||
// private void RemoveChoices()
|
||||
// {
|
||||
// foreach (ChoiceController c in choiceControllers)
|
||||
// {
|
||||
// c.conversationChangeEvent.RemoveAllListeners();
|
||||
// Destroy(c.gameObject);
|
||||
// }
|
||||
// choiceControllers.Clear();
|
||||
// }
|
||||
|
||||
public void Hide()
|
||||
{
|
||||
RemoveChoices();
|
||||
gameObject.SetActive(false);
|
||||
Time.timeScale = 1;
|
||||
//Player.Instance.allowMovement = true;
|
||||
}
|
||||
}
|
||||
// public void Hide()
|
||||
// {
|
||||
// RemoveChoices();
|
||||
// gameObject.SetActive(false);
|
||||
// Time.timeScale = 1;
|
||||
// //Player.Instance.allowMovement = true;
|
||||
// }
|
||||
//}
|
||||
|
||||
@@ -1,36 +1,36 @@
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
//using TMPro;
|
||||
//using UnityEngine;
|
||||
//using UnityEngine.UI;
|
||||
|
||||
public class ItemActionsUI : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private TextMeshProUGUI _title;
|
||||
[SerializeField]
|
||||
private TextMeshProUGUI _description;
|
||||
//public class ItemActionsUI : MonoBehaviour
|
||||
//{
|
||||
// [SerializeField]
|
||||
// private TextMeshProUGUI _title;
|
||||
// [SerializeField]
|
||||
// private TextMeshProUGUI _description;
|
||||
|
||||
[SerializeField]
|
||||
private Button _btnCancel;
|
||||
// [SerializeField]
|
||||
// private Button _btnCancel;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
Hide();
|
||||
}
|
||||
// private void Start()
|
||||
// {
|
||||
// Hide();
|
||||
// }
|
||||
|
||||
public void Show(string title, string description)
|
||||
{
|
||||
gameObject.SetActive(true);
|
||||
_title.text = title;
|
||||
_description.text = description;
|
||||
// public void Show(string title, string description)
|
||||
// {
|
||||
// gameObject.SetActive(true);
|
||||
// _title.text = title;
|
||||
// _description.text = description;
|
||||
|
||||
_btnCancel.onClick.AddListener(() =>
|
||||
{
|
||||
Hide();
|
||||
});
|
||||
}
|
||||
// _btnCancel.onClick.AddListener(() =>
|
||||
// {
|
||||
// Hide();
|
||||
// });
|
||||
// }
|
||||
|
||||
private void Hide()
|
||||
{
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
// private void Hide()
|
||||
// {
|
||||
// gameObject.SetActive(false);
|
||||
// }
|
||||
//}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -7,12 +8,14 @@ public class Fridge : BaseInteractableObject
|
||||
[SerializeField]
|
||||
private ContainerSO _containerSO;
|
||||
[SerializeField]
|
||||
private ItemActionsUI _actionsMenu;
|
||||
//private ItemActionsUI _actionsMenu;
|
||||
|
||||
private Player _player;
|
||||
private List<FoodItemSO> _foodObjects = new List<FoodItemSO>();
|
||||
|
||||
public override void Interact(Player player)
|
||||
{
|
||||
_player = player;
|
||||
if (player.IsHoldContainerItem())
|
||||
{
|
||||
var playerContainer = player.GetContainerItem();
|
||||
@@ -32,20 +35,26 @@ public class Fridge : BaseInteractableObject
|
||||
Debug.Log($"Fridge is full");
|
||||
}
|
||||
}
|
||||
//else
|
||||
//{
|
||||
// //Eat menu
|
||||
// if (_foodObjects.Count > 0)
|
||||
// {
|
||||
// while (player.Stats[StatsId.Food].Value < player.Stats[StatsId.Food].MaxValue && _foodObjects.Count > 0)
|
||||
// {
|
||||
// _foodObjects.RemoveAt(0);
|
||||
// player.Eat();
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//_containerSO.CurrentItemsCount = _foodObjects.Count;
|
||||
else
|
||||
{
|
||||
//Eat menu
|
||||
if (_foodObjects.Count > 0)
|
||||
{
|
||||
var hunger = player.Stats[StatsId.Food].MaxValue - player.Stats[StatsId.Food].Value;
|
||||
var eatingItems = _foodObjects.Count < (hunger / 10) ? _foodObjects.Count : (hunger / 10);
|
||||
StartCoroutine(EatRoutine(eatingItems));
|
||||
_foodObjects.RemoveRange(0, (int)eatingItems);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerator EatRoutine(float timeToEat)
|
||||
{
|
||||
_player.SetPlayerActing(PlayerStates.Eating);
|
||||
yield return new WaitForSeconds(timeToEat);
|
||||
_player.SetPlayerActing(PlayerStates.Awake);
|
||||
yield break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ public class ShopingContainer : BaseInteractableObject
|
||||
[SerializeField]
|
||||
private ContainerSO _containerSO;
|
||||
[SerializeField]
|
||||
private ItemActionsUI _actionsMenu;
|
||||
//private ItemActionsUI _actionsMenu;
|
||||
|
||||
public override void Interact(Player player)
|
||||
{
|
||||
|
||||
@@ -157,7 +157,7 @@ public class Player : MonoBehaviour
|
||||
return TaskStatus.InProgress;
|
||||
}
|
||||
|
||||
public static bool IsApproximate(Quaternion q1, Quaternion q2, float precision)
|
||||
private bool IsApproximate(Quaternion q1, Quaternion q2, float precision)
|
||||
{
|
||||
return Mathf.Abs(Quaternion.Dot(q1, q2)) >= 1 - precision;
|
||||
}
|
||||
@@ -189,7 +189,6 @@ public class Player : MonoBehaviour
|
||||
string stateName = PlayerHelper.GetEnumMemberValue(_currentAnimation);
|
||||
var stateInfo = _animator.GetCurrentAnimatorStateInfo(animLayer);
|
||||
return stateInfo.IsName(stateName) && stateInfo.normalizedTime < 1.0f;
|
||||
|
||||
}
|
||||
|
||||
public void AddTask(PlayerTasks task)
|
||||
@@ -204,14 +203,18 @@ public class Player : MonoBehaviour
|
||||
|
||||
public void UpdateStatsByClock()
|
||||
{
|
||||
Stats[StatsId.Food].deduct(0.034f); // 48 hours it's 100, 100/2880=~0.034 per minute
|
||||
if (_currentActing != PlayerStates.Sleeping)
|
||||
switch (_currentActing)
|
||||
{
|
||||
Stats[StatsId.Energy].deduct(0.1f); // 24 hours it's 100, 100/1440=~0.096 per minute
|
||||
}
|
||||
else
|
||||
{
|
||||
Stats[StatsId.Energy].increase(0.2f);
|
||||
case PlayerStates.Eating:
|
||||
Stats[StatsId.Food].increase(10f);
|
||||
break;
|
||||
case PlayerStates.Sleeping:
|
||||
Stats[StatsId.Energy].increase(0.2f);
|
||||
break;
|
||||
default:
|
||||
Stats[StatsId.Food].deduct(0.034f); // 48 hours it's 100, 100/2880=~0.034 per minute
|
||||
Stats[StatsId.Energy].deduct(0.1f); // 24 hours it's 100, 100/1440=~0.096 per minute
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -219,13 +222,13 @@ public class Player : MonoBehaviour
|
||||
{
|
||||
Stats[StatsId.Money].deduct(amount);
|
||||
}
|
||||
|
||||
public void SetContainerItem(ContainerItem containerItem)
|
||||
{
|
||||
containerItem.transform.parent = _holdPoint;
|
||||
containerItem.transform.localPosition = Vector3.zero;
|
||||
_containerItem = containerItem;
|
||||
}
|
||||
|
||||
public ContainerItem GetContainerItem()
|
||||
{
|
||||
return _containerItem;
|
||||
@@ -235,7 +238,6 @@ public class Player : MonoBehaviour
|
||||
Destroy(_containerItem.gameObject);
|
||||
_containerItem = null;
|
||||
}
|
||||
|
||||
public bool IsHoldContainerItem()
|
||||
{
|
||||
return _containerItem != null;
|
||||
|
||||
Reference in New Issue
Block a user