mirror of
https://github.com/ryzij/Cube-Tower-Defense.git
synced 2026-07-14 10:06:58 +00:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 893353a41c | |||
| f7f06e808f | |||
| 8f9633ef78 |
@@ -9816,6 +9816,14 @@ MonoBehaviour:
|
|||||||
m_Groups:
|
m_Groups:
|
||||||
m_Action: Deselect
|
m_Action: Deselect
|
||||||
m_Flags: 0
|
m_Flags: 0
|
||||||
|
- m_Name:
|
||||||
|
m_Id: deb5c6fa-481c-4811-a3ae-403ba593dfe2
|
||||||
|
m_Path: <Keyboard>/space
|
||||||
|
m_Interactions:
|
||||||
|
m_Processors:
|
||||||
|
m_Groups:
|
||||||
|
m_Action: Deselect
|
||||||
|
m_Flags: 0
|
||||||
m_Flags: 0
|
m_Flags: 0
|
||||||
_sellingCoefficient: 0.5
|
_sellingCoefficient: 0.5
|
||||||
_turretShopItems:
|
_turretShopItems:
|
||||||
|
|||||||
@@ -6,12 +6,14 @@ public class Turret : MonoBehaviour
|
|||||||
[SerializeField] private TurretBullet _bulletPrefab;
|
[SerializeField] private TurretBullet _bulletPrefab;
|
||||||
[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 = 3f;
|
||||||
[SerializeField] private int _price;
|
[SerializeField] private int _price;
|
||||||
|
|
||||||
private float _reloadTimer;
|
private float _reloadTimer;
|
||||||
|
|
||||||
public int Price => _price;
|
public int Price => _price;
|
||||||
|
public float Damage => _damage;
|
||||||
|
public float Distance => _distance;
|
||||||
|
|
||||||
private void Update()
|
private void Update()
|
||||||
{
|
{
|
||||||
@@ -28,9 +30,7 @@ public class Turret : MonoBehaviour
|
|||||||
if (_reloadTimer < _reloadTime || !DetectEnemy(direction))
|
if (_reloadTimer < _reloadTime || !DetectEnemy(direction))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var rot = transform.rotation;
|
_bulletPrefab.Spawn(this, direction);
|
||||||
rot.SetLookRotation(direction);
|
|
||||||
Instantiate(_bulletPrefab, transform.position, rot, transform);
|
|
||||||
_reloadTimer = 0f;
|
_reloadTimer = 0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ public class TurretBullet : MonoBehaviour
|
|||||||
{
|
{
|
||||||
[SerializeField] private float _damage = 1f;
|
[SerializeField] private float _damage = 1f;
|
||||||
[SerializeField] private float _speed = 5f;
|
[SerializeField] private float _speed = 5f;
|
||||||
[SerializeField] private float _distance = 3f;
|
[SerializeField] private float _distance;
|
||||||
|
|
||||||
private Vector3 _spawnPos;
|
private Vector3 _spawnPos;
|
||||||
|
|
||||||
@@ -22,4 +22,15 @@ public class TurretBullet : MonoBehaviour
|
|||||||
if (Vector3.Distance(transform.position, _spawnPos) > _distance)
|
if (Vector3.Distance(transform.position, _spawnPos) > _distance)
|
||||||
Destroy(gameObject);
|
Destroy(gameObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TurretBullet Spawn(Turret turret, Vector3 direction)
|
||||||
|
{
|
||||||
|
var rot = turret.transform.rotation;
|
||||||
|
rot.SetLookRotation(direction);
|
||||||
|
var bullet = Instantiate(this, turret.transform.position, rot, turret.transform);
|
||||||
|
bullet._damage += turret.Damage;
|
||||||
|
bullet._distance += turret.Distance;
|
||||||
|
|
||||||
|
return bullet;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user