public override void Update(IRealm realm, double delta) { foreach (var bullet in realm.Entities.OfType<BulletViewModel>()) { bullet.X += (bullet.NewX - bullet.X) * .5f; bullet.Y += (bullet.NewY - bullet.Y) * .5f; realm.ModifyEntity(bullet); } }
public override void Update(IRealm realm, double delta) { foreach (var ball in realm.Entities.OfType<BallViewModel>()) { ball.X += (ball.NewX - ball.X) * .5; ball.Y += (ball.NewY - ball.Y) * .5; realm.ModifyEntity(ball); } }
/// <summary>Update realm.</summary> /// <param name="realm">Realm.</param> /// <param name="delta">Time passed since last update.</param> public override void Update(IRealm realm, double delta) { foreach (var entity in realm.Entities.OfType<Player>()) { realm.ModifyEntity(entity); } foreach (var entity in realm.Entities.OfType<Ball>()) { realm.ModifyEntity(entity); } foreach (var entity in realm.Entities.OfType<Bullet>()) { realm.ModifyEntity(entity); } foreach (var entity in realm.Entities.OfType<Gate>()) { realm.ModifyEntity(entity); } // It's time for sync if (DateTime.Now > _nextUpdate) { foreach (var ent in _list) { if (ent.Value == EntityState.Added) _service.AddEntity(ent.Key); if (ent.Value == EntityState.Modified) _service.ModifyEntity(ent.Key); if (ent.Value == EntityState.Removed) _service.RemoveEntity(ent.Key); } _list.Clear(); _nextUpdate = DateTime.Now.AddMilliseconds(100); } }
public override void Update(IRealm realm, double delta) { foreach (var player in realm.Entities.OfType<PlayerViewModel>()) { player.AimAngle += (player.NewAimAngle - player.AimAngle) * .3; player.X += (player.NewX - player.X) * .3; player.Y += (player.NewY - player.Y) * .3; if ((player.NewX - player.X) > 1) player.State = "RunRight"; else if ((player.NewX - player.X) < -1) player.State = "RunLeft"; else player.State = "Stay"; //player.X = player.NewX; //player.Y = player.NewY; realm.ModifyEntity(player); } }