Exemplo n.º 1
0
        public double DistanceFrom(GameObject otherGuy)
        {
            double deltaX = otherGuy.position.X - this.position.X;
            deltaX *= deltaX;
            double deltaY = otherGuy.position.Y - this.position.Y;
            deltaY *= deltaY;

            return Math.Sqrt(deltaX + deltaY);
        }
Exemplo n.º 2
0
 public bool CanSee(GameObject otherGuy)
 {
     return GetAngle(GetDirection(otherGuy), Vector2.UnitY) - rotation < VISION_FIELD
         && DistanceFrom(otherGuy) < VISION_LENGTH;
 }
Exemplo n.º 3
0
        public void MoveTowards(GameObject otherGuy)
        {
            Vector2 direction = GetDirection(otherGuy);
            this.position.X += direction.X * this.velocity;
            this.position.Y += direction.Y * this.velocity;

            this.rotation = GetAngle(direction, Vector2.UnitY);
        }
Exemplo n.º 4
0
 private Vector2 GetDirection(GameObject otherGuy)
 {
     Vector2 direction = new Vector2(otherGuy.position.X - this.position.X, otherGuy.position.Y - this.position.Y);
     direction.Normalize();
     return direction;
 }
Exemplo n.º 5
0
 protected void CollideTop(GameObject problemTile)
 {
     this.Position.Y = problemTile.BottomRectangle.Bottom;
     this.Velocity.Y = 0;
 }