Beispiel #1
0
 public override void CollisionCheck(Frog frog)
 {
     foreach (MovingObject movingObj in GetList)
     {
         // kills frog if hit by a vehicle
         if (SplashKit.BitmapCollision(movingObj.Bitmap, movingObj.Position, SplashKit.BitmapNamed("frog"), frog.Position))
         {
             frog.Splat();
         }
     }
 }
Beispiel #2
0
        public override bool HasCollided(CPlayer plr, Component comp)
        {
            if (!comp.Self.HasComponent <CDraw>())
            {
                return(false);
            }
            CDraw toCheck = comp.Self.GetComponent <CDraw>();

            return(SplashKit.BitmapCollision(
                       SplashKit.BitmapNamed($"Player{plr.Data.PlayerNum}"),
                       plr.Data.AbsoluteX,
                       plr.Data.AbsoluteY,
                       SplashKit.BitmapNamed(toCheck.Type.ToString()),
                       toCheck.X * Settings.CellWidth,
                       toCheck.Y * Settings.CellHeight
                       ));
        }
Beispiel #3
0
        // checks collision with frog and sticks frog to platform if so
        public override void CollisionCheck(Frog frog)
        {
            bool collided = false;

            foreach (MovingObject movingObj in GetList)
            {
                if (movingObj.State is AboveWaterState)
                {
                    if (SplashKit.BitmapCollision(movingObj.Bitmap, movingObj.Position, SplashKit.BitmapNamed("frog"), frog.Position))
                    {
                        collided = true;
                        frog.Stick(movingObj);
                        // if frog has half his body over the platforms edge, collision is set to false
                        collided &= frog.X + 25 >= movingObj.X && frog.X + 25 <= movingObj.X + movingObj.Width;
                    }
                }
            }
            // kills frog when frog is in the river and is not on a platform
            if (!collided && frog.Y.Equals(_y))
            {
                frog.Splash();
            }
        }