public void buildTilesetForOgmo1() //string LevelFile, string Tiles
        {
            //push width / height to flxg.levelheight;

            Dictionary <string, string> w = FlxXMLReader.readAttributesFromOelFile("Lemonade/levels/slf/level1.oel", "level/width");

            FlxG.levelWidth = Convert.ToInt32(w["width"]);
            Dictionary <string, string> h = FlxXMLReader.readAttributesFromOelFile("Lemonade/levels/slf/level1.oel", "level/height");

            FlxG.levelHeight = Convert.ToInt32(h["height"]);

            Console.WriteLine("FlxG.lw = {0} {1}", FlxG.levelWidth, FlxG.levelHeight);


            // ------------------------------------------

            List <Dictionary <string, string> > bgString = FlxXMLReader.readNodesFromOel1File("Lemonade/levels/slf/level" + FlxG.level + ".oel", "level/solids");

            foreach (Dictionary <string, string> nodes in bgString)
            {
                FlxTileblock ta = new FlxTileblock(Convert.ToInt32(nodes["x"]), Convert.ToInt32(nodes["y"]), Convert.ToInt32(nodes["w"]), Convert.ToInt32(nodes["h"]));
                ta.loadTiles(FlxG.Content.Load <Texture2D>("Lemonade/slf1/level1/level1_tiles"), 10, 10, 0);
                ta.auto = FlxTileblock.AUTO;
                collidableTileblocks.add(ta);
            }
        }
示例#2
0
        override public void create()
        {
            FlxG.backColor = Color.White;

            base.create();

            FlxTileblock t = new FlxTileblock(8, 8, 256 - 16, 224 - 16);

            t.auto = FlxTileblock.HUDELEMENT;
            t.loadTiles("_sheet_window_06", 16, 16, 0);
            add(t);

            FlxG.playMp3("putt/music/March", 1.0f);

            text = new FlxText(16, 16, 200);
            text.setFormat(FlxG.Content.Load <SpriteFont>("flixel/initials/SMALL_PIXEL"), 1, Color.Black, FlxJustification.Left, Color.White);
            add(text);
            text.text = "Scorecard:\n";

            int total = 0;

            for (int i = 0; i < 18; i++)
            {
                try
                {
                    Console.WriteLine("Score for hole {0}: {1}", i + 1, Globals.scoreCard[i]);
                    text.text += string.Format("{0}: {1}, ", i + 1, Globals.scoreCard[i]);
                    total     += Globals.scoreCard[i];
                    if (i % 3 == 2)
                    {
                        text.text += "\n";
                    }
                }
                catch
                {
                }
            }

            text.text += string.Format("\nTotal: {0} / Par: 18 \n", total);;



            if (total <= 18 && Globals.hasPlayedHoleAgain == false)
            {
                text.text += "\nBonestorm.rom unlocked.";
            }
            else if (total >= 48)
            {
                text.text += "\nSix time national champion\nCarvello urges\nyou to keep practicing\nand improve your\nputting game.";
            }
            else if (total >= 32)
            {
                text.text += "\nYour putting game is improving\nrapidly.\nKeep it up, kid. ";
            }
            else if (total >= 24)
            {
                text.text += "\nYou're a real sharp shooter.";
            }
        }
        public LevelIntro()
        {
            //b1 = new FlxSprite(0, 0);
            //b1.createGraphic(FlxG.width, FlxG.height , Lemonade_Globals.GAMEBOY_COLOR_4);
            //b1.setScrollFactors(0, 0);
            //add(b1);

            //b2 = new FlxSprite(0, 0);
            //b2.createGraphic(FlxG.width, FlxG.height, Lemonade_Globals.GAMEBOY_COLOR_3);
            //b2.setScrollFactors(0, 0);
            //add(b2);

            //b3 = new FlxSprite(0, 0);
            //b3.createGraphic(FlxG.width , FlxG.height, Lemonade_Globals.GAMEBOY_COLOR_2);
            //b3.setScrollFactors(0, 0);
            //add(b3);

            //b4 = new FlxSprite(0, 0);
            //b4.createGraphic(FlxG.width , FlxG.height, Lemonade_Globals.GAMEBOY_COLOR_1);
            //b4.setScrollFactors(0, 0);
            //add(b4);

            block             = new FlxTileblock(0, 0, FlxG.width + 20, FlxG.height + 20);
            block.auto        = FlxTileblock.FRAMENUMBER;
            block.frameNumber = 0;
            block.setScrollFactors(0, 0);
            block.loadTiles(FlxG.Content.Load <Texture2D>("Lemonade/fade"), 20, 20, 0);

            add(block);


            bT1 = new FlxText(0, FlxG.height / 4, FlxG.width);
            bT1.setFormat(null, 3, Lemonade_Globals.GAMEBOY_COLOR_1, FlxJustification.Center, Lemonade_Globals.GAMEBOY_COLOR_3);

            bT1.text = Lemonade_Globals.niceLocationNames[Lemonade_Globals.location];
            add(bT1);

            bT2 = new FlxText(0, (FlxG.height / 4) * 3, FlxG.width);
            bT2.setFormat(null, 2, Lemonade_Globals.GAMEBOY_COLOR_1, FlxJustification.Center, Lemonade_Globals.GAMEBOY_COLOR_3);

            bT2.text = Lemonade_Globals.niceActorNames[Lemonade_Globals.location];
            add(bT2);


            textTween1 = new Tweener(FlxG.height / 4, -95, 1.20f, XNATweener.Elastic.EaseInOut);
            textTween2 = new Tweener((FlxG.height / 4) * 3, FlxG.height + 95, 1.5f, XNATweener.Elastic.EaseInOut);
            textTween3 = new Tweener(-20, FlxG.height / 4, 0.7f, XNATweener.Quintic.EaseOut);
            textTween4 = new Tweener(800, (FlxG.height / 4) * 3, 1.2f, XNATweener.Quintic.EaseOut);

            timer = 0.0f;
        }
示例#4
0
        override public void create()
        {
            base.create();

            FlxG.mouse.hide();
            FlxG.hideHud();

            playingField      = new FlxTileblock(0, 0, 640, 640);
            playingField.auto = FlxTileblock.RANDOM;
            playingField.loadTiles(FlxG.Content.Load <Texture2D>("examples/sports_ground"), 16, 16, 0);
            add(playingField);

            team1 = new FlxGroup();
            team2 = new FlxGroup();

            // Create two teams of 7 robots;
            for (int i = 0; i < 7; i++)
            {
                FlxSprite robot = new FlxSprite(20 + (i * 90), 10);
                robot.loadGraphic(FlxG.Content.Load <Texture2D>("flixel/surt/race_or_die"), true, false, 64, 64);
                robot.addAnimation("Static", new int[] { 7 }, 0, true);
                robot.play("Static");
                robot.angle      = 270;
                robot.velocity.Y = FlxU.random(10, 100);
                //robot.width = 32;
                //robot.height = 32;
                //robot.offset.X = 16;
                //robot.offset.Y = 16;
                team1.add(robot);
            }
            for (int i = 0; i < 7; i++)
            {
                FlxSprite robot = new FlxSprite(20 + (i * 90), 200);
                robot.loadGraphic(FlxG.Content.Load <Texture2D>("flixel/surt/race_or_die"), true, false, 64, 64);
                robot.addAnimation("Static", new int[] { 9 }, 0, true);
                robot.play("Static");
                robot.angle      = 90;
                robot.velocity.Y = FlxU.random(-10, -100);
                //robot.width = 32;
                //robot.height = 32;
                //robot.offset.X = 16;
                //robot.offset.Y = 16;
                team2.add(robot);
            }


            add(team1);
            add(team2);
        }
        //These next two functions look crazy, but all they're doing is generating
        //the level structure and placing the enemy spawners.
        protected void generateLevel()
        {
            int          r = 160;
            FlxTileblock b;

            //First, we create the walls, ceiling and floors:
            b = new FlxTileblock(0, 0, 640, 16);
            b.loadTiles(ImgTech);
            _blocks.add(b);

            b = new FlxTileblock(0, 16, 16, 640 - 16);
            b.loadTiles(ImgTech);
            _blocks.add(b);

            b = new FlxTileblock(640 - 16, 16, 16, 640 - 16);
            b.loadTiles(ImgTech);
            _blocks.add(b);

            b = new FlxTileblock(16, 640 - 24, 640 - 32, 8);
            b.loadTiles(ImgDirtTop);
            _blocks.add(b);

            b = new FlxTileblock(16, 640 - 16, 640 - 32, 16);
            b.loadTiles(ImgDirt);
            _blocks.add(b);

            //Then we split the game world up into a 4x4 grid,
            //and generate some blocks in each area.  Some grid spaces
            //also get a spawner!
            buildRoom(r * 0, r * 0, true);
            buildRoom(r * 1, r * 0);
            buildRoom(r * 2, r * 0);
            buildRoom(r * 3, r * 0, true);
            buildRoom(r * 0, r * 1, true);
            buildRoom(r * 1, r * 1);
            buildRoom(r * 2, r * 1);
            buildRoom(r * 3, r * 1, true);
            buildRoom(r * 0, r * 2);
            buildRoom(r * 1, r * 2);
            buildRoom(r * 2, r * 2);
            buildRoom(r * 3, r * 2);
            buildRoom(r * 0, r * 3, true);
            buildRoom(r * 1, r * 3);
            buildRoom(r * 2, r * 3);
            buildRoom(r * 3, r * 3, true);
        }
        //Just plops down a spawner and some blocks - haphazard and crappy atm but functional!
        protected void buildRoom(int RX, int RY, bool Spawners)
        {
            //first place the spawn point (if necessary)
            int rw = 20;
            int sx = 0;
            int sy = 0;

            if (Spawners)
            {
                sx = (int)(2 + FlxG.random() * (rw - 7));
                sy = (int)(2 + FlxG.random() * (rw - 7));
            }

            //then place a bunch of blocks
            int numBlocks = (int)(3 + FlxG.random() * 4);

            if (!Spawners)
            {
                numBlocks++;
            }
            int  maxW = 10;
            int  minW = 2;
            int  maxH = 8;
            int  minH = 1;
            int  bx;
            int  by;
            int  bw;
            int  bh;
            bool check;

            for (int i = 0; i < numBlocks; i++)
            {
                do
                {
                    //keep generating different specs if they overlap the spawner
                    bw = (int)(minW + FlxG.random() * (maxW - minW));
                    bh = (int)(minH + FlxG.random() * (maxH - minH));
                    bx = (int)(-1 + FlxG.random() * (rw + 1 - bw));
                    by = (int)(-1 + FlxG.random() * (rw + 1 - bh));
                    if (Spawners)
                    {
                        check = ((sx > bx + bw) || (sx + 3 < bx) || (sy > by + bh) || (sy + 3 < by));
                    }
                    else
                    {
                        check = true;
                    }
                } while(!check);

                FlxTileblock b;
                b = new FlxTileblock(RX + bx * 8, RY + by * 8, bw * 8, bh * 8);
                b.loadTiles(ImgTech);
                _blocks.add(b);

                //If the block has room, add some non-colliding "dirt" graphics for variety
                if ((bw >= 4) && (bh >= 5))
                {
                    b = new FlxTileblock(RX + bx * 8 + 8, RY + by * 8, bw * 8 - 16, 8);
                    b.loadTiles(ImgDirtTop);
                    _decorations.add(b);

                    b = new FlxTileblock(RX + bx * 8 + 8, RY + by * 8 + 8, bw * 8 - 16, bh * 8 - 24);
                    b.loadTiles(ImgDirt);
                    _decorations.add(b);
                }
            }

            if (Spawners)
            {
                //Finally actually add the spawner
                Spawner sp = new Spawner(RX + sx * 8, RY + sy * 8, _bigGibs, _enemies, _enemyBullets, _littleGibs, _player);
                _spawners.add(sp);

                //Then create a dedicated camera to watch the spawner
                _hud.add(new FlxSprite(3 + (_spawners.length - 1) * 16, 3, ImgMiniFrame));
                FlxCamera camera = new FlxCamera(10 + (_spawners.length - 1) * 32, 10, 24, 24, 1);
                camera.follow(sp);
                FlxG.addCamera(camera);
            }
        }
示例#7
0
        public override void create()
        {
            base.create();

            ImgTech=FlxG.Content.Load<Texture2D>("Mode/tech_tiles");
            ImgDirtTop=FlxG.Content.Load<Texture2D>("Mode/dirt_top");
            ImgDirt=FlxG.Content.Load<Texture2D>("Mode/dirt");
            ImgNotch=FlxG.Content.Load<Texture2D>("Mode/notch");
            ImgGibs=FlxG.Content.Load<Texture2D>("Mode/gibs");
            ImgSpawnerGibs = FlxG.Content.Load<Texture2D>("Mode/spawner_gibs");

            FlxG.mouse.hide();
            reload = false;

            //get the gibs set up and out of the way
            _littleGibs = new FlxEmitter();
            _littleGibs.delay = 3;
            _littleGibs.setXSpeed(-150,150);
            _littleGibs.setYSpeed(-200,0);
            _littleGibs.setRotation(-720,-720);
            _littleGibs.createSprites(ImgGibs,100,true,0.5f,0.65f);
            _bigGibs = new FlxEmitter();
            _bigGibs.setXSpeed(-200,200);
            _bigGibs.setYSpeed(-300,0);
            _bigGibs.setRotation(-720,-720);
            _bigGibs.createSprites(ImgSpawnerGibs,50,true,0.5f,0.35f);

            //level generation needs to know about the spawners (and thusly the bots, players, etc)
            _blocks = new FlxGroup();
            _decorations = new FlxGroup();
            _bullets = new FlxGroup();
            _player = new Player(316,300,_bullets.members,_littleGibs);
            _bots = new FlxGroup();
            _botBullets = new FlxGroup();
            _spawners = new FlxGroup();

            //simple procedural level generation
            int i;
            int r = 160;
            FlxTileblock b;

            b = new FlxTileblock(0,0,640,16);
            b.loadGraphic(ImgTech);
            _blocks.add(b);

            b = new FlxTileblock(0,16,16,640-16);
            b.loadGraphic(ImgTech);
            _blocks.add(b);

            b = new FlxTileblock(640-16,16,16,640-16);
            b.loadGraphic(ImgTech);
            _blocks.add(b);

            b = new FlxTileblock(16,640-24,640-32,8);
            b.loadGraphic(ImgDirtTop);
            _blocks.add(b);

            b = new FlxTileblock(16,640-16,640-32,16);
            b.loadGraphic(ImgDirt);
            _blocks.add(b);

            buildRoom(r * 0, r * 0, true);
            buildRoom(r*1,r*0);
            buildRoom(r*2,r*0);
            buildRoom(r * 3, r * 0, true);
            buildRoom(r * 0, r * 1, true);
            buildRoom(r*1,r*1);
            buildRoom(r*2,r*1);
            buildRoom(r * 3, r * 1, true);
            buildRoom(r*0,r*2);
            buildRoom(r*1,r*2);
            buildRoom(r*2,r*2);
            buildRoom(r*3,r*2);
            buildRoom(r*0,r*3,true);
            buildRoom(r*1,r*3);
            buildRoom(r*2,r*3);
            buildRoom(r*3,r*3,true);

            //Add bots and spawners after we add blocks to the state,
            // so that they're drawn on top of the level, and so that
            // the bots are drawn on top of both the blocks + the spawners.
            add(_spawners);
            add(_littleGibs);
            add(_bigGibs);
            add(_blocks);
            add(_decorations);
            add(_bots);

            //actually create the bullets now
            for(i = 0; i < 50; i++)
                _botBullets.add(new BotBullet());
            for(i = 0; i < 8; i++)
                _bullets.add(new Bullet());

            //add player and set up scrolling camera
            add(_player);
            FlxG.follow(_player,2.5f);
            FlxG.followAdjust(0.5f,0.0f);
            FlxG.followBounds(0,0,640,640);

            //add gibs + bullets to scene here, so they're drawn on top of pretty much everything
            add(_botBullets);
            add(_bullets);

            //finally we are going to sort things into a couple of helper groups.
            //we don't add these to the state, we just use them for collisions later!
            _enemies = new FlxGroup();
            _enemies.add(_botBullets);
            _enemies.add(_spawners);
            _enemies.add(_bots);
            _objects = new FlxGroup();
            _objects.add(_botBullets);
            _objects.add(_bullets);
            _objects.add(_bots);
            _objects.add(_player);
            _objects.add(_littleGibs);
            _objects.add(_bigGibs);

            //HUD - score
            Vector2 ssf = new Vector2(0,0);
            _score = new FlxText(0,0,FlxG.width);
            _score.color = new Color (0xd8, 0xeb, 0xa2);
            _score.scale = 2;
            _score.alignment = FlxJustification.Center;
            _score.scrollFactor = ssf;
            _score.shadow = new Color(0x13, 0x1c, 0x1b);
            add(_score);
            if (FlxG.scores.Count < 2)
            {
                FlxG.scores.Add(0);
                FlxG.scores.Add(0);
            }

            //HUD - highest and last scores
            _score2 = new FlxText(FlxG.width/2,0,FlxG.width/2);
            _score2.color = new Color(0xd8, 0xeb, 0xa2);
            _score2.alignment = FlxJustification.Right;
            _score2.scrollFactor = ssf;
            _score2.shadow = _score.shadow;
            add(_score2);
            if (FlxG.score > FlxG.scores[0])
                FlxG.scores[0] = FlxG.score;
            if (FlxG.scores[0] != 0)
                _score2.text = "HIGHEST: " + FlxG.scores[0] + "\nLAST: " + FlxG.score;
            FlxG.score = 0;
            _scoreTimer = 0;

            //HUD - the "number of spawns left" icons
            _notches = new List<FlxSprite>();
            FlxSprite tmp;
            for(i = 0; i < 6; i++)
            {
                tmp = new FlxSprite(4+i*10,4);
                tmp.loadGraphic(ImgNotch,true);
                tmp.scrollFactor.X = tmp.scrollFactor.Y = 0;
                tmp.addAnimation("on", new int[] {0});
                tmp.addAnimation("off",new int[] {1});
                tmp.moves = false;
                tmp.solid = false;
                tmp.play("on");
                _notches.Add((FlxSprite)this.add(tmp));
            }

            //HUD - the "gun jammed" notification
            _jamBar = this.add((new FlxSprite(0,FlxG.height-22)).createGraphic(FlxG.width,24, new Color(0x13, 0x1c, 0x1b))) as FlxSprite;
            _jamBar.scrollFactor.X = _jamBar.scrollFactor.Y = 0;
            _jamBar.visible = false;
            _jamText = new FlxText(0,FlxG.height-22,FlxG.width,"GUN IS JAMMED");
            _jamText.color = new Color(0xd8, 0xeb, 0xa2);
            _jamText.scale = 2;
            _jamText.alignment = FlxJustification.Center;
            _jamText.scrollFactor = ssf;
            _jamText.visible = false;
            add(_jamText);

            FlxG.playMusic(SndMode);
            FlxG.flash.start(new Color(0x13, 0x1c, 0x1b), 0.5f, null, false);
            _fading = false;
        }
示例#8
0
        protected void buildRoom(int RX, int RY, bool Spawners)
        {
            //first place the spawn point (if necessary)
            int rw = 20;
            int sx = 0;
            int sy = 0;
            if(Spawners)
            {
                sx = 2+(int)(FlxU.random()*(rw-7));
                sy = 2+(int)(FlxU.random()*(rw-7));
            }

            //then place a bunch of blocks
            int numBlocks = 5+(int)(FlxU.random()*4);
            if(!Spawners) numBlocks++;
            int maxW = 10;
            int minW = 2;
            int maxH = 6;
            int minH = 1;
            int bx;
            int by;
            int bw;
            int bh;
            bool check;
            for(int i = 0; i < numBlocks; i++)
            {
                check = false;
                do
                {
                    //keep generating different specs if they overlap the spawner
                    bw = minW + (int)(FlxU.random()*(maxW-minW));
                    bh = minH + (int)(FlxU.random() * (maxH - minH));
                    bx = -1 + (int)(FlxU.random() * (rw + 1 - bw));
                    by = -1 + (int)(FlxU.random() * (rw + 1 - bh));
                    if(Spawners)
                        check = ((sx>bx+bw) || (sx+3<bx) || (sy>by+bh) || (sy+3<by));
                    else
                        check = true;
                } while(!check);

                FlxTileblock b;

                b = new FlxTileblock(RX+bx*8,RY+by*8,bw*8,bh*8);
                b.loadTiles(ImgTech);
                _blocks.add(b);

                //If the block has room, add some non-colliding "dirt" graphics for variety
                if((bw >= 4) && (bh >= 5))
                {
                    b = new FlxTileblock(RX+bx*8+8,RY+by*8,bw*8-16,8);
                    b.loadTiles(ImgDirtTop);
                    _decorations.add(b);

                    b = new FlxTileblock(RX+bx*8+8,RY+by*8+8,bw*8-16,bh*8-24);
                    b.loadTiles(ImgDirt);
                    _decorations.add(b);
                }
            }

            //Finally actually add the spawner
            if(Spawners)
                _spawners.add(new Spawner(RX+sx*8,RY+sy*8,_bigGibs,_bots,_botBullets.members,_littleGibs,_player));
        }
示例#9
0
        override public void create()
        {
            base.create();

            FlxG.playMp3("Lemonade/music/AmbulanceCalls", 0.5f);

            block             = new FlxTileblock(0, 0, FlxG.width + 20, FlxG.height + 20);
            block.auto        = FlxTileblock.FRAMENUMBER;
            block.frameNumber = 6;
            block.setScrollFactors(0, 0);
            block.loadTiles(FlxG.Content.Load <Texture2D>("Lemonade/fade"), 20, 20, 0);

            add(block);

            icons    = new FlxGroup();
            tweeners = new List <Vector3Tweener>();

            for (int i = 0; i < 6; i++)
            {
                int offsetX  = 75;
                int offsetY  = 0;
                int offsetY2 = 0;

                                #if __ANDROID__
                offsetX  = 400;
                offsetY  = 100;
                offsetY2 = 120;
                                #endif

                FlxSprite p1 = new FlxSprite(0 + (i * 36) + offsetX, 12);
                p1.loadGraphic("Lemonade/illustration/people", true, false, 302, 640);
                p1.frame = i;
                icons.add(p1);
                tweeners.Add(new Vector3Tweener(new Vector3(-100 + (i * 36) + offsetX, -290 + offsetY2, 0.1f), new Vector3(12 + offsetY + offsetX, 100, 1), 0.45f, Bounce.EaseOut));
            }

            foreach (var item in tweeners)
            {
                item.Pause();
            }

            add(icons);

            switch (Lemonade_Globals.location)
            {
            case "warehouse":
                selected = 0;
                break;

            case "military":
                selected = 1;
                break;

            case "newyork":
                selected = 2;
                break;

            case "sydney":
                selected = 3;
                break;

            case "management":
                selected = 4;
                break;

            case "factory":
                selected = 5;
                break;

            default:
                selected = 0;
                break;
            }
            tweeners[selected].Play();

            timer = 5.0f;

            t1 = new FlxText(0, FlxG.height - 72, FlxG.width);
            t1.setFormat(null, 2, Lemonade_Globals.GAMEBOY_COLOR_1, FlxJustification.Center, Lemonade_Globals.GAMEBOY_COLOR_4);
            add(t1);

            t2 = new FlxText(0, 3, FlxG.width);
            t2.setFormat(null, 2, Lemonade_Globals.GAMEBOY_COLOR_1, FlxJustification.Center, Lemonade_Globals.GAMEBOY_COLOR_4);
            add(t2);
        }
        override public void create()
        {
            FlxG.backColor = FlxColor.ToColor("dedbc3");
            base.create();

            _world = new World(new Vector2(0, 98.0f));

            charactersGrp   = new FlxGroup();
            blocksGrp       = new FlxGroup();
            movingBlocksGrp = new FlxGroup();
            doors           = new FlxGroup();
            crates          = new FlxGroup();


            //Dictionary<string,string> levelAttrs = FlxXMLReader.readAttributesFromOelFile("ogmo/level1.oel", "level/grid");
            //FlxTilemap tiles = new FlxTilemap();
            //tiles.useExtraMiddleTiles = false;
            //tiles.auto = FlxTilemap.AUTO;
            //tiles.indexOffset = -1;
            //tiles.loadMap(levelAttrs["grid"], FlxG.Content.Load<Texture2D>("level1_tiles"), 10, 10);
            //tiles.setScrollFactors(0, 0);
            //tiles.boundingBoxOverride = true;

            //blocksGrp.add(tiles);

            List <Dictionary <string, string> > lblocks = FlxXMLReader.readNodesFromOelFile("ogmo/level1.oel", "level/grid");

            foreach (Dictionary <string, string> nodes in lblocks)
            {
                FarTileblock t = new FarTileblock(Convert.ToInt32(nodes["x"]) + (Convert.ToInt32(nodes["w"]) / 2), Convert.ToInt32(nodes["y"]) + (Convert.ToInt32(nodes["h"]) / 2), Convert.ToInt32(nodes["w"]), Convert.ToInt32(nodes["h"]), _world);
                t.auto = FlxTilemap.AUTO;
                t.loadTiles("level1_tiles", 10, 10, 0);
                blocksGrp.add(t);
                t._body.BodyType = BodyType.Static;


                FlxTileblock t2 = new FlxTileblock(Convert.ToInt32(nodes["x"]), Convert.ToInt32(nodes["y"]), Convert.ToInt32(nodes["w"]), Convert.ToInt32(nodes["h"]));
                t2.auto = FlxTilemap.AUTO;
                t2.loadTiles("level1_tiles", 10, 10, 0);
                blocksGrp.add(t2);
            }

            List <Dictionary <string, string> > blocks = FlxXMLReader.readNodesFromOelFile("ogmo/level1.oel", "level/tileblocks");

            foreach (Dictionary <string, string> nodes in blocks)
            {
                if (nodes["Name"] == "elevator")
                {
                    MovingBlock block = new MovingBlock(Convert.ToInt32(nodes["x"]), Convert.ToInt32(nodes["y"]));
                    block.loadGraphic("level1_specialBlock", false, true, 40, 20);
                    movingBlocksGrp.add(block);

                    FlxPath xpath = new FlxPath(null);
                    xpath.add(Convert.ToInt32(nodes["x"]) + 20, Convert.ToInt32(nodes["y"]) + 10);
                    xpath.addPointsUsingStrings(nodes["pathNodesX"], nodes["pathNodesY"], 20, 10);
                    block.followPath(xpath, 80, FlxObject.PATH_FORWARD, false);
                }
                if (nodes["Name"] == "door")
                {
                    Door door = new Door(Convert.ToInt32(nodes["x"]), Convert.ToInt32(nodes["y"]) - 100);
                    doors.add(door);
                }
                //foreach (var item in nodes)
                //{
                //    Console.WriteLine("{0} {1}", item.Key, item.Value);
                //}
            }
            //bat = new Bat(x, y);
            //actors.add(bat);
            //Console.WriteLine("Building a bat {0} {1} {2} {3}", x, y, PathNodesX, PathNodesY);

            //if (PathNodesX != "" && PathNodesY != "")
            //{
            //    Console.WriteLine("Building a path {0} {1} {2}", PathNodesX, PathNodesY, PathCornering);

            //    FlxPath xpath = new FlxPath(null);
            //    xpath.add(x, y);
            //    xpath.addPointsUsingStrings(PathNodesX, PathNodesY);
            //    bat.followPath(xpath, PathSpeed, PathType, false);
            //    bat.pathCornering = PathCornering;


            //}



            Andre andre = new Andre(0, 0);

            charactersGrp.add(andre);

            Liselot liselot = new Liselot(40, 40);

            charactersGrp.add(liselot);

            Army army = new Army(30, 20);

            charactersGrp.add(army);

            Inspector inspector = new Inspector(50, 50);

            charactersGrp.add(inspector);

            Worker worker = new Worker(60, 60);

            charactersGrp.add(worker);

            Chef chef = new Chef(100, 30);

            charactersGrp.add(chef);


            FlxTileblock bg = new FlxTileblock(0, 0, 240, 800);

            bg.auto = FlxTileblock.RANDOM;
            bg.loadTiles("level1_shelfTile", 80, 80, 0);
            add(bg);

            bg      = new FlxTileblock(640, 0, 240, 800);
            bg.auto = FlxTileblock.RANDOM;
            bg.loadTiles("level1_shelfTile", 80, 80, 0);
            add(bg);

            for (int i = 0; i < 5; i++)
            {
                SmallCrate c = new SmallCrate((int)FlxU.random(0, FlxG.width), (int)FlxU.random(0, FlxG.height - 100));
                crates.add(c);
            }

            for (int i = 0; i < 5; i++)
            {
                Bottle b = new Bottle((int)FlxU.random(0, FlxG.width), (int)FlxU.random(0, FlxG.height - 100));
                crates.add(b);
            }
            for (int i = 0; i < 55; i++)
            {
                Fruit f = new Fruit((int)FlxU.random(0, FlxG.width), (int)FlxU.random(0, FlxG.height - 100), _world);
                f._body.ApplyLinearImpulse(new Vector2(20, 2120));


                crates.add(f);
            }


            add(doors);
            add(charactersGrp);
            add(blocksGrp);
            add(movingBlocksGrp);
            add(crates);

            FlxG.showHud();
            FlxG.setHudTextPosition(1, FlxG.width / 2, 10);
            FlxG.setHudTextScale(1, 3);
        }
示例#11
0
        public override void create()
        {
            //load level settings

            Globals.purgeScoreHistory();

            FlxG.backColor = new Color(0,116,239);
            base.create();

            FlxLine x = new FlxLine(0, 0, new Vector2(0, Globals.diveHeight),
                new Vector2(9000, Globals.diveHeight),
                Color.White, 2);
            add(x);

            x = new FlxLine(0, 0, new Vector2(0, Globals.diveHeight + Globals.poolDepth),
                new Vector2(9000, Globals.diveHeight + Globals.poolDepth),
                Color.White, 2);
            add(x);

            poolSide = new FlxTileblock(0, Globals.diveHeight, 900, 1800);
            poolSide.auto = FlxTileblock.OFF;
            poolSide.loadTiles("tile", 9, 9, 0);

            FlxTileblock poolTile = new FlxTileblock(0, Globals.diveHeight, (int)poolSide.width + Globals.poolWidth + 900, Globals.poolDepth + 9);
            poolTile.auto = FlxTileblock.OFF;
            poolTile.loadTiles("tile", 9, 9, 0);
            poolTile.alpha = 0.3225f;
            add(poolTile);

            poolTile = new FlxTileblock(0, Globals.diveHeight + Globals.poolDepth - 90, (int)poolSide.width + Globals.poolWidth + 900, Globals.poolDepth + 9);
            poolTile.auto = FlxTileblock.OFF;
            poolTile.loadTiles("tile", 9, 9, 0);
            poolTile.alpha = 0.5225f;
            add(poolTile);

            bgTile = new FlxTileblock(0, 0, (int)poolSide.width + Globals.poolWidth + 900, Globals.diveHeight);
            bgTile.auto = FlxTileblock.OFF;
            bgTile.loadTiles("tile", 9, 9, 3);
            bgTile.alpha = 0.125f;
            add(bgTile);

            Globals.jumpPoint = (int)poolSide.width + Globals.poolWidth;

            divingPlatform = new FlxTileblock(Globals.jumpPoint, 90, 900, 1800);
            divingPlatform.auto = FlxTileblock.OFF;
            divingPlatform.loadTiles("tile", 9,9,0);
            add(divingPlatform);

            poolBottom = new FlxTileblock(0, Globals.diveHeight + Globals.poolDepth, (int)poolSide.width + Globals.poolWidth + 900, 180);
            poolBottom.auto = FlxTileblock.OFF;
            poolBottom.loadTiles("tile", 9, 9, 0);
            add(poolBottom);
            add(poolSide);

            diver = new Diver((int)(divingPlatform.x + divingPlatform.width - 64), 90-48);
            add(diver);

            bubbles = new Bubbles(0, 0);
            add(bubbles);

            FlxG.follow(diver, 50);

            FlxG.followBounds(0, 0, (int)(poolSide.width + Globals.poolWidth + divingPlatform.width), 9000);

            FlxG.score = 0;

            scoreText = new InformationText(0, 30, FlxG.width);
            scoreText.setFormat(null, 2, Color.White, FlxJustification.Center, Color.Black);
            scoreText.visible = false;
            scoreText.setScrollFactors(0, 0);
            add(scoreText);
        }