Example #1
0
        public void Collide(ICollidAble collider)
        {
            if (collider is WinTile)
            {
                Won = true;
                ChangeMovement(Movement.Idle);
            }
            else if (collider is MovementTile)
            {
                Point distance = new Point(collider.Boundingbox.Center.X - this.Boundingbox.Center.X, collider.Boundingbox.Center.Y - this.Boundingbox.Center.Y);
                if (distance.X < collider.Boundingbox.Width / 2 && distance.Y < collider.Boundingbox.Height / 2)
                {
                    ChangeMovement(collider.CurMovement);
                }
            }
            else
            {
                if (collider.CurMovement == Movement.Current)
                {
                    return;
                }

                ChangeMovement(collider.CurMovement);

                if (currentMovement == Movement.Dead)
                {
                    Tries++;
                }
            }
        }
Example #2
0
        public override void Update(GameTime dt)
        {
            if (player.Won)
            {
                backButton.Update(dt);
                return;
            }
            else if (paused)
            {
                // Game staat op pauze
                pauseBack.Update(dt);
            }
            else
            {
                foreach (object o in GameObjects)
                {
                    if (o is IUpdateAble)
                    {
                        (o as IUpdateAble).Update(dt);
                    }
                }

                foreach (object o in GameObjects)
                {
                    if (o is ICollidAble)
                    {
                        ICollidAble collideable = o as ICollidAble;

                        // Only check collision if the object is moving
                        if (collideable.Delta != Vector2.Zero)
                        {
                            foreach (object o2 in GameObjects)
                            {
                                // Check if it is not itself and the other one is an ICollidable
                                if (o2 is ICollidAble && o != o2)
                                {
                                    // Only the moving object should collide for now. like the player or an car
                                    if (collideable.Boundingbox.Intersects((o2 as ICollidAble).Boundingbox))
                                    {
                                        collideable.Collide(o2 as ICollidAble);
                                    }
                                }
                            }
                        }
                    }
                }

                if (player.CurMovement == Player.Movement.Dead)
                {
                    Reset();
                }

                // sort the items that need to be drawn with LINQ
                drawAbleItems = drawAbleItems.OrderBy(o => o.DrawIndex()).ToList();
            }

            pause.Update(dt);

            base.Update(dt);
        }
Example #3
0
 public void Collide(ICollidAble collider)
 {
     if (collider is ClickableObject)
     {
         // + because update substract this
         Position += Delta;
     }
     else if (collider is Player)
     {
         (collider as Player).ChangeMovement(Player.Movement.Dead);
     }
 }
Example #4
0
        public void Collide(ICollidAble collider)
        {
            if (collider is ClickableObject)
            {
                ClickableObject obj = collider as ClickableObject;

                if (obj.Info.texturePath.Contains("puddle") || obj.Info.texturePath.Contains("oil"))
                {
                    obj.ChangeMovement(Player.Movement.Current);
                    hidingObject = obj;
                }
            }
        }
Example #5
0
 public void Collide(ICollidAble collider)
 {
     // shouldn't be called
 }
Example #6
0
        public void Collide(ICollidAble collider)
        {
            if (collider is ClickableObject)
            {
                ClickableObject obj = collider as ClickableObject;

                if (obj.Info.texturePath.Contains("puddle") || obj.Info.texturePath.Contains("oil"))
                {
                    obj.ChangeMovement(Player.Movement.Current);
                    hidingObject = obj;
                }

            }
        }
Example #7
0
 public void Collide(ICollidAble collider)
 {
     // shouldn't be called. This won't move
 }
Example #8
0
 public void Collide(ICollidAble collider)
 {
     if (collider is ClickableObject)
     {
         // + because update substract this
         Position += Delta;
     }
     else if(collider is Player)
     {
         (collider as Player).ChangeMovement(Player.Movement.Dead);
     }
 }
 public void Collide(ICollidAble collider)
 {
     // Shouldn't be called because delta is zero
 }
Example #10
0
        public void Collide(ICollidAble collider)
        {
            if(collider is WinTile)
            {
                Won = true;
                ChangeMovement(Movement.Idle);
            }
            else if(collider is MovementTile)
            {
                Point distance = new Point(collider.Boundingbox.Center.X - this.Boundingbox.Center.X, collider.Boundingbox.Center.Y - this.Boundingbox.Center.Y);
                if (distance.X < collider.Boundingbox.Width / 2 && distance.Y < collider.Boundingbox.Height / 2)
                {
                    ChangeMovement(collider.CurMovement);
                }
            }
            else
            {
                if (collider.CurMovement == Movement.Current)
                    return;

                ChangeMovement(collider.CurMovement);

                if(currentMovement == Movement.Dead)
                {
                    Tries++;
                }
            }
        }
Example #11
0
 public void Collide(ICollidAble collider)
 {
     // shouldn't be called. This won't move
 }
 public void Collide(ICollidAble collider)
 {
     // Shouldn't be called because delta is zero
 }
Example #13
0
 public void Collide(ICollidAble collider)
 {
     // shouldn't be called
 }