protected bool trampolinesOverlap(object Sender, FlxSpriteCollisionEvent e)
 {
     if (e.Object1.dead == false)
     {
         bubbleParticle.at(e.Object1);
         bubbleParticle.start(true, 0, 30);
     }
     e.Object1.overlapped(e.Object2);
     e.Object2.overlapped(e.Object1);
     return(true);
 }
Esempio n. 2
0
        public override void kill()
        {
            fanfare.at(this);
            fanfare.start(true, 1.0f, 20);

            x = -100;
            y = -100;

            this.dead = true;

            //base.kill();
        }
Esempio n. 3
0
        //Called to kill the enemy.  A cool sound is played,
        //the jets are turned off, bits are exploded, and points are rewarded.

        public override void kill()
        {
            if (!Alive)
            {
                return;
            }
            _sfxExplode.play(true);
            base.kill();
            flicker(0);
            _jets.kill();
            _gibs.at(this);
            _gibs.start(true, 3, 0, 20);
            FlxG.score += 200;
        }
Esempio n. 4
0
 public override void kill()
 {
     if (!Alive)
     {
         return;
     }
     Solid = false;
     _sfxExplode.play(true);
     _sfxExplode2.play(true);
     base.kill();
     flicker(0);
     Exists  = true;
     Visible = false;
     Velocity.make();
     Acceleration.make();
     FlxG.camera.shake(0.005f, 0.35f);
     FlxG.camera.Flash(Color.White, 0.35f);
     if (_gibs != null)
     {
         _gibs.at(this);
         _gibs.start(true, 5, 0, 50);
     }
 }
Esempio n. 5
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;
        }
Esempio n. 6
0
        //This is the main flixel update function or loop function.
        //Most of the enemy's logic or behavior is in this function here.

        public override void update()
        {
            //Then, rotate toward that angle.
            //We could rotate instantly toward the player by simply calling:
            //angle = angleTowardPlayer();
            //However, we want some less predictable, more wobbly behavior.
            float da = angleTowardPlayer();

            if (da < Angle)
            {
                AngularAcceleration = -AngularDrag;
            }
            else if (da > Angle)
            {
                AngularAcceleration = AngularDrag;
            }
            else
            {
                AngularAcceleration = 0;
            }

            //Figure out if we want the jets on or not.
            _timer += FlxG.elapsed;
            if (_timer > 8)
            {
                _timer = 0;
            }
            bool jetsOn = _timer < 6;

            //Set the bot's movement speed and direction
            //based on angle and whether the jets are on.
            _thrust = FlxU.computeVelocity(_thrust, (jetsOn?90:0), Drag.X, 60);
            FlxU.rotatePoint(0, (int)_thrust, 0, 0, Angle, Velocity);

            //Shooting - three shots every few seconds
            if (onScreen())
            {
                bool  shoot = false;
                float os    = _shotClock;
                _shotClock += FlxG.elapsed;
                if ((os < 4.0) && (_shotClock >= 4.0))
                {
                    _shotClock = 0;
                    shoot      = true;
                }
                else if ((os < 3.5) && (_shotClock >= 3.5))
                {
                    shoot = true;
                }
                else if ((os < 3.0) && (_shotClock >= 3.0))
                {
                    shoot = true;
                }

                //If we rolled over one of those time thresholds,
                //shoot a bullet out along the angle we're currently facing.
                if (shoot)
                {
                    //First, recycle a bullet from the bullet pile.
                    //If there are none, recycle will automatically create one for us.
                    EnemyBullet b = (EnemyBullet)_bullets.recycle(typeof(EnemyBullet));
                    //Then, shoot it from our midpoint out along our angle.
                    b.shoot(getMidpoint(_tagPoint), Angle);
                }
            }

            //Then call FlxSprite's update() function, to automate
            // our motion and animation and stuff.
            base.update();

            //Finally, update the jet particles shooting out the back of the ship.
            if (jetsOn)
            {
                if (!_jets.on)
                {
                    //If they're supposed to be on and they're not,
                    //turn em on and play a little sound.
                    _jets.start(false, 0.5f, 0.01f);
                    if (onScreen())
                    {
                        _sfxJet.play(true);
                    }
                }
                //Then, position the jets at the center of the Enemy,
                //and point the jets the opposite way from where we're moving.
                _jets.at(this);
                _jets.setXSpeed(-Velocity.X - 30, -Velocity.X + 30);
                _jets.setYSpeed(-Velocity.Y - 30, -Velocity.Y + 30);
            }
            else                //If jets are supposed to be off, just turn em off.
            {
                _jets.on = false;
            }
            //Finally, update the jet emitter and all its member sprites.
            _jets.update();
        }
Esempio n. 7
0
        override public void update()
        {
            if (FlxG.keys.justPressed(Keys.Q))
            {
                FlxG.bloom.Visible    = !FlxG.bloom.Visible;
                FlxG.bloom.usePresets = true;

                follower.velocity.Y += 1450;
            }
            if (FlxG.keys.ONE)
            {
                FlxG.bloom.Settings = BloomPostprocess.BloomSettings.PresetSettings[1];
            }
            if (FlxG.keys.TWO)
            {
                FlxG.bloom.Settings = BloomPostprocess.BloomSettings.PresetSettings[2];
            }
            if (FlxG.keys.THREE)
            {
                FlxG.bloom.Settings = BloomPostprocess.BloomSettings.PresetSettings[3];
            }
            if (FlxG.keys.FOUR)
            {
                FlxG.bloom.Settings = BloomPostprocess.BloomSettings.PresetSettings[4];
            }
            if (FlxG.keys.FIVE)
            {
                FlxG.bloom.Settings = BloomPostprocess.BloomSettings.PresetSettings[5];
            }
            if (FlxG.keys.SIX)
            {
                FlxG.bloom.Settings = BloomPostprocess.BloomSettings.PresetSettings[6];
            }
            if (FlxG.keys.SEVEN)
            {
                FlxG.bloom.Settings = BloomPostprocess.BloomSettings.PresetSettings[7];
            }

            foreach (FlxSprite item in rain.members)
            {
                if (item.y > 2000)
                {
                    splashes.at(item);
                    splashes.start(true, 0.0f, 10);

                    item.y = 1200;
                }
            }

            base.update();

            if (instruction.visible)
            {
                if (tween.hasEnded)
                {
                    FlxG.play("Lemonade/sfx/cw_sound09", 0.75f, false);
                }
            }

            tween.Update(FlxG.elapsedAsGameTime);
            instruction.y = tween.Position;

            if (follower.y > 2100)
            {
                credits.visible = true;
            }
            if (follower.y > 2300)
            {
                instruction.visible = true;
            }

            if (((follower.y > int.MaxValue && follower.x == 0) ||
                 (FlxG.keys.justPressed(Keys.X) && follower.y > 100) ||
                 (FlxG.gamepads.isNewButtonPress(Buttons.A) && follower.y > 100) || (FlxControl.ACTIONJUSTPRESSED && follower.y > 100)) &&
                (FlxG.transition.members[0] as FlxSprite).scale < 0.001f)
            {
                if (Lemonade_Globals.coins == Lemonade_Globals.totalCoins)
                {
                                        #if !__ANDROID__
                    FlxU.openURL("http://initials.itch.io/slf2/download/Y9wdBOHe7a92Qpo9t5UJdz05HhZR5p10F0L6wfdP");
                                        #endif
                }

                follower.velocity.X = -250;
            }
            if (follower.x < 0)
            {
                FlxG.transition.startFadeOut(0.15f, -90, 150);
                follower.x          = 1;
                follower.velocity.X = 1;
            }
            if (FlxG.transition.complete)
            {
                FlxG.state = new IntroState();

                FlxG.transition.resetAndStop();

                return;
            }
        }
Esempio n. 8
0
        override public void update()
        {
            if (FlxG.keys.justPressed(Keys.Q))
            {
                FlxG.bloom.Visible    = !FlxG.bloom.Visible;
                FlxG.bloom.usePresets = true;

                follower.velocity.Y += 1450;
            }
            if (FlxG.keys.ONE)
            {
                FlxG.bloom.Settings = BloomPostprocess.BloomSettings.PresetSettings[1];
            }
            if (FlxG.keys.TWO)
            {
                FlxG.bloom.Settings = BloomPostprocess.BloomSettings.PresetSettings[2];
            }
            if (FlxG.keys.THREE)
            {
                FlxG.bloom.Settings = BloomPostprocess.BloomSettings.PresetSettings[3];
            }
            if (FlxG.keys.FOUR)
            {
                FlxG.bloom.Settings = BloomPostprocess.BloomSettings.PresetSettings[4];
            }
            if (FlxG.keys.FIVE)
            {
                FlxG.bloom.Settings = BloomPostprocess.BloomSettings.PresetSettings[5];
            }
            if (FlxG.keys.SIX)
            {
                FlxG.bloom.Settings = BloomPostprocess.BloomSettings.PresetSettings[6];
            }
            if (FlxG.keys.SEVEN)
            {
                FlxG.bloom.Settings = BloomPostprocess.BloomSettings.PresetSettings[7];
            }

            foreach (FlxSprite item in rain.members)
            {
                int rainOffset = 0;

                                #if __ANDROID__
                rainOffset = 50;
                                #endif
                if (item.y > 2000 - rainOffset)
                {
                    splashes.at(item);
                    splashes.start(true, 0.0f, 10);

                    item.y = 1200;
                }
            }

            base.update();

            if (instruction.visible)
            {
                if (tween.hasEnded)
                {
                    FlxG.play("Lemonade/sfx/cw_sound09", 0.75f, false);
                }
            }

            tween.Update(FlxG.elapsedAsGameTime);
            instruction.y = tween.Position;

            if (follower.y > 2100)
            {
                credits.visible = true;
            }
            if (follower.y > 2300)
            {
                credits.text = "Pixel Art by\nMiguelito";
            }
            if (follower.y > 2500)
            {
                credits.text = "Dithering Expert\nAndrio";
            }
            if (follower.y > 2700)
            {
                credits.text = "Super";
            }
            if (follower.y > 2900)
            {
                credits.text = "Lemonade";
            }
            if (follower.y > 3000)
            {
                credits.text = "Factory";
            }
            if (follower.y > 3100)
            {
                credits.scale = 5;
                credits.text  = "1989";
            }
            if (follower.y > 3200)
            {
                credits.scale = 2;

                                #if __ANDROID__
                credits.scale = 4;
                                #endif


                credits.text = "Super Lemonade\nFactory 1989";
            }
            if (follower.y > 3300)
            {
                instruction.visible = true;
            }

            if (((follower.y > int.MaxValue && follower.x == 0) ||
                 (FlxG.keys.justPressed(Keys.X) && follower.y > 100) ||
                 (FlxG.gamepads.isNewButtonPress(Buttons.A) && follower.y > 100) || (FlxControl.ACTIONJUSTPRESSED && follower.y > 100)) &&
                (FlxG.transition.members[0] as FlxSprite).scale < 0.001f)
            {
                FlxG.transition.startFadeOut(0.15f, -90, 150);
                follower.x = 1;
            }
            if (FlxG.transition.complete)
            {
                FlxG.level = 1;

                Lemonade_Globals.stateSaver = new Dictionary <string, Dictionary <string, Vector2> >
                {
                    { "newyork", new Dictionary <string, Vector2>() },
                    { "sydney", new Dictionary <string, Vector2>() },
                    { "military", new Dictionary <string, Vector2>() },
                    { "warehouse", new Dictionary <string, Vector2>() },
                    { "factory", new Dictionary <string, Vector2>() },
                    { "management", new Dictionary <string, Vector2>() },
                };

                foreach (var item in Lemonade_Globals.stateSaver)
                {
                    Lemonade_Globals.thisTurnProgress[item.Key] = 0;
                }


                Lemonade_Globals.levelChanges = 0;
                Lemonade_Globals.coins        = 0;
                Lemonade_Globals.timeLeft     = Lemonade_Globals.totalTimeAvailable = 30.1f;

                FlxG.state = new LevelChooserState();

                return;
            }
        }
        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 update()
        {
            #region cheats
            if (FlxG.debug == true && elapsedInState > 0.2f)
            {
            }
            #endregion

            #region pirateVersion

            if (Lemonade_Globals.PAID_VERSION == Lemonade_Globals.PIRATE_MODE)
            {
                if (elapsedInState > 3.0 && FlxG.level > 2)
                {
                    foreach (var item in actors.members)
                    {
                        ((FlxPlatformActor)(item)).maxVelocity.X += 2.5f;
                    }

                    foreach (var mov in movingPlatforms.members)
                    {
                        mov.pathSpeed += 0.25f;
                    }
                }
            }

            #endregion


            //FlxG.color(Color.MediumPurple);


            //FlxU.collideRamp(actors, ramps);

            //if (FlxG.keys.justPressed(Keys.F11))
            if (FlxG.gamepads.isButtonDown(Buttons.LeftTrigger) && FlxG.debug)
            {
                if (coins.getFirstAlive() != null)
                {
                    ((FlxSprite)(actors.members[0])).at(coins.getFirstAlive());
                }
            }

            currentCharHud.canStart = !levelIntro.block.visible;

            if (currentCharHud.canStart)
            {
                ((FlxPlatformActor)(actors.members[0])).control = FlxPlatformActor.Controls.player;
            }
            else if (!currentCharHud.canStart)
            {
                ((FlxPlatformActor)(actors.members[0])).control = FlxPlatformActor.Controls.none;
            }


            if (currentCharHud.time < -0.5f)
            {
                if (Lemonade_Globals.totalTimeAvailable < -0.5f)
                {
                    FlxG.state = new BaseInformationState();
                }
                else
                {
                    goToNextScheduledLevel();
                }
            }


            if (Lemonade_Globals.game_version == 2)
            {
                FlxU.collide(collidableTilemap, actors);
                FlxU.collide(crateParticle, collidableTilemap);
                FlxU.collide(levelItems, collidableTilemap);
                FlxU.collide(smallCrates, collidableTilemap);
            }
            else
            {
                FlxU.collide(collidableTileblocks, actors);
                FlxU.collide(crateParticle, collidableTileblocks);
                FlxU.collide(levelItems, collidableTileblocks);
                FlxU.collide(smallCrates, collidableTileblocks);
            }

            FlxU.overlap(actors, actors, genericOverlap);
            FlxU.overlap(actors, trampolines, trampolinesOverlap);
            FlxU.overlap(actors, levelItems, genericOverlap);
            FlxU.overlap(actors, hazards, genericOverlap);
            FlxU.overlap(actors, coins, genericOverlap);
            FlxU.overlap(actors, smallCrates, genericOverlap);
            FlxU.overlap(smallCrates, trampolines, trampolinesOverlap);

            FlxU.collide(actors, movingPlatforms);
            FlxU.collide(smallCrates, levelItems);

            FlxU.collideOnY(smallCrates, andre);
            FlxU.collideOnY(smallCrates, liselot);

            bool andreExit   = FlxU.overlap(andre, exit, exitOverlap);
            bool liselotExit = FlxU.overlap(liselot, exit, exitOverlap);

            if (andreExit && liselotExit)
            {
                levelComplete = true;
            }

            FlxU.collide(actors, levelItems);

            foreach (FlxObject crate in levelItems.members)
            {
                if (crate.GetType().ToString() == "Lemonade.LargeCrate")
                {
                    if (((LargeCrate)(crate)).canExplode && !crate.dead)
                    {
                        crateParticle.at(crate);
                        crateParticle.start(true, 0.0f, 50);
                        crate.kill();

                        FlxG.play("Lemonade/sfx/cw_sound35", 0.5f, false);
                    }
                }
            }

            base.update();

#if __ANDROID__
            if (FlxG.pauseAction == "Exit")
            {
#if __ANDROID__
                FlxG.state = new IntroState();
#endif
#if !__ANDROID__
                FlxG.state = new EasyMenuState();
#endif
            }
#endif
            if (FlxG.keys.justPressed(Keys.Escape) || FlxG.gamepads.isButtonDown(Buttons.Back))
            {
                                #if __ANDROID__
                FlxG.state = new IntroState();
                                #endif
                                #if !__ANDROID__
                FlxG.state = new BaseInformationState();
                                #endif
            }
            if (levelComplete == true)
            {
                //andre.alpha -= 0.1f;
                //liselot.alpha -= 0.1f;
            }
            if (levelComplete == true && !FlxG.transition.hasStarted)
            {
                if (transitionPause == 0.0f)
                {
                    FlxG.play("initials/initials_empire_tagtone4", 0.8f, false);
                }

                FlxG.pauseMp3();

                andre.control   = FlxPlatformActor.Controls.none;
                liselot.control = FlxPlatformActor.Controls.none;

                andre.visible    = false;
                liselot.visible  = false;
                transitionPause += FlxG.elapsed;

                if (transitionPause > 0.85f)
                {
                    FlxG.transition.startFadeOut(0.05f, -90, 150);
                }
            }
            if (FlxG.transition.complete)
            {
                if (FlxG.level != 12)
                {
                    //FlxG.level++;

                    goToNextScheduledLevel();

                    Lemonade_Globals.restartMusic = false;

                    if (Lemonade_Globals.PAID_VERSION == Lemonade_Globals.DEMO_MODE && FlxG.level >= 3)
                    {
                                                #if __ANDROID__
                        FlxG.state = new IntroState();
                                                #endif
                                                #if !__ANDROID__
                        FlxG.state = new BaseInformationState();
                                                #endif
                        FlxG.transition.resetAndStop();
                        return;
                    }
                    else
                    {
                        Lemonade_Globals.timeLeft = currentCharHud.time;

                        FlxG.transition.resetAndStop();

                        goToNextScheduledLevel();

                        return;
                    }
                }
                if (FlxG.level == 12 && Lemonade_Globals.game_version == 2)
                {
                    FlxG.state = new BaseInformationState();
                    FlxG.transition.resetAndStop();
                    return;
                }
                else if (FlxG.level == 12 && Lemonade_Globals.game_version == 1)
                {
                                        #if __ANDROID__
                    FlxG.state = new IntroState();
                                        #endif
                                        #if !__ANDROID__
                    FlxG.state = new BaseInformationState();
                                        #endif
                    FlxG.transition.resetAndStop();
                    return;
                }
            }

            if (coins.countLiving() == 0 && !FlxG.transition.hasStarted)
            {
                if (Lemonade_Globals.coins == Lemonade_Globals.totalCoins)
                {
                    FlxG.state = new BaseInformationState();
                    return;
                }
                else
                {
                    Lemonade_Globals.thisTurnProgress[Lemonade_Globals.location] = 1;

                    foreach (var item in Lemonade_Globals.thisTurnProgress)
                    {
                        Console.WriteLine("This Location: {0} -- K {1} V {2}", Lemonade_Globals.location, item.Key, item.Value);
                    }


                    FlxG.transition.startFadeOut(0.05f, -90, 150);
                }
            }
        }