From 0ccf97986937af250b3f54da6cbe7e0477da43be Mon Sep 17 00:00:00 2001 From: Pasha Bibko <156938226+PashaBibko@users.noreply.github.com> Date: Tue, 28 Apr 2026 16:22:12 +0100 Subject: [PATCH] Made price of upgrade be required --- Assets/Prefabs/Items/Items.asset | 117 +++++++++----- Assets/Scenes/UpgradesScene.unity | 176 ++++++---------------- Assets/Scripts/Global/MoneyController.cs | 12 ++ Assets/Scripts/UI/BasicUpgradeButton.cs | 16 +- Assets/Scripts/UI/BuildingUnlockButton.cs | 15 +- 5 files changed, 161 insertions(+), 175 deletions(-) diff --git a/Assets/Prefabs/Items/Items.asset b/Assets/Prefabs/Items/Items.asset index 5d55a92..9c0349e 100644 --- a/Assets/Prefabs/Items/Items.asset +++ b/Assets/Prefabs/Items/Items.asset @@ -15,196 +15,235 @@ MonoBehaviour: Registry: - Type: 1 CustomBehaviour: 1 + OverrideCost: 1 + Cost: 10 Prefab: {fileID: 4062657912758122058, guid: 23e3bfe33d8c6004c85fd638db567ab6, type: 3} - BaseItemValue: 0 - Type: 2 CustomBehaviour: 1 + OverrideCost: 1 + Cost: 100 Prefab: {fileID: 8799415981405337049, guid: c21e0b5539573904cb10d979de4a3f72, type: 3} - BaseItemValue: 0 - Type: 3 CustomBehaviour: 1 + OverrideCost: 1 + Cost: 1000 Prefab: {fileID: 4062657912758122058, guid: 5e1f7f5d4294c1d4fa3e6f88dec0dfa6, type: 3} - BaseItemValue: 0 - Type: 4 CustomBehaviour: 1 + OverrideCost: 1 + Cost: 10000 Prefab: {fileID: 4062657912758122058, guid: b224b6df33529e64d83245d78e0feb9f, type: 3} - BaseItemValue: 0 - Type: 5 CustomBehaviour: 1 + OverrideCost: 1 + Cost: 100000 Prefab: {fileID: 4062657912758122058, guid: 7af455f1c1666e5409156598fe669f74, type: 3} - BaseItemValue: 0 - Type: 7 CustomBehaviour: 1 + OverrideCost: 1 + Cost: 100000 Prefab: {fileID: 4062657912758122058, guid: 13f2740b5ae396e40940587ab2effd65, type: 3} - BaseItemValue: 0 - Type: 8 CustomBehaviour: 1 + OverrideCost: 1 + Cost: 1000000 Prefab: {fileID: 4062657912758122058, guid: ebddb1b81a288cc4c993a25bc9efe894, type: 3} - BaseItemValue: 0 - Type: 6 CustomBehaviour: 1 + OverrideCost: 1 + Cost: 10000000 Prefab: {fileID: 4062657912758122058, guid: 2cf42dbc57bb6374b9e6ec700aad5854, type: 3} - BaseItemValue: 0 - Type: 9 CustomBehaviour: 0 + OverrideCost: 0 + Cost: 1000 Prefab: {fileID: 4485779862959683977, guid: 41d6fc24602553e48b206f2ea7d60bb5, type: 3} - BaseItemValue: 0 - Type: 11 CustomBehaviour: 0 + OverrideCost: 0 + Cost: 0 Prefab: {fileID: 4485779862959683977, guid: 044e3c59048f2ec4db0a06bcabc676b0, type: 3} - BaseItemValue: 0 - Type: 19 CustomBehaviour: 0 + OverrideCost: 0 + Cost: 0 Prefab: {fileID: 4485779862959683977, guid: 1d1c1945744668945abc5ea0f9a4c760, type: 3} - BaseItemValue: 0 - Type: 20 CustomBehaviour: 0 + OverrideCost: 0 + Cost: 0 Prefab: {fileID: 4485779862959683977, guid: f2420d92fef5dde46ba12236e8315458, type: 3} - BaseItemValue: 0 - Type: 18 CustomBehaviour: 0 + OverrideCost: 0 + Cost: 0 Prefab: {fileID: 4485779862959683977, guid: e1b896c45d0dc394eb584c739794ff21, type: 3} - BaseItemValue: 0 - Type: 17 CustomBehaviour: 0 + OverrideCost: 0 + Cost: 0 Prefab: {fileID: 4485779862959683977, guid: c5580241b3a654e47a270fc00407cbd4, type: 3} - BaseItemValue: 0 - Type: 15 CustomBehaviour: 0 + OverrideCost: 0 + Cost: 0 Prefab: {fileID: 4485779862959683977, guid: 2125bd42c9c45584b9c2ed2d6421e410, type: 3} - BaseItemValue: 0 - Type: 10 CustomBehaviour: 0 + OverrideCost: 0 + Cost: 0 Prefab: {fileID: 4485779862959683977, guid: 45b8d9d3353ed7c4e8fd11c6387d2364, type: 3} - BaseItemValue: 0 - Type: 16 CustomBehaviour: 0 + OverrideCost: 0 + Cost: 0 Prefab: {fileID: 4485779862959683977, guid: b2ad6f08a32678344aa95ae220e3d030, type: 3} - BaseItemValue: 0 - Type: 29 CustomBehaviour: 0 + OverrideCost: 0 + Cost: 0 Prefab: {fileID: 4485779862959683977, guid: 46e1f4f05a477b046a5d8121bb63388d, type: 3} - BaseItemValue: 0 - Type: 28 CustomBehaviour: 0 + OverrideCost: 0 + Cost: 0 Prefab: {fileID: 4485779862959683977, guid: 7ba70ccf373f1064a9911798bc1748ce, type: 3} - BaseItemValue: 0 - Type: 12 CustomBehaviour: 0 + OverrideCost: 0 + Cost: 0 Prefab: {fileID: 4485779862959683977, guid: 9fc502b6f85c8764ab181f64c646bcf1, type: 3} - BaseItemValue: 0 - Type: 21 CustomBehaviour: 0 + OverrideCost: 0 + Cost: 0 Prefab: {fileID: 4485779862959683977, guid: 0ff4ad3b26e30d14286f45c67ce8ea91, type: 3} - BaseItemValue: 0 - Type: 23 CustomBehaviour: 0 + OverrideCost: 0 + Cost: 0 Prefab: {fileID: 4485779862959683977, guid: eb6cbc0d308433642a3157f5afe2b17e, type: 3} - BaseItemValue: 0 - Type: 22 CustomBehaviour: 0 + OverrideCost: 0 + Cost: 0 Prefab: {fileID: 4485779862959683977, guid: 642bb664840379a46b4dff87e65e229d, type: 3} - BaseItemValue: 0 - Type: 24 CustomBehaviour: 0 + OverrideCost: 0 + Cost: 0 Prefab: {fileID: 4485779862959683977, guid: 5e2046530547f3a4f807e051d6e1da05, type: 3} - BaseItemValue: 0 - Type: 26 CustomBehaviour: 0 + OverrideCost: 0 + Cost: 0 Prefab: {fileID: 4485779862959683977, guid: e37376b2f30b7d64fa634df2233ff9ab, type: 3} - BaseItemValue: 0 - Type: 14 CustomBehaviour: 0 + OverrideCost: 0 + Cost: 0 Prefab: {fileID: 4485779862959683977, guid: 082386cfbe8dfc34189664a1dd37ede4, type: 3} - BaseItemValue: 0 - Type: 25 CustomBehaviour: 0 + OverrideCost: 0 + Cost: 0 Prefab: {fileID: 4485779862959683977, guid: d0fc612fb6777b14b88133b4cd485733, type: 3} - BaseItemValue: 0 - Type: 27 CustomBehaviour: 0 + OverrideCost: 0 + Cost: 0 Prefab: {fileID: 4485779862959683977, guid: f74988e3ad5daf64f8f6c6adab75c984, type: 3} - BaseItemValue: 0 - Type: 13 CustomBehaviour: 0 + OverrideCost: 0 + Cost: 0 Prefab: {fileID: 4485779862959683977, guid: 30a47cb0b048fe14aad8715a93340ea7, type: 3} - BaseItemValue: 0 - Type: 35 CustomBehaviour: 0 + OverrideCost: 0 + Cost: 0 Prefab: {fileID: 4485779862959683977, guid: 9f42b3ba87a20c44ab1d42f2ccb5e8a9, type: 3} - BaseItemValue: 0 - Type: 30 CustomBehaviour: 0 + OverrideCost: 0 + Cost: 0 Prefab: {fileID: 4485779862959683977, guid: 6116435b2f552b645bb108b557d9f260, type: 3} - BaseItemValue: 0 - Type: 36 CustomBehaviour: 0 + OverrideCost: 0 + Cost: 0 Prefab: {fileID: 4485779862959683977, guid: c122bad889bd0e940ac04774d2931c43, type: 3} - BaseItemValue: 0 - Type: 37 CustomBehaviour: 0 + OverrideCost: 0 + Cost: 0 Prefab: {fileID: 4485779862959683977, guid: fca748809ae1f854a8be34fc012871ff, type: 3} - BaseItemValue: 0 - Type: 32 CustomBehaviour: 0 + OverrideCost: 0 + Cost: 0 Prefab: {fileID: 4485779862959683977, guid: 64672e82b5d249243be99685f35256ad, type: 3} - BaseItemValue: 0 - Type: 33 CustomBehaviour: 0 + OverrideCost: 0 + Cost: 0 Prefab: {fileID: 4485779862959683977, guid: e8214f8bfefe02445a6377c51119e395, type: 3} - BaseItemValue: 0 - Type: 34 CustomBehaviour: 0 + OverrideCost: 0 + Cost: 0 Prefab: {fileID: 4485779862959683977, guid: e0a24b112aaff3144877104e77013959, type: 3} - BaseItemValue: 0 - Type: 31 CustomBehaviour: 0 + OverrideCost: 0 + Cost: 0 Prefab: {fileID: 4485779862959683977, guid: c9b060e21a993cd4682f148bba5a95d1, type: 3} - BaseItemValue: 0 - Type: 38 CustomBehaviour: 0 + OverrideCost: 0 + Cost: 0 Prefab: {fileID: 4485779862959683977, guid: d1fe84a0b94bf2d4189838f4031a0f0b, type: 3} - BaseItemValue: 0 - Type: 39 CustomBehaviour: 0 + OverrideCost: 0 + Cost: 0 Prefab: {fileID: 4485779862959683977, guid: 592db5119c3d5c74981f7a8fdb975217, type: 3} - BaseItemValue: 0 diff --git a/Assets/Scenes/UpgradesScene.unity b/Assets/Scenes/UpgradesScene.unity index c680237..38830c3 100644 --- a/Assets/Scenes/UpgradesScene.unity +++ b/Assets/Scenes/UpgradesScene.unity @@ -391,9 +391,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: Fruitomation::Fruitomation.UI.BuildingUnlockButton Building: 1 - Cost: - Magnitude: 0 - Ammount: 0 + Cost: 0 AttachedButton: {fileID: 96977645} AttachedText: {fileID: 727674682} --- !u!1 &102766294 @@ -532,9 +530,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: Fruitomation::Fruitomation.UI.BuildingUnlockButton Building: 3 - Cost: - Magnitude: 0 - Ammount: 0 + Cost: 0 AttachedButton: {fileID: 102766296} AttachedText: {fileID: 1685724982} --- !u!1 &104174696 @@ -983,9 +979,7 @@ MonoBehaviour: m_EditorClassIdentifier: Fruitomation::Fruitomation.Game.BasicUpgradeButton Upgrade: 8 DrawDefaultLines: 1 - Cost: - Magnitude: 0 - Ammount: 0 + Cost: 0 BigText: 0 RequiredUpgrades: - {fileID: 306312747} @@ -1147,9 +1141,7 @@ MonoBehaviour: m_EditorClassIdentifier: Fruitomation::Fruitomation.UI.BasicUpgradeButton Upgrade: 3 DrawDefaultLines: 1 - Cost: - Magnitude: 0 - Ammount: 0 + Cost: 0 BigText: 1 RequiredUpgrades: [] LineMaterial: {fileID: 2100000, guid: eb8c84c9b7bce8f4ab2641ccf50d239c, type: 2} @@ -1345,9 +1337,7 @@ MonoBehaviour: m_EditorClassIdentifier: Fruitomation::Fruitomation.UI.BasicUpgradeButton Upgrade: 23 DrawDefaultLines: 1 - Cost: - Magnitude: 0 - Ammount: 0 + Cost: 0 BigText: 0 RequiredUpgrades: - {fileID: 1215656306} @@ -1624,9 +1614,7 @@ MonoBehaviour: m_EditorClassIdentifier: Fruitomation::Fruitomation.UI.BasicUpgradeButton Upgrade: 32 DrawDefaultLines: 0 - Cost: - Magnitude: 0 - Ammount: 0 + Cost: 0 BigText: 0 RequiredUpgrades: - {fileID: 531797809} @@ -1792,9 +1780,7 @@ MonoBehaviour: m_EditorClassIdentifier: Fruitomation::Fruitomation.UI.BasicUpgradeButton Upgrade: 28 DrawDefaultLines: 1 - Cost: - Magnitude: 0 - Ammount: 0 + Cost: 0 BigText: 0 RequiredUpgrades: - {fileID: 766041999} @@ -2035,9 +2021,7 @@ MonoBehaviour: m_EditorClassIdentifier: Fruitomation::Fruitomation.Game.BasicUpgradeButton Upgrade: 7 DrawDefaultLines: 1 - Cost: - Magnitude: 0 - Ammount: 0 + Cost: 0 BigText: 0 RequiredUpgrades: - {fileID: 946556767} @@ -2471,9 +2455,7 @@ MonoBehaviour: m_EditorClassIdentifier: Fruitomation::Fruitomation.Game.BasicUpgradeButton Upgrade: 12 DrawDefaultLines: 1 - Cost: - Magnitude: 0 - Ammount: 0 + Cost: 0 BigText: 0 RequiredUpgrades: - {fileID: 1077588040} @@ -2831,9 +2813,7 @@ MonoBehaviour: m_EditorClassIdentifier: Fruitomation::Fruitomation.UI.BasicUpgradeButton Upgrade: 27 DrawDefaultLines: 0 - Cost: - Magnitude: 0 - Ammount: 0 + Cost: 0 BigText: 0 RequiredUpgrades: - {fileID: 766041999} @@ -3000,9 +2980,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: Fruitomation::Fruitomation.UI.BuildingUnlockButton Building: 8 - Cost: - Magnitude: 0 - Ammount: 0 + Cost: 0 AttachedButton: {fileID: 472484162} AttachedText: {fileID: 1662323237} --- !u!1 &475841621 @@ -3280,9 +3258,7 @@ MonoBehaviour: m_EditorClassIdentifier: Fruitomation::Fruitomation.UI.BasicUpgradeButton Upgrade: 33 DrawDefaultLines: 1 - Cost: - Magnitude: 0 - Ammount: 0 + Cost: 0 BigText: 0 RequiredUpgrades: - {fileID: 531797809} @@ -3444,9 +3420,7 @@ MonoBehaviour: m_EditorClassIdentifier: Fruitomation::Fruitomation.UI.BasicUpgradeButton Upgrade: 31 DrawDefaultLines: 1 - Cost: - Magnitude: 0 - Ammount: 0 + Cost: 0 BigText: 0 RequiredUpgrades: - {fileID: 1805700036} @@ -3606,9 +3580,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: Fruitomation::Fruitomation.UI.BuildingUnlockButton Building: 6 - Cost: - Magnitude: 0 - Ammount: 0 + Cost: 0 AttachedButton: {fileID: 553044638} AttachedText: {fileID: 1891974735} --- !u!1 &556201452 @@ -3909,9 +3881,7 @@ MonoBehaviour: m_EditorClassIdentifier: Fruitomation::Fruitomation.UI.BasicUpgradeButton Upgrade: 22 DrawDefaultLines: 0 - Cost: - Magnitude: 0 - Ammount: 0 + Cost: 0 BigText: 0 RequiredUpgrades: - {fileID: 1342376329} @@ -4473,9 +4443,7 @@ MonoBehaviour: m_EditorClassIdentifier: Fruitomation::Fruitomation.Game.BasicUpgradeButton Upgrade: 10 DrawDefaultLines: 0 - Cost: - Magnitude: 0 - Ammount: 0 + Cost: 0 BigText: 0 RequiredUpgrades: - {fileID: 1077588040} @@ -4676,9 +4644,7 @@ MonoBehaviour: m_EditorClassIdentifier: Fruitomation::Fruitomation.UI.BasicUpgradeButton Upgrade: 29 DrawDefaultLines: 0 - Cost: - Magnitude: 0 - Ammount: 0 + Cost: 0 BigText: 0 RequiredUpgrades: - {fileID: 1552666745} @@ -5085,9 +5051,7 @@ MonoBehaviour: m_EditorClassIdentifier: Fruitomation::Fruitomation.UI.BasicUpgradeButton Upgrade: 4 DrawDefaultLines: 1 - Cost: - Magnitude: 0 - Ammount: 0 + Cost: 0 BigText: 1 RequiredUpgrades: [] LineMaterial: {fileID: 2100000, guid: eb8c84c9b7bce8f4ab2641ccf50d239c, type: 2} @@ -5249,9 +5213,7 @@ MonoBehaviour: m_EditorClassIdentifier: Fruitomation::Fruitomation.UI.BasicUpgradeButton Upgrade: 26 DrawDefaultLines: 0 - Cost: - Magnitude: 0 - Ammount: 0 + Cost: 0 BigText: 0 RequiredUpgrades: - {fileID: 239945582} @@ -5454,9 +5416,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: Fruitomation::Fruitomation.UI.BuildingUnlockButton Building: 4 - Cost: - Magnitude: 0 - Ammount: 0 + Cost: 0 AttachedButton: {fileID: 819595001} AttachedText: {fileID: 644778638} --- !u!1 &837873368 @@ -6254,9 +6214,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: Fruitomation::Fruitomation.UI.BuildingUnlockButton Building: 2 - Cost: - Magnitude: 0 - Ammount: 0 + Cost: 0 AttachedButton: {fileID: 937482392} AttachedText: {fileID: 837873370} --- !u!1 &946556762 @@ -6397,9 +6355,7 @@ MonoBehaviour: m_EditorClassIdentifier: Fruitomation::Fruitomation.UI.BasicUpgradeButton Upgrade: 35 DrawDefaultLines: 1 - Cost: - Magnitude: 0 - Ammount: 0 + Cost: 0 BigText: 1 RequiredUpgrades: [] LineMaterial: {fileID: 2100000, guid: eb8c84c9b7bce8f4ab2641ccf50d239c, type: 2} @@ -6716,9 +6672,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: Fruitomation::Fruitomation.UI.BuildingUnlockButton Building: 7 - Cost: - Magnitude: 0 - Ammount: 0 + Cost: 0 AttachedButton: {fileID: 1003126535} AttachedText: {fileID: 1865090572} --- !u!1 &1015076957 @@ -6861,9 +6815,7 @@ MonoBehaviour: m_EditorClassIdentifier: Fruitomation::Fruitomation.UI.BasicUpgradeButton Upgrade: 34 DrawDefaultLines: 0 - Cost: - Magnitude: 0 - Ammount: 0 + Cost: 0 BigText: 0 RequiredUpgrades: - {fileID: 528476489} @@ -7035,9 +6987,7 @@ MonoBehaviour: m_EditorClassIdentifier: Fruitomation::Fruitomation.UI.BasicUpgradeButton Upgrade: 20 DrawDefaultLines: 1 - Cost: - Magnitude: 0 - Ammount: 0 + Cost: 0 BigText: 0 RequiredUpgrades: - {fileID: 1812298575} @@ -7234,9 +7184,7 @@ MonoBehaviour: m_EditorClassIdentifier: Fruitomation::Fruitomation.UI.BasicUpgradeButton Upgrade: 0 DrawDefaultLines: 1 - Cost: - Magnitude: 0 - Ammount: 0 + Cost: 100000 BigText: 1 RequiredUpgrades: [] LineMaterial: {fileID: 2100000, guid: eb8c84c9b7bce8f4ab2641ccf50d239c, type: 2} @@ -7468,9 +7416,7 @@ MonoBehaviour: m_EditorClassIdentifier: Fruitomation::Fruitomation.UI.BasicUpgradeButton Upgrade: 17 DrawDefaultLines: 0 - Cost: - Magnitude: 0 - Ammount: 0 + Cost: 0 BigText: 0 RequiredUpgrades: - {fileID: 1486581294} @@ -8259,9 +8205,7 @@ MonoBehaviour: m_EditorClassIdentifier: Fruitomation::Fruitomation.UI.BasicUpgradeButton Upgrade: 2 DrawDefaultLines: 1 - Cost: - Magnitude: 0 - Ammount: 0 + Cost: 0 BigText: 1 RequiredUpgrades: [] LineMaterial: {fileID: 2100000, guid: eb8c84c9b7bce8f4ab2641ccf50d239c, type: 2} @@ -8465,9 +8409,7 @@ MonoBehaviour: m_EditorClassIdentifier: Fruitomation::Fruitomation.Game.BasicUpgradeButton Upgrade: 11 DrawDefaultLines: 1 - Cost: - Magnitude: 0 - Ammount: 0 + Cost: 0 BigText: 0 RequiredUpgrades: - {fileID: 683605715} @@ -8667,9 +8609,7 @@ MonoBehaviour: m_EditorClassIdentifier: Fruitomation::Fruitomation.UI.BasicUpgradeButton Upgrade: 24 DrawDefaultLines: 0 - Cost: - Magnitude: 0 - Ammount: 0 + Cost: 0 BigText: 0 RequiredUpgrades: - {fileID: 218329192} @@ -9031,9 +8971,7 @@ MonoBehaviour: m_EditorClassIdentifier: Fruitomation::Fruitomation.UI.BasicUpgradeButton Upgrade: 1 DrawDefaultLines: 1 - Cost: - Magnitude: 0 - Ammount: 0 + Cost: 10000000 BigText: 1 RequiredUpgrades: [] LineMaterial: {fileID: 2100000, guid: eb8c84c9b7bce8f4ab2641ccf50d239c, type: 2} @@ -9331,9 +9269,7 @@ MonoBehaviour: m_EditorClassIdentifier: Fruitomation::Fruitomation.UI.BasicUpgradeButton Upgrade: 21 DrawDefaultLines: 0 - Cost: - Magnitude: 0 - Ammount: 0 + Cost: 0 BigText: 0 RequiredUpgrades: - {fileID: 1992771926} @@ -9507,9 +9443,7 @@ MonoBehaviour: m_EditorClassIdentifier: Fruitomation::Fruitomation.UI.BasicUpgradeButton Upgrade: 25 DrawDefaultLines: 0 - Cost: - Magnitude: 0 - Ammount: 0 + Cost: 0 BigText: 0 RequiredUpgrades: - {fileID: 218329192} @@ -10350,9 +10284,7 @@ MonoBehaviour: m_EditorClassIdentifier: Fruitomation::Fruitomation.UI.BasicUpgradeButton Upgrade: 30 DrawDefaultLines: 1 - Cost: - Magnitude: 0 - Ammount: 0 + Cost: 0 BigText: 0 RequiredUpgrades: - {fileID: 2128693475} @@ -10515,9 +10447,7 @@ MonoBehaviour: m_EditorClassIdentifier: Fruitomation::Fruitomation.UI.BasicUpgradeButton Upgrade: 13 DrawDefaultLines: 0 - Cost: - Magnitude: 0 - Ammount: 0 + Cost: 0 BigText: 0 RequiredUpgrades: - {fileID: 406517119} @@ -10692,9 +10622,7 @@ MonoBehaviour: m_EditorClassIdentifier: Fruitomation::Fruitomation.UI.BasicUpgradeButton Upgrade: 16 DrawDefaultLines: 1 - Cost: - Magnitude: 0 - Ammount: 0 + Cost: 0 BigText: 0 RequiredUpgrades: - {fileID: 1215656306} @@ -10856,9 +10784,7 @@ MonoBehaviour: m_EditorClassIdentifier: Fruitomation::Fruitomation.UI.BasicUpgradeButton Upgrade: 6 DrawDefaultLines: 1 - Cost: - Magnitude: 0 - Ammount: 0 + Cost: 0 BigText: 1 RequiredUpgrades: [] LineMaterial: {fileID: 2100000, guid: eb8c84c9b7bce8f4ab2641ccf50d239c, type: 2} @@ -11019,9 +10945,7 @@ MonoBehaviour: m_EditorClassIdentifier: Fruitomation::Fruitomation.UI.BasicUpgradeButton Upgrade: 18 DrawDefaultLines: 1 - Cost: - Magnitude: 0 - Ammount: 0 + Cost: 0 BigText: 0 RequiredUpgrades: - {fileID: 1342376329} @@ -11184,9 +11108,7 @@ MonoBehaviour: m_EditorClassIdentifier: Fruitomation::Fruitomation.UI.BasicUpgradeButton Upgrade: 19 DrawDefaultLines: 0 - Cost: - Magnitude: 0 - Ammount: 0 + Cost: 0 BigText: 0 RequiredUpgrades: - {fileID: 1812298575} @@ -11352,9 +11274,7 @@ MonoBehaviour: m_EditorClassIdentifier: Fruitomation::Fruitomation.UI.BasicUpgradeButton Upgrade: 15 DrawDefaultLines: 1 - Cost: - Magnitude: 0 - Ammount: 0 + Cost: 0 BigText: 0 RequiredUpgrades: - {fileID: 1836886870} @@ -11517,9 +11437,7 @@ MonoBehaviour: m_EditorClassIdentifier: Fruitomation::Fruitomation.UI.BasicUpgradeButton Upgrade: 14 DrawDefaultLines: 0 - Cost: - Magnitude: 0 - Ammount: 0 + Cost: 0 BigText: 0 RequiredUpgrades: - {fileID: 1486581294} @@ -11990,9 +11908,7 @@ MonoBehaviour: m_EditorClassIdentifier: Fruitomation::Fruitomation.Game.BasicUpgradeButton Upgrade: 9 DrawDefaultLines: 0 - Cost: - Magnitude: 0 - Ammount: 0 + Cost: 0 BigText: 0 RequiredUpgrades: - {fileID: 946556767} @@ -12380,9 +12296,7 @@ MonoBehaviour: m_EditorClassIdentifier: Fruitomation::Fruitomation.UI.BasicUpgradeButton Upgrade: 5 DrawDefaultLines: 1 - Cost: - Magnitude: 0 - Ammount: 0 + Cost: 0 BigText: 1 RequiredUpgrades: [] LineMaterial: {fileID: 2100000, guid: eb8c84c9b7bce8f4ab2641ccf50d239c, type: 2} @@ -12620,9 +12534,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: Fruitomation::Fruitomation.UI.BuildingUnlockButton Building: 5 - Cost: - Magnitude: 0 - Ammount: 0 + Cost: 0 AttachedButton: {fileID: 2139157609} AttachedText: {fileID: 391812064} --- !u!1 &2145870941 diff --git a/Assets/Scripts/Global/MoneyController.cs b/Assets/Scripts/Global/MoneyController.cs index 7e39e11..d0d5ff8 100644 --- a/Assets/Scripts/Global/MoneyController.cs +++ b/Assets/Scripts/Global/MoneyController.cs @@ -17,6 +17,18 @@ namespace Fruitomation.Global Instance.InternalCurrentMoney += amount; } + public static bool CanBuy(double amount) + { + double val = Instance.InternalCurrentMoney - amount; + if (val > 0f) + { + Instance.InternalCurrentMoney = val; + return true; + } + + return false; + } + private void Awake() { if (Instance is not null) diff --git a/Assets/Scripts/UI/BasicUpgradeButton.cs b/Assets/Scripts/UI/BasicUpgradeButton.cs index 6db91fb..f328dda 100644 --- a/Assets/Scripts/UI/BasicUpgradeButton.cs +++ b/Assets/Scripts/UI/BasicUpgradeButton.cs @@ -5,6 +5,7 @@ using UnityEngine.UI; using UnityEngine; using System.Linq; using System; +using Fruitomation.Global; using PashaBibko.Pacore.Attributes; namespace Fruitomation.UI @@ -101,7 +102,16 @@ namespace Fruitomation.UI private void OnButtonClicked() { - UpgradeManager.Unlock(Upgrade); + if (Cost == 0f) + { + Debug.LogWarning("Upgrade Cost has not been set"); + return; + } + + if (MoneyController.CanBuy(Cost)) + { + UpgradeManager.Unlock(Upgrade); + } } private bool IsUnlockable => @@ -156,13 +166,15 @@ namespace Fruitomation.UI AttachedButton.interactable = State == UpgradeState.Unlockable; + string cost = Cost == 0f ? "UNAVAILABLE" : $"{Cost:F1}"; + // https://stackoverflow.com/questions/27040325/c-sharp-regex-to-convert-camelcase-to-sentence-case string formatted = Regex.Replace(Upgrade.ToString(), "[A-Z]", " $0")[1..]; AttachedText.text = State switch { UpgradeState.Hidden => "???", UpgradeState.Viewable => $"{formatted}", - UpgradeState.Unlockable => $"{formatted}\n{Cost:F1}", + UpgradeState.Unlockable => $"{formatted}\n{cost}", UpgradeState.Unlocked => $"{formatted}\nUnlocked", var _ => throw new ArgumentOutOfRangeException() }; diff --git a/Assets/Scripts/UI/BuildingUnlockButton.cs b/Assets/Scripts/UI/BuildingUnlockButton.cs index 53d3f8a..bcc54f1 100644 --- a/Assets/Scripts/UI/BuildingUnlockButton.cs +++ b/Assets/Scripts/UI/BuildingUnlockButton.cs @@ -1,5 +1,6 @@ using System.Text.RegularExpressions; using Fruitomation.Game; +using Fruitomation.Global; using UnityEngine.UI; using UnityEngine; @@ -28,16 +29,26 @@ namespace Fruitomation.UI string formatted = Regex.Replace(Building.ToString(), "[A-Z]", " $0")[1..]; bool unlocked = UpgradeManager.Is(Building); + string cost = Cost == 0f ? "UNAVAILABLE" : $"{Cost:F1}"; AttachedText.text = unlocked ? $"{formatted}\nUnlocked" - : $"{formatted}\n{Cost:F1}"; + : $"{formatted}\n{cost}"; AttachedButton.interactable = !unlocked; } private void OnButtonClicked() { - UpgradeManager.Unlock(Building); + if (Cost == 0f) + { + Debug.LogWarning("Upgrade Cost has not been set"); + return; + } + + if (MoneyController.CanBuy(Cost)) + { + UpgradeManager.Unlock(Building); + } } } }