示例#1
0
文件: Door.cs 项目: maestun/wonderboy
 public bool IsOverlapping(GameObject o)
 {
     return o.GetCollisionRectangle().IntersectsWith(this.GetCollisionRectangle());
 }
示例#2
0
 public GameObject GetCollidingObject(GameObject obj, ObjectClass objectClass)
 {
     foreach (GameObject obj2 in this.gameObjects)
     {
         if (obj2.ObjClass == objectClass)
         {
             if (obj2.CurAnimHitType == AnimHitType.HeadOnly)
             {
                 if (obj.GetCollisionRectangle().IntersectsWith(obj2.GetShieldSwordRectangle()))
                 {
                     return obj2;
                 }
             }
             else if (obj.GetCollisionRectangle().IntersectsWith(obj2.GetCollisionRectangle()))
             {
                 return obj2;
             }
         }
     }
     return null;
 }
示例#3
0
 public override bool DoAction(GameObject o)
 {
     bool flag = false;
     if (!this.started)
     {
         this.started = true;
         if (this.relativeToPlayer)
         {
             GameObject player = GameEngine.Game.GetPlayer();
             this.pivotX = player.X;
             if (player.CurrentRotation == Direction.Up)
             {
                 this.pivotY = player.Y - (player.GetCollisionRectangle().Height / 2f);
             }
             else
             {
                 this.pivotY = player.Y + player.GetCollisionRectangle().Height;
             }
         }
         else
         {
             this.pivotX = o.Location.X;
             this.pivotY = o.Location.Y;
         }
         if (this.yMove.Acceleration != 0f)
         {
             o.YSpeed.Acceleration = this.yMove.Acceleration;
             o.YSpeed.TargetSpeed = this.yMove.TargetSpeed;
             if (this.yMove.CurrentSpeed != 0f)
             {
                 o.YSpeed.CurrentSpeed = this.yMove.CurrentSpeed;
             }
         }
         if (this.xMove.Acceleration != 0f)
         {
             o.XSpeed.Acceleration = this.xMove.Acceleration;
             o.XSpeed.TargetSpeed = this.xMove.TargetSpeed;
             if (this.xMove.CurrentSpeed != 0f)
             {
                 o.XSpeed.CurrentSpeed = this.xMove.CurrentSpeed;
             }
             if (o.Location.X > this.pivotX)
             {
                 Speed xSpeed = o.XSpeed;
                 xSpeed.TargetSpeed *= -1f;
             }
         }
     }
     if (this.relativeToPlayer)
     {
         GameObject obj3 = GameEngine.Game.GetPlayer();
         this.pivotX = obj3.X;
         if (obj3.CurrentRotation == Direction.Up)
         {
             this.pivotY = (obj3.Y - (obj3.GetCollisionRectangle().Height / 2f)) + (o.GetCollisionRectangle().Height / 2f);
         }
         else
         {
             this.pivotY = (obj3.Y + (obj3.GetCollisionRectangle().Height / 2f)) + (o.GetCollisionRectangle().Height / 2f);
         }
     }
     if (this.xMove.Acceleration != 0f)
     {
         flag = o.XSpeed.CurrentSpeed == o.XSpeed.TargetSpeed;
         if ((((o.XSpeed.TargetSpeed > 0f) && flag) && (o.Location.X > this.pivotX)) || (((o.XSpeed.TargetSpeed < 0f) && flag) && (o.Location.X < this.pivotX)))
         {
             Speed speed2 = o.XSpeed;
             speed2.TargetSpeed *= -1f;
         }
     }
     if (this.yMove.Acceleration != 0f)
     {
         flag = (o.YSpeed.CurrentSpeed == o.YSpeed.TargetSpeed) || (o.YSpeed.CurrentSpeed == 0f);
         if ((((o.YSpeed.TargetSpeed > 0f) && flag) && (o.Location.Y > this.pivotY)) || (((o.YSpeed.TargetSpeed < 0f) && flag) && (o.Location.Y < this.pivotY)))
         {
             Speed ySpeed = o.YSpeed;
             ySpeed.TargetSpeed *= -1f;
         }
     }
     if (this.timeLeft > 0)
     {
         this.timeLeft--;
     }
     return (this.timeLeft <= 0);
 }