Example #1
0
        /// <summary>
        /// Make a new camera focusing on the given game object.
        /// </summary>
        /// <param name="target">The target to focus on.</param>
        /// <param name="roomWidth">The width of the room this camera resides in. Used to prevent the camera from looking
        /// out of bounds.</param>
        /// <param name="roomHeight">The height of the room this camera resides in. Used to prevent the camera from looking
        /// out of bounds.</param>
        /// <param name="zoomLevel">The zoom level of the camera.</param>
        public Camera(GameObject target, int roomWidth, int roomHeight, float zoomLevel)
        {
            Zoom = zoomLevel;
            Rotation = 0.0f;
            position = target.Position;
            this.target = target;

            this.roomWidth = roomWidth;
            this.roomHeight = roomHeight;
        }
Example #2
0
 /// <summary>
 /// Returns the intersection between two objects.
 /// </summary>
 /// <param name="obj1">The other object</param>
 /// <returns>Whether or not the objects are intersecting</returns>
 public virtual bool Intersects(GameObject other)
 {
     return (this.Right > other.Left && this.Left < other.Right && this.Bottom > other.Top && this.Top < other.Bottom);
 }
Example #3
0
 public override bool Intersects(GameObject other)
 {
     return (Vector2.DistanceSquared(world.Player.Center + Direction * CLOSE_COLLISION_FACTOR, other.Center) < Math.Pow(DAMAGE_RADIUS_AROUND_PLAYER, 2)) ||
         MathExtra.PointInTriangle(world.Player.Center, collisionEndPoints[0], collisionEndPoints[1], other.Center);
 }
Example #4
0
 public void Remove(GameObject gameObject)
 {
     if (gameObject is Player)
         Player = null;
     else if (gameObject as Laser != null)
         Lasers.BufferRemove((Laser)gameObject);
     else if (gameObject as Zombie != null)
         Zombies.BufferRemove((Zombie)gameObject);
     else if (gameObject as Vampire != null)
         Vampires.BufferRemove((Vampire)gameObject);
     else if (gameObject as Block != null)
         Blocks.BufferRemove((Block)gameObject);
     else
         throw new InvalidOperationException("Unhandled removal of object.");
 }