mirror of
https://github.com/ryzij/Cube-Tower-Defense.git
synced 2026-07-14 01:56:57 +00:00
Изменил логику перезарядки туррелей
This commit is contained in:
@@ -15,27 +15,23 @@ public class Turret : MonoBehaviour
|
|||||||
|
|
||||||
private void Update()
|
private void Update()
|
||||||
{
|
{
|
||||||
if (_reloadTimer >= _reloadTime)
|
SpawnBullet(Vector3.forward);
|
||||||
{
|
SpawnBullet(Vector3.back);
|
||||||
SpawnBullet(Vector3.forward);
|
SpawnBullet(Vector3.left);
|
||||||
SpawnBullet(Vector3.back);
|
SpawnBullet(Vector3.right);
|
||||||
SpawnBullet(Vector3.left);
|
|
||||||
SpawnBullet(Vector3.right);
|
|
||||||
|
|
||||||
_reloadTimer = 0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
_reloadTimer += Time.deltaTime;
|
_reloadTimer += Time.deltaTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SpawnBullet(Vector3 direction)
|
private void SpawnBullet(Vector3 direction)
|
||||||
{
|
{
|
||||||
if (!DetectEnemy(direction))
|
if (_reloadTimer < _reloadTime || !DetectEnemy(direction))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var rot = transform.rotation;
|
var rot = transform.rotation;
|
||||||
rot.SetLookRotation(direction);
|
rot.SetLookRotation(direction);
|
||||||
Instantiate(_bulletPrefab, transform.position, rot, transform);
|
Instantiate(_bulletPrefab, transform.position, rot, transform);
|
||||||
|
_reloadTimer = 0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool DetectEnemy(Vector3 direction) =>
|
private bool DetectEnemy(Vector3 direction) =>
|
||||||
|
|||||||
Reference in New Issue
Block a user