public void Fire() { if (IsDestroyed()) { return; } if (_target == null) { OnFlavourText(_name, "No target to fire at!"); return; } if (Ammo <= 0) { OnFlavourText(_name, "No more ammo!"); return; } var distance = Parent.Position.DistanceTo(_target.Position); if (distance < _range) { Ammo--; OnGameEngineEvent(this, GameEngineEventArgs.Damage(_target, new DamageSource() { Magnitude = _power, DamageType = DamageType.CONCUSSIVE, Origin = Parent.Position })); // power is not attenuated because there is no drag. } else { OnFlavourText(_name, "Target was too far away to hit!"); } }
private void InvokeGameEngineStateEvent(GameEngineEventArgs args) { if (this.GameEngineStateEvent != null) { this.GameEngineStateEvent(this, args); } }
public void Fire() { if (IsDestroyed()) { return; } if (_target == null) { OnFlavourText(_name, "No target to fire at!"); return; } var distance = Parent.Position.DistanceTo(_target.Position); if (distance < _range) { // use power for charge... OnGameEngineEvent(this, GameEngineEventArgs.Damage(_target, (new DamageSource() { Magnitude = _power - (_power * distance / _range), DamageType = DamageType.DRAINING, Origin = Parent.Position }))); } else { OnFlavourText(_name, "Target was too far away to hit!"); } }
public void Fire() { OnFlavourText(_name, "Launching ship from hanger!"); var shipToSpawn = _shipCreationFunc(); shipToSpawn.Team = Parent.Team; OnGameEngineEvent(this, GameEngineEventArgs.Spawn(shipToSpawn, Parent.Position)); }
private void BlowUp() { _isDestroyed = true; OnGameEngineEvent(this, GameEngineEventArgs.Destroy(this)); // destroy first so we don't get in a infinite loop of destruction. OnGameEngineEvent(this, GameEngineEventArgs.SplashDamage(_damageRadius, new DamageSource() { Magnitude = _damage, Origin = Position, DamageType = DamageType.EXPLOSIVE })); }
private void OnEngineEvent(object sender, GameEngineEventArgs gameEngineEventArgs) { // TODO implement a lookup by uint key if (gameEngineEventArgs.Event is EntityAdded) { var e = (EntityAdded)gameEngineEventArgs.Event; AddEntity(gameEngineEventArgs.Engine.Entities.Single(p => p.Id == e.EntityId)); } if (gameEngineEventArgs.Event is EntityRemoved) { var e = (EntityRemoved)gameEngineEventArgs.Event; RemoveEntity(gameEngineEventArgs.Engine.Entities.Single(p => p.Id == e.EntityId)); } }
private void ChangeGameEngineStateHandler(object sender, GameEngineEventArgs args) { switch (args.GameState) { case GameEngineState.AITurn: case GameEngineState.BeginShuffling: this.DisableButtons(); break; case GameEngineState.HumanTurn: case GameEngineState.EndShuffling: this.EnableButtons(); break; } }
protected void OnGameEngineEvent(object sender, GameEngineEventArgs e) { GameEngineEventHandler?.Invoke(sender, e); }