This commit is contained in:
Vladimir Koshevarov
2022-10-18 16:58:28 +03:00
7 changed files with 59 additions and 14 deletions
+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;
}
}