Ejemplo n.º 1
0
 /// <summary>
 /// This metod defines what should happen on collision with banzaibill
 /// </summary>
 /// <param name="entity"></param>
 /// <param name="col"></param>
 public override void OnCollision(MovingGameObject entity, GameObject col)
 {
     if (entity is Mario)
     {
         if (entity.BoundingBox.Bottom <= this.BoundingBox.Top + size)
         {
             entity.SetOnGround(true);
             entity.forcedJump = true;
             entity.MakeMeNull();
         }
         else if (entity.BoundingBox.Left <= this.BoundingBox.Left || entity.BoundingBox.Right >= this.BoundingBox.Right || entity.BoundingBox.Top > this.BoundingBox.Bottom - size)
         {
             if (entity.Stage == 0)
             {
                 entity.Die();
                 entity.lostLife = true;
                 entity.UpdatePosition(1, 20);
             }
             else
             {
                 entity.Stage--;
             }
         }
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// The actions on collision between the entity and the colliding object col are excecuted here
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="col"></param>
        public override void OnCollision(MovingGameObject entity, GameObject col)
        {
            if (entity is Mario)
            {
                if (entity.BoundingBox.Bottom <= this.BoundingBox.Top + size)
                {
                    entity.SetOnGround(true);
                    entity.forcedJump = true;
                    if (this.Stage == 0)
                    {
                        RightTexture = ShellTexture;
                        LeftTexture  = ShellTexture;
                        Stage        = 1;
                        Position.Y++;
                        Columns = 4;
                    }
                    // KoopaShell shell = new KoopaShell(col.ObjectTexture, (int)Position.X, (int)Position.Y - 1);
                    //level[(int)shell.Position.X, (int)shell.Position.Y] = shell;
                    else
                    {
                        moving = !moving;
                        //entity.DoIllegalStuff(null);
                    }
                }
                else if (entity.BoundingBox.Left <= this.BoundingBox.Left)
                {
                    if (Stage == 0 || moving)
                    {
                        if (entity.Stage == 0)
                        {
                            entity.Die();
                            entity.lostLife = true;
                            entity.UpdatePosition(1, 20);
                        }
                        else
                        {
                            entity.Stage--;
                        }
                    }
                    else
                    {
                        movementDirection = false;
                        moving            = true;
                    }
                }
                else if (entity.BoundingBox.Right >= this.BoundingBox.Right)
                {
                    if (Stage == 0 || moving)
                    {
                        if (entity.Stage == 0)
                        {
                            entity.Die();
                            entity.lostLife = true;
                            entity.UpdatePosition(1, 20);
                        }
                        else
                        {
                            entity.Stage--;
                        }
                    }
                    else
                    {
                        movementDirection = true;
                        moving            = true;
                    }
                }
            }
            else if (entity is Koopa)
            {
                if (entity.Stage == 1 && entity.moving)
                {
                    if (entity.BoundingBox.Bottom <= this.BoundingBox.Top + size)
                    {
                        entity.SetOnGround(true);
                        entity.UpdatePositionY(entity.BoundingBox.Top / 16);
                    }
                    else if (entity.BoundingBox.Right <= this.BoundingBox.Left + size)
                    {
                        entity.MakeMeNull();
                    }
                    else if (entity.BoundingBox.Left >= this.BoundingBox.Right - size)
                    {
                        entity.MakeMeNull();
                    }
                }
                else
                {
                    if (entity.BoundingBox.Bottom <= this.BoundingBox.Top + size)
                    {
                        entity.SetOnGround(true);
                        entity.UpdatePositionY(entity.BoundingBox.Top / 16);
                    }

                    else if (entity.BoundingBox.Right <= this.BoundingBox.Left + size)
                    {
                        entity.movementDirection = true;
                    }
                    else if (entity.BoundingBox.Left >= this.BoundingBox.Right - size)
                    {
                        entity.movementDirection = false;
                    }
                }
            }
        }