public void Fire(Unit unit) { var now = DateTime.UtcNow; if (now - lastFire < TimeSpan.FromMilliseconds(400)) { return; } lastFire = now; magazineCount--; Random random = RandomNum(); for (int i = 0; i < 11; i++) { var newShot = new Shot(this.Engine); newShot.Initialize().Attach(); var offset = (random.NextDouble() - 0.5) * MathHelper.PiOver4; var speedChange = random.NextDouble() + 1; var direction = (this.body.Rotation + (float)offset).RadiansToDirection(); newShot.Velocity = direction * this.projectileSpeed * (float)speedChange + this.owner.LinearVelocity; newShot.Rotation = this.body.Rotation; newShot.Position = this.body.Position + direction * 2f; } const float kickback = -25; this.Kickbacks.OnNext(this.body.Rotation.RadiansToDirection() * kickback); }
public void Fire(Unit unit) { var newRocket = new Rocket(this.Engine); newRocket.Initialize().Attach(); var direction = this.body.Rotation.RadiansToDirection(); newRocket.Velocity = direction * this.projectileSpeed + this.owner.LinearVelocity; newRocket.Rotation = this.body.Rotation; newRocket.Position = this.body.Position + direction * 2f; }
private void OnActivate(Unit _) { this.peopleTableViewController = (PeopleTableViewController) this.ChildViewControllers[0]; this.createPersonViewController = (CreatePersonViewController) this.ChildViewControllers[1]; this.peopleTableViewController.WhenAnyObservable(controller => controller.Selected) .Subscribe(cell => this.PerformSegue("WhenCellSelected", cell)); this.createPersonViewController.WhenAnyValue(controller => controller.ViewModel.Document.IsCreated) .Where(isCreated => isCreated) .InvokeCommand(this.peopleTableViewController.ViewModel.Query.Query); this.peopleTableViewController.WhenAnyObservable(controller => controller.ViewModel.Model.Changed) .Subscribe(args => this.createPersonViewController.ViewModel = Locator.Current.GetService<IReactiveDocumentViewModel<User>>()); }
public void Fire(Unit unit) { var newBolt = new Bolt(this.Engine); newBolt.Initialize().Attach(); var direction = this.body.Rotation.RadiansToDirection(); newBolt.Velocity = direction * this.projectileSpeed + this.owner.LinearVelocity; newBolt.Rotation = this.body.Rotation; newBolt.Position = this.body.Position + direction * 2f; this.Fires.OnNext(Unit.Default); const float kickbackForce = -10; this.Kickbacks.OnNext(this.body.Rotation.RadiansToDirection() * kickbackForce); }
public void Reload(Unit unit) { }
private void ShowMainMenu(Unit unit) { this.Detach(); new MainMenu(this.Engine).Initialize().Attach(); }