Added basic popup action menu

This commit is contained in:
Vladimir Koshevarov
2023-03-02 18:33:51 +02:00
parent 5a58ce2ce6
commit 2337bc1423
14 changed files with 1256 additions and 567 deletions
+1
View File
@@ -122,6 +122,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
_playerArrivePoint: {fileID: 3909525920100175952}
_containerSO: {fileID: 11400000, guid: b8fcf00b76085f54baafb32a2e47c70e, type: 2}
--- !u!1 &677083019419746855
GameObject:
m_ObjectHideFlags: 0
+8 -51
View File
@@ -161,7 +161,6 @@ GameObject:
- component: {fileID: 3806516703338386383}
- component: {fileID: 3806516703338386379}
- component: {fileID: 3806516703338386376}
- component: {fileID: 3806516703338386377}
- component: {fileID: 3806516703338386382}
- component: {fileID: 8115133298804345861}
- component: {fileID: 2413812458207048714}
@@ -188,9 +187,9 @@ RectTransform:
m_Father: {fileID: 3806516704876462308}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 21.18, y: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 21.18, y: -16.175}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &3806516703338386379
@@ -231,21 +230,6 @@ MonoBehaviour:
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!114 &3806516703338386377
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3806516703338386380}
m_Enabled: 0
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e19747de3f5aca642ab2be37e372fb86, type: 3}
m_Name:
m_EditorClassIdentifier:
m_EffectColor: {r: 1, g: 1, b: 1, a: 1}
m_EffectDistance: {x: 1, y: 1}
m_UseGraphicAlpha: 1
--- !u!114 &3806516703338386382
MonoBehaviour:
m_ObjectHideFlags: 0
@@ -311,7 +295,6 @@ GameObject:
m_Component:
- component: {fileID: 3806516704876462308}
- component: {fileID: 3806516704876462311}
- component: {fileID: 327755658309153619}
m_Layer: 5
m_Name: button
m_TagString: Untagged
@@ -333,12 +316,12 @@ RectTransform:
m_Children:
- {fileID: 3806516703338386383}
m_Father: {fileID: 0}
m_RootOrder: 0
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.791, y: 0.19664745}
m_AnchorMax: {x: 0.82527876, y: 0.24948958}
m_AnchoredPosition: {x: 0.17080688, y: 0.33007812}
m_SizeDelta: {x: 0.3415985, y: -0.6603012}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &3806516704876462311
MonoBehaviour:
@@ -384,29 +367,3 @@ MonoBehaviour:
m_OnClick:
m_PersistentCalls:
m_Calls: []
--- !u!114 &327755658309153619
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3806516704876462309}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 30649d3a9faa99c48a7b1166b86bf2a0, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Padding:
m_Left: 0
m_Right: 0
m_Top: 0
m_Bottom: 0
m_ChildAlignment: 0
m_Spacing: 0
m_ChildForceExpandWidth: 0
m_ChildForceExpandHeight: 0
m_ChildControlWidth: 0
m_ChildControlHeight: 0
m_ChildScaleWidth: 0
m_ChildScaleHeight: 0
m_ReverseArrangement: 0
+1141 -437
View File
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,37 @@
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class ItemActionsUI : MonoBehaviour
{
[SerializeField]
private TextMeshProUGUI _title;
[SerializeField]
private TextMeshProUGUI _description;
[SerializeField]
private Button _btnCancel;
private void Awake()
{
Hide();
}
public void Show(string title, string description)
{
_title.text = title;
_description.text = description;
_btnCancel.onClick.AddListener(() =>
{
Hide();
});
gameObject.SetActive(true);
}
private void Hide()
{
gameObject.SetActive(false);
//Destroy(gameObject);
}
}
@@ -1,27 +0,0 @@
using UnityEditor;
using UnityEngine;
public class TestingQuestionDialog : MonoBehaviour
{
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.Escape))
{
YesNoDialogUI.Instance.ShowQuestion("To be or not to be ?",
() =>
{
Application.Quit();
EditorApplication.ExitPlaymode();
},
() =>
{
//do nothing
});
}
}
}
@@ -1,44 +0,0 @@
using System;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class YesNoDialogUI : MonoBehaviour
{
public static YesNoDialogUI Instance { get; private set; }
[SerializeField]
private TextMeshProUGUI _textMeshPro;
[SerializeField]
private Button _yesBtn;
[SerializeField]
private Button _noBtn;
private void Awake()
{
Instance = this;
Hide();
}
public void ShowQuestion(string questionText, Action yesAction, Action noAction)
{
_textMeshPro.text = questionText;
_yesBtn.onClick.AddListener(() =>
{
Hide();
yesAction();
});
_noBtn.onClick.AddListener(() =>
{
Hide();
noAction();
});
gameObject.SetActive(true);
}
private void Hide()
{
gameObject.SetActive(false);
}
}
+14 -7
View File
@@ -4,14 +4,20 @@ using UnityEngine;
public class Fridge : BaseInteractableObject
{
private const int _maxCapacity=10;
private List<FoodObject> _foodObjects= new List<FoodObject>();
[SerializeField]
private ContainerSO _containerSO;
[SerializeField]
private ItemActionsUI _actionsMenu;
private List<FoodObject> _foodObjects = new List<FoodObject>();
public override void Interact(Player player)
{
_actionsMenu.Show(_containerSO.Name, $"Max items:{_containerSO.MaxCapacity} current items: {_containerSO.CurrentItemsCount}");
if (player.HasFoodObject())
{
if (_foodObjects.Count < _maxCapacity)
if (_foodObjects.Count < _containerSO.MaxCapacity)
{
_foodObjects.Add(player.GetFoodObject());
player.ClearFoodObject();
@@ -20,19 +26,20 @@ public class Fridge : BaseInteractableObject
else
Debug.Log($"Fridge is full");
}
else
else
{
//Eat menu
if (_foodObjects.Count>0)
if (_foodObjects.Count > 0)
{
while(player.Stats[StatsId.Food].Value< player.Stats[StatsId.Food].MaxValue && _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;
}
}
+9
View File
@@ -0,0 +1,9 @@
using UnityEngine;
public class LookAtCamera : MonoBehaviour
{
private void LateUpdate()
{
transform.LookAt(Camera.main.transform);
}
}
@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 9922754e62fe4b84397a0d1f84482f7e
guid: 7cfda29cc43f07b4f9af450516d8a828
MonoImporter:
externalObjects: {}
serializedVersion: 2
@@ -0,0 +1,9 @@
using UnityEngine;
[CreateAssetMenu()]
public class ContainerSO : ScriptableObject
{
public string Name;
public int MaxCapacity;
public int CurrentItemsCount;
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 570c5458f6b5110448188e51cb5becbb
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,17 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 570c5458f6b5110448188e51cb5becbb, type: 3}
m_Name: ModernFridge
m_EditorClassIdentifier:
Name: Modern Firdge
MaxCapacity: 10
CurrentItemsCount: 0
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: b8fcf00b76085f54baafb32a2e47c70e
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant: