示例#1
0
文件: Camera.cs 项目: akbiggs/Zombies
        /// <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;
        }
示例#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);
 }
示例#3
0
文件: Laser.cs 项目: akbiggs/Zombies
 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);
 }
示例#4
0
文件: World.cs 项目: akbiggs/Zombies
 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.");
 }