This commit is contained in:
Vladimir Koshevarov
2022-10-18 16:58:28 +03:00
7 changed files with 59 additions and 14 deletions
+7 -6
View File
@@ -38,7 +38,7 @@ RenderSettings:
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 705507994}
m_IndirectSpecularColor: {r: 0.44657826, g: 0.49641263, b: 0.57481676, a: 1}
m_IndirectSpecularColor: {r: 0.44657898, g: 0.4964133, b: 0.5748178, a: 1}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:
@@ -3145,7 +3145,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: -472, y: 295}
m_AnchoredPosition: {x: -450, y: 223}
m_SizeDelta: {x: 200, y: 50}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &443940496
@@ -4195,6 +4195,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: c802a0d9d32b0c04b841113e87b83e4b, type: 3}
m_Name:
m_EditorClassIdentifier:
_moneyText: {fileID: 443940496}
Clock: 0
--- !u!1 &875821251
GameObject:
@@ -6943,7 +6944,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 192.27, y: -259}
m_AnchoredPosition: {x: 199.2, y: -230}
m_SizeDelta: {x: 93.6024, y: 40.945}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1765440972
@@ -7071,8 +7072,8 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: -256, y: -265}
m_SizeDelta: {x: 512, y: 530}
m_AnchoredPosition: {x: -256, y: -226.06555}
m_SizeDelta: {x: 512, y: 474.0656}
m_Pivot: {x: 0, y: 0}
--- !u!114 &1928618663
MonoBehaviour:
@@ -7459,7 +7460,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 478, y: 295}
m_AnchoredPosition: {x: 448, y: 223}
m_SizeDelta: {x: 200, y: 50}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &2089282903
+1 -1
View File
@@ -1,6 +1,6 @@
namespace Assets.Scripts.Actions
{
public class Eat : BaseAction
public class Eat : BaseAction, ISellableItem
{
private double _price;
private int _energyPerTick;
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 75ecd68a88c4c904393604b692b01a43
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
namespace Assets.Scripts.Actions.Interfaces
{
internal interface ISellableItem
{
public double Cost { get; }
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 11ca03325bf76704b91eb2f9b2fafec9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -42,7 +42,20 @@ public class ChoiceController : MonoBehaviour
public void MakeChoice()
{
playerController.TryBuyAction(_option.Value);
conversationChangeEvent.Invoke(_option.Value);
if (playerController.TryBuyAction(_option.Value))
{
conversationChangeEvent.Invoke(_option.Value);
}
else
{
YesNoDialogUI.Instance.ShowQuestion("not enouth money",
() =>
{
},
() =>
{
//do nothing
});
}
}
}
+9 -5
View File
@@ -1,6 +1,3 @@
using Assets.Scripts.Actions;
using UnityEngine;
public class PlayerController : MonoBehaviour
{
public Stat money = new Stat("Money", 100.00);
@@ -47,7 +44,7 @@ public class PlayerController : MonoBehaviour
// Start is called before the first frame update
void Start()
{
_moneyText.text = $"Money: {money.Value}$";
}
// Update is called once per frame
@@ -62,9 +59,16 @@ public class PlayerController : MonoBehaviour
Clock = 24;
}
public void TryBuyAction(BaseAction action)
public bool TryBuyAction(BaseAction action)
{
if (action is ISellableItem)
{
if (!money.deduct(((ISellableItem)action).Cost))
return false;
_moneyText.text = $"Money: {money.Value}$";
}
action.ApplyAction(this);
return true;
}
}