Beispiel #1
0
        public override void Collide(FroggerObject fo, Rectangle intersection)
        {
            if (fo is Frog )
            {
                if (intersection.Area() > 0.75f)
                    has_frog=true;

                if (is_locked && intersection.Area() > 0.25f)
                {

                    Rectangle locked = new Rectangle(0.0f, 1.0f, 1.0f, 1.0f);
                    locked += rect.loc;

                    if(Rectangle.Area(locked.Intersect(fo.rect))<Rectangle.Area(locked.Intersect(fo.rect + fo.delta)))
                    {
                        fo.delta *= 0.0f;
                        fo.Stop();
                    }

                }

            }
        }
Beispiel #2
0
        public override void Collide(FroggerObject fo, Rectangle intersection)
        {
            float common_area = intersection.Area() / fo.rect.Area();

            if (fo.level == Level.Walking && common_area > 0.75)
            {
                fo.MoveBy(this.delta);
            }
            else if (fo.level == Level.Floor && common_area > 0.1)
            {
                //w coś uderzyliśmy
                this.colision=true;
            }
        }
Beispiel #3
0
 public MovingFloor(FroggerBoard board, Rectangle r)
     : base(board, r)
 {
     this.level = Level.Floor;
 }
Beispiel #4
0
 public override void Collide(FroggerObject fo, Rectangle intersection)
 {
     if( fo is Frog && intersection.Area()/rect.Area() > 0.75)
     {
         this.Remove();
     }
 }
Beispiel #5
0
        public override void Collide(FroggerObject fo, Rectangle intersection)
        {
            if (fo is Frog && intersection.Area() > 0.50f)
            {
                had_frog = true;
                has_frog = true;
            }

            base.Collide(fo, intersection);
        }
Beispiel #6
0
 public override void Collide(FroggerObject fo, Rectangle intersection)
 {
     if(fo is Frog && intersection.Area()/fo.rect.Area() > 0.75)
     {
         this.board.Win();
     }
 }
Beispiel #7
0
        public override void Collide(FroggerObject fo, Rectangle intersection)
        {
            float intersection_area=intersection.Area()/rect.Area();

            if (fo.level==Level.Floor && !is_moving && intersection.Area() / rect.Area() > 0.50)
            {
                this.Location = fo.Location.Align(this.Location, 1.0f);
                is_moving = true;
            }

            if(fo.level==Level.Floor &&  intersection_area > 0.10)
            {
                this.floor_area+=intersection_area;
            }
        }
Beispiel #8
0
        /// <summary>
        /// oblicza iloczyn prostokątów
        /// jeżeli są rozłączne zwraca null
        /// </summary>
        /// <param name="r"></param>
        /// <returns></returns>
        public Rectangle Intersect(Rectangle r)
        {
            Rectangle i=new Rectangle();

            if(x<r.x)
            {
                i.x=x+w;
                i.w=i.x-r.x;

            }
            else
            {
                i.x=r.x+r.w;
                i.w=i.x-x;
            }

            if(y<r.y)
            {
                i.y=y+h;
                i.h=i.y-r.y;

            }
            else
            {
                i.y=r.y+r.h;
                i.h=i.y-y;
            }

            if(i.w <= 0.0f || i.h<=0.0f)
                return null;
            else
                return i;
        }
Beispiel #9
0
 /// <summary>
 /// zwraca pole powierzchni r
 /// jeżeli r jest nullem zraca 0.0f
 /// </summary>
 /// <param name="r">prostokąt</param>
 /// <returns>pole powierzchni r</returns>
 public static float Area(Rectangle r)
 {
     if (r == null)
         return 0.0f;
     else
         return r.Area();
 }