public void initialize(GunPoints point, Weapon weapon, LayerTags frendlyLayer) { _frendlyLayerTags = frendlyLayer; var r = Random.Range(0, 10); if (r > 4) { _soundManager.PlaySFX(SoundDataConfig.FIRE); } _speed = weapon.Speed; _weapon = weapon; transform.position = point.StartbulletPoint.transform.position; _target = point.FinishBulletPoint.transform.position; _colorBack.color = HexColorUtils.HexToColor(_bulletsColorPool[Random.Range(0, _bulletsColorPool.Count - 1)]); transform.localScale = new Vector3(weapon.Scale, weapon.Scale, weapon.Scale); _tw = transform.DOMove(_target, Time.deltaTime * _speed).SetEase(Ease.Linear).Play().OnComplete(() => { if (r > 4) { _soundManager.PlaySFX(SoundDataConfig.SPLASH); var sPart = _splashParticle.Create(); sPart.transform.SetParent(_gameManager.GamePresenter.transform); sPart.transform.position = new Vector3(transform.position.x, transform.position.y, -1); } }).OnKill(() => { Destroy(gameObject); }); }
public void InitFire(BaseTank tank, Weapon weapon, LayerTags frendlyLayer) { if (null == weapon) { GDebug.LogWarning("Weapon parameters is null", this, LogCategory.FIRE_CONTROLLER); return; } var dl1 = 0f; var dl2 = 0f; for (int i = 0; i < weapon.MaxBulletInShot; i++) { _delayService.DelayedCall(dl1, () => { foreach (var point in weapon.GamePointsPool) { if (weapon.InMomentShot) { AddBullet(point, weapon, frendlyLayer); } else { _delayService.DelayedCall(dl2, () => { AddBullet(point, weapon, frendlyLayer); }); dl2 += 0.1f; } } }); dl1 += 0.1f; } }
private void AddBullet(GunPoints point, Weapon weapon, LayerTags frendlyLayer) { if (null == point.StartbulletPoint || null == point.FinishBulletPoint) { return; } var bl = _bulletFactory.Create(); bl.initialize(point, weapon, frendlyLayer); bl.transform.SetParent(_gameManager.GamePresenter.transform); }
void Awake() { _frendlyLayerTags = LayerTags.Bullet; _rBody = GetComponent <Rigidbody2D>(); Subscriptions(); }