public Coin(int xPos, int yPos, bool Outline)
            : base(xPos, yPos)
        {
            if (Outline)
            {
                loadGraphic("Lemonade/GoldCoinGameboyWithOutline", true, false, 32, 32);
            }
            else
            {
                loadGraphic("Lemonade/GoldCoinGameboy", true, false, 32, 32);
            }

            addAnimation("animation", new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 4 }, (int)FlxU.random(4, 8), true);
            play("animation");

            width  = 16;
            height = 16;
            setOffset(8, 8);

            fanfare = new FlxEmitter();
            fanfare.createSprites("Lemonade/bubble", 8, true, 0.0f, 0.0f);
            fanfare.setXSpeed(-100, 100);
            fanfare.setYSpeed(-100, 100);
            fanfare.gravity = 5;
            fanfare.delay   = 3.0f;

            tween          = new XNATweener.Tweener(-25, 25, FlxU.random(0.8f, 1.2f), XNATweener.Quadratic.EaseInOut);
            tween.PingPong = true;
            tween.Start();
        }
Example #2
0
        /// <summary>
        /// Plant that can lose leaves
        /// </summary>
        /// <param name="xPos"></param>
        /// <param name="yPos"></param>
        /// <param name="type">Two types of plants. 1 and 2.</param>
        public Plant(int xPos, int yPos, int type)
            : base(xPos, yPos)
        {
            if (type == 1)
            {
                loadGraphic(FlxG.Content.Load <Texture2D>("Lemonade/plant1"), false, false, 10, 110);
            }
            else if (type == 2)
            {
                loadGraphic(FlxG.Content.Load <Texture2D>("Lemonade/plant2"), false, false, 13, 110);
            }

            _leaves = new FlxEmitter();
            _leaves.setSize(2, 110);
            _leaves.createSprites(FlxG.Content.Load <Texture2D>("Lemonade/leaves"), 30, true, 0.0f, 0.0f);
            _leaves.setRotation(0, 360);
            _leaves.setYSpeed(15, 85);
            _leaves.setXSpeed(-40, 40);
            _leaves.gravity = 15;
            _leaves.at(this);


            canLoseLeaves = 110;
        }
Example #3
0
        override public void create()
        {
            base.create();

            Lemonade_Globals.totalCoins = Lemonade_Globals.calculateTotalCoins();

            FlxTilemap bgMap = new FlxTilemap();

            bgMap.auto        = FlxTilemap.STRING;
            bgMap.indexOffset = -1;
            bgMap.loadTMXMap("Lemonade/levels/slf2/newyork/newyork_intro.tmx", "map", "bg", FlxXMLReader.TILES, FlxG.Content.Load <Texture2D>("Lemonade/bgtiles_newyork"), 20, 20);
            bgMap.boundingBoxOverride = false;
            bgMap.setScrollFactors(1, 1);
            add(bgMap);

            bgMap             = new FlxTilemap();
            bgMap.auto        = FlxTilemap.STRING;
            bgMap.indexOffset = -1;
            bgMap.loadTMXMap("Lemonade/levels/slf2/newyork/newyork_intro.tmx", "map", "bg2", FlxXMLReader.TILES, FlxG.Content.Load <Texture2D>("Lemonade/bgtiles_newyork"), 20, 20);
            bgMap.boundingBoxOverride = false;
            bgMap.setScrollFactors(1, 1);
            add(bgMap);

            FlxTilemap bgMap3 = new FlxTilemap();

            bgMap3.auto        = FlxTilemap.STRING;
            bgMap3.indexOffset = -1;
            bgMap3.loadTMXMap("Lemonade/levels/slf2/newyork/newyork_intro.tmx", "map", "stars", FlxXMLReader.TILES, FlxG.Content.Load <Texture2D>("Lemonade/bgtiles_newyork"), 20, 20);
            bgMap3.boundingBoxOverride = false;
            bgMap3.setScrollFactors(0.5f, 0.5f);
            add(bgMap3);

            FlxTilemap bgMap4 = new FlxTilemap();

            bgMap4.auto        = FlxTilemap.STRING;
            bgMap4.indexOffset = -1;
            bgMap4.loadTMXMap("Lemonade/levels/slf2/newyork/newyork_intro.tmx", "map", "city", FlxXMLReader.TILES, FlxG.Content.Load <Texture2D>("Lemonade/bgtiles_newyork"), 20, 20);
            bgMap4.boundingBoxOverride = false;
            bgMap4.setScrollFactors(1, 1);
            add(bgMap4);

            follower         = new FlxSprite(400, 1500);
            follower.visible = false;
            add(follower);
            follower.velocity.Y = this.speed;

            FlxG.follow(follower, 20.0f);
            FlxG.followBounds(0, 0, int.MaxValue, 2000);

            int textSize = 2;

                        #if __ANDROID__
            textSize = 4;
                        #endif


            heading = new FlxText(0, 50, FlxG.width, "Collection Incomplete");
            heading.setFormat(FlxG.Content.Load <SpriteFont>("Lemonade/SMALL_PIXEL"), textSize, Lemonade_Globals.GAMEBOY_COLOR_4, FlxJustification.Center, Lemonade_Globals.GAMEBOY_COLOR_1);
            heading.setScrollFactors(0, 0);
            add(heading);



            string howWellDidYouGo = "Collected " + Lemonade_Globals.coins.ToString() + "\nfrom " + Lemonade_Globals.totalCoins.ToString() + " Coins ";
            credits = new FlxText(0, FlxG.height / 1.75f, FlxG.width, howWellDidYouGo);
            credits.setFormat(FlxG.Content.Load <SpriteFont>("Lemonade/SMALL_PIXEL"), textSize, Lemonade_Globals.GAMEBOY_COLOR_4, FlxJustification.Center, Lemonade_Globals.GAMEBOY_COLOR_1);
            credits.setScrollFactors(0, 0);
            credits.visible = false;
            add(credits);

            string ins = "Press X to Continue";
#if __ANDROID__
            ins = "Press O to Continue";
#endif

            instruction = new FlxText(0, FlxG.height / 1.3f, FlxG.width, ins);
            instruction.setFormat(FlxG.Content.Load <SpriteFont>("Lemonade/SMALL_PIXEL"), textSize, Lemonade_Globals.GAMEBOY_COLOR_4, FlxJustification.Center, Lemonade_Globals.GAMEBOY_COLOR_1);
            instruction.setScrollFactors(0, 0);
            instruction.visible = false;
            add(instruction);

            if (Lemonade_Globals.coins == Lemonade_Globals.totalCoins)
            {
                heading.setFormat(FlxG.Content.Load <SpriteFont>("Lemonade/SMALL_PIXEL"), textSize, Lemonade_Globals.GAMEBOY_COLOR_4, FlxJustification.Center, Lemonade_Globals.GAMEBOY_COLOR_1);
                heading.text = "Complete Collection!!\nThe Lemonade Factory is saved.";
                instruction.setFormat(FlxG.Content.Load <SpriteFont>("Lemonade/SMALL_PIXEL"), textSize, Lemonade_Globals.GAMEBOY_COLOR_4, FlxJustification.Center, Lemonade_Globals.GAMEBOY_COLOR_1);


                string ins2 = "Press X to Continue";
#if __ANDROID__
                ins2 = "Press O to Continue";
#endif

                instruction.text = ins2;

                //FlxU.openURL("http://initials.itch.io/slf2/download/Y9wdBOHe7a92Qpo9t5UJdz05HhZR5p10F0L6wfdP");
            }

            tween          = new Tweener(FlxG.height / 1.3f, FlxG.height / 1.2f, TimeSpan.FromSeconds(0.67f), XNATweener.Cubic.EaseInOut);
            tween.PingPong = true;
            tween.Start();

            // play some music
            FlxG.playMp3("Lemonade/music/March", 0.75f);

            rain = new FlxGroup();
            for (int i = 0; i < 150; i++)
            {
                FlxSprite rainDrop = new FlxSprite((FlxU.random() * FlxG.width * 2), -200 + (FlxU.random() * 1000));
                rainDrop.loadGraphic("Lemonade/rain", true, false, 2, 2);
                rainDrop.frame      = (int)FlxU.random(0, 6);
                rainDrop.velocity.Y = FlxU.random(350, 400);
                rain.add(rainDrop);
            }
            add(rain);

            splashes = new FlxEmitter();
            splashes.createSprites("Lemonade/rain", 150, true, 0.0f, 0.0f);
            splashes.setXSpeed(-25, 25);
            splashes.setYSpeed(-30, 0);
            splashes.gravity = 1.0f;
            add(splashes);
        }
Example #4
0
        override public void create()
        {
            base.create();

            Lemonade_Globals.totalCoins = Lemonade_Globals.calculateTotalCoins();

            Console.WriteLine("Total coins = {0}", Lemonade_Globals.totalCoins);

                        #if __ANDROID__
            FlxG.BUILD_TYPE = FlxG.BUILD_TYPE_OUYA;
                        #endif

            FlxTilemap bgMap = new FlxTilemap();
            bgMap.auto        = FlxTilemap.STRING;
            bgMap.indexOffset = -1;
            bgMap.loadTMXMap("Lemonade/levels/slf2/newyork/newyork_intro.tmx", "map", "bg", FlxXMLReader.TILES, FlxG.Content.Load <Texture2D>("Lemonade/bgtiles_newyork"), 20, 20);
            bgMap.boundingBoxOverride = false;
            bgMap.setScrollFactors(1, 1);
            add(bgMap);

            bgMap             = new FlxTilemap();
            bgMap.auto        = FlxTilemap.STRING;
            bgMap.indexOffset = -1;
            bgMap.loadTMXMap("Lemonade/levels/slf2/newyork/newyork_intro.tmx", "map", "bg2", FlxXMLReader.TILES, FlxG.Content.Load <Texture2D>("Lemonade/bgtiles_newyork"), 20, 20);
            bgMap.boundingBoxOverride = false;
            bgMap.setScrollFactors(1, 1);
            add(bgMap);

            FlxTilemap bgMap3 = new FlxTilemap();
            bgMap3.auto        = FlxTilemap.STRING;
            bgMap3.indexOffset = -1;
            bgMap3.loadTMXMap("Lemonade/levels/slf2/newyork/newyork_intro.tmx", "map", "stars", FlxXMLReader.TILES, FlxG.Content.Load <Texture2D>("Lemonade/bgtiles_newyork"), 20, 20);
            bgMap3.boundingBoxOverride = false;
            bgMap3.setScrollFactors(0.5f, 0.5f);
            add(bgMap3);

            FlxTilemap bgMap4 = new FlxTilemap();
            bgMap4.auto        = FlxTilemap.STRING;
            bgMap4.indexOffset = -1;
            bgMap4.loadTMXMap("Lemonade/levels/slf2/newyork/newyork_intro.tmx", "map", "city", FlxXMLReader.TILES, FlxG.Content.Load <Texture2D>("Lemonade/bgtiles_newyork"), 20, 20);
            bgMap4.boundingBoxOverride = false;
            bgMap4.setScrollFactors(1, 1);
            add(bgMap4);

            follower         = new FlxSprite(0, -100);
            follower.visible = false;
            add(follower);
            follower.velocity.Y = 450;

            FlxG.follow(follower, 20.0f);
            FlxG.followBounds(0, 0, int.MaxValue, 2000);

            FlxText text1 = new FlxText(0, FlxG.height / 2 - 50, FlxG.width, "Initials\nVideo\nGames\nPresents");
            text1.setFormat(FlxG.Content.Load <SpriteFont>("Lemonade/SMALL_PIXEL"), 2, Lemonade_Globals.GAMEBOY_COLOR_4, FlxJustification.Center, Lemonade_Globals.GAMEBOY_COLOR_1);
            text1.setScrollFactors(1.5f, 1.5f);

            add(text1);

            credits = new FlxText(0, FlxG.height / 2 - 100, FlxG.width, "A Game by\nShane Brouwer");
            credits.setFormat(FlxG.Content.Load <SpriteFont>("Lemonade/SMALL_PIXEL"), 2, Lemonade_Globals.GAMEBOY_COLOR_4, FlxJustification.Center, Lemonade_Globals.GAMEBOY_COLOR_1);
            credits.setScrollFactors(0, 0);
            credits.visible = false;
            add(credits);

            string ins = "Press X to Continue";
                        #if __ANDROID__
            ins = "Press O to Continue";
                        #endif

            instruction = new FlxText(0, FlxG.height / 1.3f, FlxG.width, ins);
            instruction.setFormat(FlxG.Content.Load <SpriteFont>("Lemonade/SMALL_PIXEL"), 2, Lemonade_Globals.GAMEBOY_COLOR_4, FlxJustification.Center, Lemonade_Globals.GAMEBOY_COLOR_1);
            instruction.setScrollFactors(0, 0);
            instruction.visible = false;
            add(instruction);

            tween          = new Tweener(FlxG.height / 1.3f, FlxG.height / 1.2f, TimeSpan.FromSeconds(0.67f), XNATweener.Cubic.EaseInOut);
            tween.PingPong = true;
            tween.Start();

            // play some music
            FlxG.playMp3("Lemonade/music/Beyond", 0.75f);

            rain = new FlxGroup();
            for (int i = 0; i < 150; i++)
            {
                FlxSprite rainDrop = new FlxSprite((FlxU.random() * FlxG.width), -200 + (FlxU.random() * 1000));
                rainDrop.loadGraphic("Lemonade/rain", true, false, 2, 2);
                rainDrop.frame      = (int)FlxU.random(0, 6);
                rainDrop.velocity.Y = FlxU.random(350, 400);
                rain.add(rainDrop);
            }
            add(rain);

            splashes = new FlxEmitter();
            splashes.createSprites("Lemonade/rain", 150, true, 0.0f, 0.0f);
            splashes.setXSpeed(-25, 25);
            splashes.setYSpeed(-30, 0);
            splashes.gravity = 1.0f;
            add(splashes);
        }
        override public void create()
        {
            base.create();

            FlxG.setHudGamepadButton(FlxHud.TYPE_KEYBOARD, FlxHud.Keyboard_Arrow_Left, 10, 110);
            FlxG.setHudGamepadButton(FlxHud.TYPE_KEYBOARD_DIRECTION, FlxHud.Keyboard_Arrow_Right, 110, 110);



            FlxSprite bg = new FlxSprite(0, 0);

            bg.createGraphic(FlxG.width, FlxG.width, new Color(0.05f, 0.05f, 0.08f));
            bg.setScrollFactors(0, 0);
            add(bg);

            stars = new FlxGroup();


            // Make a starfield to fly through.
            for (int i = 0; i < 100; i++)
            {
                star = new FlxSprite(FlxU.random(0, FlxG.width), FlxU.random(0, FlxG.height));
                star.createGraphic(3, 3, Color.White);
                star.velocity.Y = FlxU.random(20, 100);
                star.velocity.X = 0;
                stars.add(star);
            }

            add(stars);

            spaceShip = new FlxSprite(FlxG.width / 2, FlxG.height / 2);
            spaceShip.loadGraphic(FlxG.Content.Load <Texture2D>("flixel/surt/spaceship_32x32"), true, false, 32, 32);

            //Add some animations to our Spaceship
            spaceShip.addAnimation("static", new int[] { 0 }, 36, true);

            spaceShip.addAnimation("transform1", new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 }, 12, false);
            spaceShip.addAnimation("transform2", new int[] { 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39 }, 12, false);
            spaceShip.addAnimation("transform3", new int[] { 40, 41, 42 }, 12, false);


            //spaceShip.addAnimation("transform", new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39}, 24, false);
            //spaceShip.addAnimation("reverse", new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39 }, 24, false);

            spaceShip.addAnimation("transform", spaceShip.generateFrameNumbersBetween(0, 39), 24, false);
            spaceShip.addAnimation("reverse", spaceShip.generateFrameNumbersBetween(39, 0), 24, false);

            spaceShip.play("static");

            //Add an animation callback - This will call Pulse on every frame.
            spaceShip.addAnimationCallback(pulse);

            spaceShip.scale = 3;
            spaceShip.setDrags(1100, 1100);
            add(spaceShip);

            jets = new FlxEmitter();

            jets.setSize(5, 50);
            jets.createSprites(FlxG.Content.Load <Texture2D>("flixel/diagnostic/testpalette"), 100, true, 0.0f, 0.0f);
            jets.setXSpeed(-110, 110);
            jets.setYSpeed(40, 80);

            add(jets);
            jets.at(spaceShip);
        }
        override public void create()
        {
            base.create();

            Lemonade_Globals.coinsThisLevel = 0;

            Console.WriteLine("Starting Level {0} : {1}", FlxG.level, Lemonade_Globals.location);
            FlxG.transition.resetAndStop();


            FlxG._game.hud.p1HudText.x = -1000;
            FlxG._game.hud.p2HudText.x = -1000;
            FlxG._game.hud.p3HudText.x = -1000;
            FlxG._game.hud.p4HudText.x = -1000;

            FlxG._game.hud.setHudGamepadButton(FlxHud.TYPE_KEYBOARD, 0, -1000, -1000);

            FlxG.mouse.hide();

            FlxG.autoHandlePause = true;

            actors               = new FlxGroup();
            trampolines          = new FlxGroup();
            levelItems           = new FlxGroup();
            ramps                = new FlxGroup();
            smallCrates          = new FlxGroup();
            movingPlatforms      = new FlxGroup();
            hazards              = new FlxGroup();
            collidableTileblocks = new FlxGroup();
            coins                = new FlxGroup();


            //Level Adjust

            buildTileset();
            buildActors();
            buildBoxes();

            add(trampolines);
            add(levelItems);

            add(ramps);
            add(smallCrates);
            add(movingPlatforms);
            add(actors);
            add(collidableTileblocks);

            add(hazards);
            add(coins);



            //set up a little bubble particle system.

            bubbleParticle       = new FlxEmitter();
            bubbleParticle.delay = 3;
            bubbleParticle.setXSpeed(-150, 150);
            bubbleParticle.setYSpeed(-40, 100);
            bubbleParticle.setRotation(-720, 720);
            bubbleParticle.gravity = Lemonade_Globals.GRAVITY * -0.25f;
            bubbleParticle.createSprites(FlxG.Content.Load <Texture2D>("Lemonade/bubble"), 200, true, 1.0f, 0.65f);
            add(bubbleParticle);

            crateParticle       = new FlxEmitter();
            crateParticle.delay = float.MaxValue;
            crateParticle.setSize(80, 60);
            crateParticle.setXSpeed(-350, 350);
            crateParticle.setYSpeed(-200, 200);
            crateParticle.setRotation(-720, 720);
            crateParticle.gravity = Lemonade_Globals.GRAVITY;
            crateParticle.createSprites(FlxG.Content.Load <Texture2D>("Lemonade/crateShards"), 200, true, 1.0f, 0.65f);
            add(crateParticle);


            // follow.
            FlxG.followBounds(0, 0, FlxG.levelWidth, FlxG.levelHeight);

            if (Lemonade_Globals.location == "factory")
            {
                FlxG.follow(worker, LERP);
            }
            if (Lemonade_Globals.location == "management")
            {
                FlxG.follow(liselot, LERP);
            }
            if (Lemonade_Globals.location == "military")
            {
                FlxG.follow(army, LERP);
            }
            if (Lemonade_Globals.location == "newyork")
            {
                FlxG.follow(chef, LERP);
            }
            if (Lemonade_Globals.location == "warehouse")
            {
                FlxG.follow(andre, LERP);
            }
            if (Lemonade_Globals.location == "sydney")
            {
                FlxG.follow(inspector, LERP);
            }

            playSong();

            currentCharHud = new Hud(5, 5);
            add(currentCharHud);

            levelIntro = new LevelIntro();
            add(levelIntro);

            currentCharHud.time = Lemonade_Globals.timeLeft;

            foreach (FlxSprite item in actors.members)
            {
                if (Lemonade_Globals.stateSaver[Lemonade_Globals.location].ContainsKey(item.ToString()))
                {
                    try
                    {
                        item.x = Lemonade_Globals.stateSaver[Lemonade_Globals.location][item.ToString()].X;
                        item.y = Lemonade_Globals.stateSaver[Lemonade_Globals.location][item.ToString()].Y;
                    }
                    catch (Exception)
                    {
                        Console.WriteLine("State saver not working for actors.");
                    }
                }
            }
            int count = 0;

            foreach (FlxSprite item in coins.members)
            {
                if (Lemonade_Globals.stateSaver[Lemonade_Globals.location].ContainsKey(item.ToString() + count.ToString()))
                {
                    try
                    {
                        //Lemonade_Globals.stateSaver[Lemonade_Globals.location][item.ToString() + count.ToString()] = new Vector2(item.x, item.y);
                        if (item.ToString().StartsWith("Lemonade.Coin"))
                        {
                            //item.x = Lemonade_Globals.stateSaver[Lemonade_Globals.location][item.ToString() + count.ToString()].X;
                            //item.y = Lemonade_Globals.stateSaver[Lemonade_Globals.location][item.ToString() + count.ToString()].Y;
                            item.dead = Convert.ToBoolean(Lemonade_Globals.stateSaver[Lemonade_Globals.location][item.ToString() + count.ToString()].X);

                            if (Convert.ToBoolean(Lemonade_Globals.stateSaver[Lemonade_Globals.location][item.ToString() + count.ToString()].X))
                            {
                                item.x = -100;
                                item.y = -100;
                            }
                        }

                        count++;
                    }
                    catch (Exception)
                    {
                        Console.WriteLine("State saver not working for coins");
                    }
                }
            }
        }