Exemple #1
0
        public static ChallengeSaveData GetSaveData(
            string guid,
            Profile p,
            bool canBeNull = false)
        {
            if (Challenges._saveData.ContainsKey(guid))
            {
                foreach (ChallengeSaveData challengeSaveData in Challenges._saveData[guid])
                {
                    if (challengeSaveData.profileID == p.id)
                    {
                        return(challengeSaveData);
                    }
                }
            }
            else if (canBeNull)
            {
                return((ChallengeSaveData)null);
            }
            ChallengeSaveData element = new ChallengeSaveData();

            element.profileID = p.id;
            element.challenge = guid;
            Challenges._saveData.Add(guid, element);
            return(element);
        }
Exemple #2
0
 public static void Initialize()
 {
     foreach (string level1 in Content.GetLevels("challenge", LevelLocation.Content))
     {
         LevelData level2 = Content.GetLevel(level1);
         string    guid   = level2.metaData.guid;
         foreach (BinaryClassChunk node in level2.objects.objects)
         {
             string property = node.GetProperty <string>("type");
             if (property != null)
             {
                 if (property.Contains("DuckGame.ChallengeMode,"))
                 {
                     try
                     {
                         if (Thing.LoadThing(node, false) is ChallengeMode challengeMode)
                         {
                             challengeMode.challenge.fileName = level1;
                             challengeMode.challenge.levelID  = guid;
                             challengeMode.challenge.preview  = level2.previewData.preview;
                             if (challengeMode.challenge.trophies[5].goodies == -1 && challengeMode.challenge.trophies[5].targets == -1)
                             {
                                 int timeRequirement = challengeMode.challenge.trophies[5].timeRequirement;
                             }
                             Challenges._challenges.Add(level2.metaData.guid, challengeMode.challenge);
                         }
                     }
                     catch (Exception ex)
                     {
                     }
                 }
             }
         }
     }
     foreach (string file in DuckFile.GetFiles(DuckFile.challengeDirectory))
     {
         XDocument xdocument = DuckFile.LoadXDocument(file);
         if (xdocument != null)
         {
             string   withoutExtension = Path.GetFileNameWithoutExtension(file);
             XElement xelement         = xdocument.Element((XName)"Data");
             if (xelement != null)
             {
                 foreach (XElement element1 in xelement.Elements((XName)"challengeSaveData"))
                 {
                     ChallengeSaveData element2 = new ChallengeSaveData();
                     element2.LegacyDeserialize(element1);
                     element2.challenge = withoutExtension;
                     Challenges._saveData.Add(withoutExtension, element2);
                 }
             }
         }
     }
 }
Exemple #3
0
        public static int GetNumTrophies(Profile p)
        {
            int num = 0;

            foreach (KeyValuePair <string, ChallengeData> challenge in Challenges._challenges)
            {
                ChallengeSaveData saveData = Challenges.GetSaveData(challenge.Value.levelID, p, true);
                if (saveData != null && saveData.trophy != TrophyType.Baseline)
                {
                    ++num;
                }
            }
            return(num);
        }
Exemple #4
0
        public static List <ChallengeData> GetEligibleIncompleteChancyChallenges(
            Profile p)
        {
            List <ChallengeData> chancyChallenges  = Challenges.GetEligibleChancyChallenges(p);
            List <ChallengeData> challengeDataList = new List <ChallengeData>();

            foreach (ChallengeData challengeData in chancyChallenges)
            {
                ChallengeSaveData saveData = Challenges.GetSaveData(challengeData.levelID, Profiles.active[0], true);
                if (saveData == null || saveData.trophy < TrophyType.Bronze)
                {
                    challengeDataList.Add(challengeData);
                }
            }
            return(challengeDataList);
        }
Exemple #5
0
        public static int GetTicketCount(Profile p)
        {
            int num = 0;

            foreach (KeyValuePair <string, ChallengeData> challenge in Challenges._challenges)
            {
                if (Challenges.challengesInArcade.Contains(challenge.Value))
                {
                    ChallengeSaveData saveData = Challenges.GetSaveData(challenge.Value.levelID, p, true);
                    if (saveData != null)
                    {
                        if (saveData.trophy >= TrophyType.Bronze)
                        {
                            num += Challenges.valueBronze;
                        }
                        if (saveData.trophy >= TrophyType.Silver)
                        {
                            num += Challenges.valueSilver;
                        }
                        if (saveData.trophy >= TrophyType.Gold)
                        {
                            num += Challenges.valueGold;
                        }
                        if (saveData.trophy >= TrophyType.Platinum)
                        {
                            num += Challenges.valuePlatinum;
                        }
                    }
                }
            }
            foreach (UnlockData unlock in Unlocks.GetUnlocks(UnlockType.Any))
            {
                if (unlock.ProfileUnlocked(p))
                {
                    num -= unlock.cost;
                }
            }
            return(num);
        }
Exemple #6
0
        public static float GetChallengeSkillIndex()
        {
            int num1 = 0;
            int num2 = 0;
            List <ChallengeData> available = new List <ChallengeData>();

            if (!(Level.current is ArcadeLevel arcadeLevel))
            {
                arcadeLevel = ArcadeLevel.currentArcade;
            }
            if (arcadeLevel == null)
            {
                return(0.0f);
            }
            foreach (ArcadeMachine challenge1 in arcadeLevel._challenges)
            {
                foreach (string challenge2 in challenge1.data.challenges)
                {
                    available.Add(Challenges.GetChallenge(challenge2));
                }
            }
            foreach (ChallengeData allChancyChallenge in Challenges.GetAllChancyChallenges(available))
            {
                available.Add(allChancyChallenge);
            }
            foreach (KeyValuePair <string, ChallengeData> challenge in Challenges._challenges)
            {
                if (available.Contains(challenge.Value))
                {
                    num2 += 4;
                    ChallengeSaveData saveData = Challenges.GetSaveData(challenge.Value.levelID, Profiles.active[0], true);
                    if (saveData != null)
                    {
                        num1 += (int)saveData.trophy;
                    }
                }
            }
            return((float)num1 / (float)num2);
        }
Exemple #7
0
        public static List <ChallengeData> GetEligibleChancyChallenges(Profile p)
        {
            List <ChallengeData> challengeDataList = new List <ChallengeData>();

            foreach (KeyValuePair <string, ChallengeData> challenge in Challenges.challenges)
            {
                if (challenge.Value.requirement != "" && challenge.Value.CheckRequirement(p))
                {
                    if (challenge.Value.prevchal != "")
                    {
                        ChallengeSaveData saveData = Challenges.GetSaveData(Challenges.GetChallenge(challenge.Value.prevchal).levelID, p, true);
                        if (saveData != null && saveData.trophy > TrophyType.Baseline)
                        {
                            challengeDataList.Add(challenge.Value);
                        }
                    }
                    else
                    {
                        challengeDataList.Add(challenge.Value);
                    }
                }
            }
            return(challengeDataList);
        }
Exemple #8
0
        public override void Update()
        {
            Options.openOnClose = this._pauseMenu;
            if (this.spawnKey)
            {
                if ((double)this.spawnKeyWait > 0.0)
                {
                    this.spawnKeyWait -= Maths.IncFrameTimer();
                }
                else
                {
                    SFX.Play("ching");
                    this.spawnKey = false;
                    Key key = new Key(this._prizeTable.x, this._prizeTable.y);
                    key.vSpeed = -4f;
                    key.depth  = this._duck.depth + 50;
                    Level.Add((Thing)SmallSmoke.New(key.x + Rando.Float(-4f, 4f), key.y + Rando.Float(-4f, 4f)));
                    Level.Add((Thing)SmallSmoke.New(key.x + Rando.Float(-4f, 4f), key.y + Rando.Float(-4f, 4f)));
                    Level.Add((Thing)SmallSmoke.New(key.x + Rando.Float(-4f, 4f), key.y + Rando.Float(-4f, 4f)));
                    Level.Add((Thing)SmallSmoke.New(key.x + Rando.Float(-4f, 4f), key.y + Rando.Float(-4f, 4f)));
                    Level.Add((Thing)key);
                }
            }
            Chancy.Update();
            if (this._pendingSpawns != null && this._pendingSpawns.Count > 0)
            {
                Duck pendingSpawn = this._pendingSpawns[0];
                this.AddThing((Thing)pendingSpawn);
                this._pendingSpawns.RemoveAt(0);
                this._duck   = pendingSpawn;
                this._arcade = this.things[typeof(ArcadeMode)].First <Thing>() as ArcadeMode;
            }
            Layer.Lighting.fade  = Layer.Lighting2.fade = 1f - Math.Min(1f, Math.Max(0.0f, (float)((1.0 - (double)Layer.Game.fade) * 1.5)));
            this.backgroundColor = Color.Black;
            if (UnlockScreen.open || ArcadeHUD.open)
            {
                foreach (Thing challenge in this._challenges)
                {
                    challenge.visible = false;
                }
                this._prizeTable.visible = false;
            }
            else
            {
                foreach (Thing challenge in this._challenges)
                {
                    challenge.visible = true;
                }
                this._prizeTable.visible = true;
            }
            if (this._state == this._desiredState && this._state != ArcadeState.UnlockMachine && this._state != ArcadeState.LaunchChallenge)
            {
                if (!this._quitting)
                {
                    if (Input.Pressed("START"))
                    {
                        this._pauseGroup.Open();
                        this._pauseMenu.Open();
                        MonoMain.pauseMenu = this._pauseGroup;
                        if (!this._paused)
                        {
                            Music.Pause();
                            SFX.Play("pause", 0.6f);
                            this._paused           = true;
                            this._duck.immobilized = true;
                        }
                        this.simulatePhysics = false;
                        return;
                    }
                    if (this._paused && MonoMain.pauseMenu == null)
                    {
                        this._paused = false;
                        SFX.Play("resume", 0.6f);
                        if (this._quit.value)
                        {
                            this._quitting = true;
                        }
                        else
                        {
                            Music.Resume();
                            this._duck.immobilized = false;
                            this.simulatePhysics   = true;
                        }
                    }
                }
                else
                {
                    Graphics.fade = Lerp.Float(Graphics.fade, 0.0f, 0.02f);
                    if ((double)Graphics.fade > 0.00999999977648258)
                    {
                        return;
                    }
                    Level.current = (Level) new TitleScreen();
                    return;
                }
            }
            if (this._paused)
            {
                return;
            }
            if (this._hud.launchChallenge)
            {
                this._desiredState = ArcadeState.LaunchChallenge;
            }
            if (this._desiredState != this._state)
            {
                this._duck.active = false;
                bool flag = false;
                if (this._desiredState == ArcadeState.ViewChallenge)
                {
                    this._duck.alpha = Lerp.FloatSmooth(this._duck.alpha, 0.0f, 0.1f);
                    this._followCam.manualViewSize = Lerp.FloatSmooth(this._followCam.manualViewSize, 2f, 0.16f);
                    if ((double)this._followCam.manualViewSize < 30.0)
                    {
                        Layer.Game.fade       = Lerp.Float(Layer.Game.fade, 0.0f, 0.08f);
                        Layer.Background.fade = Lerp.Float(Layer.Game.fade, 0.0f, 0.08f);
                        this._hud.alpha       = Lerp.Float(this._hud.alpha, 1f, 0.08f);
                        if ((double)this._followCam.manualViewSize < 3.0 && (double)this._hud.alpha == 1.0 && (double)Layer.Game.fade == 0.0)
                        {
                            flag = true;
                        }
                    }
                }
                else if (this._desiredState == ArcadeState.Normal)
                {
                    if (!this._flipState)
                    {
                        this._followCam.Clear();
                        this._followCam.Add((Thing)this._duck);
                        HUD.CloseAllCorners();
                    }
                    this._duck.alpha = Lerp.FloatSmooth(this._duck.alpha, 1f, 0.1f, 1.1f);
                    if (this._state == ArcadeState.ViewChallenge || this._state == ArcadeState.UnlockScreen)
                    {
                        this._followCam.manualViewSize = Lerp.FloatSmooth(this._followCam.manualViewSize, this._followCam.viewSize, 0.14f, 1.05f);
                    }
                    Layer.Game.fade          = Lerp.Float(Layer.Game.fade, 1f, 0.05f);
                    Layer.Background.fade    = Lerp.Float(Layer.Game.fade, 1f, 0.05f);
                    this._hud.alpha          = Lerp.Float(this._hud.alpha, 0.0f, 0.08f);
                    this._unlockScreen.alpha = Lerp.Float(this._unlockScreen.alpha, 0.0f, 0.08f);
                    if (((double)this._followCam.manualViewSize < 0.0 || (double)this._followCam.manualViewSize == (double)this._followCam.viewSize) && ((double)this._hud.alpha == 0.0 && (double)Layer.Game.fade == 1.0))
                    {
                        flag = true;
                        this._followCam.manualViewSize = -1f;
                        this._duck.alpha = 1f;
                    }
                    if (Unlockables.HasPendingUnlocks())
                    {
                        MonoMain.pauseMenu = (UIComponent) new UIUnlockBox(Unlockables.GetPendingUnlocks().ToList <Unlockable>(), Layer.HUD.camera.width / 2f, Layer.HUD.camera.height / 2f, 190f);
                    }
                }
                else if (this._desiredState == ArcadeState.ViewSpecialChallenge || this._desiredState == ArcadeState.ViewChallengeList || this._desiredState == ArcadeState.ViewProfileSelector)
                {
                    if (!this._flipState)
                    {
                        this._followCam.Clear();
                        this._followCam.Add((Thing)this._duck);
                        HUD.CloseAllCorners();
                    }
                    this._duck.alpha = Lerp.FloatSmooth(this._duck.alpha, 1f, 0.1f, 1.1f);
                    if (this._state == ArcadeState.ViewChallenge || this._state == ArcadeState.UnlockScreen)
                    {
                        this._followCam.manualViewSize = Lerp.FloatSmooth(this._followCam.manualViewSize, this._followCam.viewSize, 0.14f, 1.05f);
                    }
                    Layer.Game.fade          = Lerp.Float(Layer.Game.fade, 1f, 0.05f);
                    Layer.Background.fade    = Lerp.Float(Layer.Game.fade, 1f, 0.05f);
                    this._hud.alpha          = Lerp.Float(this._hud.alpha, 0.0f, 0.08f);
                    this._unlockScreen.alpha = Lerp.Float(this._unlockScreen.alpha, 0.0f, 0.08f);
                    if (((double)this._followCam.manualViewSize < 0.0 || (double)this._followCam.manualViewSize == (double)this._followCam.viewSize) && ((double)this._hud.alpha == 0.0 && (double)Layer.Game.fade == 1.0))
                    {
                        flag = true;
                        this._followCam.manualViewSize = -1f;
                        this._duck.alpha = 1f;
                    }
                }
                else if (this._desiredState == ArcadeState.UnlockMachine)
                {
                    if (!this._flipState)
                    {
                        this._followCam.Clear();
                        this._followCam.Add((Thing)this._unlockMachines[0]);
                        HUD.CloseAllCorners();
                    }
                    if (this._state == ArcadeState.ViewChallenge)
                    {
                        this._followCam.manualViewSize = Lerp.FloatSmooth(this._followCam.manualViewSize, this._followCam.viewSize, 0.14f, 1.05f);
                    }
                    this._duck.alpha         = Lerp.FloatSmooth(this._duck.alpha, 1f, 0.1f, 1.1f);
                    Layer.Game.fade          = Lerp.Float(Layer.Game.fade, 1f, 0.05f);
                    Layer.Background.fade    = Lerp.Float(Layer.Game.fade, 1f, 0.05f);
                    this._hud.alpha          = Lerp.Float(this._hud.alpha, 0.0f, 0.08f);
                    this._unlockScreen.alpha = Lerp.Float(this._unlockScreen.alpha, 0.0f, 0.08f);
                    this._unlockMachineWait  = 1f;
                    if (((double)this._followCam.manualViewSize < 0.0 || (double)this._followCam.manualViewSize == (double)this._followCam.viewSize) && ((double)this._hud.alpha == 0.0 && (double)Layer.Game.fade == 1.0))
                    {
                        flag = true;
                        this._followCam.manualViewSize = -1f;
                        this._duck.alpha = 1f;
                    }
                }
                else if (this._desiredState == ArcadeState.LaunchChallenge)
                {
                    if (!this._flipState)
                    {
                        HUD.CloseAllCorners();
                    }
                    Music.volume             = Lerp.Float(Music.volume, 0.0f, 0.01f);
                    this._hud.alpha          = Lerp.Float(this._hud.alpha, 0.0f, 0.02f);
                    this._unlockScreen.alpha = Lerp.Float(this._unlockScreen.alpha, 0.0f, 0.08f);
                    if ((double)this._hud.alpha == 0.0)
                    {
                        flag = true;
                    }
                }
                if (this._desiredState == ArcadeState.UnlockScreen)
                {
                    this._duck.alpha = Lerp.FloatSmooth(this._duck.alpha, 0.0f, 0.1f);
                    this._followCam.manualViewSize = Lerp.FloatSmooth(this._followCam.manualViewSize, 2f, 0.16f);
                    if ((double)this._followCam.manualViewSize < 30.0)
                    {
                        Layer.Game.fade          = Lerp.Float(Layer.Game.fade, 0.0f, 0.08f);
                        Layer.Background.fade    = Lerp.Float(Layer.Game.fade, 0.0f, 0.08f);
                        this._unlockScreen.alpha = Lerp.Float(this._unlockScreen.alpha, 1f, 0.08f);
                        if ((double)this._followCam.manualViewSize < 3.0 && (double)this._unlockScreen.alpha == 1.0 && (double)Layer.Game.fade == 0.0)
                        {
                            flag = true;
                        }
                    }
                }
                this._flipState = true;
                if (this._launchedChallenge)
                {
                    Layer.Background.fade = 0.0f;
                    Layer.Game.fade       = 0.0f;
                }
                if (!flag)
                {
                    return;
                }
                this._flipState = false;
                HUD.CloseAllCorners();
                this._state = this._desiredState;
                if (this._state == ArcadeState.ViewChallenge)
                {
                    if (this._afterChallenge)
                    {
                        Music.Play("Arcade");
                        this._afterChallenge = false;
                    }
                    this._hud.MakeActive();
                    Level.Add((Thing)this._hud);
                    this._duck.active = false;
                }
                else if (this._state == ArcadeState.LaunchChallenge)
                {
                    ArcadeLevel.currentArcade = this;
                    foreach (Thing thing in this.things[typeof(ChallengeConfetti)])
                    {
                        Level.Remove(thing);
                    }
                    Music.Stop();
                    Level.current = (Level) new ChallengeLevel(this._hud.selected.challenge.fileName);
                    if (!this.launchSpecialChallenge)
                    {
                        this._desiredState        = ArcadeState.ViewChallenge;
                        this._hud.launchChallenge = false;
                        this._launchedChallenge   = false;
                        this._afterChallenge      = true;
                    }
                    else
                    {
                        this._desiredState          = ArcadeState.ViewSpecialChallenge;
                        this._hud.launchChallenge   = false;
                        this._launchedChallenge     = false;
                        this._afterChallenge        = true;
                        this.launchSpecialChallenge = false;
                    }
                }
                else
                {
                    if (this._state == ArcadeState.UnlockMachine)
                    {
                        return;
                    }
                    if (this._state == ArcadeState.Normal)
                    {
                        this._unlockMachines.Clear();
                        foreach (ArcadeMachine challenge in this._challenges)
                        {
                            if (challenge.CheckUnlocked())
                            {
                                this._unlockMachines.Add(challenge);
                            }
                        }
                        if (this._unlockMachines.Count > 0)
                        {
                            this._desiredState = ArcadeState.UnlockMachine;
                        }
                        else
                        {
                            if (!this.basementWasUnlocked && Unlocks.IsUnlocked("BASEMENTKEY", Profiles.active[0]))
                            {
                                this.spawnKey            = true;
                                this.basementWasUnlocked = true;
                            }
                            this._duck.active = true;
                        }
                    }
                    else if (this._state == ArcadeState.ViewSpecialChallenge)
                    {
                        this._duck.active = false;
                        if (this._afterChallenge)
                        {
                            Music.Play("Arcade");
                            this._afterChallenge = false;
                            HUD.AddCornerCounter(HUDCorner.TopLeft, "@TICKET@ ", new FieldBinding((object)Profiles.active[0], "ticketCount"), animateCount: true);
                            Chancy.afterChallenge     = true;
                            Chancy.afterChallengeWait = 1f;
                        }
                        else
                        {
                            HUD.AddCornerControl(HUDCorner.BottomLeft, "ACCEPT@SELECT@");
                            HUD.AddCornerControl(HUDCorner.BottomRight, "@QUACK@CANCEL");
                            HUD.AddCornerCounter(HUDCorner.TopLeft, "@TICKET@ ", new FieldBinding((object)Profiles.active[0], "ticketCount"), animateCount: true);
                        }
                        this._duck.active = false;
                    }
                    else if (this._state == ArcadeState.ViewProfileSelector)
                    {
                        this._duck.active = false;
                        ArcadeHatConsole arcadeHatConsole = (ArcadeHatConsole)Level.First <ArcadeHatConsole>();
                        if (arcadeHatConsole == null)
                        {
                            return;
                        }
                        HUD.CloseAllCorners();
                        arcadeHatConsole.Open();
                    }
                    else if (this._state == ArcadeState.ViewChallengeList)
                    {
                        this._duck.active = false;
                        HUD.AddCornerControl(HUDCorner.BottomLeft, "ACCEPT@SELECT@");
                        HUD.AddCornerControl(HUDCorner.BottomRight, "@QUACK@BACK");
                    }
                    else
                    {
                        if (this._state != ArcadeState.UnlockScreen)
                        {
                            return;
                        }
                        this.basementWasUnlocked = Unlocks.IsUnlocked("BASEMENTKEY", Profiles.active[0]);
                        this._unlockScreen.MakeActive();
                        this._duck.active = false;
                    }
                }
            }
            else if (this._state == ArcadeState.Normal || this._state == ArcadeState.UnlockMachine)
            {
                Layer.Game.fade       = Lerp.Float(Layer.Game.fade, 1f, 0.08f);
                Layer.Background.fade = Lerp.Float(Layer.Game.fade, 1f, 0.08f);
                this._hud.alpha       = Lerp.Float(this._hud.alpha, 0.0f, 0.08f);
                if (this._state == ArcadeState.Normal)
                {
                    object obj = (object)null;
                    foreach (ArcadeMachine challenge in this._challenges)
                    {
                        double length = (double)(this._duck.position - challenge.position).length;
                        if (challenge.hover)
                        {
                            obj = (object)challenge;
                            if (Input.Pressed("SHOOT"))
                            {
                                this._hud.activeChallengeGroup = challenge.data;
                                this._desiredState             = ArcadeState.ViewChallenge;
                                this._followCam.manualViewSize = this._followCam.viewSize;
                                this._followCam.Clear();
                                this._followCam.Add((Thing)challenge);
                                HUD.CloseAllCorners();
                                this._hoverMachine = (ArcadeMachine)null;
                                this._hoverThing   = (object)null;
                                return;
                            }
                        }
                        if (this._prizeTable.hover)
                        {
                            obj = (object)this._prizeTable;
                            if (Input.Pressed("SHOOT"))
                            {
                                this._desiredState             = ArcadeState.UnlockScreen;
                                this._followCam.manualViewSize = this._followCam.viewSize;
                                this._followCam.Clear();
                                this._followCam.Add((Thing)this._prizeTable);
                                HUD.CloseAllCorners();
                                this._hoverMachine = (ArcadeMachine)null;
                                this._hoverThing   = (object)null;
                                return;
                            }
                        }
                    }
                    if (Chancy.hover && Input.Pressed("SHOOT"))
                    {
                        this._desiredState = ArcadeState.ViewSpecialChallenge;
                        HUD.CloseAllCorners();
                        this._hoverMachine        = (ArcadeMachine)null;
                        this._hoverThing          = (object)null;
                        Chancy.hover              = false;
                        Chancy.lookingAtChallenge = true;
                        Chancy.OpenChallengeView();
                    }
                    else
                    {
                        ArcadeHatConsole arcadeHatConsole = (ArcadeHatConsole)Level.First <ArcadeHatConsole>();
                        if (arcadeHatConsole != null && Input.Pressed("SHOOT") && arcadeHatConsole.hover)
                        {
                            this._desiredState = ArcadeState.ViewProfileSelector;
                            HUD.CloseAllCorners();
                            this._hoverMachine = (ArcadeMachine)null;
                            this._hoverThing   = (object)null;
                        }
                        else
                        {
                            Chancy.hover = false;
                            if (!Chancy.atCounter)
                            {
                                if ((double)(this._duck.position - Chancy.standingPosition).length < 22.0)
                                {
                                    obj          = (object)Chancy.context;
                                    Chancy.hover = true;
                                }
                                if ((double)Chancy.standingPosition.x < (double)Layer.Game.camera.left - 16.0 || (double)Chancy.standingPosition.x > (double)Layer.Game.camera.right + 16.0 || ((double)Chancy.standingPosition.y < (double)Layer.Game.camera.top - 16.0 || (double)Chancy.standingPosition.y > (double)Layer.Game.camera.bottom + 16.0))
                                {
                                    Chancy.atCounter       = true;
                                    Chancy.activeChallenge = (ChallengeData)null;
                                }
                            }
                            else if (this._prizeTable.hoverChancyChallenge)
                            {
                                obj = (object)this._arcade;
                                if (Input.Pressed("SHOOT"))
                                {
                                    this._desiredState = ArcadeState.ViewChallengeList;
                                    HUD.CloseAllCorners();
                                    Chancy.OpenChallengeList();
                                    this._hoverMachine   = (ArcadeMachine)null;
                                    this._hoverThing     = (object)null;
                                    Chancy.hover         = false;
                                    Chancy.lookingAtList = true;
                                    return;
                                }
                            }
                            if (this._hoverThing == obj)
                            {
                                return;
                            }
                            HUD.CloseAllCorners();
                            this._hoverThing   = obj;
                            this._hoverMachine = !(this._hoverThing is ArcadeMachine) ? (ArcadeMachine)null : obj as ArcadeMachine;
                            if (this._hoverMachine != null)
                            {
                                HUD.AddCornerControl(HUDCorner.BottomLeft, "PLAY@SHOOT@");
                                string text = this._hoverMachine.data.name + " ";
                                foreach (string challenge1 in this._hoverMachine.data.challenges)
                                {
                                    ChallengeData challenge2 = Challenges.GetChallenge(challenge1);
                                    if (challenge2 != null)
                                    {
                                        ChallengeSaveData saveData = Challenges.GetSaveData(challenge2.levelID, this._duck.profile);
                                        if (saveData.trophy == TrophyType.Baseline)
                                        {
                                            text += "@BASELINE@";
                                        }
                                        else if (saveData.trophy == TrophyType.Bronze)
                                        {
                                            text += "@BRONZE@";
                                        }
                                        else if (saveData.trophy == TrophyType.Silver)
                                        {
                                            text += "@SILVER@";
                                        }
                                        else if (saveData.trophy == TrophyType.Gold)
                                        {
                                            text += "@GOLD@";
                                        }
                                        else if (saveData.trophy == TrophyType.Platinum)
                                        {
                                            text += "@PLATINUM@";
                                        }
                                        else if (saveData.trophy == TrophyType.Developer)
                                        {
                                            text += "@DEVELOPER@";
                                        }
                                    }
                                }
                                HUD.AddCornerMessage(HUDCorner.TopLeft, text);
                            }
                            else if (this._prizeTable.hover)
                            {
                                if (this._prizeTable.hoverChancyChallenge)
                                {
                                    HUD.AddCornerControl(HUDCorner.BottomRight, "@SHOOT@VIEW CHALLENGES");
                                }
                                else
                                {
                                    HUD.AddCornerControl(HUDCorner.BottomRight, "@SHOOT@SPEND TICKETS");
                                    HUD.AddCornerCounter(HUDCorner.BottomLeft, "@TICKET@ ", new FieldBinding((object)Profiles.active[0], "ticketCount"), animateCount: true);
                                }
                            }
                            else
                            {
                                switch (obj)
                                {
                                case ArcadeMode _:
                                    if (!this._prizeTable.hoverChancyChallenge)
                                    {
                                        break;
                                    }
                                    HUD.AddCornerControl(HUDCorner.BottomRight, "@SHOOT@VIEW CHALLENGES");
                                    break;

                                case Chancy _:
                                    HUD.AddCornerControl(HUDCorner.BottomLeft, "CHANCY@SHOOT@");
                                    break;
                                }
                            }
                        }
                    }
                }
                else
                {
                    if (this._state != ArcadeState.UnlockMachine)
                    {
                        return;
                    }
                    this._unlockMachineWait   -= 0.02f;
                    Layer.Lighting2.targetFade = Lerp.Float(Layer.Lighting2.targetFade, 0.5f, 0.01f);
                    if ((double)this._unlockMachineWait >= 0.0)
                    {
                        return;
                    }
                    if (this._unlockingMachine)
                    {
                        this._unlockingMachine = false;
                        this._followCam.Clear();
                        this._followCam.Add((Thing)this._unlockMachines[0]);
                        this._unlockMachineWait = 1f;
                    }
                    else if (this._unlockMachines.Count > 0)
                    {
                        this._unlockMachines[0].unlocked = true;
                        this._unlockMachines.RemoveAt(0);
                        this._unlockingMachine = this._unlockMachines.Count > 0;
                        SFX.Play("lightTurnOn", pitch: Rando.Float(-0.1f, 0.1f));
                        this._unlockMachineWait    = 1f;
                        Layer.Lighting2.targetFade = 1f;
                    }
                    else
                    {
                        this._desiredState = ArcadeState.Normal;
                    }
                }
            }
            else if (this._state == ArcadeState.ViewChallenge)
            {
                Graphics.fade         = Lerp.Float(Graphics.fade, 1f, 0.05f);
                Layer.Game.fade       = Lerp.Float(Layer.Game.fade, 0.0f, 0.05f);
                Layer.Background.fade = Lerp.Float(Layer.Game.fade, 0.0f, 0.05f);
                this._hud.alpha       = Lerp.Float(this._hud.alpha, 1f, 0.05f);
                if (!this._hud.quitOut)
                {
                    return;
                }
                this._hud.quitOut  = false;
                this._desiredState = ArcadeState.Normal;
                if (Chancy.activeChallenge != null)
                {
                    return;
                }
                List <ChallengeData> chancyChallenges = Challenges.GetEligibleIncompleteChancyChallenges(Profiles.active[0]);
                if (chancyChallenges.Count <= 0)
                {
                    return;
                }
                Vec2          position      = this._duck.position;
                ArcadeMachine arcadeMachine = Level.Nearest <ArcadeMachine>(this._duck.x, this._duck.y);
                if (arcadeMachine != null)
                {
                    position = arcadeMachine.position;
                }
                chancyChallenges.OrderBy <ChallengeData, int>((Func <ChallengeData, int>)(v => v.GetRequirementValue()));
                Chancy.AddProposition(chancyChallenges[chancyChallenges.Count - 1], position);
            }
            else if (this._state == ArcadeState.UnlockScreen)
            {
                if (!this._unlockScreen.quitOut)
                {
                    return;
                }
                this._unlockScreen.quitOut = false;
                this._desiredState         = ArcadeState.Normal;
            }
            else if (this._state == ArcadeState.ViewSpecialChallenge)
            {
                if (!this.launchSpecialChallenge)
                {
                    Graphics.fade = Lerp.Float(Graphics.fade, 1f, 0.05f);
                    if (Input.Pressed("QUACK"))
                    {
                        if (this.returnToChallengeList)
                        {
                            this._desiredState   = ArcadeState.ViewChallengeList;
                            Chancy.hover         = false;
                            Chancy.lookingAtList = true;
                        }
                        else
                        {
                            this._desiredState = ArcadeState.Normal;
                        }
                        Chancy.lookingAtChallenge = false;
                        HUD.CloseAllCorners();
                        SFX.Play("consoleCancel");
                    }
                    else
                    {
                        if (!Input.Pressed("SELECT"))
                        {
                            return;
                        }
                        this.launchSpecialChallenge = true;
                        SFX.Play("consoleSelect");
                    }
                }
                else
                {
                    Graphics.fade = Lerp.Float(Graphics.fade, 0.0f, 0.05f);
                    if ((double)Graphics.fade >= 0.00999999977648258)
                    {
                        return;
                    }
                    this._hud.launchChallenge = true;
                    this._hud.selected        = new ChallengeCard(0.0f, 0.0f, Chancy.activeChallenge);
                    HUD.CloseAllCorners();
                }
            }
            else if (this._state == ArcadeState.ViewChallengeList)
            {
                Graphics.fade = Lerp.Float(Graphics.fade, 1f, 0.05f);
                if (Input.Pressed("QUACK"))
                {
                    this._desiredState        = ArcadeState.Normal;
                    Chancy.lookingAtChallenge = false;
                    Chancy.lookingAtList      = false;
                    HUD.CloseAllCorners();
                    SFX.Play("consoleCancel");
                }
                else
                {
                    if (!Input.Pressed("SELECT"))
                    {
                        return;
                    }
                    Chancy.AddProposition(Chancy.selectedChallenge, Chancy.standingPosition);
                    this.returnToChallengeList = true;
                    this._desiredState         = ArcadeState.ViewSpecialChallenge;
                    HUD.CloseAllCorners();
                    this._hoverMachine        = (ArcadeMachine)null;
                    this._hoverThing          = (object)null;
                    Chancy.hover              = false;
                    Chancy.lookingAtChallenge = true;
                    Chancy.lookingAtList      = false;
                    Chancy.OpenChallengeView();
                }
            }
            else
            {
                if (this._state != ArcadeState.ViewProfileSelector)
                {
                    return;
                }
                Graphics.fade = Lerp.Float(Graphics.fade, 1f, 0.05f);
                ArcadeHatConsole arcadeHatConsole = (ArcadeHatConsole)Level.First <ArcadeHatConsole>();
                if (arcadeHatConsole == null || arcadeHatConsole.IsOpen())
                {
                    return;
                }
                foreach (ArcadeMachine challenge in this._challenges)
                {
                    challenge.unlocked = challenge.CheckUnlocked(false);
                }
                this._unlockMachines.Clear();
                this.UpdateDefault();
                this._desiredState = ArcadeState.Normal;
            }
        }
 public override void Update()
 {
     this.backgroundColor = Color.Black;
     if (UnlockScreen.open || ArcadeHUD.open)
     {
         this._background.visible = false;
         foreach (Thing challenge in this._challenges)
         {
             challenge.visible = false;
         }
         this._prizeTable.visible = false;
     }
     else
     {
         this._background.visible = true;
         foreach (Thing challenge in this._challenges)
         {
             challenge.visible = true;
         }
         this._prizeTable.visible = true;
     }
     if (this._state == this._desiredState && this._state != ArcadeState.UnlockMachine && this._state != ArcadeState.LaunchChallenge)
     {
         if (!this._quitting)
         {
             if (Input.Pressed("START"))
             {
                 this._pauseGroup.Open();
                 this._pauseMenu.Open();
                 MonoMain.pauseMenu = this._pauseGroup;
                 if (!this._paused)
                 {
                     Music.Pause();
                     SFX.Play("pause", 0.6f);
                     this._paused           = true;
                     this._duck.immobilized = true;
                 }
                 this.simulatePhysics = false;
                 return;
             }
             if (this._paused && MonoMain.pauseMenu == null)
             {
                 this._paused = false;
                 SFX.Play("resume", 0.6f);
                 if (this._quit.value)
                 {
                     this._quitting = true;
                 }
                 else
                 {
                     Music.Resume();
                     this._duck.immobilized = false;
                     this.simulatePhysics   = true;
                 }
             }
         }
         else
         {
             Graphics.fade = Lerp.Float(Graphics.fade, 0.0f, 0.02f);
             if ((double)Graphics.fade <= 0.00999999977648258)
             {
                 Level.current = (Level) new TitleScreen();
             }
         }
     }
     if (this._paused)
     {
         return;
     }
     this._hud.Update();
     if (this._hud.launchChallenge)
     {
         this._desiredState = ArcadeState.LaunchChallenge;
     }
     if (this._desiredState != this._state)
     {
         this._duck.active = false;
         bool flag = false;
         if (this._desiredState == ArcadeState.ViewChallenge)
         {
             this._duck.alpha = Lerp.FloatSmooth(this._duck.alpha, 0.0f, 0.1f);
             this._followCam.manualViewSize = Lerp.FloatSmooth(this._followCam.manualViewSize, 2f, 0.16f);
             if ((double)this._followCam.manualViewSize < 30.0)
             {
                 Layer.Game.fade       = Lerp.Float(Layer.Game.fade, 0.0f, 0.08f);
                 Layer.Background.fade = Lerp.Float(Layer.Game.fade, 0.0f, 0.08f);
                 this._hud.alpha       = Lerp.Float(this._hud.alpha, 1f, 0.08f);
                 if ((double)this._followCam.manualViewSize < 3.0 && (double)this._hud.alpha == 1.0 && (double)Layer.Game.fade == 0.0)
                 {
                     flag = true;
                 }
             }
         }
         else if (this._desiredState == ArcadeState.Normal)
         {
             if (!this._flipState)
             {
                 this._followCam.Clear();
                 this._followCam.Add((Thing)this._duck);
                 HUD.CloseAllCorners();
             }
             this._duck.alpha = Lerp.FloatSmooth(this._duck.alpha, 1f, 0.1f, 1.1f);
             if (this._state == ArcadeState.ViewChallenge || this._state == ArcadeState.UnlockScreen)
             {
                 this._followCam.manualViewSize = Lerp.FloatSmooth(this._followCam.manualViewSize, this._followCam.viewSize, 0.14f, 1.05f);
             }
             Layer.Game.fade          = Lerp.Float(Layer.Game.fade, 1f, 0.05f);
             Layer.Background.fade    = Lerp.Float(Layer.Game.fade, 1f, 0.05f);
             this._hud.alpha          = Lerp.Float(this._hud.alpha, 0.0f, 0.08f);
             this._unlockScreen.alpha = Lerp.Float(this._unlockScreen.alpha, 0.0f, 0.08f);
             if (((double)this._followCam.manualViewSize < 0.0 || (double)this._followCam.manualViewSize == (double)this._followCam.viewSize) && ((double)this._hud.alpha == 0.0 && (double)Layer.Game.fade == 1.0))
             {
                 flag = true;
                 this._followCam.manualViewSize = -1f;
                 this._duck.alpha = 1f;
             }
         }
         else if (this._desiredState == ArcadeState.UnlockMachine)
         {
             if (!this._flipState)
             {
                 this._followCam.Clear();
                 this._followCam.Add((Thing)this._unlockMachines[0]);
                 HUD.CloseAllCorners();
             }
             if (this._state == ArcadeState.ViewChallenge)
             {
                 this._followCam.manualViewSize = Lerp.FloatSmooth(this._followCam.manualViewSize, this._followCam.viewSize, 0.14f, 1.05f);
             }
             this._duck.alpha         = Lerp.FloatSmooth(this._duck.alpha, 1f, 0.1f, 1.1f);
             Layer.Game.fade          = Lerp.Float(Layer.Game.fade, 1f, 0.05f);
             Layer.Background.fade    = Lerp.Float(Layer.Game.fade, 1f, 0.05f);
             this._hud.alpha          = Lerp.Float(this._hud.alpha, 0.0f, 0.08f);
             this._unlockScreen.alpha = Lerp.Float(this._unlockScreen.alpha, 0.0f, 0.08f);
             this._unlockMachineWait  = 1f;
             if (((double)this._followCam.manualViewSize < 0.0 || (double)this._followCam.manualViewSize == (double)this._followCam.viewSize) && ((double)this._hud.alpha == 0.0 && (double)Layer.Game.fade == 1.0))
             {
                 flag = true;
                 this._followCam.manualViewSize = -1f;
                 this._duck.alpha = 1f;
             }
         }
         else if (this._desiredState == ArcadeState.LaunchChallenge)
         {
             if (!this._flipState)
             {
                 HUD.CloseAllCorners();
             }
             Music.volume             = Lerp.Float(Music.volume, 0.0f, 0.01f);
             this._hud.alpha          = Lerp.Float(this._hud.alpha, 0.0f, 0.02f);
             this._unlockScreen.alpha = Lerp.Float(this._unlockScreen.alpha, 0.0f, 0.08f);
             if ((double)this._hud.alpha == 0.0)
             {
                 flag = true;
             }
         }
         if (this._desiredState == ArcadeState.UnlockScreen)
         {
             this._duck.alpha = Lerp.FloatSmooth(this._duck.alpha, 0.0f, 0.1f);
             this._followCam.manualViewSize = Lerp.FloatSmooth(this._followCam.manualViewSize, 2f, 0.16f);
             if ((double)this._followCam.manualViewSize < 30.0)
             {
                 Layer.Game.fade          = Lerp.Float(Layer.Game.fade, 0.0f, 0.08f);
                 Layer.Background.fade    = Lerp.Float(Layer.Game.fade, 0.0f, 0.08f);
                 this._unlockScreen.alpha = Lerp.Float(this._unlockScreen.alpha, 1f, 0.08f);
                 if ((double)this._followCam.manualViewSize < 3.0 && (double)this._unlockScreen.alpha == 1.0 && (double)Layer.Game.fade == 0.0)
                 {
                     flag = true;
                 }
             }
         }
         this._flipState = true;
         if (this._launchedChallenge)
         {
             Layer.Background.fade = 0.0f;
             Layer.Game.fade       = 0.0f;
         }
         if (!flag)
         {
             return;
         }
         this._flipState = false;
         HUD.CloseAllCorners();
         this._state = this._desiredState;
         if (this._state == ArcadeState.ViewChallenge)
         {
             if (this._afterChallenge)
             {
                 Music.Play(nameof(Arcade));
                 this._afterChallenge = false;
             }
             this._hud.MakeActive();
             this._duck.active = false;
         }
         else if (this._state == ArcadeState.LaunchChallenge)
         {
             Arcade.currentArcade = this;
             foreach (Thing thing in this.things[typeof(ChallengeConfetti)])
             {
                 Level.Remove(thing);
             }
             Music.Stop();
             Level.current             = (Level) new ChallengeLevel(this._hud.selected.challenge.fileName);
             this._desiredState        = ArcadeState.ViewChallenge;
             this._hud.launchChallenge = false;
             this._launchedChallenge   = false;
             this._afterChallenge      = true;
         }
         else
         {
             if (this._state == ArcadeState.UnlockMachine)
             {
                 return;
             }
             if (this._state == ArcadeState.Normal)
             {
                 this._unlockMachines.Clear();
                 foreach (ArcadeMachine challenge in this._challenges)
                 {
                     if (challenge.CheckUnlocked())
                     {
                         this._unlockMachines.Add(challenge);
                     }
                 }
                 if (this._unlockMachines.Count > 0)
                 {
                     this._desiredState = ArcadeState.UnlockMachine;
                 }
                 else
                 {
                     this._duck.active = true;
                 }
             }
             else if (this._state == ArcadeState.UnlockScreen)
             {
                 this._unlockScreen.MakeActive();
                 this._duck.active = false;
             }
             else
             {
                 if (this._state != ArcadeState.ViewSpecialChallenge)
                 {
                     return;
                 }
                 if (this._afterChallenge)
                 {
                     Music.Play(nameof(Arcade));
                     this._afterChallenge = false;
                 }
                 Chancy.afterChallenge     = true;
                 Chancy.afterChallengeWait = 1f;
                 this._duck.active         = false;
             }
         }
     }
     else if (this._state == ArcadeState.Normal || this._state == ArcadeState.UnlockMachine)
     {
         Layer.Game.fade       = Lerp.Float(Layer.Game.fade, 1f, 0.08f);
         Layer.Background.fade = Lerp.Float(Layer.Game.fade, 1f, 0.08f);
         this._hud.alpha       = Lerp.Float(this._hud.alpha, 0.0f, 0.08f);
         if (this._state == ArcadeState.Normal)
         {
             object obj = (object)null;
             foreach (ArcadeMachine challenge in this._challenges)
             {
                 double length = (double)(this._duck.position - challenge.position).length;
                 if (challenge.hover)
                 {
                     obj = (object)challenge;
                     if (Input.Pressed("SHOOT"))
                     {
                         this._hud.activeChallengeGroup = challenge.data;
                         this._desiredState             = ArcadeState.ViewChallenge;
                         this._followCam.manualViewSize = this._followCam.viewSize;
                         this._followCam.Clear();
                         this._followCam.Add((Thing)challenge);
                         HUD.CloseAllCorners();
                         this._hoverMachine = (ArcadeMachine)null;
                         this._hoverThing   = (object)null;
                         return;
                     }
                 }
                 if (this._prizeTable.hover)
                 {
                     obj = (object)this._prizeTable;
                     if (Input.Pressed("SHOOT"))
                     {
                         this._desiredState             = ArcadeState.UnlockScreen;
                         this._followCam.manualViewSize = this._followCam.viewSize;
                         this._followCam.Clear();
                         this._followCam.Add((Thing)this._prizeTable);
                         HUD.CloseAllCorners();
                         this._hoverMachine = (ArcadeMachine)null;
                         this._hoverThing   = (object)null;
                         return;
                     }
                 }
             }
             if (this._hoverThing == obj)
             {
                 return;
             }
             HUD.CloseAllCorners();
             this._hoverThing   = obj;
             this._hoverMachine = !(this._hoverThing is ArcadeMachine) ? (ArcadeMachine)null : obj as ArcadeMachine;
             if (this._hoverMachine != null)
             {
                 HUD.AddCornerControl(HUDCorner.BottomLeft, "PLAY@SHOOT@", this._duck.inputProfile);
                 string text = this._hoverMachine.data.name + " ";
                 foreach (string challenge in this._hoverMachine.data.challenges)
                 {
                     ChallengeSaveData saveData = Challenges.GetSaveData(Challenges.GetChallenge(challenge).levelID, this._duck.profile);
                     if (saveData.trophy == TrophyType.Baseline)
                     {
                         text += "@BASELINE@";
                     }
                     else if (saveData.trophy == TrophyType.Bronze)
                     {
                         text += "@BRONZE@";
                     }
                     else if (saveData.trophy == TrophyType.Silver)
                     {
                         text += "@SILVER@";
                     }
                     else if (saveData.trophy == TrophyType.Gold)
                     {
                         text += "@GOLD@";
                     }
                     else if (saveData.trophy == TrophyType.Platinum)
                     {
                         text += "@PLATINUM@";
                     }
                     else if (saveData.trophy == TrophyType.Developer)
                     {
                         text += "@DEVELOPER@";
                     }
                 }
                 HUD.AddCornerMessage(HUDCorner.TopLeft, text);
             }
             else
             {
                 if (!this._prizeTable.hover)
                 {
                     return;
                 }
                 HUD.AddCornerControl(HUDCorner.BottomRight, "@SHOOT@SPEND TICKETS", this._duck.inputProfile);
                 HUD.AddCornerCounter(HUDCorner.BottomLeft, "@TICKET@ ", new FieldBinding((object)Profiles.active[0], "ticketCount"), animateCount: true);
             }
         }
         else
         {
             if (this._state != ArcadeState.UnlockMachine)
             {
                 return;
             }
             this._unlockMachineWait -= 0.02f;
             if ((double)this._unlockMachineWait >= 0.0)
             {
                 return;
             }
             if (this._unlockingMachine)
             {
                 this._unlockingMachine = false;
                 this._followCam.Clear();
                 this._followCam.Add((Thing)this._unlockMachines[0]);
                 this._unlockMachineWait = 1f;
             }
             else if (this._unlockMachines.Count > 0)
             {
                 this._unlockMachines[0].unlocked = true;
                 this._unlockMachines.RemoveAt(0);
                 this._unlockingMachine = this._unlockMachines.Count > 0;
                 SFX.Play("lightTurnOn", pitch: Rando.Float(-0.1f, 0.1f));
                 this._unlockMachineWait = 1f;
             }
             else
             {
                 this._desiredState = ArcadeState.Normal;
             }
         }
     }
     else if (this._state == ArcadeState.ViewChallenge)
     {
         Layer.Game.fade       = Lerp.Float(Layer.Game.fade, 0.0f, 0.05f);
         Layer.Background.fade = Lerp.Float(Layer.Game.fade, 0.0f, 0.05f);
         this._hud.alpha       = Lerp.Float(this._hud.alpha, 1f, 0.05f);
         if (!this._hud.quitOut)
         {
             return;
         }
         this._hud.quitOut  = false;
         this._desiredState = ArcadeState.Normal;
     }
     else
     {
         if (this._state != ArcadeState.UnlockScreen || !this._unlockScreen.quitOut)
         {
             return;
         }
         this._unlockScreen.quitOut = false;
         this._desiredState         = ArcadeState.Normal;
     }
 }
        public override void Update()
        {
            ChallengeLevel._timer.Update();
            if (this._fading)
            {
                DuckGame.Graphics.fade = Lerp.Float(DuckGame.Graphics.fade, 0.0f, 0.05f);
                if ((double)DuckGame.Graphics.fade >= 0.00999999977648258)
                {
                    return;
                }
                if (this._validityTest)
                {
                    ArcadeTestDialogue.success = this._challenge.wonTrophies.Count > 0 && this._challenge.wonTrophies[0].type == TrophyType.Developer;
                    Level.current          = (Level)ArcadeTestDialogue.currentEditor;
                    DuckGame.Graphics.fade = 1f;
                }
                else
                {
                    if (this.things[typeof(EditorTestLevel)].Count <Thing>() > 0)
                    {
                        Level.current = (Level)(this.things[typeof(EditorTestLevel)].First <Thing>() as EditorTestLevel).editor;
                        Music.Stop();
                    }
                    else
                    {
                        Level.current = Arcade.currentArcade == null ? (Level)ArcadeLevel.currentArcade : (Level)Arcade.currentArcade;
                    }
                    this._fading = false;
                }
            }
            else
            {
                if ((double)this._restartMessageWait > 0.0)
                {
                    this._restartMessageWait -= 0.008f;
                }
                else
                {
                    HUD.CloseCorner(HUDCorner.TopLeft);
                }
                if (this._doRestart)
                {
                    ChallengeLevel.running = false;
                    this._waitForRestart  -= 0.04f;
                    if ((double)this._waitForRestart <= 0.0)
                    {
                        this._restarting = true;
                    }
                }
                this._waitFade -= 0.04f;
                if (!this._didFade && (double)this._waitFade <= 0.0 && (double)DuckGame.Graphics.fade < 1.0)
                {
                    DuckGame.Graphics.fade = Lerp.Float(DuckGame.Graphics.fade, 1f, 0.04f);
                }
                else if (this._restarting)
                {
                    ChallengeLevel.running         = false;
                    this.transitionSpeedMultiplier = 2f;
                    EditorTestLevel editorTestLevel = (EditorTestLevel)null;
                    if (this.things[typeof(EditorTestLevel)].Count <Thing>() > 0)
                    {
                        editorTestLevel = this.things[typeof(EditorTestLevel)].First <Thing>() as EditorTestLevel;
                    }
                    Level.current = !(this._level != "") ? (Level) new ChallengeLevel(this._levelData, this._validityTest) : (Level) new ChallengeLevel(this._level);
                    Level.current.transitionSpeedMultiplier    = 2f;
                    ((ChallengeLevel)Level.current)._waitSpawn = 0.0f;
                    if (editorTestLevel == null)
                    {
                        return;
                    }
                    Level.current.AddThing((Thing)editorTestLevel);
                }
                else
                {
                    if ((double)this._waitFade > 0.0)
                    {
                        return;
                    }
                    this._didFade = true;
                    if (this._finished)
                    {
                        ChallengeLevel.running = false;
                        this.PauseLogic();
                        if ((double)this._finishWait > 0.0)
                        {
                            this._finishWait -= 0.01f;
                        }
                        else
                        {
                            if (!this._playedEndMusic)
                            {
                                this._playedEndMusic          = true;
                                Level.current.simulatePhysics = false;
                                ArcadeFrame arcadeFrame = (ArcadeFrame)null;
                                if (this._win)
                                {
                                    if (ArcadeLevel.currentArcade != null)
                                    {
                                        arcadeFrame = ArcadeLevel.currentArcade.GetFrame();
                                        if (arcadeFrame != null)
                                        {
                                            Vec2  renderTargetSize = arcadeFrame.GetRenderTargetSize();
                                            float renderTargetZoom = arcadeFrame.GetRenderTargetZoom();
                                            if (this._captureTarget == null)
                                            {
                                                this._captureTarget = new RenderTarget2D((int)((double)renderTargetSize.x * 6.0), (int)((double)renderTargetSize.y * 6.0));
                                            }
                                            int    num    = DuckGame.Graphics.width / 320;
                                            Camera camera = new Camera(0.0f, 0.0f, (float)this._captureTarget.width * renderTargetZoom, (float)this._captureTarget.height * renderTargetZoom);
                                            if (ChallengeLevel._duck != null)
                                            {
                                                Layer.HUD.visible = false;
                                                MonoMain.RenderGame(MonoMain.screenCapture);
                                                Layer.HUD.visible = true;
                                                Matrix result;
                                                Matrix.CreateOrthographicOffCenter(0.0f, (float)MonoMain.screenCapture.width, (float)MonoMain.screenCapture.height, 0.0f, 0.0f, -1f, out result);
                                                result.M41 += -0.5f * result.M11;
                                                result.M42 += -0.5f * result.M22;
                                                Matrix matrix = Level.current.camera.getMatrix();
                                                Vec3   vec3   = (Vec3)DuckGame.Graphics.viewport.Project((Vector3) new Vec3(ChallengeLevel._duck.cameraPosition.x, ChallengeLevel._duck.cameraPosition.y, 0.0f), (Microsoft.Xna.Framework.Matrix)result, (Microsoft.Xna.Framework.Matrix)matrix, (Microsoft.Xna.Framework.Matrix)Matrix.Identity);
                                                DuckGame.Graphics.SetRenderTarget(this._captureTarget);
                                                camera.center = new Vec2(vec3.x, vec3.y);
                                                if ((double)camera.bottom > (double)MonoMain.screenCapture.height)
                                                {
                                                    camera.centerY = (float)MonoMain.screenCapture.height - camera.height / 2f;
                                                }
                                                if ((double)camera.top < 0.0)
                                                {
                                                    camera.centerY = camera.height / 2f;
                                                }
                                                if ((double)camera.right > (double)MonoMain.screenCapture.width)
                                                {
                                                    camera.centerX = (float)MonoMain.screenCapture.width - camera.width / 2f;
                                                }
                                                if ((double)camera.left < 0.0)
                                                {
                                                    camera.centerX = camera.width / 2f;
                                                }
                                                DuckGame.Graphics.Clear(Color.Black);
                                                DuckGame.Graphics.screen.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.DepthRead, RasterizerState.CullNone, (MTEffect)null, camera.getMatrix());
                                                DuckGame.Graphics.Draw((Tex2D)MonoMain.screenCapture, 0.0f, 0.0f);
                                                DuckGame.Graphics.screen.End();
                                                DuckGame.Graphics.SetRenderTarget((RenderTarget2D)null);
                                            }
                                        }
                                    }
                                    if (this._challenge.wonTrophies.Count > 0 && this._challenge.wonTrophies[0].type == TrophyType.Developer)
                                    {
                                        SFX.Play("developerWin");
                                    }
                                    else
                                    {
                                        SFX.Play("challengeWin");
                                    }
                                    this._showEndTextWait = 1f;
                                }
                                else
                                {
                                    SFX.Play("challengeLose");
                                    this._showEndTextWait = 1f;
                                }
                                if (this._challenge.wonTrophies.Count > 0)
                                {
                                    this._trophyGroup = new UIComponent(Layer.HUD.camera.width / 2f, Layer.HUD.camera.height / 2f, 0.0f, 0.0f);
                                    this._trophyMenu  = new UIMenu("@LWING@" + this._challenge.challenge.name + "@RWING@", Layer.HUD.camera.width / 2f, Layer.HUD.camera.height / 2f, 210f, conString: "@DPAD@MOVE  @SELECT@SELECT");
                                    UIDivider uiDivider1 = new UIDivider(false, 0.0f, 6f);
                                    UIDivider uiDivider2 = new UIDivider(true, 0.0f);
                                    SpriteMap spriteMap  = new SpriteMap("challengeTrophy", 70, 65);
                                    if (this._challenge.wonTrophies.Count > 0)
                                    {
                                        if (this._challenge.wonTrophies[0].type == TrophyType.Bronze)
                                        {
                                            spriteMap.frame = 1;
                                            uiDivider2.leftSection.Add((UIComponent) new UIText("BRONZE", Colors.Bronze, UIAlign.Top), true);
                                        }
                                        else if (this._challenge.wonTrophies[0].type == TrophyType.Silver)
                                        {
                                            spriteMap.frame = 2;
                                            uiDivider2.leftSection.Add((UIComponent) new UIText("SILVER", Colors.Silver, UIAlign.Top), true);
                                        }
                                        else if (this._challenge.wonTrophies[0].type == TrophyType.Gold)
                                        {
                                            spriteMap.frame = 3;
                                            uiDivider2.leftSection.Add((UIComponent) new UIText("GOLD", Colors.Gold, UIAlign.Top), true);
                                        }
                                        else if (this._challenge.wonTrophies[0].type == TrophyType.Platinum)
                                        {
                                            spriteMap.frame = 4;
                                            uiDivider2.leftSection.Add((UIComponent) new UIText("PLATINUM", Colors.Platinum, UIAlign.Top), true);
                                        }
                                        else if (this._challenge.wonTrophies[0].type == TrophyType.Developer)
                                        {
                                            spriteMap.frame = 5;
                                            uiDivider2.leftSection.Add((UIComponent) new UIText("UR THE BEST", Colors.Developer, UIAlign.Top), true);
                                        }
                                    }
                                    uiDivider2.leftSection.Add((UIComponent) new UIText("               ", Color.White, UIAlign.Left), true);
                                    bool flag = false;
                                    ChallengeSaveData saveData = Challenges.GetSaveData(this.id, ChallengeLevel._duck.profile);
                                    int bestTime = saveData.bestTime;
                                    if (saveData.bestTime == 0 || (int)(ChallengeLevel.timer.elapsed.TotalSeconds * 1000.0) < saveData.bestTime)
                                    {
                                        saveData.bestTime = (int)(ChallengeLevel.timer.elapsed.TotalSeconds * 1000.0);
                                    }
                                    if (this._challenge.wonTrophies[0].type > saveData.trophy)
                                    {
                                        saveData.trophy = this._challenge.wonTrophies[0].type;
                                        if (saveData.trophy > TrophyType.Silver)
                                        {
                                            flag = true;
                                        }
                                    }
                                    int targets1 = saveData.targets;
                                    if (ChallengeLevel.targetsShot > saveData.targets)
                                    {
                                        saveData.targets = ChallengeLevel.targetsShot;
                                    }
                                    int targets2 = saveData.targets;
                                    if (ChallengeLevel.goodiesGot > saveData.goodies)
                                    {
                                        saveData.goodies = ChallengeLevel.goodiesGot;
                                    }
                                    if (this._challenge.challenge.hasTimeRequirements)
                                    {
                                        uiDivider2.leftSection.Add((UIComponent) new UIText("TIME", Color.White, UIAlign.Left), true);
                                        uiDivider2.leftSection.Add((UIComponent) new UIText(MonoMain.TimeString(ChallengeLevel.timer.elapsed, small: true), Color.Lime, UIAlign.Right), true);
                                        uiDivider2.leftSection.Add((UIComponent) new UIText("               ", Color.White, UIAlign.Left), true);
                                        if (targets1 != 0)
                                        {
                                            if ((double)bestTime < ChallengeLevel.timer.elapsed.TotalSeconds * 1000.0)
                                            {
                                                TimeSpan span = TimeSpan.FromMilliseconds(ChallengeLevel.timer.elapsed.TotalSeconds * 1000.0 - (double)bestTime);
                                                uiDivider2.leftSection.Add((UIComponent) new UIText("DIFFERENCE", Color.White, UIAlign.Left), true);
                                                uiDivider2.leftSection.Add((UIComponent) new UIText("+" + MonoMain.TimeString(span, small: true), Color.Red, UIAlign.Right), true);
                                            }
                                            else
                                            {
                                                TimeSpan span = TimeSpan.FromMilliseconds((double)bestTime - ChallengeLevel.timer.elapsed.TotalSeconds * 1000.0);
                                                uiDivider2.leftSection.Add((UIComponent) new UIText("DIFFERENCE", Color.White, UIAlign.Left), true);
                                                uiDivider2.leftSection.Add((UIComponent) new UIText("-" + MonoMain.TimeString(span, small: true), Color.Lime, UIAlign.Right), true);
                                                flag = true;
                                            }
                                        }
                                        else
                                        {
                                            uiDivider2.leftSection.Add((UIComponent) new UIText("               ", Color.White, UIAlign.Left), true);
                                            uiDivider2.leftSection.Add((UIComponent) new UIText("               ", Color.White, UIAlign.Left), true);
                                        }
                                    }
                                    if (saveData.trophy < TrophyType.Gold)
                                    {
                                        flag = false;
                                    }
                                    if (this._challenge.challenge.countTargets)
                                    {
                                        if (this._challenge.challenge.prefix != "" && this._challenge.challenge.prefix != null)
                                        {
                                            uiDivider2.leftSection.Add((UIComponent) new UIText(this._challenge.challenge.prefix, Color.White, UIAlign.Left), true);
                                        }
                                        else
                                        {
                                            uiDivider2.leftSection.Add((UIComponent) new UIText("TARGETS", Color.White, UIAlign.Left), true);
                                        }
                                        string textVal = Convert.ToString(ChallengeLevel.targetsShot);
                                        Color  c       = Color.Lime;
                                        if (targets1 != 0)
                                        {
                                            if (targets1 < ChallengeLevel.targetsShot)
                                            {
                                                int num = ChallengeLevel.targetsShot - targets1;
                                                c       = Color.Lime;
                                                textVal = textVal + " (+" + Convert.ToString(num) + ")";
                                                flag    = true;
                                            }
                                            else if (targets1 > ChallengeLevel.targetsShot)
                                            {
                                                int num = targets1 - ChallengeLevel.targetsShot;
                                                c       = Color.Red;
                                                textVal = textVal + " (-" + Convert.ToString(num) + ")";
                                            }
                                            else
                                            {
                                                c = Color.White;
                                            }
                                        }
                                        uiDivider2.leftSection.Add((UIComponent) new UIText(textVal, c, UIAlign.Right), true);
                                        uiDivider2.leftSection.Add((UIComponent) new UIText("               ", Color.White, UIAlign.Left), true);
                                    }
                                    if (this._challenge.challenge.countGoodies)
                                    {
                                        if (this._challenge.challenge.prefix != "" && this._challenge.challenge.prefix != null)
                                        {
                                            uiDivider2.leftSection.Add((UIComponent) new UIText(this._challenge.challenge.prefix, Color.White, UIAlign.Left), true);
                                        }
                                        else
                                        {
                                            uiDivider2.leftSection.Add((UIComponent) new UIText("NUMBER", Color.White, UIAlign.Left), true);
                                        }
                                        string textVal = Convert.ToString(ChallengeLevel.goodiesGot);
                                        Color  c       = Color.Lime;
                                        if (targets2 != 0)
                                        {
                                            if (targets2 < ChallengeLevel.goodiesGot)
                                            {
                                                int num = ChallengeLevel.goodiesGot - targets2;
                                                c       = Color.Lime;
                                                textVal = textVal + " (+" + Convert.ToString(num) + ")";
                                                flag    = true;
                                            }
                                            else if (targets2 > ChallengeLevel.goodiesGot)
                                            {
                                                int num = targets2 - ChallengeLevel.goodiesGot;
                                                c       = Color.Red;
                                                textVal = textVal + " (-" + Convert.ToString(num) + ")";
                                            }
                                            else
                                            {
                                                c = Color.White;
                                            }
                                        }
                                        uiDivider2.leftSection.Add((UIComponent) new UIText(textVal, c, UIAlign.Right), true);
                                        uiDivider2.leftSection.Add((UIComponent) new UIText("               ", Color.White, UIAlign.Left), true);
                                    }
                                    uiDivider2.rightSection.Add((UIComponent) new UIImage((Sprite)spriteMap, UIAlign.Right), true);
                                    uiDivider1.leftSection.Add((UIComponent)uiDivider2, true);
                                    uiDivider1.rightSection.vertical     = false;
                                    uiDivider1.rightSection.borderSize.y = 2f;
                                    if (this._validityTest)
                                    {
                                        if (this._challenge.wonTrophies.Count > 0 && this._challenge.wonTrophies[0].type == TrophyType.Developer)
                                        {
                                            uiDivider1.rightSection.Add((UIComponent) new UIMenuItem("CONTINUE   ", (UIMenuAction) new UIMenuActionCloseMenuSetBoolean(this._trophyGroup, this._quit), UIAlign.Left), true);
                                        }
                                        else
                                        {
                                            uiDivider1.rightSection.Add((UIComponent) new UIMenuItem("RETRY", (UIMenuAction) new UIMenuActionCloseMenuSetBoolean(this._trophyGroup, this._restart), UIAlign.Left), true);
                                        }
                                    }
                                    else
                                    {
                                        uiDivider1.rightSection.Add((UIComponent) new UIMenuItem("CONTINUE   ", (UIMenuAction) new UIMenuActionCloseMenuSetBoolean(this._trophyGroup, this._quit), UIAlign.Left), true);
                                        uiDivider1.rightSection.Add((UIComponent) new UIMenuItem("RETRY", (UIMenuAction) new UIMenuActionCloseMenuSetBoolean(this._trophyGroup, this._restart), UIAlign.Left), true);
                                    }
                                    this._trophyMenu.Add((UIComponent)uiDivider1, true);
                                    this._trophyMenu.Close();
                                    this._trophyGroup.Add((UIComponent)this._trophyMenu, false);
                                    this._trophyGroup.Close();
                                    Level.Add((Thing)this._trophyGroup);
                                    if (arcadeFrame != null && flag && saveData != null)
                                    {
                                        saveData.frameID     = arcadeFrame._identifier;
                                        saveData.frameImage  = Editor.TextureToString((Texture2D)(Tex2D)this._captureTarget);
                                        arcadeFrame.saveData = saveData;
                                    }
                                    Challenges.Save(this.id);
                                    Profiles.Save(ChallengeLevel._duck.profile);
                                }
                                else
                                {
                                    this._trophyGroup = new UIComponent(Layer.HUD.camera.width / 2f, Layer.HUD.camera.height / 2f, 0.0f, 0.0f);
                                    this._trophyMenu  = new UIMenu("@LWING@" + this._challenge.challenge.name + "@RWING@", Layer.HUD.camera.width / 2f, Layer.HUD.camera.height / 2f, 210f, conString: "@DPAD@MOVE  @SELECT@SELECT");
                                    UIDivider uiDivider1 = new UIDivider(false, 0.0f, 6f);
                                    UIDivider uiDivider2 = new UIDivider(true, 0.0f);
                                    uiDivider2.leftSection.Add((UIComponent) new UIText("FAILED", Color.Red, UIAlign.Top), true);
                                    uiDivider2.leftSection.Add((UIComponent) new UIText("               ", Color.White, UIAlign.Left), true);
                                    uiDivider2.leftSection.Add((UIComponent) new UIText("               ", Color.White, UIAlign.Left), true);
                                    uiDivider2.leftSection.Add((UIComponent) new UIText("               ", Color.Lime, UIAlign.Right), true);
                                    uiDivider2.leftSection.Add((UIComponent) new UIText("               ", Color.White, UIAlign.Left), true);
                                    uiDivider2.leftSection.Add((UIComponent) new UIText("               ", Color.White, UIAlign.Left), true);
                                    uiDivider2.leftSection.Add((UIComponent) new UIText("               ", Color.White, UIAlign.Left), true);
                                    uiDivider2.rightSection.Add((UIComponent) new UIImage((Sprite) new SpriteMap("challengeTrophy", 70, 65)
                                    {
                                        frame = 0
                                    }, UIAlign.Right), true);
                                    uiDivider1.leftSection.Add((UIComponent)uiDivider2, true);
                                    uiDivider1.rightSection.vertical     = false;
                                    uiDivider1.rightSection.borderSize.y = 2f;
                                    uiDivider1.rightSection.Add((UIComponent) new UIMenuItem("CONTINUE   ", (UIMenuAction) new UIMenuActionCloseMenuSetBoolean(this._trophyGroup, this._quit), UIAlign.Left), true);
                                    uiDivider1.rightSection.Add((UIComponent) new UIMenuItem("RETRY", (UIMenuAction) new UIMenuActionCloseMenuSetBoolean(this._trophyGroup, this._restart), UIAlign.Left), true);
                                    this._trophyMenu.Add((UIComponent)uiDivider1, true);
                                    this._trophyMenu.Close();
                                    this._trophyGroup.Add((UIComponent)this._trophyMenu, false);
                                    this._trophyGroup.Add((UIComponent)Options.optionsMenu, false);
                                    Options.openOnClose = this._trophyMenu;
                                    this._trophyGroup.Close();
                                    Level.Add((Thing)this._trophyGroup);
                                }
                            }
                            if ((double)this._showEndTextWait > 0.0)
                            {
                                this._showEndTextWait -= 0.01f;
                            }
                            else
                            {
                                this._fontFade = 1f;
                                if ((double)this._showResultsWait > 0.0)
                                {
                                    this._showResultsWait -= 0.01f;
                                }
                                else if (!this._showedEndMenu)
                                {
                                    this._trophyGroup.Open();
                                    this._trophyMenu.Open();
                                    MonoMain.pauseMenu = this._trophyGroup;
                                    SFX.Play("pause", 0.6f, -0.2f);
                                    this._showedEndMenu = true;
                                }
                                if (this._restart.value)
                                {
                                    this._restarting = true;
                                    SFX.Play("resume", 0.6f);
                                }
                                else
                                {
                                    if (!this._quit.value)
                                    {
                                        return;
                                    }
                                    this._fading = true;
                                    SFX.Play("resume", 0.6f);
                                }
                            }
                        }
                    }
                    else
                    {
                        this._waitSpawn -= 0.06f;
                        if ((double)this._waitSpawn > 0.0)
                        {
                            return;
                        }
                        if (this._pendingSpawns != null && this._pendingSpawns.Count > 0)
                        {
                            this._waitSpawn = 0.5f;
                            Duck pendingSpawn = this._pendingSpawns[0];
                            this.AddThing((Thing)pendingSpawn);
                            this._pendingSpawns.RemoveAt(0);
                            Vec3 color = pendingSpawn.profile.persona.color;
                            Level.Add((Thing) new SpawnLine(pendingSpawn.x, pendingSpawn.y, 0, 0.0f, new Color((int)color.x, (int)color.z, (int)color.z), 32f));
                            Level.Add((Thing) new SpawnLine(pendingSpawn.x, pendingSpawn.y, 0, -4f, new Color((int)color.x, (int)color.y, (int)color.z), 4f));
                            Level.Add((Thing) new SpawnLine(pendingSpawn.x, pendingSpawn.y, 0, 4f, new Color((int)color.x, (int)color.y, (int)color.z), 4f));
                            SFX.Play("pullPin", 0.7f);
                            ChallengeLevel._duck          = pendingSpawn;
                            this._challenge               = this.things[typeof(ChallengeMode)].First <Thing>() as ChallengeMode;
                            ChallengeLevel.random         = this._challenge.random.value;
                            this._challenge.duck          = pendingSpawn;
                            ChallengeLevel._timer.maxTime = TimeSpan.FromSeconds((double)this._challenge.challenge.trophies[0].timeRequirement);
                            HUD.AddCornerTimer(HUDCorner.BottomRight, "", (Timer)ChallengeLevel._timer);
                            if (this._challenge.challenge.countTargets)
                            {
                                int targets = this._challenge.challenge.trophies[0].targets;
                                HUD.AddCornerCounter(HUDCorner.BottomLeft, "@RETICULE@", new FieldBinding((object)this, "targetsShot"), targets > 0 ? targets : 0);
                            }
                            if (this._challenge.challenge.countGoodies)
                            {
                                MultiMap <System.Type, ISequenceItem> multiMap = new MultiMap <System.Type, ISequenceItem>();
                                foreach (ISequenceItem element in Level.current.things[typeof(ISequenceItem)])
                                {
                                    System.Type  type     = element.GetType();
                                    SequenceItem sequence = (element as Thing).sequence;
                                    if (sequence.isValid && sequence.type == SequenceItemType.Goody)
                                    {
                                        multiMap.Add(type, element);
                                    }
                                }
                                System.Type key = (System.Type)null;
                                int         num = 0;
                                foreach (KeyValuePair <System.Type, List <ISequenceItem> > keyValuePair in (MultiMap <System.Type, ISequenceItem, List <ISequenceItem> >)multiMap)
                                {
                                    if (keyValuePair.Value.Count > num)
                                    {
                                        key = keyValuePair.Key;
                                        num = keyValuePair.Value.Count;
                                    }
                                }
                                if (key != (System.Type)null)
                                {
                                    ISequenceItem sequenceItem = multiMap[key][0];
                                    string        text         = "@STARGOODY@";
                                    switch (sequenceItem)
                                    {
                                    case LapGoody _:
                                    case InvisiGoody _:
                                        text = "@LAPGOODY@";
                                        break;

                                    case SuitcaseGoody _:
                                        text = "@SUITCASEGOODY@";
                                        break;

                                    case Window _:
                                    case YellowBarrel _:
                                    case Door _:
                                        text = "@RETICULE@";
                                        break;
                                    }
                                    int goodies = this._challenge.challenge.trophies[0].goodies;
                                    HUD.AddCornerCounter(HUDCorner.BottomLeft, text, new FieldBinding((object)this, "goodiesGot"), goodies > 0 ? goodies : 0);
                                }
                            }
                            if (this._firstStart)
                            {
                                if (ChallengeLevel.random)
                                {
                                    IEnumerable <Thing> thing = this.things[typeof(ISequenceItem)];
                                    if (thing.Count <Thing>() > 0)
                                    {
                                        thing.ElementAt <Thing>(Rando.Int(thing.Count <Thing>() - 1)).sequence.BeginRandomSequence();
                                    }
                                }
                                else
                                {
                                    foreach (TargetDuck targetDuck in this.things[typeof(TargetDuck)])
                                    {
                                        if (targetDuck.sequence.order == 0)
                                        {
                                            targetDuck.sequence.Activate();
                                        }
                                    }
                                }
                                this._firstStart = false;
                            }
                            if (!Music.stopped)
                            {
                                return;
                            }
                            if ((string)this._challenge.music == "")
                            {
                                Music.Load("Challenging");
                            }
                            else if ((string)this._challenge.music == "donutmystery")
                            {
                                Music.Load("spacemystery");
                            }
                            else
                            {
                                Music.Load(Music.FindSong((string)this._challenge.music));
                            }
                        }
                        else if (!this._started)
                        {
                            this._waitAfterSpawn -= 0.06f;
                            if ((double)this._waitAfterSpawn > 0.0)
                            {
                                return;
                            }
                            ++this._waitAfterSpawnDings;
                            if (this._waitAfterSpawnDings > 2)
                            {
                                this._started          = true;
                                this.simulatePhysics   = true;
                                ChallengeLevel.running = true;
                                SFX.Play("ding");
                                ChallengeLevel._timer.Start();
                                if (Music.stopped)
                                {
                                    Music.PlayLoaded();
                                }
                            }
                            else
                            {
                                SFX.Play("preStartDing");
                            }
                            this._waitSpawn = 1.1f;
                        }
                        else
                        {
                            this._fontFade -= 0.1f;
                            if ((double)this._fontFade < 0.0)
                            {
                                this._fontFade = 0.0f;
                            }
                            this.PauseLogic();
                        }
                    }
                }
            }
        }