public void update(PhysicsEntity actor, GameTime time) { this.actor = actor; if (timer == new TimeSpan (0, 0, 0, 0, millisecondsToWait)) { SetMoveDirection (); MoveEntity (actor); } if ((actor.position - nodePositions [nextNode]).LengthSquared() < 2) { reachedNode = true; } if (reachedNode) { nextNodeTimer = new TimeSpan (0, 0, 0, 0, nextNodeWaitTime); timer -= time.ElapsedGameTime; if (timer <= TimeSpan.Zero) { UpdateNodes (); } } else { nextNodeTimer -= time.ElapsedGameTime; if (nextNodeTimer <= TimeSpan.Zero) { UpdateNodes (); nextNodeTimer = new TimeSpan (0, 0, 0, 0, nextNodeWaitTime); } } }
public void update(PhysicsEntity actor, GameTime time) { if (GameState.Scene ().LineOfSight (actor.getHitBox ().Center, GameScene.player.getHitBox ().Center)) { Console.Out.WriteLine ("I see you."); Vector2 dir = new Vector2 (GameScene.player.getHitBox().Center.X - actor.getHitBox().Center.X, GameScene.player.getHitBox().Center.Y - actor.getHitBox().Center.Y); dir.Normalize (); actor.Impulse (dir); } }
public void update(PhysicsEntity actor, GameTime time) { if (timer >= TimeSpan.Zero) { timer -= time.ElapsedGameTime; } else { timer = new TimeSpan (0, 0, 0, 0, 500); impulseDir = new Vector2 ((float)rng.NextDouble () - 0.5f, (float)rng.NextDouble () - 0.5f); impulseDir.Normalize (); } actor.Impulse (impulseDir); }
private void MoveEntity(PhysicsEntity actor) { actor.Impulse (0.2f * moveDirection); }