示例#1
0
 void CustomInitialize()
 {
     CombinedShapeCollection.InsertCollidables(A_BrickList);
     CombinedShapeCollection.InsertCollidables(Lucky_blockList);
     Camera.Main.Y = -120;
     Camera.Main.X = 140;
 }
        void OnMarioInstanceVsA_BrickListCollisionOccurred(Super_Marios_Bros.Entities.Mario first, Entities.A_Brick second)
        {
            Console.WriteLine("Collsion occured");
            bool wasPushedDown = first.AxisAlignedRectangleInstance.LastMoveCollisionReposition.Y < 0;

            if (wasPushedDown && PassonClass.mariobig)
            {
                Console.WriteLine("was pushed down true");
                bool hasDestroyedBlock = false;
                for (int i = 0; i < A_BrickList.Count; i++)
                {
                    //Console.WriteLine("New Brick");
                    if (A_BrickList[i].AxisAlignedRectangleInstance.CollideAgainst(first.CollisionThing))
                    {
                        // New code:
                        Console.WriteLine("Collided");
                        CombinedShapeCollection.RemoveRectangle(A_BrickList[i].AxisAlignedRectangleInstance);
                        A_BrickList[i].Imdead();
                        hasDestroyedBlock = true;
                        break;
                    }
                }
                if (!hasDestroyedBlock)
                {
                    // New code:
                    Console.WriteLine("The other way");

                    CombinedShapeCollection.RemoveRectangle(second.AxisAlignedRectangleInstance);

                    second.Imdead();
                }
            }
        }
        void OnMarioInstanceVsGumbaListAxisAlignedRectangleInstanceCollisionOccurred(Super_Marios_Bros.Entities.Mario first, Entities.Gumba second)
        {
            Console.WriteLine("Collsion occured");
            bool wasPushedDown     = first.AxisAlignedRectangleInstance.LastMoveCollisionReposition.Y > 0;
            bool hasDestroyedBlock = false;

            if (wasPushedDown)
            {
                for (int i = 0; i < GumbaList.Count; i++)
                {
                    if (GumbaList[i].AxisAlignedRectangleInstance.CollideAgainst(first.DieThing))
                    {
                        Console.WriteLine("Collided");
                        MarioInstance.Velocity.Y = 160;
                        CombinedShapeCollection.RemoveRectangle(A_BrickList[i].AxisAlignedRectangleInstance);
                        GumbaList[i].Deadgumba();
                        PassonClass.Score += 100;
                        hasDestroyedBlock  = true;
                        break;
                    }
                }
                if (!hasDestroyedBlock)
                {
                    // New code:
                    Console.WriteLine("The other way");
                    MarioInstance.Velocity.Y = 160;
                    second.Deadgumba();
                    PassonClass.Score += 100;
                }
            }
            else if (MarioInstance.AxisAlignedRectangleInstance.CollideAgainst(second.RightMarioDead) || MarioInstance.AxisAlignedRectangleInstance.CollideAgainst(second.LeftMarioDead))
            {
                second.Destroy();
                if (PassonClass.mariobig == true)
                {
                    PassonClass.mariobig = false;
                }
                else if (PassonClass.mariobig == false)
                {
                    HandleMarioDead();
                }
            }
        }