private void TowerAI_BulletShoot(BulletModel bullet) { if (BulletShoot != null) { BulletShoot(bullet); } }
private void Tower_BulletShoot(BulletModel bullet) { _bullets.Add(bullet); bullet.Hitted += Bullet_Hitted; if (BulletCreated != null) { BulletCreated(bullet); } }
private void Bullet_Hitted(BulletModel bullet, UnitModel unit) { if (_bulletViews.ContainsKey(bullet)) { var bulletView = _bulletViews[bullet]; bulletView.Stop(); Destroy(bulletView.gameObject, bulletView.DestroyDelay); _bulletViews.Remove(bullet); } }
private void CreateBullet(BulletModel bullet) { foreach (var bulletPrefab in _bulletViewPrefabs) { if (bulletPrefab.name == bullet.Visual) { var bulletView = Instantiate(bulletPrefab, _bulletsRoot); bullet.Hitted += Bullet_Hitted; bulletView.AttachTo(bullet); _bulletViews.Add(bullet, bulletView); break; } } }
protected override void _bullet_Hitted(BulletModel bullet, UnitModel _) { foreach (var unit in _getUnits().ToArray()) { if (unit.Position.x >= bullet.Position.x - _explosionRadius && unit.Position.x <= bullet.Position.x + _explosionRadius && unit.Position.y >= bullet.Position.y - _explosionRadius && unit.Position.y <= bullet.Position.y + _explosionRadius) { if (unit.Position.DistanceTo(bullet.Position) < _explosionRadius) { unit.Health -= _damage; } } } }
private void Map_BulletCreated(BulletModel bullet) { CreateBullet(bullet); }
protected override void _bullet_Hitted(BulletModel bullet, UnitModel unit) { }
private void Bullet_Hitted(BulletModel bullet, UnitModel unit) { _bullets.Remove(bullet); }
protected virtual void Shot() { _bullet = new BulletModel(_bulletVisual, _position, _target, _bulletSpeed); _bullet.Hitted += _bullet_Hitted; OnBulletShoot(); }
protected virtual void _bullet_Hitted(BulletModel bullet, UnitModel unit) { unit.Health -= _damage; }