public override void Update(double fps = 1) { base.Update(fps); TickDamping(fps); if (_pos.X < 0) { _pos.X = 0; _vec.X = -_vec.X / BumpDamping; } else if (_pos.X > _grid.Width - _canvas.Width - 30) { _pos.X = _grid.Width - _canvas.Width - 30; _vec.X = -_vec.X / BumpDamping; } if (_pos.Y < 0) { _pos.Y = 0; _vec.Y = -_vec.Y / BumpDamping; } else if (_pos.Y > _grid.ActualHeight - _canvas.ActualHeight - 45) { _pos.Y = _grid.ActualHeight - _canvas.ActualHeight - 45; _vec.Y = -_vec.Y / BumpDamping; } for (int i = 0; i < Missiles.Count; i++) { Missiles[i].Update(fps); if (Missiles[i].ToRemove) { Missiles[i].Remove(); Missiles.Remove(Missiles[i]); } } if (_lastShot < fps / _shotsPerSec) { _lastShot++; } if (HP <= 0) { Death?.Invoke(this, new EventArgs()); } }
private void OnEntityRemove(MyEntity myEntity) { try { if (myEntity == null || !_isServer || DsState.State.ReInforce) { return; } if (!(myEntity.DefinitionId.HasValue && myEntity.DefinitionId.Value.TypeId == typeof(MyObjectBuilder_Missile))) { return; } Missiles.Remove(myEntity); FriendlyMissileCache.Remove(myEntity); } catch (Exception ex) { Log.Line($"Exception in Controller OnEntityRemove: {ex}"); } }