public void HandleCollision(CollisionDetector.Collision collision, Level1 level)
        {
            PlayerContext player = null;

            if (collision.entity1 is PlayerContext)
            {
                player = (PlayerContext)collision.entity1;
            }
            else if (collision.entity2 is PlayerContext)
            {
                player = (PlayerContext)collision.entity2;
            }


            CollisionDetector.CollisionSide side = collision.GetSide();

            if (collision.entity2 is GreenKoopaSprite || collision.entity2 is RedKoopaSprite || collision.entity2 is RedGoombaSprite)
            {
                if (side == CollisionDetector.CollisionSide.Bottom)
                {
                    side = CollisionDetector.CollisionSide.Top;
                    level.Remove(collision.entity2);
                    //make this damage them instead of remove
                }
            }
            else if (side == CollisionDetector.CollisionSide.Top)
            {
                level.Remove(collision.entity1);
            }
        }
Beispiel #2
0
    //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    //                                                                                                                        GameOver()
    //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    public void GameOver()
    {
        if (level1IsActive == true)
        {
            _level1.Destroy();
            _level1.Remove();
        }

        if (level2IsActive == true)
        {
            _level2.Destroy();
            _level2.Remove();
        }

        if (Globals.levelBossIsActive == true)
        {
            _levelBoss.Destroy();
            _levelBoss.Remove();
        }

        stopMusic();

        _gameover = new GameOver();
        AddChild(_gameover);
    }
 public void HandleCollision(CollisionDetector.Collision collision, Level1 level)
 {
     if (collision.entity1 is PlayerContext)
     {
         level.Remove(collision.entity2);
     }
     else if (collision.entity2 is PlayerContext)
     {
         level.Remove(collision.entity1);
     }
 }