mirror of
https://github.com/ryzij/Cube-Tower-Defense.git
synced 2026-07-14 01:56:57 +00:00
Пуля теперь может врезаться в другую башню
This commit is contained in:
@@ -94,6 +94,12 @@ public class Turret : MonoBehaviour
|
|||||||
_reloadTimer += Time.deltaTime;
|
_reloadTimer += Time.deltaTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnTriggerEnter(Collider other)
|
||||||
|
{
|
||||||
|
if (other.TryGetComponent(out TurretBullet bullet) && bullet.From != this)
|
||||||
|
Destroy(bullet.gameObject);
|
||||||
|
}
|
||||||
|
|
||||||
private void SpawnBullet(Vector3 direction)
|
private void SpawnBullet(Vector3 direction)
|
||||||
{
|
{
|
||||||
if (_reloadTimer < _reloadTime || !DetectEnemy(direction))
|
if (_reloadTimer < _reloadTime || !DetectEnemy(direction))
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ public class TurretBullet : MonoBehaviour
|
|||||||
|
|
||||||
private Vector3 _spawnPos;
|
private Vector3 _spawnPos;
|
||||||
|
|
||||||
|
public Turret From { get; private set; }
|
||||||
public float Damage => _damage;
|
public float Damage => _damage;
|
||||||
public float Distance => _distance;
|
public float Distance => _distance;
|
||||||
|
|
||||||
@@ -28,6 +29,7 @@ public class TurretBullet : MonoBehaviour
|
|||||||
var rot = turret.transform.rotation;
|
var rot = turret.transform.rotation;
|
||||||
rot.SetLookRotation(direction);
|
rot.SetLookRotation(direction);
|
||||||
var bullet = Instantiate(this, spawnPoint, rot, turret.transform);
|
var bullet = Instantiate(this, spawnPoint, rot, turret.transform);
|
||||||
|
bullet.From = turret;
|
||||||
bullet._damage += turret.Damage;
|
bullet._damage += turret.Damage;
|
||||||
bullet._distance += turret.Distance - Vector3.Distance(spawnPoint, bullet.transform.position);
|
bullet._distance += turret.Distance - Vector3.Distance(spawnPoint, bullet.transform.position);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user