コード例 #1
0
        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);
                }
            }
        }