mirror of
https://github.com/ryzij/Cube-Tower-Defense.git
synced 2026-07-14 01:56:57 +00:00
Перенёс поле _price для туррели
This commit is contained in:
@@ -47,6 +47,9 @@ MonoBehaviour:
|
|||||||
m_EditorClassIdentifier: Assembly-CSharp::Turret
|
m_EditorClassIdentifier: Assembly-CSharp::Turret
|
||||||
_bulletPrefab: {fileID: 2630910966893525057, guid: 73dab2e2f6b94fed1bca337e79ee22f4, type: 3}
|
_bulletPrefab: {fileID: 2630910966893525057, guid: 73dab2e2f6b94fed1bca337e79ee22f4, type: 3}
|
||||||
_reloadTime: 1
|
_reloadTime: 1
|
||||||
|
_damage: 0
|
||||||
|
_distance: 0
|
||||||
|
_price: 100
|
||||||
--- !u!1 &4329906039658757740
|
--- !u!1 &4329906039658757740
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|||||||
@@ -7,9 +7,12 @@ public class Turret : MonoBehaviour
|
|||||||
[SerializeField] private float _reloadTime = 1f;
|
[SerializeField] private float _reloadTime = 1f;
|
||||||
[SerializeField] private float _damage;
|
[SerializeField] private float _damage;
|
||||||
[SerializeField] private float _distance;
|
[SerializeField] private float _distance;
|
||||||
|
[SerializeField] private int _price;
|
||||||
|
|
||||||
private float _reloadTimer;
|
private float _reloadTimer;
|
||||||
|
|
||||||
|
public int Price => _price;
|
||||||
|
|
||||||
private void Update()
|
private void Update()
|
||||||
{
|
{
|
||||||
if (_reloadTimer >= _reloadTime)
|
if (_reloadTimer >= _reloadTime)
|
||||||
@@ -38,4 +41,9 @@ public class Turret : MonoBehaviour
|
|||||||
private bool DetectEnemy(Vector3 direction) =>
|
private bool DetectEnemy(Vector3 direction) =>
|
||||||
Physics.Raycast(transform.position, direction, out var hit, _bulletPrefab.Distance + _distance) &&
|
Physics.Raycast(transform.position, direction, out var hit, _bulletPrefab.Distance + _distance) &&
|
||||||
hit.transform.TryGetComponent(out Enemy _);
|
hit.transform.TryGetComponent(out Enemy _);
|
||||||
|
|
||||||
|
public void OnMouseDown()
|
||||||
|
{
|
||||||
|
print("Click on turret");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,9 +6,8 @@ public struct TurretShopItem
|
|||||||
{
|
{
|
||||||
[SerializeField] private Turret _turretPrefab;
|
[SerializeField] private Turret _turretPrefab;
|
||||||
[SerializeField] private Sprite _icon;
|
[SerializeField] private Sprite _icon;
|
||||||
[SerializeField] private int _price;
|
|
||||||
|
|
||||||
public readonly Turret TurretPrefab => _turretPrefab;
|
public readonly Turret TurretPrefab => _turretPrefab;
|
||||||
public readonly Sprite Icon => _icon;
|
public readonly Sprite Icon => _icon;
|
||||||
public readonly int Price => _price;
|
public readonly int Price => _turretPrefab.Price;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user