Beispiel #1
0
 /// <summary>
 /// If the entity colliding with the finish is mario, set touched to true
 /// </summary>
 /// <param name="entity"></param>
 /// <param name="col"></param>
 public override void OnCollision(MovingGameObject entity, GameObject col)
 {
     if (entity is Mario)
     {
         touched = true;
     }
 }
Beispiel #2
0
 /// <summary>
 /// On collision between a moving game object and a game object it sets a variable in mario to null
 /// </summary>
 /// <param name="mario"></param>
 /// <param name="col"></param>
 public override void OnCollision(MovingGameObject entity, GameObject col)
 {
     if (entity is Mario)
     {
         entity.MakeMeNull();
     }
 }
 /// <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--;
             }
         }
     }
 }
Beispiel #4
0
 /// <summary>
 /// Changes the state of mario if mario picks up a powerup
 /// </summary>
 /// <param name="entity"></param>
 /// <param name="col"></param>
 public override void OnCollision(MovingGameObject entity, GameObject col)
 {
     if (entity is Mario)
     {
         entity.Stage       = this.powerUpStage;
         entity.Position.Y -= 1;
         entity.MakeMeNull();
     }
 }
Beispiel #5
0
        /// <summary>
        /// the specific actions tile performs on collision
        /// </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);

                    if (entity.Stage == 0)
                    {
                        //entity.BoundingBox.Top/16 werkt niet omdat de mario sprite niet uit 16*16 vakjes bestaat
                        entity.UpdatePositionY(BoundingBox.Top / size - entity.ObjectTexture.Height / size);
                    }
                    else
                    {
                        entity.UpdatePositionY(BoundingBox.Top / size - entity.ObjectTexture.Height / size - 0.5f);
                    }
                }
                else if (entity.BoundingBox.Right <= this.BoundingBox.Left + size)
                {
                    if (entity.Stage == 0)
                    {
                        entity.UpdatePositionX(BoundingBox.Left / size - entity.ObjectTexture.Width / size);
                    }
                    else
                    {
                        entity.UpdatePositionX(BoundingBox.Left / size - (entity.ObjectTexture.Width - 16) / size);
                    }
                }
                else if (entity.BoundingBox.Left >= this.BoundingBox.Right - size)
                {
                    entity.UpdatePositionX(BoundingBox.Right / size);
                }
                else if (entity.BoundingBox.Top <= this.BoundingBox.Bottom - size)
                {
                    entity.UpdatePositionY(BoundingBox.Bottom / size);
                }
            }
            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;
                }
            }
        }
Beispiel #6
0
 /// <summary>
 /// Mario currently does nothing on collision
 /// </summary>
 /// <param name="mario"></param>
 /// <param name="col"></param>
 public override void OnCollision(MovingGameObject mario, GameObject col)
 {
 }
Beispiel #7
0
 /// <summary>
 /// This is a specific OnCollision action that is mainly used to change the specified gameobject in the level array to eiter a different object or to null.
 /// </summary>
 /// <param name="mario"></param>
 /// <param name="col"></param>
 /// <param name="level"></param>
 public virtual void OnCollision(MovingGameObject mario, GameObject col, GameObject[,] level)
 {
 }
Beispiel #8
0
 /// <summary>
 /// The OnCollision method of a gameobject specifies the actions that should happen on a collision with another object
 /// </summary>
 /// <param name="obj"></param>
 public abstract void OnCollision(MovingGameObject mario, GameObject col);
Beispiel #9
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;
                    }
                }
            }
        }
        /// <summary>
        /// Decides what action should happen based on the form of the collision
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="col"></param>
        /// <param name="level"></param>
        public override void OnCollision(MovingGameObject entity, GameObject col, GameObject[,] level)
        {
            if (entity is Mario)
            {
                if (entity.BoundingBox.Bottom <= this.BoundingBox.Top + size)
                {
                    entity.SetOnGround(true);
                    if (entity.Stage == 0)
                    {
                        entity.UpdatePositionY(BoundingBox.Top / size - entity.ObjectTexture.Height / size);
                    }
                    else
                    {
                        entity.UpdatePositionY(BoundingBox.Top / size - entity.ObjectTexture.Height / size - 0.5f);
                    }
                }
                else if (entity.BoundingBox.Top > this.BoundingBox.Bottom - size)
                {
                    entity.UpdatePositionY(BoundingBox.Bottom / size + 1);
                    if (_enabled == true)
                    {
                        PowerUp item = new PowerUp(MushroomTexture, FlowerTexture, (int)Position.X, (int)Position.Y - 1, entity.Stage + 1);

                        level[(int)item.Position.X - 1, (int)item.Position.Y - 1] = item;
                        _enabled = false;

                        ObjectTexture = usedMysteryBlocktexture;
                        totalFrames   = 0;
                        Columns       = 1;
                    }
                }
                else if (entity.BoundingBox.Left <= this.BoundingBox.Left)
                {
                    entity.UpdatePositionX(BoundingBox.Left / size - entity.ObjectTexture.Width / size);
                }
                else if (entity.BoundingBox.Right >= this.BoundingBox.Right)
                {
                    entity.UpdatePositionX(BoundingBox.Right / size);
                }
            }

            else if (entity is PowerUp)
            {
                if (entity.BoundingBox.Bottom <= this.BoundingBox.Top + size)
                {
                    entity.SetOnGround(true);
                    entity.UpdatePositionY(entity.BoundingBox.Top / 16);
                }
            }
            else if (entity is Koopa)
            {
                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;
                }
            }
        }