public override void Initialize(bool addToManagers)
        {
            LoadStaticContent(ContentManagerName);
            // Not instantiating for FlatRedBall.TileGraphics.LayeredTileMap Map in Screens\GameScreen (Screen) because properties on the object prevent it
            // Not instantiating for FlatRedBall.TileCollisions.TileShapeCollection SolidCollision in Screens\GameScreen (Screen) because properties on the object prevent it
            // Not instantiating for FlatRedBall.TileCollisions.TileShapeCollection CloudCollision in Screens\GameScreen (Screen) because properties on the object prevent it
            A_BrickList                      = new FlatRedBall.Math.PositionedObjectList <Super_Marios_Bros.Entities.A_Brick>();
            A_BrickList.Name                 = "A_BrickList";
            MarioInstance                    = new Super_Marios_Bros.Entities.Mario(ContentManagerName, false);
            MarioInstance.Name               = "MarioInstance";
            Lucky_blockList                  = new FlatRedBall.Math.PositionedObjectList <Super_Marios_Bros.Entities.Lucky_block>();
            Lucky_blockList.Name             = "Lucky_blockList";
            GumbaList                        = new FlatRedBall.Math.PositionedObjectList <Super_Marios_Bros.Entities.Gumba>();
            GumbaList.Name                   = "GumbaList";
            A_Brick_being_destroyedList      = new FlatRedBall.Math.PositionedObjectList <Super_Marios_Bros.Entities.A_Brick_being_destroyed>();
            A_Brick_being_destroyedList.Name = "A_Brick_being_destroyedList";
            CombinedShapeCollection          = new FlatRedBall.TileCollisions.TileShapeCollection();
            MushroomList                     = new FlatRedBall.Math.PositionedObjectList <Super_Marios_Bros.Entities.Mushroom>();
            MushroomList.Name                = "MushroomList";
            TurtleList                       = new FlatRedBall.Math.PositionedObjectList <Super_Marios_Bros.Entities.Turtle>();
            TurtleList.Name                  = "TurtleList";
            DeadMarioInstance                = new Super_Marios_Bros.Entities.DeadMario(ContentManagerName, false);
            DeadMarioInstance.Name           = "DeadMarioInstance";
            CoinList      = new FlatRedBall.Math.PositionedObjectList <Super_Marios_Bros.Entities.Coin>();
            CoinList.Name = "CoinList";
            MarioInstanceVsGumbaListAxisAlignedRectangleInstance = FlatRedBall.Math.Collision.CollisionManager.Self.CreateRelationship(MarioInstance, GumbaList);
            MarioInstanceVsGumbaListAxisAlignedRectangleInstance.SetSecondSubCollision(item => item.AxisAlignedRectangleInstance);
            MarioInstanceVsGumbaListAxisAlignedRectangleInstance.Name = "MarioInstanceVsGumbaListAxisAlignedRectangleInstance";
            MarioInstanceVsGumbaListAxisAlignedRectangleInstance.SetMoveCollision(1f, 1f);

            {
                var temp    = new FlatRedBall.Math.Collision.DelegateCollisionRelationship <Super_Marios_Bros.Entities.Mario, FlatRedBall.TileCollisions.TileShapeCollection>(MarioInstance, SolidCollision);
                var isCloud = false;
                temp.CollisionFunction = (first, second) =>
                {
                    return(first.CollideAgainst(second, isCloud));
                }
                ;
                FlatRedBall.Math.Collision.CollisionManager.Self.Relationships.Add(temp);
                MarioInstanceVsSolidCollision = temp;
            }
            MarioInstanceVsSolidCollision.Name = "MarioInstanceVsSolidCollision";

            {
                var temp    = new FlatRedBall.Math.Collision.DelegateSingleVsListRelationship <Super_Marios_Bros.Entities.Mario, Entities.Lucky_block>(MarioInstance, Lucky_blockList);
                var isCloud = false;
                temp.CollisionFunction = (first, second) =>
                {
                    return(first.CollideAgainst(second, isCloud));
                }
                ;
                FlatRedBall.Math.Collision.CollisionManager.Self.Relationships.Add(temp);
                MarioInstanceVsLucky_blockList = temp;
            }
            MarioInstanceVsLucky_blockList.Name = "MarioInstanceVsLucky_blockList";

            GumbaListAxisAlignedRectangleInstanceVsSolidCollision = FlatRedBall.Math.Collision.CollisionManagerTileShapeCollectionExtensions.CreateTileRelationship(FlatRedBall.Math.Collision.CollisionManager.Self, GumbaList, SolidCollision);
            GumbaListAxisAlignedRectangleInstanceVsSolidCollision.SetFirstSubCollision(item => item.AxisAlignedRectangleInstance);
            GumbaListAxisAlignedRectangleInstanceVsSolidCollision.Name = "GumbaListAxisAlignedRectangleInstanceVsSolidCollision";
            GumbaListAxisAlignedRectangleInstanceVsSolidCollision.SetMoveCollision(0f, 1f);

            {
                var temp    = new FlatRedBall.Math.Collision.DelegateSingleVsListRelationship <Super_Marios_Bros.Entities.Mario, Entities.A_Brick>(MarioInstance, A_BrickList);
                var isCloud = false;
                temp.CollisionFunction = (first, second) =>
                {
                    return(first.CollideAgainst(second, isCloud));
                }
                ;
                FlatRedBall.Math.Collision.CollisionManager.Self.Relationships.Add(temp);
                MarioInstanceVsA_BrickList = temp;
            }
            MarioInstanceVsA_BrickList.Name = "MarioInstanceVsA_BrickList";

            MarioInstanceAxisAlignedRectangleInstanceVsGumbaListLeftMarioDead = FlatRedBall.Math.Collision.CollisionManager.Self.CreateRelationship(MarioInstance, GumbaList);
            MarioInstanceAxisAlignedRectangleInstanceVsGumbaListLeftMarioDead.SetFirstSubCollision(item => item.AxisAlignedRectangleInstance);
            MarioInstanceAxisAlignedRectangleInstanceVsGumbaListLeftMarioDead.SetSecondSubCollision(item => item.LeftMarioDead);
            MarioInstanceAxisAlignedRectangleInstanceVsGumbaListLeftMarioDead.Name = "MarioInstanceAxisAlignedRectangleInstanceVsGumbaListLeftMarioDead";

            MarioInstanceAxisAlignedRectangleInstanceVsGumbaListRightMarioDead = FlatRedBall.Math.Collision.CollisionManager.Self.CreateRelationship(MarioInstance, GumbaList);
            MarioInstanceAxisAlignedRectangleInstanceVsGumbaListRightMarioDead.SetFirstSubCollision(item => item.AxisAlignedRectangleInstance);
            MarioInstanceAxisAlignedRectangleInstanceVsGumbaListRightMarioDead.SetSecondSubCollision(item => item.RightMarioDead);
            MarioInstanceAxisAlignedRectangleInstanceVsGumbaListRightMarioDead.Name = "MarioInstanceAxisAlignedRectangleInstanceVsGumbaListRightMarioDead";

            MarioInstanceAxisAlignedRectangleInstanceVsMushroomListAxisAlignedRectangleInstance = FlatRedBall.Math.Collision.CollisionManager.Self.CreateRelationship(MarioInstance, MushroomList);
            MarioInstanceAxisAlignedRectangleInstanceVsMushroomListAxisAlignedRectangleInstance.SetFirstSubCollision(item => item.AxisAlignedRectangleInstance);
            MarioInstanceAxisAlignedRectangleInstanceVsMushroomListAxisAlignedRectangleInstance.SetSecondSubCollision(item => item.AxisAlignedRectangleInstance);
            MarioInstanceAxisAlignedRectangleInstanceVsMushroomListAxisAlignedRectangleInstance.Name = "MarioInstanceAxisAlignedRectangleInstanceVsMushroomListAxisAlignedRectangleInstance";
            MarioInstanceAxisAlignedRectangleInstanceVsMushroomListAxisAlignedRectangleInstance.SetMoveCollision(1f, 1f);

            {
                var temp    = new FlatRedBall.Math.Collision.DelegateListVsSingleRelationship <Entities.Mushroom, FlatRedBall.TileCollisions.TileShapeCollection>(MushroomList, SolidCollision);
                var isCloud = false;
                temp.CollisionFunction = (first, second) =>
                {
                    return(first.CollideAgainst(second, isCloud));
                }
                ;
                FlatRedBall.Math.Collision.CollisionManager.Self.Relationships.Add(temp);
                MushroomListVsSolidCollision = temp;
            }
            MushroomListVsSolidCollision.Name = "MushroomListVsSolidCollision";

            {
                var temp    = new FlatRedBall.Math.Collision.DelegateListVsListRelationship <Entities.Mushroom, Entities.A_Brick>(MushroomList, A_BrickList);
                var isCloud = false;
                temp.CollisionFunction = (first, second) =>
                {
                    return(first.CollideAgainst(second, isCloud));
                }
                ;
                FlatRedBall.Math.Collision.CollisionManager.Self.Relationships.Add(temp);
                MushroomListVsA_BrickList = temp;
            }
            MushroomListVsA_BrickList.CollisionLimit = FlatRedBall.Math.Collision.CollisionLimit.All;
            MushroomListVsA_BrickList.Name           = "MushroomListVsA_BrickList";

            {
                var temp    = new FlatRedBall.Math.Collision.DelegateListVsListRelationship <Entities.Mushroom, Entities.Lucky_block>(MushroomList, Lucky_blockList);
                var isCloud = false;
                temp.CollisionFunction = (first, second) =>
                {
                    return(first.CollideAgainst(second, isCloud));
                }
                ;
                FlatRedBall.Math.Collision.CollisionManager.Self.Relationships.Add(temp);
                MushroomListVsLucky_blockList = temp;
            }
            MushroomListVsLucky_blockList.CollisionLimit = FlatRedBall.Math.Collision.CollisionLimit.All;
            MushroomListVsLucky_blockList.Name           = "MushroomListVsLucky_blockList";

            {
                var temp    = new FlatRedBall.Math.Collision.DelegateListVsSingleRelationship <Entities.Turtle, FlatRedBall.TileCollisions.TileShapeCollection>(TurtleList, SolidCollision);
                var isCloud = false;
                temp.CollisionFunction = (first, second) =>
                {
                    return(first.CollideAgainst(second, first.AxisAlignedRectangleInstance, isCloud));
                }
                ;
                FlatRedBall.Math.Collision.CollisionManager.Self.Relationships.Add(temp);
                TurtleListAxisAlignedRectangleInstanceVsSolidCollision = temp;
            }
            TurtleListAxisAlignedRectangleInstanceVsSolidCollision.Name = "TurtleListAxisAlignedRectangleInstanceVsSolidCollision";

            {
                var temp    = new FlatRedBall.Math.Collision.DelegateListVsListRelationship <Entities.Gumba, Entities.Turtle>(GumbaList, TurtleList);
                var isCloud = false;
                temp.CollisionFunction = (first, second) =>
                {
                    return(first.CollideAgainst(second, isCloud));
                }
                ;
                FlatRedBall.Math.Collision.CollisionManager.Self.Relationships.Add(temp);
                GumbaListVsTurtleList = temp;
            }
            GumbaListVsTurtleList.CollisionLimit = FlatRedBall.Math.Collision.CollisionLimit.All;
            GumbaListVsTurtleList.Name           = "GumbaListVsTurtleList";

            MarioInstanceAxisAlignedRectangleInstanceVsTurtleListAxisAlignedRectangleInstance = FlatRedBall.Math.Collision.CollisionManager.Self.CreateRelationship(MarioInstance, TurtleList);
            MarioInstanceAxisAlignedRectangleInstanceVsTurtleListAxisAlignedRectangleInstance.SetFirstSubCollision(item => item.AxisAlignedRectangleInstance);
            MarioInstanceAxisAlignedRectangleInstanceVsTurtleListAxisAlignedRectangleInstance.SetSecondSubCollision(item => item.AxisAlignedRectangleInstance);
            MarioInstanceAxisAlignedRectangleInstanceVsTurtleListAxisAlignedRectangleInstance.Name = "MarioInstanceAxisAlignedRectangleInstanceVsTurtleListAxisAlignedRectangleInstance";
            MarioInstanceAxisAlignedRectangleInstanceVsTurtleListAxisAlignedRectangleInstance.SetMoveCollision(0f, 1f);

            {
                var temp    = new FlatRedBall.Math.Collision.DelegateListVsSingleRelationship <Entities.Turtle, FlatRedBall.TileCollisions.TileShapeCollection>(TurtleList, CombinedShapeCollection);
                var isCloud = false;
                temp.CollisionFunction = (first, second) =>
                {
                    return(first.CollideAgainst(second, first.AxisAlignedRectangleInstance, isCloud));
                }
                ;
                FlatRedBall.Math.Collision.CollisionManager.Self.Relationships.Add(temp);
                TurtleListAxisAlignedRectangleInstanceVsCombinedShapeCollection = temp;
            }
            TurtleListAxisAlignedRectangleInstanceVsCombinedShapeCollection.Name = "TurtleListAxisAlignedRectangleInstanceVsCombinedShapeCollection";

            MarioInstanceVsCoinList      = FlatRedBall.Math.Collision.CollisionManager.Self.CreateRelationship(MarioInstance, CoinList);
            MarioInstanceVsCoinList.Name = "MarioInstanceVsCoinList";

            Forms = new Super_Marios_Bros.FormsControls.Screens.Mario_Main_GUIForms(Mario_Main_GUI);
            // normally we wait to set variables until after the object is created, but in this case if the
            // TileShapeCollection doesn't have its Visible set before creating the tiles, it can result in
            // really bad performance issues, as shapes will be made visible, then invisible. Really bad perf!
            if (SolidCollision != null)
            {
                SolidCollision.Visible = false;
            }
            FlatRedBall.TileCollisions.TileShapeCollectionLayeredTileMapExtensions.AddCollisionFromTilesWithType(SolidCollision, Map, "SolidCollision", false);
            // normally we wait to set variables until after the object is created, but in this case if the
            // TileShapeCollection doesn't have its Visible set before creating the tiles, it can result in
            // really bad performance issues, as shapes will be made visible, then invisible. Really bad perf!
            if (CloudCollision != null)
            {
                CloudCollision.Visible = false;
            }
            FlatRedBall.TileCollisions.TileShapeCollectionLayeredTileMapExtensions.AddCollisionFromTilesWithType(CloudCollision, Map, "CloudCollision", false);
            // normally we wait to set variables until after the object is created, but in this case if the
            // TileShapeCollection doesn't have its Visible set before creating the tiles, it can result in
            // really bad performance issues, as shapes will be made visible, then invisible. Really bad perf!
            if (CombinedShapeCollection != null)
            {
                CombinedShapeCollection.Visible = false;
            }


            PostInitialize();
            base.Initialize(addToManagers);
            if (addToManagers)
            {
                AddToManagers();
            }
        }
Example #2
0
        public override void Initialize(bool addToManagers)
        {
            LoadStaticContent(ContentManagerName);
            SolidCollision      = new FlatRedBall.TileCollisions.TileShapeCollection();
            PlayerInstance      = new Soccer.Entities.Player(ContentManagerName, false);
            PlayerInstance.Name = "PlayerInstance";
            {
                var temp    = new FlatRedBall.Math.Collision.DelegateCollisionRelationship <Soccer.Entities.Player, FlatRedBall.TileCollisions.TileShapeCollection>(PlayerInstance, SolidCollision);
                var isCloud = false;
                temp.CollisionFunction = (first, second) =>
                {
                    return(first.CollideAgainst(second, first.AxisAlignedRectangleInstance, isCloud));
                }
                ;
                FlatRedBall.Math.Collision.CollisionManager.Self.Relationships.Add(temp);
                PlayerInstanceAxisAlignedRectangleInstanceVsSolidCollision = temp;
            }
            PlayerInstanceAxisAlignedRectangleInstanceVsSolidCollision.Name = "PlayerInstanceAxisAlignedRectangleInstanceVsSolidCollision";

            // Not instantiating for LayeredTileMap Map in Screens\GameScreen (Screen) because properties on the object prevent it
            BallList      = new FlatRedBall.Math.PositionedObjectList <Soccer.Entities.Ball>();
            BallList.Name = "BallList";
            BallListVsPlayerInstanceAxisAlignedRectangleInstance = FlatRedBall.Math.Collision.CollisionManager.Self.CreateRelationship(BallList, PlayerInstance);
            BallListVsPlayerInstanceAxisAlignedRectangleInstance.SetSecondSubCollision(item => item.AxisAlignedRectangleInstance);
            BallListVsPlayerInstanceAxisAlignedRectangleInstance.Name = "BallListVsPlayerInstanceAxisAlignedRectangleInstance";
            BallListVsPlayerInstanceAxisAlignedRectangleInstance.SetBounceCollision(0f, 1f, 0.5f);

            BallListVsSolidCollision      = FlatRedBall.Math.Collision.CollisionManagerTileShapeCollectionExtensions.CreateTileRelationship(FlatRedBall.Math.Collision.CollisionManager.Self, BallList, SolidCollision);
            BallListVsSolidCollision.Name = "BallListVsSolidCollision";
            BallListVsSolidCollision.SetBounceCollision(0f, 1f, 0.8f);

            GoalCollision = new FlatRedBall.TileCollisions.TileShapeCollection();
            {
                var temp    = new FlatRedBall.Math.Collision.DelegateCollisionRelationship <Soccer.Entities.Player, FlatRedBall.TileCollisions.TileShapeCollection>(PlayerInstance, GoalCollision);
                var isCloud = false;
                temp.CollisionFunction = (first, second) =>
                {
                    return(first.CollideAgainst(second, first.AxisAlignedRectangleInstance, isCloud));
                }
                ;
                FlatRedBall.Math.Collision.CollisionManager.Self.Relationships.Add(temp);
                PlayerInstanceAxisAlignedRectangleInstanceVsGoalCollision = temp;
            }
            PlayerInstanceAxisAlignedRectangleInstanceVsGoalCollision.Name = "PlayerInstanceAxisAlignedRectangleInstanceVsGoalCollision";

            BallListCollisionCircleVsGoalCollision = FlatRedBall.Math.Collision.CollisionManagerTileShapeCollectionExtensions.CreateTileRelationship(FlatRedBall.Math.Collision.CollisionManager.Self, BallList, GoalCollision);
            BallListCollisionCircleVsGoalCollision.SetFirstSubCollision(item => item.CollisionCircle);
            BallListCollisionCircleVsGoalCollision.Name = "BallListCollisionCircleVsGoalCollision";

            GoalDisplay      = new FlatRedBall.Sprite();
            GoalDisplay.Name = "GoalDisplay";
            PlayerInstanceBallCatchAreaVsBallListCollisionCircle = FlatRedBall.Math.Collision.CollisionManager.Self.CreateRelationship(PlayerInstance, BallList);
            PlayerInstanceBallCatchAreaVsBallListCollisionCircle.SetFirstSubCollision(item => item.BallCatchArea);
            PlayerInstanceBallCatchAreaVsBallListCollisionCircle.SetSecondSubCollision(item => item.CollisionCircle);
            PlayerInstanceBallCatchAreaVsBallListCollisionCircle.Name = "PlayerInstanceBallCatchAreaVsBallListCollisionCircle";

            UpSpringCollision = new FlatRedBall.TileCollisions.TileShapeCollection();
            PlayerInstanceAxisAlignedRectangleInstanceVsUpSpringCollision = FlatRedBall.Math.Collision.CollisionManagerTileShapeCollectionExtensions.CreateTileRelationship(FlatRedBall.Math.Collision.CollisionManager.Self, PlayerInstance, UpSpringCollision);
            PlayerInstanceAxisAlignedRectangleInstanceVsUpSpringCollision.SetFirstSubCollision(item => item.AxisAlignedRectangleInstance);
            PlayerInstanceAxisAlignedRectangleInstanceVsUpSpringCollision.Name = "PlayerInstanceAxisAlignedRectangleInstanceVsUpSpringCollision";

            BallListCollisionCircleVsUpSpringCollision = FlatRedBall.Math.Collision.CollisionManagerTileShapeCollectionExtensions.CreateTileRelationship(FlatRedBall.Math.Collision.CollisionManager.Self, BallList, UpSpringCollision);
            BallListCollisionCircleVsUpSpringCollision.SetFirstSubCollision(item => item.CollisionCircle);
            BallListCollisionCircleVsUpSpringCollision.Name = "BallListCollisionCircleVsUpSpringCollision";

            // normally we wait to set variables until after the object is created, but in this case if the
            // TileShapeCollection doesn't have its Visible set before creating the tiles, it can result in
            // really bad performance issues, as shapes will be made visible, then invisible. Really bad perf!
            if (SolidCollision != null)
            {
                SolidCollision.Visible = false;
            }
            FlatRedBall.TileCollisions.TileShapeCollectionLayeredTileMapExtensions.AddCollisionFromTilesWithType(SolidCollision, Map, "Solid");
            // normally we wait to set variables until after the object is created, but in this case if the
            // TileShapeCollection doesn't have its Visible set before creating the tiles, it can result in
            // really bad performance issues, as shapes will be made visible, then invisible. Really bad perf!
            if (GoalCollision != null)
            {
                GoalCollision.Visible = false;
            }
            FlatRedBall.TileCollisions.TileShapeCollectionLayeredTileMapExtensions.AddCollisionFromTilesWithType(GoalCollision, Map, "Goal");
            // normally we wait to set variables until after the object is created, but in this case if the
            // TileShapeCollection doesn't have its Visible set before creating the tiles, it can result in
            // really bad performance issues, as shapes will be made visible, then invisible. Really bad perf!
            if (UpSpringCollision != null)
            {
                UpSpringCollision.Visible = false;
            }
            FlatRedBall.TileCollisions.TileShapeCollectionLayeredTileMapExtensions.AddCollisionFromTilesWithType(UpSpringCollision, Map, "Spring");


            PostInitialize();
            base.Initialize(addToManagers);
            if (addToManagers)
            {
                AddToManagers();
            }
        }