Пример #1
0
        public override CollisionResponse CanCollide(WorldBody projectedBody)
        {
            if (PendingDestruction)
            {
                return(new CollisionResponse(false));
            }

            // ship-to-ship collisions

            /*if (projectedBody is Ship ship)
             *  if (ship.Fleet != null && this.Fleet != null && this.Fleet != ship.Fleet)
             *      return new CollisionResponse(true, true);*/


            if (projectedBody is ShipWeaponBullet bullet)
            {
                //if (projectedBody is ShipWeaponSeeker && this.Abandoned)
                //    return new CollisionResponse(false);

                if (bullet.Consumed)
                {
                    return(new CollisionResponse(false));
                }

                // if it came from this fleet
                if (bullet.OwnedByFleet == this?.Fleet)
                {
                    return(new CollisionResponse(false));
                }

                // if it came from this fleet
                if (bullet.OwnedByFleet == this?.AbandonedByFleet &&
                    World.Time < (this.AbandonedTime + World.Hook.AbandonBuffer))
                {
                    return(new CollisionResponse(false));
                }

                // team mode ensures that bullets of like colors do no harm
                if (World.Hook.TeamMode && bullet.Color == this.Color)
                {
                    return(new CollisionResponse(false));
                }

                return(new CollisionResponse(true, false));
            }

            if (!this.Abandoned)
            {
                // TODO: do we still need this beast?
                if (projectedBody is PickupBase ||
                    projectedBody is HasteToken)
                {
                    return(new CollisionResponse(true, false));
                }
            }

            return(base.CanCollide(projectedBody));
        }
Пример #2
0
 public override void CollisionExecute(WorldBody projectedBody)
 {
     if (projectedBody is ShipWeaponBullet bullet)
     {
         if (!bullet.Consumed)
         {
             bullet.Consumed = true;
         }
     }
 }
Пример #3
0
        public override CollisionResponse CanCollide(WorldBody projectedBody)
        {
            if (projectedBody is ShipWeaponBullet bullet)
            {
                return(new CollisionResponse(true, true, frictionCoefficient: 0.3f));
            }

            if (projectedBody is Ship)
            {
                return(new CollisionResponse(true, true, frictionCoefficient: 0.3f));
            }

            if (projectedBody is Obstacle)
            {
                return(new CollisionResponse(true, true, frictionCoefficient: 0.3f));
            }

            return(base.CanCollide(projectedBody));
        }
Пример #4
0
        public override void CollisionExecute(WorldBody projectedBody)
        {
            if (projectedBody is ShipWeaponBullet bullet)
            {
                if (this.PendingDestruction)
                {
                    return;
                }
                if (bullet.Consumed || this.PendingDestruction)
                {
                    return;
                }

                bullet.Consumed = true;

                var fleet  = bullet?.OwnedByFleet;
                var player = fleet?.Owner;

                var takesDamage = !Fleet?.Owner?.IsInvulnerable ?? true;
                if (takesDamage && ShieldStrength > 0)
                {
                    if (projectedBody is ShipWeaponSeeker)
                    {
                        ShieldStrength = 0;
                    }
                    else
                    {
                        ShieldStrength--;
                    }

                    takesDamage = false;
                }

                if (takesDamage)
                {
                    Die(player, fleet, bullet);
                }
            }
        }
Пример #5
0
 public override CollisionResponse CanCollide(WorldBody projectedBody)
 {
     return(new CollisionResponse(true, true));
 }
Пример #6
0
 public override void CollisionExecute(WorldBody projectedBody)
 {
 }