Пример #1
0
 public override void Update()
 {
     if (this._mode != null)
     {
         this._mode.DoUpdate();
     }
     if (this._level == "RANDOM")
     {
         if (this.wait < 4)
         {
             ++this.wait;
         }
         if (this.wait == 4)
         {
             ++this.wait;
             foreach (AutoBlock autoBlock in this.things[typeof(AutoBlock)])
             {
                 autoBlock.PlaceBlock();
             }
             foreach (AutoPlatform autoPlatform in this.things[typeof(AutoPlatform)])
             {
                 autoPlatform.PlaceBlock();
                 autoPlatform.UpdateNubbers();
             }
             foreach (BlockGroup blockGroup in this.things[typeof(BlockGroup)])
             {
                 foreach (Block block in blockGroup.blocks)
                 {
                     if (block is AutoBlock)
                     {
                         (block as AutoBlock).PlaceBlock();
                     }
                 }
             }
         }
     }
     if (this._showInfo && !GameMode.started)
     {
         this._infoSlide = Lerp.Float(this._infoSlide, 1f, 0.06f);
         if ((double)this._infoSlide > 0.949999988079071)
         {
             this._infoWait += Maths.IncFrameTimer();
             if ((double)this._infoWait > 2.5)
             {
                 this._showInfo = false;
             }
         }
     }
     else
     {
         this._infoSlide = Lerp.Float(this._infoSlide, 0.0f, 0.1f);
     }
     base.Update();
 }
 public static void TickWeather()
 {
     RockWeather._timeOfDay   += 6.17284E-06f;
     RockWeather._weatherTime += 6.17284E-06f;
     if (RockWeather._weather == Weather.Raining)
     {
         RockWeather._timeRaining += Maths.IncFrameTimer();
     }
     if ((double)RockWeather._timeOfDay <= 1.0)
     {
         return;
     }
     RockWeather._timeOfDay = 0.0f;
 }
Пример #3
0
 public override void Update()
 {
     if (!Level.current.simulatePhysics)
     {
         return;
     }
     if (!this._started)
     {
         this.PopUpItems();
         this._started = true;
     }
     if (this._up.Count > 0)
     {
         for (int index = 0; index < this._up.Count; ++index)
         {
             if (this._up[index].finished)
             {
                 this._lastUp = this._up[index];
                 this._up[index].Reset();
                 this._up.Remove(this._up[index]);
                 --index;
             }
         }
     }
     if (this._up.Count >= (int)this.max_up)
     {
         return;
     }
     if (this._up.Count == 0)
     {
         this.PopUpItems();
         this._waitCount = 0.0f;
     }
     else
     {
         this._waitCount += Maths.IncFrameTimer();
         if ((double)this._waitCount < (double)this.wait.value)
         {
             return;
         }
         this._waitCount = 0.0f;
         this.PopUpItems();
     }
 }
Пример #4
0
 public bool Update()
 {
     if (Network.activeNetwork.core.networkTimeFallback)
     {
         this.waitTime -= (double)Maths.IncFrameTimer();
         if (this.waitTime <= 0.0)
         {
             return(true);
         }
     }
     else
     {
         if (Math.Abs(this.waitTime - (double)Network.activeNetwork.core.networkTime) > 3000.0)
         {
             this.waitTime = (double)(Network.activeNetwork.core.networkTime + 1000UL);
         }
         if ((double)Network.activeNetwork.core.networkTime >= this.waitTime)
         {
             this.waitTime = -1.0;
             return(true);
         }
     }
     return(false);
 }
Пример #5
0
 public override void Update()
 {
     if (Network.isActive && this._prevVisible && !this.visible)
     {
         for (int i = 0; i < 4; i++)
         {
             SmallSmoke s = SmallSmoke.New(base.x + Rando.Float(-4f, 4f), base.y + Rando.Float(-4f, 4f));
             s.hSpeed += this.hSpeed * Rando.Float(0.3f, 0.5f);
             s.vSpeed -= Rando.Float(0.1f, 0.2f);
             Level.Add(s);
         }
     }
     if (this._duckOwner == null)
     {
         return;
     }
     this._framesSinceTransfer++;
     base.Update();
     if (base.y > Level.current.lowestPoint + 100f)
     {
         this.OnDestroy(new DTFall());
     }
     this.jumpCountdown -= Maths.IncFrameTimer();
     this._prevVisible   = this.visible;
     this._shakeInc     += 0.8f;
     this._shakeMult     = Lerp.Float(this._shakeMult, 0f, 0.05f);
     if (Network.isActive && this._duckOwner._trapped == this && !this._duckOwner.isServerForObject && this._duckOwner.inputProfile.Pressed("JUMP", false))
     {
         this._shakeMult = 1f;
     }
     if (this._duckOwner.isServerForObject && this._duckOwner._trapped == this)
     {
         if (!this.visible)
         {
             base.y = -9999f;
         }
         if (!this.infinite)
         {
             this._duckOwner.profile.stats.timeInNet += Maths.IncFrameTimer();
             if (this._duckOwner.inputProfile.Pressed("JUMP", false))
             {
                 this._shakeMult    = 1f;
                 this._trapTime    -= 0.007f;
                 this.jumpCountdown = 0.25f;
             }
             if (base.grounded && this._duckOwner.inputProfile.Pressed("JUMP", false))
             {
                 this._shakeMult = 1f;
                 this._trapTime -= 0.028f;
                 if (this.owner == null)
                 {
                     if (Math.Abs(this.hSpeed) < 1f && this._framesSinceTransfer > 30)
                     {
                         this._duckOwner.Fondle(this);
                     }
                     this.vSpeed -= Rando.Float(0.8f, 1.1f);
                     if (this._duckOwner.inputProfile.Down("LEFT") && this.hSpeed > -1f)
                     {
                         this.hSpeed -= Rando.Float(0.6f, 0.8f);
                     }
                     if (this._duckOwner.inputProfile.Down("RIGHT") && this.hSpeed < 1f)
                     {
                         this.hSpeed += Rando.Float(0.6f, 0.8f);
                     }
                 }
             }
             if (this._duckOwner.inputProfile.Pressed("JUMP", false) && this._duckOwner.HasEquipment(typeof(Jetpack)))
             {
                 Equipment e = this._duckOwner.GetEquipment(typeof(Jetpack));
                 e.PressAction();
             }
             if (this._duckOwner.inputProfile.Released("JUMP") && this._duckOwner.HasEquipment(typeof(Jetpack)))
             {
                 Equipment e2 = this._duckOwner.GetEquipment(typeof(Jetpack));
                 e2.ReleaseAction();
             }
             this._trapTime -= 0.0028f;
             if (this._trapTime <= 0f || this._duckOwner.dead)
             {
                 this.OnDestroy(null);
             }
         }
         if (this.owner == null)
         {
             base.depth = this._duckOwner.depth;
         }
         this._duckOwner.position = this.position;
         this._duckOwner.UpdateSkeleton();
     }
 }
        public override void Update()
        {
            this._scroll += 0.1f;
            if ((double)this._scroll > 9.0)
            {
                this._scroll = 0.0f;
            }
            this._dots += 0.01f;
            if ((double)this._dots > 1.0)
            {
                this._dots = 0.0f;
            }
            if (this.open)
            {
                foreach (BlacklistServer failedAttempt in this._failedAttempts)
                {
                    failedAttempt.cooldown = Lerp.Float(failedAttempt.cooldown, 0.0f, Maths.IncFrameTimer());
                }
                if (this._signalCrossLocal.currentAnimation == "idle")
                {
                    if (UIMatchmakingBox.pulseLocal)
                    {
                        this._signalCrossLocal.SetAnimation("flicker");
                        UIMatchmakingBox.pulseLocal = false;
                    }
                }
                else if (this._signalCrossLocal.finished)
                {
                    this._signalCrossLocal.SetAnimation("idle");
                }
                if (this._signalCrossNetwork.currentAnimation == "idle")
                {
                    if (UIMatchmakingBox.pulseNetwork)
                    {
                        this._signalCrossNetwork.SetAnimation("flicker");
                        UIMatchmakingBox.pulseNetwork = false;
                    }
                }
                else if (this._signalCrossNetwork.finished)
                {
                    this._signalCrossNetwork.SetAnimation("idle");
                }
                if (Network.connections.Count > 0 && UIMatchmakingBox._state != MatchmakingState.Connecting)
                {
                    this.ChangeState(MatchmakingState.Connecting);
                    DevConsole.Log("|PURPLE|MATCHMAKING |DGGREEN|Network appears to be connecting...", Color.White);
                }
                if (DuckNetwork.status == DuckNetStatus.Connected)
                {
                    if (this._tryHostingLobby != null)
                    {
                        (Level.current as TeamSelect2).CloseAllDialogs();
                        Level.current = (Level) new TeamSelect2();
                        DevConsole.Log("|PURPLE|MATCHMAKING |DGGREEN|Finished! (HOST).", Color.White);
                        return;
                    }
                    if (Level.current is TeamSelect2)
                    {
                        (Level.current as TeamSelect2).CloseAllDialogs();
                        Level.current = (Level) new ConnectingScreen();
                        DevConsole.Log("|PURPLE|MATCHMAKING |DGGREEN|Finished! (CLIENT).", Color.White);
                        return;
                    }
                    Network.Disconnect();
                    this.ChangeState(MatchmakingState.SearchForLobbies);
                    DevConsole.Log("|PURPLE|MATCHMAKING |DGGREEN|Last minute connection error.", Color.White);
                    return;
                }
                switch (UIMatchmakingBox._state)
                {
                case MatchmakingState.ConnectToMoon:
                    Steam.AddLobbyStringFilter("started", "true", SteamLobbyComparison.Equal);
                    Steam.SearchForLobby((User)null);
                    Steam.RequestGlobalStats();
                    UIMatchmakingBox.pulseLocal = true;
                    this.ChangeState(MatchmakingState.ConnectingToMoon);
                    break;

                case MatchmakingState.ConnectingToMoon:
                    if (Steam.lobbySearchComplete)
                    {
                        if (this.searchTryIndex == 0)
                        {
                            this._totalInGameLobbies = Steam.lobbiesFound;
                            if (this._totalInGameLobbies < 0)
                            {
                                this._totalInGameLobbies = 0;
                            }
                            ++this.searchTryIndex;
                            Steam.AddLobbyStringFilter("started", "false", SteamLobbyComparison.Equal);
                            Steam.SearchForLobby((User)null);
                            break;
                        }
                        UIMatchmakingBox.pulseNetwork = true;
                        this._totalLobbiesFound       = Steam.lobbiesFound;
                        List <User> users = Steam.GetSearchLobbyAtIndex(0).users;
                        this._newStatusList.Add("|DGGREEN|Connected to Moon!");
                        this._newStatusList.Add("");
                        this._newStatusList.Add("|DGYELLOW|Searching for companions.");
                        this.ChangeState(MatchmakingState.SearchForLobbies);
                        break;
                    }
                    break;

                case MatchmakingState.SearchForLobbies:
                    if (this._triesSinceSearch == 3)
                    {
                        Steam.AddLobbyStringFilter("started", "true", SteamLobbyComparison.Equal);
                        Steam.SearchForLobby((User)null);
                        this.ChangeState(MatchmakingState.CheckingTotalGames);
                        return;
                    }
                    if (this._tries > 0 && this._tryHostingLobby == null)
                    {
                        DuckNetwork.Host(TeamSelect2.GetSettingInt("maxplayers"), NetworkLobbyType.Public);
                        this._tryHostingLobby = (Network.activeNetwork.core as NCSteam).lobby;
                        if (!this.triedHostingAlready)
                        {
                            this._newStatusList.Add("|DGYELLOW|Searching even harder.");
                        }
                        else
                        {
                            this._newStatusList.Add("|DGYELLOW|Searching.");
                        }
                        this.triedHostingAlready = true;
                        DevConsole.Log("|PURPLE|MATCHMAKING |DGYELLOW|Opened lobby while searching.", Color.White);
                        this._tryHostingWait = 5f + Rando.Float(2f);
                    }
                    foreach (MatchSetting matchSetting in TeamSelect2.matchSettings)
                    {
                        if (matchSetting.value is int)
                        {
                            if (matchSetting.filtered)
                            {
                                Steam.AddLobbyNumericalFilter(matchSetting.id, (int)matchSetting.value, (SteamLobbyComparison)matchSetting.filterMode);
                            }
                            else if (!matchSetting.filtered)
                            {
                                Steam.AddLobbyNearFilter(matchSetting.id, (int)matchSetting.defaultValue);
                            }
                        }
                        if (matchSetting.value is bool)
                        {
                            if (matchSetting.filtered)
                            {
                                Steam.AddLobbyNumericalFilter(matchSetting.id, (bool)matchSetting.value ? 1 : 0, (SteamLobbyComparison)matchSetting.filterMode);
                            }
                            else if (!matchSetting.filtered)
                            {
                                Steam.AddLobbyNearFilter(matchSetting.id, (bool)matchSetting.defaultValue ? 1 : 0);
                            }
                        }
                    }
                    foreach (MatchSetting onlineSetting in TeamSelect2.onlineSettings)
                    {
                        if (onlineSetting.value is int)
                        {
                            if (onlineSetting.filtered)
                            {
                                Steam.AddLobbyNumericalFilter(onlineSetting.id, (int)onlineSetting.value, (SteamLobbyComparison)onlineSetting.filterMode);
                            }
                            else if (!onlineSetting.filtered)
                            {
                                Steam.AddLobbyNearFilter(onlineSetting.id, (int)onlineSetting.defaultValue);
                            }
                        }
                        if (onlineSetting.value is bool)
                        {
                            if (onlineSetting.id == "modifiers")
                            {
                                if (onlineSetting.filtered)
                                {
                                    Steam.AddLobbyStringFilter(onlineSetting.id, (bool)onlineSetting.value ? "true" : "false", SteamLobbyComparison.Equal);
                                }
                            }
                            else if (onlineSetting.filtered)
                            {
                                Steam.AddLobbyNumericalFilter(onlineSetting.id, (bool)onlineSetting.value ? 1 : 0, (SteamLobbyComparison)onlineSetting.filterMode);
                            }
                            else if (!onlineSetting.filtered)
                            {
                                Steam.AddLobbyNearFilter(onlineSetting.id, (bool)onlineSetting.defaultValue ? 1 : 0);
                            }
                        }
                    }
                    Steam.AddLobbyStringFilter("started", "false", SteamLobbyComparison.Equal);
                    Steam.AddLobbyStringFilter("beta", "2.0", SteamLobbyComparison.Equal);
                    Steam.AddLobbyStringFilter("dev", DG.devBuild ? "true" : "false", SteamLobbyComparison.Equal);
                    Steam.AddLobbyStringFilter("modhash", ModLoader.modHash, SteamLobbyComparison.Equal);
                    if (!Steam.waitingForGlobalStats)
                    {
                        this._globalKills = (long)Steam.GetDailyGlobalStat("kills");
                    }
                    Steam.RequestGlobalStats();
                    UIMatchmakingBox.pulseLocal = true;
                    this.ChangeState(MatchmakingState.Searching);
                    ++this._triesSinceSearch;
                    ++this._tries;
                    break;

                case MatchmakingState.CheckingTotalGames:
                    if (Steam.lobbySearchComplete)
                    {
                        this._totalInGameLobbies = Steam.lobbiesFound;
                        if (this._totalInGameLobbies < 0)
                        {
                            this._totalInGameLobbies = 0;
                        }
                        this.ChangeState(MatchmakingState.SearchForLobbies);
                        this._triesSinceSearch = 0;
                        break;
                    }
                    break;

                case MatchmakingState.Searching:
                    if (Steam.lobbySearchComplete)
                    {
                        this._totalLobbiesFound = Steam.lobbiesFound;
                        if (this._tryHostingLobby != null)
                        {
                            --this._totalLobbiesFound;
                        }
                        List <Lobby> lobbyList = new List <Lobby>();
                        DevConsole.Log("|PURPLE|MATCHMAKING |LIME|found " + (object)Math.Max(this._totalLobbiesFound, 0) + " lobbies.", Color.White);
                        for (int index1 = 0; index1 < 2; ++index1)
                        {
                            int num1 = index1 != 0 ? lobbyList.Count : Steam.lobbiesFound;
                            for (int index2 = 0; index2 < num1; ++index2)
                            {
                                Lobby lobby = index1 != 0 ? lobbyList[index2] : Steam.GetSearchLobbyAtIndex(index2);
                                if (this._tryHostingLobby == null || (long)lobby.id != (long)this._tryHostingLobby.id)
                                {
                                    if (index2 == Steam.lobbiesFound - 1)
                                    {
                                        this._failedAttempts.RemoveAll((Predicate <BlacklistServer>)(x => (double)x.cooldown <= 0.0));
                                    }
                                    if (UIMatchmakingBox.nonPreferredServers.Contains(lobby.id) && index1 == 0)
                                    {
                                        lobbyList.Add(lobby);
                                        DevConsole.Log("|PURPLE|MATCHMAKING |DGRED|Skipping " + (object)lobby.id + " (NOT PREFERRED)", Color.White);
                                    }
                                    else if (this.IsBlacklisted(lobby.id))
                                    {
                                        DevConsole.Log("|PURPLE|MATCHMAKING |DGRED|Skipping " + (object)lobby.id + " (BLACKLISTED)", Color.White);
                                    }
                                    else
                                    {
                                        if (this._tryHostingLobby != null)
                                        {
                                            int num2 = -1;
                                            try
                                            {
                                                string lobbyData = lobby.GetLobbyData("randomID");
                                                if (lobbyData != "")
                                                {
                                                    num2 = Convert.ToInt32(lobbyData);
                                                }
                                            }
                                            catch
                                            {
                                            }
                                            if (num2 == -1)
                                            {
                                                DevConsole.Log("|PURPLE|MATCHMAKING |DGYELLOW|Bad lobby seed.", Color.White);
                                                num2 = Rando.Int(2147483646);
                                            }
                                            if (num2 >= this._tryHostingLobby.randomID)
                                            {
                                                DevConsole.Log("|PURPLE|MATCHMAKING |DGYELLOW|Lobby beats own lobby, Attempting join.", Color.White);
                                            }
                                            else
                                            {
                                                DevConsole.Log("|PURPLE|MATCHMAKING |DGYELLOW|Skipping lobby (Chose to keep hosting).", Color.White);
                                                NCSteam.UpdateRandomID(this._tryHostingLobby);
                                                continue;
                                            }
                                        }
                                        this._tryConnectLobby = lobby;
                                        if (lobby.owner != null)
                                        {
                                            this._newStatusList.Add("|LIME|Trying to join " + lobby.owner.name + ".");
                                        }
                                        else
                                        {
                                            this._newStatusList.Add("|LIME|Trying to join server.");
                                        }
                                        this.ChangeState(MatchmakingState.Disconnect);
                                        break;
                                    }
                                }
                            }
                        }
                        if (this._tryConnectLobby == null)
                        {
                            DevConsole.Log("|PURPLE|MATCHMAKING |DGYELLOW|Found no valid lobbies.", Color.White);
                            this.ChangeState(MatchmakingState.SearchForLobbies, 3f);
                            break;
                        }
                        break;
                    }
                    break;

                case MatchmakingState.Waiting:
                    this._stateWait -= Maths.IncFrameTimer();
                    if ((double)this._stateWait <= 0.0)
                    {
                        this._stateWait = 0.0f;
                        this.OnStateChange(this._pendingState);
                        break;
                    }
                    break;

                default:
                    int state = (int)UIMatchmakingBox._state;
                    break;
                }
                if (Input.Pressed("QUACK"))
                {
                    this._quit = true;
                    this.ChangeState(MatchmakingState.Disconnect);
                }
            }
            if (this._newStatusList.Count > 0)
            {
                this._newStatusWait -= 0.1f;
                if ((double)this._newStatusWait <= 0.0)
                {
                    this._newStatusWait = 1f;
                    while ((double)this._fancyFont.GetWidth(this._newStatusList[0]) > 98.0)
                    {
                        this._newStatusList[0] = this._newStatusList[0].Substring(0, this._newStatusList[0].Length - 1);
                    }
                    this._statusList.Add(this._newStatusList[0]);
                    if (this._statusList.Count > 7)
                    {
                        this._statusList.RemoveAt(0);
                    }
                    this._newStatusList.RemoveAt(0);
                }
            }
            base.Update();
        }
 public void Tick() => this._timeSinceReceived += Maths.IncFrameTimer();
 public static void Update()
 {
     foreach (KeyValuePair <NetworkConnection, ConnectionIndicatorElement> connection in ConnectionIndicator._connections)
     {
         if (connection.Value.duck != null && (connection.Value.duck.removeFromLevel || connection.Value.duck.level != Level.current))
         {
             connection.Value.duck = (Duck)null;
         }
         connection.Value.position = connection.Value.duck == null ? new Vec2(-1000f, -1000f) : connection.Value.duck.cameraPosition;
         foreach (KeyValuePair <ConnectionIndicatorType, ConnectionIndicatorDetail> detail in connection.Value.details)
         {
             detail.Value.buildup -= Maths.IncFrameTimer() * 0.25f;
             if ((double)detail.Value.buildup > (double)detail.Value.maxBuildup)
             {
                 detail.Value.buildup = detail.Value.maxBuildup;
             }
             if ((double)detail.Value.buildup < 0.0)
             {
                 detail.Value.buildup = 0.0f;
                 detail.Value.popOut += 0.02f;
                 if ((double)detail.Value.popOut > 1.0)
                 {
                     detail.Value.popOut = 1f;
                 }
                 detail.Value.grow -= 0.1f;
                 if ((double)detail.Value.grow < 0.0)
                 {
                     detail.Value.grow = 0.0f;
                 }
             }
             else
             {
                 detail.Value.popOut = 0.0f;
                 detail.Value.grow   = Lerp.FloatSmooth(detail.Value.grow, 1f, 0.2f);
                 if ((double)detail.Value.grow > 1.0)
                 {
                     detail.Value.grow = 1f;
                 }
             }
         }
     }
     foreach (Duck duck in Level.current.things[typeof(Duck)])
     {
         NetworkConnection key = (NetworkConnection)null;
         if (duck.profile != null && duck.profile.connection != null)
         {
             key = duck.profile.connection;
         }
         if (Network.isActive && key != null)
         {
             ConnectionIndicatorElement indicatorElement = (ConnectionIndicatorElement)null;
             if (!ConnectionIndicator._connections.TryGetValue(key, out indicatorElement))
             {
                 indicatorElement = new ConnectionIndicatorElement();
                 ConnectionIndicator._connections[key] = indicatorElement;
             }
             indicatorElement.duck = duck;
             if ((double)key.manager.ping > 0.25)
             {
                 indicatorElement.GetDetail(ConnectionIndicatorType.Lag).buildup += Maths.IncFrameTimer();
             }
             if ((double)key.manager.ping > 0.899999976158142 || key.status != ConnectionStatus.Connected)
             {
                 indicatorElement.GetDetail(ConnectionIndicatorType.Failure).buildup += Maths.IncFrameTimer();
             }
             if (key.manager.lossThisFrame)
             {
                 indicatorElement.GetDetail(ConnectionIndicatorType.Loss).buildup += 0.2f;
                 key.manager.lossThisFrame = false;
             }
             if ((double)key.manager.jitter > 0.800000011920929)
             {
                 indicatorElement.GetDetail(ConnectionIndicatorType.Loss).buildup += 0.25f;
             }
             ConnectionIndicatorDetail detail1 = indicatorElement.GetDetail(ConnectionIndicatorType.AFK);
             if (!duck.afk)
             {
                 detail1.buildup = 0.0f;
             }
             else
             {
                 detail1.buildup += Maths.IncFrameTimer();
             }
             ConnectionIndicatorDetail detail2 = indicatorElement.GetDetail(ConnectionIndicatorType.Chatting);
             if (duck.chatting)
             {
                 detail2.buildup += 0.25f;
             }
             else
             {
                 detail2.buildup = 0.0f;
             }
         }
     }
     if (ConnectionIndicator._lagIcons != null)
     {
         return;
     }
     ConnectionIndicator._lagIcons = new SpriteMap("lagturtle", 16, 16);
     ConnectionIndicator._lagIcons.CenterOrigin();
     ConnectionIndicator._rainbowGradient = new Sprite("rainbowGradient");
 }
Пример #9
0
 public override void Update()
 {
     this.impacting.Clear();
     if (this._up && this._popup && this.holdObject is Gun)
     {
         Gun   holdObject = this.holdObject as Gun;
         float num        = 300f;
         if (holdObject.ammoType != null)
         {
             num = holdObject.ammoType.range;
         }
         Vec2 vec2 = this.holdObject.position + new Vec2((float)this.offDir * num, 0.0f);
         foreach (Duck duck in Level.current.things[typeof(Duck)].Where <Thing>((Func <Thing, bool>)(d => !(d is TargetDuck))))
         {
             if ((Collision.Line(this.holdObject.position + new Vec2(0.0f, -5f), vec2 + new Vec2(0.0f, -5f), duck.rectangle) || Collision.Line(this.holdObject.position + new Vec2(0.0f, 5f), vec2 + new Vec2(0.0f, 5f), duck.rectangle)) && Level.CheckLine <Block>(this.holdObject.position, duck.position) == null)
             {
                 this._waitFire -= 0.03f;
                 break;
             }
         }
         bool flag = false;
         if ((double)this._autoFireWait > 0.0)
         {
             this._autoFireWait -= Maths.IncFrameTimer();
             if ((double)this._autoFireWait <= 0.0)
             {
                 flag = true;
             }
         }
         if ((double)this._waitFire <= 0.0 || flag)
         {
             holdObject.PressAction();
             this._waitFire = 1f;
         }
         if ((double)this._waitFire < 1.0)
         {
             this._waitFire += 0.01f;
         }
     }
     this.UpdateCollision();
     this.UpdateSkeleton();
     if ((double)this._hitPoints <= 0.0)
     {
         this.Destroy((DestroyType) new DTCrush((PhysicsObject)null));
     }
     if (!this._up)
     {
         this._timeCount = 0.0f;
         if (this._popup)
         {
             this._upSpeed += 0.1f;
         }
         if (this._stance != TargetStance.Fly)
         {
             this.yscale += this._upSpeed;
             if ((double)this.yscale < 1.0)
             {
                 return;
             }
             this.yscale   = 1f;
             this._upSpeed = 0.0f;
             this._up      = true;
             SFX.Play("grappleHook", 0.7f, Rando.Float(-0.2f, 0.2f));
             Level.Add((Thing)SmallSmoke.New(this.x - 4f, this.y));
             Level.Add((Thing)SmallSmoke.New(this.x + 4f, this.y));
             this.SpawnHoldObject();
             if (this.helmet)
             {
                 Helmet helmet = new Helmet(this.x, this.y);
                 Level.Add((Thing)helmet);
                 this.Equip((Equipment)helmet);
             }
             if (!this.chestPlate)
             {
                 return;
             }
             ChestPlate chestPlate = new ChestPlate(this.x, this.y);
             Level.Add((Thing)chestPlate);
             this.Equip((Equipment)chestPlate);
         }
         else
         {
             this.xscale += this._upSpeed;
             if ((double)this.xscale < 1.0)
             {
                 return;
             }
             this.xscale   = 1f;
             this._upSpeed = 0.0f;
             this._up      = true;
             SFX.Play("grappleHook", 0.7f, Rando.Float(-0.2f, 0.2f));
             Level.Add((Thing)SmallSmoke.New(this.x - 4f, this.y));
             Level.Add((Thing)SmallSmoke.New(this.x + 4f, this.y));
             if (this.helmet)
             {
                 Helmet helmet = new Helmet(this.x, this.y);
                 Level.Add((Thing)helmet);
                 this.Equip((Equipment)helmet);
             }
             if (!this.chestPlate)
             {
                 return;
             }
             ChestPlate chestPlate = new ChestPlate(this.x, this.y);
             Level.Add((Thing)chestPlate);
             this.Equip((Equipment)chestPlate);
         }
     }
     else
     {
         this._timeCount += Maths.IncFrameTimer();
         if (this._popup && (double)this.time.value != 0.0 && (double)this._timeCount >= (double)this.time.value)
         {
             SFX.Play("grappleHook", 0.2f, Rando.Float(-0.2f, 0.2f));
             this.PopDown();
         }
         else
         {
             if (!this._popup)
             {
                 this._upSpeed += 0.1f;
             }
             if (this._stance != TargetStance.Fly)
             {
                 this.yscale -= this._upSpeed;
                 if ((double)this.yscale >= 0.0)
                 {
                     return;
                 }
                 this.yscale   = 0.0f;
                 this._upSpeed = 0.0f;
                 this._up      = false;
                 SFX.Play("grappleHook", 0.2f, Rando.Float(-0.2f, 0.2f));
                 Level.Add((Thing)SmallSmoke.New(this.x - 4f, this.y));
                 Level.Add((Thing)SmallSmoke.New(this.x + 4f, this.y));
                 this._hitPoints = this._maxHealth = 0.1f;
             }
             else
             {
                 this.xscale -= this._upSpeed;
                 if ((double)this.xscale >= 0.0)
                 {
                     return;
                 }
                 this.xscale   = 0.0f;
                 this._upSpeed = 0.0f;
                 this._up      = false;
                 SFX.Play("grappleHook", 0.2f, Rando.Float(-0.2f, 0.2f));
                 Level.Add((Thing)SmallSmoke.New(this.x - 4f, this.y));
                 Level.Add((Thing)SmallSmoke.New(this.x + 4f, this.y));
                 this._hitPoints = this._maxHealth = 0.1f;
             }
         }
     }
 }
Пример #10
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()
 {
     if (this._testMode)
     {
         this._wait += Maths.IncFrameTimer();
         if (Keyboard.Pressed(Keys.F5) || (double)this._wait > 0.1)
         {
             this._wait = 0.0f;
             try
             {
                 this._tie        = new SpriteMap((Tex2D)ContentPack.LoadTexture2D("tieTest.png"), 64, 64);
                 this._tie.center = new Vec2(26f, 27f);
             }
             catch (Exception ex)
             {
             }
         }
     }
     DuckGame.Graphics.fadeAdd = Lerp.Float(DuckGame.Graphics.fadeAdd, 0.0f, 0.01f);
     if (Main.isDemo && this._skip && !this._firedSkipLogic)
     {
         this._firedSkipLogic = true;
         Vote.CloseVoting();
         HUD.CloseAllCorners();
         this.DoSkip();
     }
     if ((double)DuckGame.Graphics.fade > 0.990000009536743 && !this._skip && Vote.Passed(VoteType.Skip))
     {
         this._skip = true;
     }
     if (this._talker.finished || !HighlightLevel._cancelSkip && this._skip && !Main.isDemo)
     {
         this._done -= 0.04f;
     }
     DuckGame.Graphics.fade = Lerp.Float(DuckGame.Graphics.fade, (double)this._done < 0.0 ? 0.0f : 1f, 0.02f);
     if ((double)DuckGame.Graphics.fade < 0.00999999977648258 && (this._talker.finished || this._skip))
     {
         if (this._endOfHighlights || this._skip)
         {
             Vote.CloseVoting();
             Level.current = (Level) new RockScoreboard(RockScoreboard.returnLevel, ScoreBoardMode.ShowWinner, true);
         }
         else
         {
             Level.current = (Level) new HighlightPlayback(4);
         }
     }
     if (this._state == TVState.ShowPedestals)
     {
         this._waitZoom -= 0.008f;
         if ((double)this._waitZoom < 0.00999999977648258)
         {
             this._waitZoom     = 0.0f;
             this._desiredState = TVState.ShowNewscaster;
         }
     }
     if (this._state == TVState.ShowHotness && this._hotness.ready)
     {
         this._talker.Resume();
     }
     if (this._state == TVState.ShowInterview)
     {
         this._interviewWait -= 0.02f;
         if ((double)this._interviewWait < 0.0 && !this._askedQuestion)
         {
             this._talker.InsertLine(Script.winner() + "! To what do you attribute your success?", this._interviewIndex);
             this._talker.Resume();
             this._askedQuestion = true;
         }
     }
     this._cameraOffset.x = Lerp.Float(this._cameraOffset.x, HighlightLevel._image != null ? 20f : 0.0f, 2f);
     this._talker.active  = this._talker.visible = this._state != TVState.ShowPedestals;
     if (this._state == this._desiredState)
     {
         return;
     }
     this._talker.active = false;
     this._transition.PlaySwipe();
     if (!this._transition.doTransition)
     {
         return;
     }
     this._state = this._desiredState;
 }
Пример #12
0
 public override void Update()
 {
     base.Update();
     this._sprite.frame = this._owner == null || this._raised ? 0 : 1;
     this._raiseArm     = Lerp.Float(this._raiseArm, 0.0f, 0.05f);
     this._preachWait   = Lerp.Float(this._preachWait, 0.0f, 0.06f);
     this._ringPulse    = Lerp.Float(this._ringPulse, 0.0f, 0.05f);
     if (Network.isActive)
     {
         if (this.isServerForObject)
         {
             if (this.controlling1)
             {
                 Duck duck = this.GetDuck(0);
                 if (duck != null)
                 {
                     if (duck.listenTime <= 0)
                     {
                         this.controlling1 = false;
                     }
                     else
                     {
                         this.Fondle((Thing)duck);
                         this.Fondle((Thing)duck.holdObject);
                         foreach (Thing t in duck._equipment)
                         {
                             this.Fondle(t);
                         }
                         this.Fondle((Thing)duck._ragdollInstance);
                         this.Fondle((Thing)duck._trappedInstance);
                         this.Fondle((Thing)duck._cookedInstance);
                     }
                 }
             }
             if (this.controlling2)
             {
                 Duck duck = this.GetDuck(1);
                 if (duck != null)
                 {
                     if (duck.listenTime <= 0)
                     {
                         this.controlling2 = false;
                     }
                     else
                     {
                         this.Fondle((Thing)duck);
                         this.Fondle((Thing)duck.holdObject);
                         foreach (Thing t in duck._equipment)
                         {
                             this.Fondle(t);
                         }
                         this.Fondle((Thing)duck._ragdollInstance);
                         this.Fondle((Thing)duck._trappedInstance);
                         this.Fondle((Thing)duck._cookedInstance);
                     }
                 }
             }
             if (this.controlling3)
             {
                 Duck duck = this.GetDuck(2);
                 if (duck != null)
                 {
                     if (duck.listenTime <= 0)
                     {
                         this.controlling3 = false;
                     }
                     else
                     {
                         this.Fondle((Thing)duck);
                         this.Fondle((Thing)duck.holdObject);
                         foreach (Thing t in duck._equipment)
                         {
                             this.Fondle(t);
                         }
                         this.Fondle((Thing)duck._ragdollInstance);
                         this.Fondle((Thing)duck._trappedInstance);
                         this.Fondle((Thing)duck._cookedInstance);
                     }
                 }
             }
             if (this.controlling4)
             {
                 Duck duck = this.GetDuck(3);
                 if (duck != null)
                 {
                     if (duck.listenTime <= 0)
                     {
                         this.controlling4 = false;
                     }
                     else
                     {
                         this.Fondle((Thing)duck);
                         this.Fondle((Thing)duck.holdObject);
                         foreach (Thing t in duck._equipment)
                         {
                             this.Fondle(t);
                         }
                         this.Fondle((Thing)duck._ragdollInstance);
                         this.Fondle((Thing)duck._trappedInstance);
                         this.Fondle((Thing)duck._cookedInstance);
                     }
                 }
             }
         }
         else
         {
             Duck duck1 = this.GetDuck(0);
             if (duck1 != null)
             {
                 if (this.controlling1)
                 {
                     duck1.listening = true;
                     duck1.Fondle((Thing)duck1.holdObject);
                     foreach (Equipment equipment in duck1._equipment)
                     {
                         duck1.Fondle((Thing)equipment);
                     }
                     duck1.Fondle((Thing)duck1._ragdollInstance);
                     duck1.Fondle((Thing)duck1._trappedInstance);
                     duck1.Fondle((Thing)duck1._cookedInstance);
                 }
                 if (!this.controlling1 && this.prevControlling1)
                 {
                     duck1.listening = false;
                 }
                 this.prevControlling1 = this.controlling1;
             }
             Duck duck2 = this.GetDuck(1);
             if (duck2 != null)
             {
                 if (this.controlling2)
                 {
                     duck2.listening = true;
                     duck2.Fondle((Thing)duck2.holdObject);
                     foreach (Equipment equipment in duck2._equipment)
                     {
                         duck2.Fondle((Thing)equipment);
                     }
                     duck2.Fondle((Thing)duck2._ragdollInstance);
                     duck2.Fondle((Thing)duck2._trappedInstance);
                     duck2.Fondle((Thing)duck2._cookedInstance);
                 }
                 if (!this.controlling2 && this.prevControlling2)
                 {
                     duck2.listening = false;
                 }
                 this.prevControlling2 = this.controlling2;
             }
             Duck duck3 = this.GetDuck(2);
             if (duck3 != null)
             {
                 if (this.controlling3)
                 {
                     duck3.listening = true;
                     duck3.Fondle((Thing)duck3.holdObject);
                     foreach (Equipment equipment in duck3._equipment)
                     {
                         duck3.Fondle((Thing)equipment);
                     }
                     duck3.Fondle((Thing)duck3._ragdollInstance);
                     duck3.Fondle((Thing)duck3._trappedInstance);
                     duck3.Fondle((Thing)duck3._cookedInstance);
                 }
                 if (!this.controlling3 && this.prevControlling3)
                 {
                     duck3.listening = false;
                 }
                 this.prevControlling3 = this.controlling3;
             }
             Duck duck4 = this.GetDuck(3);
             if (duck4 != null)
             {
                 if (this.controlling4)
                 {
                     duck4.listening = true;
                     duck4.Fondle((Thing)duck4.holdObject);
                     foreach (Equipment equipment in duck4._equipment)
                     {
                         duck4.Fondle((Thing)equipment);
                     }
                     duck4.Fondle((Thing)duck4._ragdollInstance);
                     duck4.Fondle((Thing)duck4._trappedInstance);
                     duck4.Fondle((Thing)duck4._cookedInstance);
                 }
                 if (!this.controlling4 && this.prevControlling4)
                 {
                     duck4.listening = false;
                 }
                 this.prevControlling4 = this.controlling4;
             }
         }
     }
     if (this._triggerHeld && this.isServerForObject && (this.duck != null && (double)this._preachWait <= 0.0 & this.duck.quack < 1) && this.duck.grounded)
     {
         if (Network.isActive)
         {
             this._netPreach.Play();
         }
         else
         {
             SFX.Play("preach" + (object)Rando.Int(5), Rando.Float(0.8f, 1f), Rando.Float(-0.2f, -0.3f));
         }
         this.duck.quack = (int)(byte)Rando.Int(12, 30);
         this.duck.profile.stats.timePreaching += (float)this.duck.quack / 0.1f * Maths.IncFrameTimer();
         this._preachWait = Rando.Float(1.8f, 2.5f);
         this._ringPulse  = 1f;
         if (Rando.Int(1) == 0)
         {
             this._raiseArm = Rando.Float(1.2f, 2f);
         }
         Ragdoll ragdoll = Level.Nearest <Ragdoll>(this.x, this.y, (Thing)this);
         if (ragdoll != null && ragdoll.captureDuck != null && (ragdoll.captureDuck.dead && Level.CheckLine <Block>(this.duck.position, ragdoll.position) == null) && (double)(ragdoll.position - this.duck.position).length < (double)this._ammoType.range)
         {
             if (Network.isActive)
             {
                 this.Fondle((Thing)ragdoll.captureDuck);
                 this.Fondle((Thing)ragdoll);
                 Send.Message((NetMessage) new NMLayToRest(ragdoll.captureDuck.profile.networkIndex));
             }
             ragdoll.captureDuck.LayToRest(this.duck.profile);
         }
         foreach (Duck duck in Level.current.things[typeof(Duck)])
         {
             if (duck != this.duck && duck.grounded && (!(duck.holdObject is GoodBook) && Level.CheckLine <Block>(this.duck.position, duck.position) == null) && (double)(duck.position - this.duck.position).length < (double)this._ammoType.range)
             {
                 if (duck.dead)
                 {
                     this.Fondle((Thing)duck);
                     duck.LayToRest(this.duck.profile);
                 }
                 else if (duck.converted != this.duck && this.duck.converted != duck && duck.profile.team != this.duck.profile.team)
                 {
                     if (Network.isActive)
                     {
                         if (duck.profile.networkIndex == (byte)0)
                         {
                             this.controlling1 = true;
                         }
                         if (duck.profile.networkIndex == (byte)1)
                         {
                             this.controlling2 = true;
                         }
                         if (duck.profile.networkIndex == (byte)2)
                         {
                             this.controlling3 = true;
                         }
                         if (duck.profile.networkIndex == (byte)3)
                         {
                             this.controlling4 = true;
                         }
                     }
                     duck.listening = true;
                     this.Fondle((Thing)duck);
                     this.Fondle((Thing)duck.holdObject);
                     foreach (Thing t in duck._equipment)
                     {
                         this.Fondle(t);
                     }
                     this.Fondle((Thing)duck._ragdollInstance);
                     this.Fondle((Thing)duck._trappedInstance);
                     this.Fondle((Thing)duck._cookedInstance);
                     duck.listenTime = 80;
                     if ((double)this.owner.x < (double)duck.x)
                     {
                         duck.offDir = (sbyte)-1;
                     }
                     else
                     {
                         duck.offDir = (sbyte)1;
                     }
                     duck.ThrowItem(false);
                     duck.conversionResistance -= 30;
                     if (duck.conversionResistance <= 0)
                     {
                         duck.ConvertDuck(this.duck.converted != null ? this.duck.converted : this.duck);
                         if (Network.isActive)
                         {
                             Send.Message((NetMessage) new NMConversion(duck.profile.networkIndex, this.duck.profile.networkIndex));
                         }
                         duck.conversionResistance = 50;
                     }
                 }
             }
         }
     }
     this._haloAlpha = Lerp.Float(this._haloAlpha, !this._triggerHeld || this.duck == null || !this.duck.grounded ? 0.0f : 1f, 0.05f);
 }
Пример #13
0
 public override void Update()
 {
     this._sprite.frame = (int)((double)this._heat * 7.0);
     if (this._equippedDuck != null)
     {
         float num1 = 0.0f;
         this._offset = new Vec2(-3f, 3f);
         this.angle   = 0.0f;
         if (this._equippedDuck.sliding && this._equippedDuck._trapped == null)
         {
             if (this._equippedDuck.offDir > (sbyte)0)
             {
                 this.angle = -1.570796f;
             }
             else
             {
                 this.angle = 1.570796f;
             }
             this._offset.y += 12f;
             num1           -= 6f;
         }
         if (this._equippedDuck.crouch && !this._equippedDuck.sliding)
         {
             this._offset.y += 4f;
         }
         this.collisionOffset = new Vec2(0.0f, -9999f);
         this.collisionSize   = new Vec2(0.0f, 0.0f);
         this.solid           = false;
         PhysicsObject physicsObject1 = (PhysicsObject)this._equippedDuck;
         if (this._equippedDuck._trapped != null)
         {
             physicsObject1 = (PhysicsObject)this._equippedDuck._trapped;
         }
         else if (this._equippedDuck.ragdoll != null && this._equippedDuck.ragdoll.part1 != null)
         {
             physicsObject1 = (PhysicsObject)this._equippedDuck.ragdoll.part1;
         }
         this._sprite.flipH = this._equippedDuck._sprite.flipH;
         if (this._on && (double)this._heat < 1.0)
         {
             if (this._equippedDuck._trapped == null && this._equippedDuck.crouch)
             {
                 this._equippedDuck.sliding = true;
             }
             if (this.isServerForObject)
             {
                 Global.data.jetFuelUsed.valueFloat += Maths.IncFrameTimer();
             }
             this._heat += 11f / 1000f;
             if (physicsObject1 is RagdollPart)
             {
                 float angle = this.angle;
                 this.angle = physicsObject1.angle;
                 Vec2 vec2_1 = this.Offset(new Vec2(0.0f, 8f));
                 Level.Add((Thing) new JetpackSmoke(vec2_1.x, vec2_1.y));
                 this.angle = angle;
                 if ((double)physicsObject1.velocity.length < 7.0)
                 {
                     RagdollPart ragdollPart = physicsObject1 as RagdollPart;
                     ragdollPart.addWeight = 0.2f;
                     this._equippedDuck.ragdoll.jetting = true;
                     float num2   = (float)-((double)physicsObject1.angle - 1.57079637050629);
                     Vec2  vec2_2 = Vec2.Zero;
                     if ((double)this._equippedDuck.inputProfile.leftStick.length > 0.100000001490116)
                     {
                         vec2_2 = new Vec2(this._equippedDuck.inputProfile.leftStick.x, -this._equippedDuck.inputProfile.leftStick.y);
                     }
                     else
                     {
                         vec2_2 = new Vec2(0.0f, 0.0f);
                         if (this._equippedDuck.inputProfile.Down("LEFT"))
                         {
                             --vec2_2.x;
                         }
                         if (this._equippedDuck.inputProfile.Down("RIGHT"))
                         {
                             ++vec2_2.x;
                         }
                         if (this._equippedDuck.inputProfile.Down("UP"))
                         {
                             --vec2_2.y;
                         }
                         if (this._equippedDuck.inputProfile.Down("DOWN"))
                         {
                             ++vec2_2.y;
                         }
                     }
                     if ((double)vec2_2.length < 0.100000001490116)
                     {
                         vec2_2 = new Vec2((float)Math.Cos((double)num2), (float)-Math.Sin((double)num2));
                     }
                     PhysicsObject physicsObject2 = physicsObject1;
                     physicsObject2.velocity = physicsObject2.velocity + vec2_2 * 1.5f;
                     if (ragdollPart.doll != null && ragdollPart.doll.part1 != null && (ragdollPart.doll.part2 != null && ragdollPart.doll.part3 != null))
                     {
                         ragdollPart.doll.part1.extraGravMultiplier = 0.4f;
                         ragdollPart.doll.part2.extraGravMultiplier = 0.4f;
                         ragdollPart.doll.part3.extraGravMultiplier = 0.7f;
                     }
                 }
             }
             else
             {
                 Level.Add((Thing) new JetpackSmoke(this.x, this.y + 8f + num1));
                 if ((double)this.angle > 0.0)
                 {
                     if ((double)physicsObject1.hSpeed < 6.0)
                     {
                         physicsObject1.hSpeed += 0.9f;
                     }
                 }
                 else if ((double)this.angle < 0.0)
                 {
                     if ((double)physicsObject1.hSpeed > -6.0)
                     {
                         physicsObject1.hSpeed -= 0.9f;
                     }
                 }
                 else if ((double)physicsObject1.vSpeed > -4.5)
                 {
                     physicsObject1.vSpeed -= 0.38f;
                 }
             }
         }
         if ((double)this._heat >= 1.0)
         {
             this._on = false;
         }
         if (physicsObject1.grounded)
         {
             if ((double)this._heat > 0.0)
             {
                 this._heat -= 0.25f;
             }
             else
             {
                 this._heat = 0.0f;
             }
         }
     }
     else
     {
         this._sprite.flipH   = false;
         this.collisionOffset = new Vec2(-5f, -5f);
         this.collisionSize   = new Vec2(11f, 12f);
         this.solid           = true;
     }
     base.Update();
 }
Пример #14
0
        public override void Update()
        {
            if (RockWeather.alwaysRainbow)
            {
                RockWeather.rainbowFade = 1f;
                RockWeather.rainbowTime = 1f;
            }
            RockWeather.rainbowFade  = Lerp.Float(RockWeather.rainbowFade, (double)RockWeather.rainbowTime > 0.0 ? 1f : 0.0f, 1f / 1000f);
            RockWeather.rainbowTime -= Maths.IncFrameTimer();
            if (RockWeather._weather != Weather.Sunny)
            {
                RockWeather.rainbowTime -= Maths.IncFrameTimer() * 8f;
            }
            if ((double)RockWeather.rainbowTime < 0.0)
            {
                RockWeather.rainbowTime = 0.0f;
            }
            if (RockWeather.neverRainbow)
            {
                RockWeather.rainbowFade = 0.0f;
            }
            RockWeatherState weatherState = this.GetWeatherState(RockWeather._timeOfDay);

            this.rainbowLight  = weatherState.rainbowLight * RockWeather.rainbowFade;
            this.rainbowLight2 = weatherState.rainbowLight2 * RockWeather.rainbowFade;
            this.ApplyWeatherState(weatherState);
            RockWeather._prevWeatherLerp = Lerp.Float(RockWeather._prevWeatherLerp, 0.0f, 0.05f);
            if (Network.isServer)
            {
                this.wait += 3f / 1000f;
                if ((double)this.wait > 1.0)
                {
                    this.wait = 0.0f;
                    if ((double)RockWeather._weatherTime > 0.100000001490116)
                    {
                        if ((double)RockWeather.snowChance > 0.0 && RockWeather._weather != Weather.Snowing && (double)Rando.Float(1f) > 1.0 - (double)RockWeather.snowChance)
                        {
                            RockWeather._prevWeatherLerp = 1f;
                            RockWeather.sunshowers       = 0.0f;
                            RockWeather._prevWeather     = RockWeather._weather;
                            RockWeather._weather         = Weather.Snowing;
                            if (Network.isActive)
                            {
                                Send.Message((NetMessage) new NMChangeWeather((byte)RockWeather._weather));
                            }
                            RockWeather._weatherTime = 0.0f;
                        }
                        if ((double)RockWeather.rainChance > 0.0 && RockWeather._weather != Weather.Raining && (double)Rando.Float(1f) > 1.0 - (double)RockWeather.rainChance)
                        {
                            RockWeather._prevWeatherLerp = 1f;
                            RockWeather.sunshowers       = 0.0f;
                            RockWeather._prevWeather     = RockWeather._weather;
                            RockWeather._weather         = Weather.Raining;
                            if (Network.isActive)
                            {
                                Send.Message((NetMessage) new NMChangeWeather((byte)RockWeather._weather));
                            }
                            RockWeather._weatherTime = 0.0f;
                        }
                        if (RockWeather._weather != Weather.Sunny && (double)Rando.Float(1f) > 0.980000019073486)
                        {
                            RockWeather._prevWeatherLerp = 1f;
                            if (RockWeather._weather == Weather.Raining)
                            {
                                if ((double)RockWeather._timeRaining > 900.0 && (double)Rando.Float(1f) > 0.850000023841858 || (double)Rando.Float(1f) > 0.949999988079071)
                                {
                                    RockWeather.rainbowTime = Rando.Float(30f, 240f);
                                }
                                if ((double)Rando.Float(1f) > 0.300000011920929)
                                {
                                    RockWeather.sunshowers = Rando.Float(0.1f, 60f);
                                }
                            }
                            RockWeather._timeRaining = 0.0f;
                            RockWeather._prevWeather = RockWeather._weather;
                            RockWeather._weather     = Weather.Sunny;
                            if (Network.isActive)
                            {
                                Send.Message((NetMessage) new NMChangeWeather((byte)RockWeather._weather));
                            }
                            RockWeather._weatherTime = 0.0f;
                        }
                    }
                }
            }
            RockWeather.sunshowers -= Maths.IncFrameTimer();
            if ((double)RockWeather.sunshowers <= 0.0)
            {
                RockWeather.sunshowers = 0.0f;
            }
            switch (RockWeather._weather)
            {
            case Weather.Snowing:
                while ((double)this._particleWait <= 0.0)
                {
                    ++this._particleWait;
                    SnowParticle snowParticle = new SnowParticle(new Vec2(Rando.Float(-100f, 400f), Rando.Float(-500f, -550f)));
                    snowParticle.z = Rando.Float(0.0f, 200f);
                    this._particles.Add((WeatherParticle)snowParticle);
                }
                this._particleWait -= 0.5f;
                break;

            case Weather.Raining:
                while ((double)this._particleWait <= 0.0)
                {
                    ++this._particleWait;
                    RainParticle rainParticle = new RainParticle(new Vec2(Rando.Float(-100f, 900f), Rando.Float(-500f, -550f)));
                    rainParticle.z = Rando.Float(0.0f, 200f);
                    this._particles.Add((WeatherParticle)rainParticle);
                }
                --this._particleWait;
                break;

            default:
                if ((double)RockWeather.sunshowers <= 0.0)
                {
                    break;
                }
                goto case Weather.Raining;
            }
            List <WeatherParticle> weatherParticleList = new List <WeatherParticle>();

            foreach (WeatherParticle particle in this._particles)
            {
                particle.Update();
                if ((double)particle.position.y > 0.0)
                {
                    particle.die = true;
                }
                switch (particle)
                {
                case RainParticle _ when(double) particle.z <70.0 && (double)particle.position.y> -62.0:
                    particle.die = true;

                    particle.position.y = -58f;
                    break;

                case RainParticle _ when(double) particle.z <40.0 && (double)particle.position.y> -98.0:
                    particle.die = true;

                    particle.position.y = -98f;
                    break;

                case RainParticle _ when(double) particle.z < 25.0 && ((double)particle.position.x > 175.0 && (double)particle.position.x < 430.0) && ((double)particle.position.y > -362.0 && (double)particle.position.y < -352.0):
                    particle.die = true;

                    particle.position.y = -362f;
                    break;
                }
                if ((double)particle.alpha < 0.00999999977648258)
                {
                    weatherParticleList.Add(particle);
                }
            }
            foreach (WeatherParticle weatherParticle in weatherParticleList)
            {
                this._particles.Remove(weatherParticle);
            }
        }
Пример #15
0
        public override void Update()
        {
            if (!this.pin)
            {
                this.collisionOffset = new Vec2(-6f, -2f);
                this.collisionSize   = new Vec2(12f, 3f);
            }
            base.Update();
            if (!this.pin && (double)Math.Abs(this.prevAngle - this.angle) > 0.100000001490116)
            {
                Vec2  vec2_1 = new Vec2(14f, 3f);
                Vec2  vec2_2 = new Vec2(-7f, -2f);
                Vec2  vec2_3 = new Vec2(4f, 14f);
                Vec2  vec2_4 = new Vec2(-2f, -7f);
                float num    = (float)Math.Abs(Math.Sin((double)this.angle));
                this.collisionSize   = vec2_1 * (1f - num) + vec2_3 * num;
                this.collisionOffset = vec2_2 * (1f - num) + vec2_4 * num;
                this.prevAngle       = this.angle;
            }
            this.UpdatePinState();
            if (this._sprite.imageIndex == 2)
            {
                this._mineFlash.alpha = Lerp.Float(this._mineFlash.alpha, 0.4f, 0.08f);
            }
            else
            {
                this._mineFlash.alpha = Lerp.Float(this._mineFlash.alpha, 0.0f, 0.08f);
            }
            if (this._armed)
            {
                this._sprite.speed = 2f;
            }
            if (this._thrown && this.owner == null)
            {
                this._thrown = false;
                if ((double)Math.Abs(this.hSpeed) + (double)Math.Abs(this.vSpeed) > 0.400000005960464)
                {
                    this.angleDegrees = 180f;
                }
            }
            if (this._armed)
            {
                ++this._framesSinceArm;
            }
            if (!this._pin && this._grounded && (!this._armed || this._framesSinceArm > 4))
            {
                this.canPickUp = false;
                float addWeight = this.addWeight;
                IEnumerable <PhysicsObject> physicsObjects = Level.CheckLineAll <PhysicsObject>(new Vec2(this.x - 6f, this.y - 3f), new Vec2(this.x + 6f, this.y - 3f));
                List <Duck> duckList1 = new List <Duck>();
                Duck        duck      = (Duck)null;
                bool        flag      = false;
                foreach (Thing previousThing in this.previousThings)
                {
                    if (previousThing.isServerForObject)
                    {
                        flag = true;
                    }
                }
                this.previousThings.Clear();
                foreach (PhysicsObject physicsObject in physicsObjects)
                {
                    if (physicsObject != this && physicsObject.owner == null && (!(physicsObject is Holdable) || (physicsObject as Holdable).canPickUp && (physicsObject as Holdable).hoverSpawner == null) && (double)Math.Abs(physicsObject.bottom - this.bottom) <= 6.0)
                    {
                        this.previousThings.Add(physicsObject);
                        switch (physicsObject)
                        {
                        case Duck _:
                        case TrappedDuck _:
                        case RagdollPart _:
                            addWeight += 5f;
                            Duck key1 = physicsObject as Duck;
                            if (physicsObject is TrappedDuck)
                            {
                                key1 = (physicsObject as TrappedDuck).captureDuck;
                            }
                            else if (physicsObject is RagdollPart && (physicsObject as RagdollPart).doll != null)
                            {
                                key1 = (physicsObject as RagdollPart).doll.captureDuck;
                            }
                            if (key1 != null)
                            {
                                duck = key1;
                                if (!this._ducksOnMine.ContainsKey(key1))
                                {
                                    this._ducksOnMine[key1] = 0.0f;
                                }
                                Dictionary <Duck, float> ducksOnMine;
                                Duck key2;
                                (ducksOnMine = this._ducksOnMine)[key2 = key1] = ducksOnMine[key2] + Maths.IncFrameTimer();
                                duckList1.Add(key1);
                                continue;
                            }
                            continue;

                        default:
                            addWeight += physicsObject.weight;
                            continue;
                        }
                    }
                }
                List <Duck> duckList2 = new List <Duck>();
                foreach (KeyValuePair <Duck, float> keyValuePair in this._ducksOnMine)
                {
                    if (!duckList1.Contains(keyValuePair.Key))
                    {
                        duckList2.Add(keyValuePair.Key);
                    }
                    else
                    {
                        keyValuePair.Key.profile.stats.timeSpentOnMines += Maths.IncFrameTimer();
                    }
                }
                foreach (Duck key in duckList2)
                {
                    this._ducksOnMine.Remove(key);
                }
                if ((double)addWeight < (double)this._holdingWeight && flag)
                {
                    Thing.Fondle((Thing)this, DuckNetwork.localConnection);
                    if (!this._armed)
                    {
                        this.Arm();
                    }
                    else
                    {
                        this._timer = -1f;
                    }
                }
                if (this._armed && (double)addWeight > (double)this._holdingWeight)
                {
                    if (!this._clicked && duck != null)
                    {
                        ++duck.profile.stats.minesSteppedOn;
                    }
                    this._clicked = true;
                    if (Network.isActive)
                    {
                        this._netDoubleBeep.Play();
                    }
                    else
                    {
                        SFX.Play("doubleBeep");
                    }
                }
                this._holdingWeight = addWeight;
            }
            if ((double)this._timer < 0.0 && this.isServerForObject)
            {
                this._timer = 1f;
                this.BlowUp();
            }
            this.addWeight = 0.0f;
        }