Ejemplo n.º 1
0
 /// <summary>
 /// Check if the given coordinate is inside this entity.
 /// </summary>
 public bool IsInside(Vector2 position)
 {
     return (position.X > Position.X - Size.X / 2 &&
         position.X < Position.X + Size.X / 2) &&
         (position.Y > Position.Y - Size.Y / 2 &&
         position.Y < Position.Y + Size.Y / 2);
 }
Ejemplo n.º 2
0
 public House(Vector2 position)
 {
     this.Position = position;
     this._size = new Vector2(224, 144);
     this._drawOrder = -1;
     _spriteSet = new AnimatedSpriteSet("house.png", (int)_size.X, (int)_size.Y);
 }
Ejemplo n.º 3
0
 public Tree(Vector2 position)
 {
     this.Position = position;
     this._size = new Vector2(64, 80);
     this._drawOrder = -1;
     _spriteSet = new AnimatedSpriteSet("tree.png", (int)_size.X, (int)_size.Y);
 }
Ejemplo n.º 4
0
 public void PaintAt(Graphics g, Vector2 position)
 {
     _srcRectangle = new Rectangle(
         _currentColumn * _spriteWidth,
         _currentRow * _spriteHeight,
         _spriteWidth,
         _spriteHeight
     );
     Rectangle destRectangle = new Rectangle(
         (int)position.X - _spriteWidth / 2,
         (int)position.Y - _spriteHeight / 2,
         _spriteWidth, _spriteHeight);
     g.DrawImage(_spriteSet, destRectangle, _srcRectangle, GraphicsUnit.Pixel);
 }
Ejemplo n.º 5
0
 public Vector2 Steer(MovingEntity agent, double elapsed)
 {
     Vector2 force = new Vector2();
     if (Keyboard.IsKeyDown(Keys.Left) || Keyboard.IsKeyDown(Keys.A))
     {
         force.X -= 1;
     }
     if (Keyboard.IsKeyDown(Keys.Right) || Keyboard.IsKeyDown(Keys.D))
     {
         force.X += 1;
     }
     if (Keyboard.IsKeyDown(Keys.Up) || Keyboard.IsKeyDown(Keys.W))
     {
         force.Y -= 1;
     }
     if (Keyboard.IsKeyDown(Keys.Down) || Keyboard.IsKeyDown(Keys.S))
     {
         force.Y += 1;
     }
     return force * agent.MaxSpeed;
 }
Ejemplo n.º 6
0
        public Vector2 Steer(MovingEntity agent, double elapsed)
        {
            Vector2 steeringForce = new Vector2(0, 0);
            foreach (Entity entity in _world.Entities)
            {
                if (agent == entity)
                {
                    // Can't escape from yourself, so continue with the next one.
                    continue;
                }
                Vector2 distance = entity.Position - agent.Position;

                // Add seperating force to steering force for the current entity.
                if (distance.Length > 0 && distance.Length < Radius)
                {
                    distance = Vector2.Normalize(distance) / distance.Length;
                    steeringForce += distance;
                }
            }
            return steeringForce;
        }
Ejemplo n.º 7
0
 public SeekAtSteering(Vector2 location)
 {
     this.Location = location;
 }
Ejemplo n.º 8
0
 public CreeperExplosion(World world, Vector2 position)
 {
     Position = position;
     _world = world;
     _currentRadius = StartRadius;
 }
Ejemplo n.º 9
0
 public GraphNode(Vector2 position)
 {
     this._position = position;
     this._adjecentEdges = new LinkedList<GraphEdge>();
 }