Ejemplo n.º 1
0
        void ReloadLevel()
        {
            if (scene != null)
            {
                SetLevelState();

                scene.UnloadContent();
                withChicks.UnloadContent();
            }
            //if (blank != null)
            {
                blank = null;
                LowerFlag(Jabber.Flags.FADE_OUT);
            }
            IsQuitting = false;
            Components.Clear();

            world = new FarWorld();
            world.Initialize(new Vector2(0, -15.0f));
            world.SimulationSpeedFactor = 1.0f;

            withChicks = new ChicksScene(this, world, Content);
            withChicks.DoWorldUpdateDraw = false;
            // withChicks.AddNode(cannon);

            scene = new ThisGamesScene(this, world, withChicks, Content);
            scene.DoWorldUpdateDraw = false;

            scene.AddTextureLoadInterceptor("textures\\Physical\\wood", "break", "break_frames", "wood");
            scene.AddTextureLoadInterceptor("textures\\Physical\\cement", "break", "break_frames", "cement");
            scene.AddTextureLoadInterceptor("textures\\Physical\\glass", "break", "break_frames", "glass");


            scene.AddTextureLoadInterceptor("textures\\Backgrounds\\Bavaria\\cowright", "textures/backgrounds/bavaria/bavaria", "textures/backgrounds/bavaria/bavaria_frames", "cowleft");
            scene.AddTextureLoadInterceptor("textures\\Backgrounds\\Bavaria\\cowleft", "textures/backgrounds/bavaria/bavaria", "textures/backgrounds/bavaria/bavaria_frames", "cowright");

            LevelDir = "Content/Levels/" + location + "/Level" + levelNum + ".xml";
            scene.LoadGScene(LevelDir);

            withChicks.startPos = scene.startPos;


            ChickenDrawer chickdrawer = new ChickenDrawer(withChicks, scene);

            chickdrawer.Initialize(Content);
            scene.AddNode(chickdrawer);

            ChickenBience bience = new ChickenBience(this);

            bience.Initialize(Content);
            bience.Position = scene.startPos;
            scene.AddNode(bience);

            cannon          = new Cannon(this);
            cannon.Position = scene.startPos;
            cannon.Initialize(Content);
            scene.AddNode(cannon);
            //scene.AddNode(cannon);


            if (withChicks.GetRightMaxPos() > scene.GetRightMaxPos())
            {
                rightMostPos = withChicks.GetRightMaxPos() + 200.0f;
            }
            else
            {
                rightMostPos = scene.GetRightMaxPos() + 200.0f;
            }


            leftMostPos = scene.startPos.X - 500;
            /// rightMostPos = 10000000;
            world.SetCollisionForAll(Fox.FOX_NONE_COLLISION_GROUP, false);
            world.SetCollisionForAll(BreakableBody.BodyNoneCollisionGroup, false);

            string country = scene.countryName;

            //scene.ToFire.Clear();
            if (scene.ToFire.Count == 0)
            {
                for (int i = 0; i < 4; i++)
                {
                    scene.ToFire.Add(0);
                }
            }
            //GameScene worldLoc = new GameScene(world, Content);
            //WorldLocation.CreateVesuvius(scene, (int)leftMostPos, (int)rightMostPos);

            // WorldLocation.CreatePolar(scene, (int)leftMostPos, (int)rightMostPos);

            switch (scene.countryName)
            {
            case "bavaria":
                WorldLocation.CreateBavaria(scene, (int)leftMostPos, (int)rightMostPos);
                break;

            case "paris":
                WorldLocation.CreateParis(scene, (int)leftMostPos, (int)rightMostPos);
                break;

            case "australia":
                WorldLocation.CreateAustralia(scene, (int)leftMostPos, (int)rightMostPos);
                break;

            case "polar":
                WorldLocation.CreatePolar(scene, (int)leftMostPos, (int)rightMostPos);
                break;

            case "vesuvius":
                WorldLocation.CreateVesuvius(scene, (int)leftMostPos, (int)rightMostPos);
                break;
            }

            feathers.RaiseFlag(Jabber.Flags.FADE_OUT);
            Components.Add(scene);
            Components.Add(withChicks);


            MenuObj pause = new Button("ui/ui");

            pause.Initialize(Content);
            pause.Name = "pause";
            pause.CreateFramesFromXML("ui/ui_frames");
            pause.CurrentFrame = "pause";
            pause.ResetDimensions();
            pause.UniformScale             = ScaleFactor;
            (pause as Button).RegularScale = ScaleFactor;
            (pause as Button).ScaleOnHover = (pause as Button).RegularScale * 1.4f;
            pause.PosX = -Jabber.BaseGame.Get.BackBufferWidth / 2.0f + pause.Width * pause.ScaleX;
            pause.PosY = Jabber.BaseGame.Get.BackBufferHeight / 2.0f - pause.Height * pause.ScaleY;
            Components.Add(pause);


            forceEndGame = new Button("ui/ui");
            forceEndGame.Initialize(Content);
            forceEndGame.UniformScale = 0.001f;
            forceEndGame.Name         = "forceendgame";
            forceEndGame.CreateFramesFromXML("ui/ui_frames");
            forceEndGame.CurrentFrame = "doublearrow";
            forceEndGame.ResetDimensions();
            forceEndGame.RegularScale = 0.0f; // ScaleFactor * 0.35f;
            forceEndGame.ScaleOnHover = 0.0f; // ScaleFactor * 1.1f * 0.35f;
            forceEndGame.PosX         = -Jabber.BaseGame.Get.BackBufferWidth / 2.0f + pause.Width * pause.ScaleX;
            forceEndGame.PosY         = Jabber.BaseGame.Get.BackBufferHeight / 2.0f - pause.Height * pause.ScaleY * 2.3f;
            Components.Add(forceEndGame);
            forceEndGame.RaiseFlag(Flags.PASSRENDER);


            float widthHeightToUse = pause.Width;

            pause = new Button("ui/ui");
            pause.Initialize(Content);
            pause.Name   = "restart";
            pause.Colour = Color.Green;
            pause.CreateFramesFromXML("ui/ui_frames");
            pause.CurrentFrame             = "restart";
            (pause as Button).RegularScale = ScaleFactor;
            (pause as Button).ScaleOnHover = (pause as Button).RegularScale * 1.4f;
            pause.ResetDimensions();
            pause.UniformScale = ScaleFactor;
            pause.Width        = pause.Height = widthHeightToUse;
            pause.PosX         = -Jabber.BaseGame.Get.BackBufferWidth / 2.0f + pause.Width * pause.ScaleX * 2.5f;
            pause.PosY         = Jabber.BaseGame.Get.BackBufferHeight / 2.0f - pause.Height * pause.ScaleY;
            Components.Add(pause);


            maxNumFox    = 0;
            maxNumDonuts = 0;
            for (int i = 0; i < scene.Nodes.Count; i++)
            {
                if (scene.Nodes[i] is Fox)
                {
                    ++maxNumFox;
                }
                else if (scene.Nodes[i] is Donut)
                {
                    ++maxNumDonuts;
                }
                else if (scene.Nodes[i] is DonutCase)
                {
                    maxNumDonuts += 5;
                }
            }

            donutScore = new DonutScore();
            donutScore.Initialize(Content);
            scene.AddNode(donutScore);



            score = new Score(scene, this.location, levelNum);
            score.Initialize(Content);
            scene.AddNode(score);

            AudioQueue q = new AudioQueue(this);

            q.Initialize(Content);

            scene.AddNode(q);
        }