Exemplo n.º 1
0
 private void addRandomObjects(int NumberToAdd, string typeOfObject, FlxGroup group)
 {
     for (int i = 0; i < NumberToAdd; i++)
     {
         Vector2 randomSpot = Registry.levelAsTilemap.getRandomTilePositionWithType(Registry.levelAsTilemap.remapGuide[15]);
         if (group == null) add(SpriteFactory.createObject(typeOfObject, (int)randomSpot.X, (int)randomSpot.Y));
         else group.add(SpriteFactory.createObject(typeOfObject, (int)randomSpot.X, (int)randomSpot.Y));
     }
 }
Exemplo n.º 2
0
        public FlxRecord()
        {
            vcrGroup = new FlxGroup();


            // Customizable things
            filename   = "File";
            controller = PlayerIndex.One;


            //int xPos = 150;
            int yPos = 30;


            openSprite = new FlxSprite(130, yPos);
            openSprite.loadGraphic(FlxG.Content.Load <Texture2D>("flixel/vcr/open"));
            openSprite.setScrollFactors(0, 0);
            openSprite.debugName = "open";
            vcrGroup.add(openSprite);
            openSprite.boundingBoxOverride = false;

            pauseSprite = new FlxSprite(230, yPos);
            pauseSprite.loadGraphic(FlxG.Content.Load <Texture2D>("flixel/vcr/pause"));
            pauseSprite.setScrollFactors(0, 0);
            pauseSprite.debugName = "pause";
            vcrGroup.add(pauseSprite);
            pauseSprite.boundingBoxOverride = false;

            playSprite = new FlxSprite(330, yPos);
            playSprite.loadGraphic(FlxG.Content.Load <Texture2D>("flixel/vcr/play"));
            playSprite.setScrollFactors(0, 0);
            playSprite.debugName = "play";
            vcrGroup.add(playSprite);
            playSprite.boundingBoxOverride = false;

            recordSprite = new FlxSprite(430, yPos);
            recordSprite.loadGraphic(FlxG.Content.Load <Texture2D>("flixel/vcr/record_on"));
            recordSprite.setScrollFactors(0, 0);
            recordSprite.debugName = "record";
            vcrGroup.add(recordSprite);
            recordSprite.boundingBoxOverride = false;

            restartSprite = new FlxSprite(530, yPos);
            restartSprite.loadGraphic(FlxG.Content.Load <Texture2D>("flixel/vcr/restart"));
            restartSprite.setScrollFactors(0, 0);
            restartSprite.debugName = "restart";
            vcrGroup.add(restartSprite);
            restartSprite.boundingBoxOverride = false;

            stopSprite = new FlxSprite(630, yPos);
            stopSprite.loadGraphic(FlxG.Content.Load <Texture2D>("flixel/vcr/stop"));
            stopSprite.setScrollFactors(0, 0);
            stopSprite.debugName = "stop";
            vcrGroup.add(stopSprite);

            stopSprite.boundingBoxOverride = false;

            infoText = new FlxText(360, yPos, FlxG.width);
            infoText.boundingBoxOverride = false;
        }
Exemplo n.º 3
0
        public override void create()
        {
            ImgTiles = FlxG.Content.Load<Texture2D>("Mode/tiles_all");

            //load map from file
            string sMap;
            using (Stream file = TitleContainer.OpenStream("Content/" + TxtMap))
            {
                StreamReader sr = new StreamReader(file);
                sMap = sr.ReadToEnd().Replace("\r", "");
                sr.Close();
            }
            //create tilemap
            _tilemap = new FlxTilemap();
            _tilemap.collideIndex = 3;
            _tilemap.loadMap(sMap, ImgTiles, 8, 8);
            //_tilemap.loadMap(new TxtMap2,ImgTiles,8); //This is an alternate tiny map

            //create player and bullets
            _bullets = new FlxGroup();
            _player = new Player((int)(_tilemap.width/2-4),(int)_tilemap.height/2-4,_bullets.members,null);
            for(int i = 0; i < 8; i++)
                _bullets.add(new Bullet());
            add(_bullets);

            //add player and set up camera
            add(_player);
            FlxG.follow(_player,2.5f);
            FlxG.followAdjust(0.5f,0.0f);
            _tilemap.follow();	//Set the followBounds to the map dimensions

            //Uncomment these lines if you want to center TxtMap2
            //var fx:uint = _tilemap.width/2 - FlxG.width/2;
            //var fy:uint = _tilemap.height/2 - FlxG.height/2;
            //FlxG.followBounds(fx,fy,fx,fy);

            //add tilemap last so it is in front, looks neat
            add(_tilemap);

            //fade in
            FlxG.flash.start(new Color(0x13, 0x1c, 0x1b), 1f);

            //The music in this mode is positional - it fades out toward the edges of the level
            FlxSound s = FlxG.play(SndMode,1,true);
            s.proximity(320,320,_player,160);
        }
Exemplo n.º 4
0
        override public void create()
        {
            FlxG.resetHud();
            FlxG.hideHud();

            FlxG.backColor = Color.DarkTurquoise;

            base.create();



            FlxCaveGeneratorExt caveExt = new FlxCaveGeneratorExt(100, 60, 0.42f, 3);
            string[,] caveLevel = caveExt.generateCaveLevel();

            tileGrp = new FlxGroup();

            for (int i = 0; i < caveLevel.GetLength(1); i++)
            {
                for (int y = 0; y < caveLevel.GetLength(0); y++)
                {
                    //string toPrint = tiles[y, i];
                    if (Convert.ToInt32(caveLevel[y, i]) != 0)
                    {
                        FlxSprite x = new FlxSprite(i * 8, y * 8);
                        //x.createGraphic(8, 8, colors[Convert.ToInt32(caveLevel[y, i])]);
                        x.loadGraphic("flixel/autotilesIsland", false, false, 8, 8);
                        //x.color = colors[Convert.ToInt32(caveLevel[y, i])];

                        x.frame = Convert.ToInt32(caveLevel[y, i]);
                        //x.scale = 2;
                        x.angularDrag = 250;
                        //x.setOffset(4, 4);

                        x.@fixed = true;
                        tileGrp.add(x);
                    }
                    //Console.Write(toPrint);
                }

                //Console.WriteLine();
            }

            //string newMap = caveExt.convertMultiArrayStringToString(caveLevel);


            add(tileGrp);

            boats = new FlxGroup();

            for (int i = 0; i < 20; i++)
            {
                Boat b = new Boat((int)FlxU.random(0, FlxG.width), (int)FlxU.random(0, FlxG.height));
                b.velocity.X = FlxU.random(-40, 40);
                b.velocity.Y = FlxU.random(-40, 40);


                boats.add(b);
            }

            add(boats);
        }
Exemplo n.º 5
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;
        }
Exemplo n.º 6
0
 //@desc		Adds a new FlxCore subclass (FlxSprite, FlxBlock, etc) to the game loop
 //@param	Core	The object you want to add to the game loop
 virtual public FlxObject add(FlxObject Core)
 {
     return(defaultGroup.add(Core));
 }
Exemplo n.º 7
0
 virtual public FlxObject addToScrollingGroup(FlxObject Core)
 {
     return(scrollingSpritesGroup.add(Core));
 }
Exemplo n.º 8
0
        public override void create()
        {
            base.create();

            FlxSprite bg = new FlxSprite(0, 0);

            bg.createGraphic(FlxG.width, FlxG.height, FlxG.splashBGColor);
            add(bg);

            _f         = null;
            _poweredBy = FlxG.Content.Load <Texture2D>("flixel/poweredby");
            _fSound    = FlxG.Content.Load <SoundEffect>(FlxG.splashAudioWaveFlixel);

            _initialsLogo = FlxG.Content.Load <Texture2D>(FlxG.splashLogo);

            //_logo = new FlxSprite();
            //_logo.loadGraphic(_initialsLogo, false, false, 216,24);
            //_logo.x = FlxG.width / 2 - 216 / 2;
            //_logo.y = FlxG.height / 2 - 24;
            //add(_logo);

            logoParts = new FlxGroup();

            for (int i = 0; i < 18; i++)
            {
                for (int j = 0; j < 2; j++)
                {
                    _logo = new FlxLogoSprite(i, j);
                    _logo.loadGraphic(_initialsLogo, false, false, 12, 12);
                    _logo.x = (FlxG.width / 2 - 216 / 2) + (i * 12);
                    _logo.y = (FlxG.height / 2 - 24) + (j * 12);
                    _logo.addAnimation("bugs", new int[] { 0, 1, 2, FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24),
                                                           (j * 18) + i }, FlxU.randomInt(12, 18), false);

                    _logo.addAnimation("bugs2", new int[] { 0, 1, 2, FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24),
                                                            0 }, FlxU.randomInt(18, 24), false);

                    _logo.play("bugs");
                    logoParts.add(_logo);

                    float offset = 25.0f;
                    if (j >= 1)
                    {
                        offset *= -1.0f;
                    }
                    _logo.t = new Tweener((float)(_logo.y + offset), (float)_logo.y, 0.25f + (i / 18.0f), XNATweener.Quadratic.EaseInOut);
                    _logo.t.Start();
                }
            }
            add(logoParts);


            _logoTweener = new Tweener(-150, FlxG.height / 2 - 24, TimeSpan.FromSeconds(0.9f), Bounce.EaseOut);

            SndTag = FlxG.splashAudioWave;
            //FlxG.play(SndTag,1.0f);



            debugMode         = new FlxText(10, 90, 200, "DEBUG MODE!");
            debugMode.visible = false;
            add(debugMode);

            Console.WriteLine(" !!! Type {0} To Enter Debug Mode !!! ", FlxGlobal.titleScreenDebugMode);
        }