From d13bc748f74004a6486728c4dd86af6b237a116f Mon Sep 17 00:00:00 2001 From: kittyegg Date: Tue, 12 May 2026 01:00:34 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20?= =?UTF-8?q?=D0=BF=D1=80=D0=BE=D0=B4=D0=B0=D0=B6=D1=83=20=D1=82=D1=83=D1=80?= =?UTF-8?q?=D1=80=D0=B5=D0=BB=D0=B5=D0=B9=20=D0=BF=D1=80=D0=B8=20=D0=BA?= =?UTF-8?q?=D0=BB=D0=B8=D0=BA=D0=B5=20=D0=BD=D0=B0=20=D0=BD=D0=B5=D1=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Scripts/TurretsShop.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Assets/Scripts/TurretsShop.cs b/Assets/Scripts/TurretsShop.cs index fdbc165..459dc6f 100644 --- a/Assets/Scripts/TurretsShop.cs +++ b/Assets/Scripts/TurretsShop.cs @@ -9,6 +9,7 @@ public class TurretsShop : MonoBehaviour [SerializeField] private BlockDetector _blockDetector; [SerializeField] private Transform _turretsHolder; [SerializeField] private InputAction _deselectAction; + [SerializeField] private float _sellingCoefficient = 0.5f; [SerializeField] private TurretShopItem[] _turretShopItems; [SerializeField] private UnityEvent _onTurretSelected; [SerializeField] private UnityEvent _onTurretDeselected; @@ -71,6 +72,12 @@ public class TurretsShop : MonoBehaviour private void OnBlockClicked(BlockScript block) { + if (block.Type == BlockScript.BlockType.Turret) + { + DestroyTurret(block.GetComponent()); + return; + } + if (!block.CompareTag("GrassBlock") || !_isTurretSelected || _selectedTurret.Price > _wallet.Money) return; @@ -82,4 +89,14 @@ public class TurretsShop : MonoBehaviour if (_wallet.Money < _selectedTurret.Price) DeselectTurret(); } + + private void DestroyTurret(Turret turret) + { + // TODO: проверять нажата ли кнопку продажи туррелей + if (turret == null) + return; + + _wallet.AddMoney(Mathf.RoundToInt(turret.Price * _sellingCoefficient)); + Destroy(turret.gameObject); + } }