display player money, dialog when player have not enough money
This commit is contained in:
@@ -38,7 +38,7 @@ RenderSettings:
|
|||||||
m_ReflectionIntensity: 1
|
m_ReflectionIntensity: 1
|
||||||
m_CustomReflection: {fileID: 0}
|
m_CustomReflection: {fileID: 0}
|
||||||
m_Sun: {fileID: 705507994}
|
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
|
m_UseRadianceAmbientProbe: 0
|
||||||
--- !u!157 &3
|
--- !u!157 &3
|
||||||
LightmapSettings:
|
LightmapSettings:
|
||||||
@@ -3129,7 +3129,7 @@ RectTransform:
|
|||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||||
m_AnchorMax: {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_SizeDelta: {x: 200, y: 50}
|
||||||
m_Pivot: {x: 0.5, y: 0.5}
|
m_Pivot: {x: 0.5, y: 0.5}
|
||||||
--- !u!114 &443940496
|
--- !u!114 &443940496
|
||||||
@@ -4179,6 +4179,7 @@ MonoBehaviour:
|
|||||||
m_Script: {fileID: 11500000, guid: c802a0d9d32b0c04b841113e87b83e4b, type: 3}
|
m_Script: {fileID: 11500000, guid: c802a0d9d32b0c04b841113e87b83e4b, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
|
_moneyText: {fileID: 443940496}
|
||||||
Clock: 0
|
Clock: 0
|
||||||
--- !u!1 &875821251
|
--- !u!1 &875821251
|
||||||
GameObject:
|
GameObject:
|
||||||
@@ -6927,7 +6928,7 @@ RectTransform:
|
|||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||||
m_AnchorMax: {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_SizeDelta: {x: 93.6024, y: 40.945}
|
||||||
m_Pivot: {x: 0.5, y: 0.5}
|
m_Pivot: {x: 0.5, y: 0.5}
|
||||||
--- !u!114 &1765440972
|
--- !u!114 &1765440972
|
||||||
@@ -7055,8 +7056,8 @@ RectTransform:
|
|||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||||
m_AnchoredPosition: {x: -256, y: -265}
|
m_AnchoredPosition: {x: -256, y: -226.06555}
|
||||||
m_SizeDelta: {x: 512, y: 530}
|
m_SizeDelta: {x: 512, y: 474.0656}
|
||||||
m_Pivot: {x: 0, y: 0}
|
m_Pivot: {x: 0, y: 0}
|
||||||
--- !u!114 &1928618663
|
--- !u!114 &1928618663
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
@@ -7443,7 +7444,7 @@ RectTransform:
|
|||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||||
m_AnchorMax: {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_SizeDelta: {x: 200, y: 50}
|
||||||
m_Pivot: {x: 0.5, y: 0.5}
|
m_Pivot: {x: 0.5, y: 0.5}
|
||||||
--- !u!114 &2089282903
|
--- !u!114 &2089282903
|
||||||
|
|||||||
@@ -1,10 +1,14 @@
|
|||||||
namespace Assets.Scripts.Actions
|
using Assets.Scripts.Actions.Interfaces;
|
||||||
|
|
||||||
|
namespace Assets.Scripts.Actions
|
||||||
{
|
{
|
||||||
public class Eat : BaseAction
|
public class Eat : BaseAction, ISellableItem
|
||||||
{
|
{
|
||||||
|
public double Cost { get; private set; }
|
||||||
private int energyPerTick;
|
private int energyPerTick;
|
||||||
public Eat(int duration, int energyPerTick, double cost) : base(duration)
|
public Eat(int duration, int energyPerTick, double cost) : base(duration)
|
||||||
{
|
{
|
||||||
|
Cost = cost;
|
||||||
this.energyPerTick = energyPerTick;
|
this.energyPerTick = energyPerTick;
|
||||||
}
|
}
|
||||||
public override void ApplyAction(PlayerController playerController)
|
public override void ApplyAction(PlayerController playerController)
|
||||||
|
|||||||
@@ -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()
|
public void MakeChoice()
|
||||||
{
|
{
|
||||||
playerController.TryBuyAction(_option.Value);
|
if (playerController.TryBuyAction(_option.Value))
|
||||||
conversationChangeEvent.Invoke(_option.Value);
|
{
|
||||||
|
conversationChangeEvent.Invoke(_option.Value);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
YesNoDialogUI.Instance.ShowQuestion("not enouth money",
|
||||||
|
() =>
|
||||||
|
{
|
||||||
|
},
|
||||||
|
() =>
|
||||||
|
{
|
||||||
|
//do nothing
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,14 @@
|
|||||||
using Assets.Scripts.Actions;
|
using Assets.Scripts.Actions;
|
||||||
|
using Assets.Scripts.Actions.Interfaces;
|
||||||
|
using TMPro;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
public class PlayerController : MonoBehaviour
|
public class PlayerController : MonoBehaviour
|
||||||
{
|
{
|
||||||
public Stat money = new Stat("Money", 1000.00);
|
[SerializeField]
|
||||||
|
private TextMeshProUGUI _moneyText;
|
||||||
|
|
||||||
|
public Stat money = new Stat("Money", 100.00);
|
||||||
public Stat rentAccount = new Stat("Rent Account", 0);
|
public Stat rentAccount = new Stat("Rent Account", 0);
|
||||||
public Stat foodEnergy = new Stat("Food Energy", 0);
|
public Stat foodEnergy = new Stat("Food Energy", 0);
|
||||||
public Stat restEnergy = new Stat("Rest Energy", 0);
|
public Stat restEnergy = new Stat("Rest Energy", 0);
|
||||||
@@ -47,7 +52,7 @@ public class PlayerController : MonoBehaviour
|
|||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
|
_moneyText.text = $"Money: {money.Value}$";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update is called once per frame
|
// Update is called once per frame
|
||||||
@@ -62,9 +67,16 @@ public class PlayerController : MonoBehaviour
|
|||||||
Clock = 24;
|
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);
|
action.ApplyAction(this);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user