void ISignalListener <SpawnUnitSignal> .SignalFired(SpawnUnitSignal signal) { ClientOnlyConditionalDebug.Log("spawn"); var viewInstance = Object.Instantiate(signal.View, signal.Position, Quaternion.identity); var unit = new Entities.Unit(signal.Data, viewInstance); _signalService.FireSignal(new UnitSpawnedSignal(unit)); }
private int GetCalculatedDamage(int damage, Vector3 damagePosition, Vector3 targetPosition) { RaycastHit hit; UnityEngine.Debug.DrawLine(damagePosition, targetPosition); if (!Physics.Linecast(damagePosition, targetPosition, out hit) || hit.transform.GetComponent <ObstacleView>() == null) { return(damage); } ClientOnlyConditionalDebug.Log("obstacle found"); return((int)(damage * _settings.ObstacleFactor)); }
private void Awake() { ClientOnlyConditionalDebug.Log("game started"); Assert.IsNotNull(_unitGenerationSettingsProvider); Assert.IsNotNull(_bombGenerationSettingsProvider); Assert.IsNotNull(_damageSettingsProvider); _currentContext = new GameContext( _unitGenerationSettingsProvider.Settings, _bombGenerationSettingsProvider.Settings, _damageSettingsProvider.Settings); _currentContext.Init(); ClientOnlyConditionalDebug.Log("context created"); }
void ISignalListener <UnitViewUnderAttackSignal> .SignalFired(UnitViewUnderAttackSignal signal) { ClientOnlyConditionalDebug.LogWarning("hey, I got apply damage signal :)"); var view = signal.View; var damage = signal.Damage; var unit = GetUnitByView(view); if (unit == null) { ClientOnlyConditionalDebug.LogWarning("unit not found"); return; } unit.Damagable.CurrentHealth -= GetCalculatedDamage(damage.Amount, signal.DamagerPosition, unit.View.transform.position); if (unit.Damagable.CurrentHealth > 0) { return; } _units.Remove(unit); _signalService.FireSignal(new DestroyUnitSignal(unit)); }
public UnitDamageService(ISignalService signalService, DamageSettings settings) { _signalService = signalService; _settings = settings; ClientOnlyConditionalDebug.Log("hello I am damage service"); }
public BombGenerationService(ISignalService signalService, BombGenerationSettings settings) { _signalService = signalService; _settings = settings; ClientOnlyConditionalDebug.Log("hello I am unit generation service"); }