Exemple #1
0
        public GameLoop(ContentManager _content, Rufus _rufus)
        {
            rufus = _rufus;
            List <int> teste = new List <int>();

            content     = _content;
            lineID      = new List <int>();
            colID       = new List <int>();
            acumSpecial = 40;
            for (int i = 1; i <= 9; i++)
            {
                if (i < 6)
                {
                    lineID.Add(i);
                }
                colID.Add(i);
            }
        }
        public override void build()
        {
            base.build();
            layerManager = new LayerManager();
            //loadAlpha = 1;
            levelModel = (GameModel.levelsModels.ElementAt(GameModel.currentLevelID).behaviour as LevelBehaviour).levelModel;
            //loadScreen.init(content);
            backColor = levelModel.color;
            clouds    = new LinkedList <Clouds>();
            if (levelModel.clouds != null)
            {
                for (int i = 0; i < levelModel.clouds.Count; i++)
                {
                    Clouds tempCloud = new Clouds();
                    tempCloud.texture = content.Load <Texture2D>(levelModel.clouds.ElementAt(i));
                    Vector2 temp = new Vector2((i + 1) % 2 == 0 ? -100 : 600, (float)new Random().Next(0, 50));
                    tempCloud.position = temp;
                    clouds.AddLast(tempCloud);
                }
            }


            /*Cria as layers*/
            environment = new StaticLayer("ENVIRONMENT");


            for (int i = 0; i < levelModel.levelLayers.Count; i++)
            {
                environment.add(new StaticObject(levelModel.levelLayers.ElementAt(i)));
            }

            FXLayer           = new Layer("FX");
            BackEntityFXLayer = new Layer("BACK ENTITY FX");
            entityLayer       = new Layer("ENTITY LAYER");
            rufus             = new Rufus(400 - 30);
            rufus.position.Y  = 200;
            rufus.dieCallback = endGame;
            entityLayer.add(rufus);



            /*Adiciona as layers*/
            layerManager.add(environment);
            layerManager.add(BackEntityFXLayer);
            layerManager.add(entityLayer);
            layerManager.add(FXLayer);
            layerManager.init(content);

            baseHUD = new BaseHUD();
            baseHUD.init(content);
            baseHUD.position.X = 6;
            baseHUD.position.Y = 444;
            baseHUD.start();
            addChild(baseHUD);


            pauseButton = new PauseButton(pauseGame);
            pauseButton.init(content);
            pauseButton.position.X = 732;
            pauseButton.position.Y = 410;
            pauseButton.scale      = new Vector2(1f);
            addChild(pauseButton);

            gameLoop = new GameLoop(content, rufus);
            gameLoop.beginGame(entityLayer);

            pause = false;

            comboBar = new ComboBar(rufus.setOnInvencible, rufus.setOffInvencible);
            comboBar.init(content);
            comboBar.updateScale(0);

            addChild(comboBar);

            inGameMenu = new InGameMenu();
            inGameMenu.init(content, menuPlayCallback, backToMenu, reinitGame);
            inGameMenu.hide();
            addChild(inGameMenu);

            endGameMenu = new EndGameMenu();
            endGameMenu.init(content, menuPlayCallback, backToMenu, reinitGame, goShop, goPreGame);
            endGameMenu.hide();
            addChild(endGameMenu);

            totMush = 0;

            rufus.collideCallback = collideCallback;


            //endGame();
        }