コード例 #1
0
ファイル: SequencerExe.cs プロジェクト: strangea/OpenHacknet
 public override void Update(float t)
 {
     base.Update(t);
     if (HasBeenKilled)
         return;
     bars.Update(t);
     UpdateRamCost(t);
     stateTimer += t;
     switch (state)
     {
         case SequencerExeState.Unavaliable:
             if (os.Flags.HasFlag(flagForProgressionName) || Settings.debugCommandsEnabled)
             {
                 state = SequencerExeState.AwaitingActivation;
                 break;
             }
             bars.MinLineChangeTime = 1f;
             bars.MaxLineChangeTime = 3f;
             break;
         case SequencerExeState.SpinningUp:
             if (MediaPlayer.State == MediaState.Playing)
             {
                 if (MediaPlayer.PlayPosition.TotalSeconds < beatDropTime || stateTimer <= 10.0)
                     break;
                 MoveToActiveState();
                 break;
             }
             if (stateTimer <= (double) SPIN_UP_TIME)
                 break;
             MoveToActiveState();
             break;
         case SequencerExeState.Active:
             var num = 2.5f;
             if (stateTimer < (double) num)
             {
                 if (Utils.randm(1f) < 0.300000011920929 + stateTimer/(double) num*0.699999988079071)
                 {
                     ThemeManager.switchThemeColors(os, targetTheme);
                     ThemeManager.loadThemeBackground(os, targetTheme);
                     ThemeManager.currentTheme = targetTheme;
                 }
                 else
                 {
                     ThemeManager.switchThemeColors(os, originalTheme);
                     ThemeManager.loadThemeBackground(os, originalTheme);
                     ThemeManager.currentTheme = originalTheme;
                 }
                 if ((MediaPlayer.PlayPosition.TotalSeconds - beatDropTime)%beatHits < 0.00999999977648258)
                     os.warningFlash();
             }
             ActiveStateUpdate(t);
             break;
     }
 }
コード例 #2
0
ファイル: SequencerExe.cs プロジェクト: strangea/OpenHacknet
 private void MoveToActiveState()
 {
     state                          = SequencerExeState.Active;
     stateTimer                     = 0.0f;
     targetRamUse                   = BASE_RAM_COST;
     os.warningFlashTimer           = OS.WARNING_FLASH_TIME;
     os.netMap.DimNonConnectedNodes = true;
     os.netMap.discoverNode(targetComp);
     os.runCommand("connect " + targetComp.ip);
     os.delayer.Post(ActionDelayer.Wait(0.05), () => os.runCommand("probe"));
 }
コード例 #3
0
ファイル: SequencerExe.cs プロジェクト: strangea/OpenHacknet
 public override void Draw(float t)
 {
     base.Draw(t);
     drawOutline();
     drawTarget("app:");
     var rectangle = Utils.InsetRectangle(GetContentAreaDest(), 1);
     var amount = os.warningFlashTimer/OS.WARNING_FLASH_TIME;
     var minHeight = 2f;
     if (amount > 0.0)
         minHeight += amount*(rectangle.Height - minHeight);
     var drawColor = Color.Lerp(Utils.AddativeWhite*0.5f, Utils.AddativeRed, amount);
     bars.Draw(spriteBatch, GetContentAreaDest(), minHeight, 4f, 1f, drawColor);
     switch (state)
     {
         case SequencerExeState.Unavaliable:
             spriteBatch.Draw(Utils.white, rectangle, Color.Black*0.5f);
             var dest = Utils.InsetRectangle(rectangle, 6);
             if (!isExiting)
                 TextItem.doFontLabelToSize(dest, "LINK UNAVAILABLE", GuiData.titlefont, Utils.AddativeWhite);
             var destinationRectangle1 = dest;
             destinationRectangle1.Y += destinationRectangle1.Height - 20;
             destinationRectangle1.Height = 20;
             if (isExiting)
                 break;
             GuiData.spriteBatch.Draw(Utils.white, destinationRectangle1, Color.Black*0.5f);
             if (
                 !Button.doButton(32711803, destinationRectangle1.X, destinationRectangle1.Y,
                     destinationRectangle1.Width, destinationRectangle1.Height, "Exit", os.lockedColor))
                 break;
             isExiting = true;
             break;
         case SequencerExeState.AwaitingActivation:
             var height = 30;
             var destinationRectangle2 = new Rectangle(this.bounds.X + 1,
                 this.bounds.Y + this.bounds.Height/2 - height, this.bounds.Width - 2, height*2);
             spriteBatch.Draw(Utils.white, destinationRectangle2, Color.Black*0.92f);
             if (
                 !Button.doButton(8310101, this.bounds.X + 10, this.bounds.Y + this.bounds.Height/2 - height/2,
                     this.bounds.Width - 20, height, "ACTIVATE", os.highlightColor))
                 break;
             stateTimer = 0.0f;
             state = SequencerExeState.SpinningUp;
             bars.MinLineChangeTime = 0.1f;
             bars.MaxLineChangeTime = 1f;
             originalTheme = ThemeManager.currentTheme;
             MusicManager.FADE_TIME = 0.6f;
             oldSongName = MusicManager.currentSongName;
             MusicManager.transitionToSong("Music\\Roller_Mobster_Clipped");
             MediaPlayer.IsRepeating = false;
             targetComp = Programs.getComputer(os, targetID);
             var webServerDaemon = (WebServerDaemon) targetComp.getDaemon(typeof (WebServerDaemon));
             if (webServerDaemon == null)
                 break;
             webServerDaemon.LoadWebPage("index.html");
             break;
         case SequencerExeState.SpinningUp:
             var bounds = rectangle;
             bounds.Height = (int) (bounds.Height*(stateTimer/(double) SPIN_UP_TIME));
             bounds.Y = rectangle.Y + rectangle.Height - bounds.Height + 1;
             bounds.Width += 4;
             bars.Draw(spriteBatch, bounds, minHeight, 4f, 1f, os.brightLockedColor);
             break;
         case SequencerExeState.Active:
             spriteBatch.Draw(Utils.white, GetContentAreaDest(), Color.Black*0.5f);
             TextItem.doFontLabelToSize(GetContentAreaDest(), " G O   G O   G O ", GuiData.titlefont,
                 Color.Lerp(Utils.AddativeRed, os.brightLockedColor, Math.Min(1f, stateTimer/2f)));
             DrawActiveState();
             break;
     }
 }
コード例 #4
0
ファイル: SequencerExe.cs プロジェクト: strangea/OpenHacknet
 private void MoveToActiveState()
 {
     state = SequencerExeState.Active;
     stateTimer = 0.0f;
     targetRamUse = BASE_RAM_COST;
     os.warningFlashTimer = OS.WARNING_FLASH_TIME;
     os.netMap.DimNonConnectedNodes = true;
     os.netMap.discoverNode(targetComp);
     os.runCommand("connect " + targetComp.ip);
     os.delayer.Post(ActionDelayer.Wait(0.05), () => os.runCommand("probe"));
 }
コード例 #5
0
ファイル: SequencerExe.cs プロジェクト: strangea/OpenHacknet
        public override void Update(float t)
        {
            base.Update(t);
            if (HasBeenKilled)
            {
                return;
            }
            bars.Update(t);
            UpdateRamCost(t);
            stateTimer += t;
            switch (state)
            {
            case SequencerExeState.Unavaliable:
                if (os.Flags.HasFlag(flagForProgressionName) || Settings.debugCommandsEnabled)
                {
                    state = SequencerExeState.AwaitingActivation;
                    break;
                }
                bars.MinLineChangeTime = 1f;
                bars.MaxLineChangeTime = 3f;
                break;

            case SequencerExeState.SpinningUp:
                if (MediaPlayer.State == MediaState.Playing)
                {
                    if (MediaPlayer.PlayPosition.TotalSeconds < beatDropTime || stateTimer <= 10.0)
                    {
                        break;
                    }
                    MoveToActiveState();
                    break;
                }
                if (stateTimer <= (double)SPIN_UP_TIME)
                {
                    break;
                }
                MoveToActiveState();
                break;

            case SequencerExeState.Active:
                var num = 2.5f;
                if (stateTimer < (double)num)
                {
                    if (Utils.randm(1f) < 0.300000011920929 + stateTimer / (double)num * 0.699999988079071)
                    {
                        ThemeManager.switchThemeColors(os, targetTheme);
                        ThemeManager.loadThemeBackground(os, targetTheme);
                        ThemeManager.currentTheme = targetTheme;
                    }
                    else
                    {
                        ThemeManager.switchThemeColors(os, originalTheme);
                        ThemeManager.loadThemeBackground(os, originalTheme);
                        ThemeManager.currentTheme = originalTheme;
                    }
                    if ((MediaPlayer.PlayPosition.TotalSeconds - beatDropTime) % beatHits < 0.00999999977648258)
                    {
                        os.warningFlash();
                    }
                }
                ActiveStateUpdate(t);
                break;
            }
        }
コード例 #6
0
ファイル: SequencerExe.cs プロジェクト: strangea/OpenHacknet
        public override void Draw(float t)
        {
            base.Draw(t);
            drawOutline();
            drawTarget("app:");
            var rectangle = Utils.InsetRectangle(GetContentAreaDest(), 1);
            var amount    = os.warningFlashTimer / OS.WARNING_FLASH_TIME;
            var minHeight = 2f;

            if (amount > 0.0)
            {
                minHeight += amount * (rectangle.Height - minHeight);
            }
            var drawColor = Color.Lerp(Utils.AddativeWhite * 0.5f, Utils.AddativeRed, amount);

            bars.Draw(spriteBatch, GetContentAreaDest(), minHeight, 4f, 1f, drawColor);
            switch (state)
            {
            case SequencerExeState.Unavaliable:
                spriteBatch.Draw(Utils.white, rectangle, Color.Black * 0.5f);
                var dest = Utils.InsetRectangle(rectangle, 6);
                if (!isExiting)
                {
                    TextItem.doFontLabelToSize(dest, "LINK UNAVAILABLE", GuiData.titlefont, Utils.AddativeWhite);
                }
                var destinationRectangle1 = dest;
                destinationRectangle1.Y     += destinationRectangle1.Height - 20;
                destinationRectangle1.Height = 20;
                if (isExiting)
                {
                    break;
                }
                GuiData.spriteBatch.Draw(Utils.white, destinationRectangle1, Color.Black * 0.5f);
                if (
                    !Button.doButton(32711803, destinationRectangle1.X, destinationRectangle1.Y,
                                     destinationRectangle1.Width, destinationRectangle1.Height, "Exit", os.lockedColor))
                {
                    break;
                }
                isExiting = true;
                break;

            case SequencerExeState.AwaitingActivation:
                var height = 30;
                var destinationRectangle2 = new Rectangle(this.bounds.X + 1,
                                                          this.bounds.Y + this.bounds.Height / 2 - height, this.bounds.Width - 2, height * 2);
                spriteBatch.Draw(Utils.white, destinationRectangle2, Color.Black * 0.92f);
                if (
                    !Button.doButton(8310101, this.bounds.X + 10, this.bounds.Y + this.bounds.Height / 2 - height / 2,
                                     this.bounds.Width - 20, height, "ACTIVATE", os.highlightColor))
                {
                    break;
                }
                stateTimer             = 0.0f;
                state                  = SequencerExeState.SpinningUp;
                bars.MinLineChangeTime = 0.1f;
                bars.MaxLineChangeTime = 1f;
                originalTheme          = ThemeManager.currentTheme;
                MusicManager.FADE_TIME = 0.6f;
                oldSongName            = MusicManager.currentSongName;
                MusicManager.transitionToSong("Music\\Roller_Mobster_Clipped");
                MediaPlayer.IsRepeating = false;
                targetComp = Programs.getComputer(os, targetID);
                var webServerDaemon = (WebServerDaemon)targetComp.getDaemon(typeof(WebServerDaemon));
                if (webServerDaemon == null)
                {
                    break;
                }
                webServerDaemon.LoadWebPage("index.html");
                break;

            case SequencerExeState.SpinningUp:
                var bounds = rectangle;
                bounds.Height = (int)(bounds.Height * (stateTimer / (double)SPIN_UP_TIME));
                bounds.Y      = rectangle.Y + rectangle.Height - bounds.Height + 1;
                bounds.Width += 4;
                bars.Draw(spriteBatch, bounds, minHeight, 4f, 1f, os.brightLockedColor);
                break;

            case SequencerExeState.Active:
                spriteBatch.Draw(Utils.white, GetContentAreaDest(), Color.Black * 0.5f);
                TextItem.doFontLabelToSize(GetContentAreaDest(), " G O   G O   G O ", GuiData.titlefont,
                                           Color.Lerp(Utils.AddativeRed, os.brightLockedColor, Math.Min(1f, stateTimer / 2f)));
                DrawActiveState();
                break;
            }
        }