コード例 #1
0
 public void OnStateChange(KMGameInfo.State state)
 {
     if (state == KMGameInfo.State.Setup)
     {
         StartCoroutine(InstanceHoldable());
     }
 }
コード例 #2
0
    public static void RefreshModes(KMGameInfo.State state)
    {
        _state = state;

        if (currentMode == TwitchPlaysMode.Normal)
        {
            if (Assets.Scripts.Records.RecordManager.Instance != null)
            {
                _disableBestRecords = Assets.Scripts.Records.RecordManager.Instance.DisableBestRecords;
            }
            if (Assets.Scripts.Stats.StatsManager.Instance != null)
            {
                _disableStats = Assets.Scripts.Stats.StatsManager.Instance.DisableStatChanges;
            }
        }

        if ((_state != KMGameInfo.State.PostGame && _state != KMGameInfo.State.Setup) || currentMode == nextMode)
        {
            return;
        }

        currentMode = nextMode;
        DisableLeaderboard();
        IRCConnection.Instance.SendMessage("Mode is now set to: {0}", Enum.GetName(typeof(TwitchPlaysMode), currentMode));
    }
コード例 #3
0
        private void StateChange(KMGameInfo.State state)
        {
            // ReSharper disable once SwitchStatementMissingSomeCases
            switch (state)
            {
            case KMGameInfo.State.Setup:
                StopCoroutine(FactoryCheck());
                StopCoroutine(WaitUntilEndFactory());
                SetupHandler();
                Bombs.Clear();
                _factoryCheckComplete = false;
                break;

            case KMGameInfo.State.Gameplay:
                StartCoroutine(WaitForBomb());
                StartCoroutine(FactoryCheck());
                break;

            case KMGameInfo.State.PostGame:
                StopCoroutine(FactoryCheck());
                StopCoroutine(WaitUntilEndFactory());
                PostGameHandler();
                Bombs.Clear();
                _factoryCheckComplete = false;
                break;

            case KMGameInfo.State.Transitioning:
                StopCoroutine(WaitForBomb());
                StopCoroutine(FactoryCheck());
                break;
            }
        }
コード例 #4
0
    private void OnStateChange(KMGameInfo.State state)
    {
        DebugLog("Game State changed from {0} to {1}", _state.ToString(), state.ToString());

        switch (state)
        {
        case KMGameInfo.State.Setup:
        case KMGameInfo.State.PostGame:
        case KMGameInfo.State.Quitting:
        case KMGameInfo.State.Unlock:
            _refreshWidgetCount = false;
            break;

        case KMGameInfo.State.Transitioning:
            if (_state == KMGameInfo.State.Transitioning || _state == KMGameInfo.State.Gameplay)
            {
                break;
            }
            _refreshWidgetCount = true;

            ReadSettings();
            _refreshWidgetCount &= _modSettings.allowWidgetCountChange;
            SetCustomIndicators(_modSettings.allowCustomIndicators);
            StartCoroutine(ReplaceSerialNumber(_modSettings.allowSerialNumberChange));
            break;
        }
        _state = state;
    }
コード例 #5
0
    private MessageResponder GetActiveResponder(KMGameInfo.State state)
    {
        switch (state)
        {
        case KMGameInfo.State.Gameplay:
            DefaultCamera();
            return(bombMessageResponder);

        case KMGameInfo.State.Setup:
            DefaultCamera();
            _coroutinesToStart.Enqueue(VanillaRuleModifier.Refresh());
            _coroutinesToStart.Enqueue(MultipleBombs.Refresh());
            _coroutinesToStart.Enqueue(FactoryRoomAPI.Refresh());
            _coroutinesToStart.Enqueue(CreateSolversForAllBombComponents());

            return(missionMessageResponder);

        case KMGameInfo.State.PostGame:
            DefaultCamera();
            return(postGameMessageResponder);

        case KMGameInfo.State.Transitioning:
            ModuleData.LoadDataFromFile();
            TwitchPlaySettings.LoadDataFromFile();
            return(null);

        default:
            return(null);
        }
    }
コード例 #6
0
 void StateChange(KMGameInfo.State state)
 {
     if (state == KMGameInfo.State.Setup)
     {
         StopAllCoroutines();
         StartCoroutine(FetchModules());
     }
 }
コード例 #7
0
    private void OnStateChange(KMGameInfo.State state)
    {
        CurrentState = state;
        if (!transform.gameObject.activeInHierarchy)
        {
            return;
        }

        StartCoroutine(StopEveryCoroutine());

        if (state != KMGameInfo.State.PostGame && _leaderboardDisplay != null)
        {
            DestroyObject(_leaderboardDisplay);
            _leaderboardDisplay = null;
        }

        twitchGame?.gameObject.SetActive(state == KMGameInfo.State.Gameplay);

        OtherModes.RefreshModes(state);

        // Automatically check for updates after a round is finished or when entering the setup state but never more than once per hour.
        bool hourPassed = DateTime.Now.Subtract(Updater.LastCheck).TotalHours >= 1;

        if ((state == KMGameInfo.State.PostGame || state == KMGameInfo.State.Setup) && hourPassed && !Updater.UpdateAvailable)
        {
            _coroutinesToStart.Enqueue(AutomaticUpdateCheck());
        }

        switch (state)
        {
        case KMGameInfo.State.Gameplay:
            DefaultCamera();
            break;

        case KMGameInfo.State.Setup:
            DefaultCamera();
            _coroutinesToStart.Enqueue(VanillaRuleModifier.Refresh());
            _coroutinesToStart.Enqueue(MultipleBombs.Refresh());
            _coroutinesToStart.Enqueue(FactoryRoomAPI.Refresh());
            _coroutinesToStart.Enqueue(FindSupportedModules());
            break;

        case KMGameInfo.State.PostGame:
            DefaultCamera();
            if (_leaderboardDisplay == null)
            {
                _leaderboardDisplay = Instantiate(TwitchLeaderboardPrefab);
            }
            Leaderboard.Instance.SaveDataToFile();
            break;

        case KMGameInfo.State.Transitioning:
            ModuleData.LoadDataFromFile();
            TwitchPlaySettings.LoadDataFromFile();
            break;
        }
    }
コード例 #8
0
 void OnStateChange(KMGameInfo.State state)
 {
     AlarmClockHandler.DebugLog("Current state = {0}", state.ToString());
     _alarmClockHandler.GameState = state;
     if (state == KMGameInfo.State.Gameplay)
     {
         StartCoroutine(_alarmClockHandler.CheckForAlarmClock());
     }
 }
コード例 #9
0
 private void Start()
 {
     GameCommands            = GetComponent <KMGameCommands>();
     GameInfo                = GetComponent <KMGameInfo>();
     GameInfo.OnStateChange += delegate(KMGameInfo.State state)
     {
         CurrentState = state;
     };
 }
コード例 #10
0
 internal void OnStateChange(KMGameInfo.State state)
 {
     if (!Instance.transform.gameObject.activeInHierarchy)
     {
         return;
     }
     if (state == KMGameInfo.State.Setup)
     {
         Instance.StartCoroutine(CheckForBrochure());
     }
 }
コード例 #11
0
 protected void OnStateChange(KMGameInfo.State newState)
 {
     if (newState == KMGameInfo.State.Gameplay)
     {
         handler.disableLogOutput();
     }
     else
     {
         handler.enableLogOutput();
     }
 }
コード例 #12
0
    private void OnStateChange(KMGameInfo.State state)
    {
        if (_updateRequired && state == KMGameInfo.State.Setup)
        {
            //Update the mod info
            SetupModInfo();

            //Reload the active configuration
            ProfileManager.ReloadActiveConfiguration();

            _updateRequired = false;
        }
    }
コード例 #13
0
 private void OnStateChange(KMGameInfo.State state)
 {
     DebugLog("Transitioning from {1} to {0}", state, CurrentState);
     if ((_prevState == KMGameInfo.State.Setup || _prevState == KMGameInfo.State.PostGame) && CurrentState == KMGameInfo.State.Transitioning && state == KMGameInfo.State.Transitioning)
     {
         _modSettings.ReadSettings();
         var seed = _modSettings.Settings.RuleSeed;
         DebugLog("Generating Rules based on Seed {0}", seed);
         GenerateRules(seed);
         ManualGenerator.Instance.WriteManual(seed);
     }
     _prevState   = CurrentState;
     CurrentState = state;
 }
コード例 #14
0
 void OnStateChange(KMGameInfo.State state)
 {
     DebugLog("Current state = {0}", state.ToString());
     StopAllCoroutines();
     if (state == KMGameInfo.State.Setup)
     {
         StartCoroutine(CheckForFreeplayDevice());
     }
     else
     {
         _freeplayCommander = null;
         _handler           = null;
     }
 }
コード例 #15
0
 private void OnStateChange(KMGameInfo.State state)
 {
     currentState = state;
     setPins();
     if (currentState != KMGameInfo.State.PostGame)
     {
         arduinoConnection.Stop();
     }
     else
     {
         if (bombState == 0)
         {
             StopCoroutines(); arduinoConnection.sendMSG(String.Format("{0} {1} {2} 0 0 255", RP, GP, BP));
         }                                                                                                                      //For multiple bombs
     }
     if (currentState == KMGameInfo.State.Gameplay)
     {
         //if(arduinoConnection._connected) StartCoroutine(Test());
         bombState   = 0;
         lastStrikes = 0;
         lastSolves  = 0;
         strikeCounts.Clear();
         solveCounts.Clear();
         StartCoroutine(getField());
         StartCoroutine(Warning());
         StartCoroutine(OnStrike());
         StartCoroutine(OnSolve());
         StartCoroutine(CheckForBomb(true));
         StartCoroutine(FactoryCheck());
         StartCoroutine(getBomb());
         StartCoroutine(HandleReflectors());
     }
     else
     {
         currentModuleName = "";
         Modules.Clear();
         StopCoroutine(CheckForBomb(false));
         StopCoroutine(FactoryCheck());
         StopCoroutine(WaitUntilEndFactory());
         StopCoroutine(HandleReflectors());
         BombActive = false;
         Bombs.Clear();
         BombCommanders.Clear();
     }
     if (currentState == KMGameInfo.State.Quitting)
     {
         arduinoConnection.Disconnect();
     }
 }
コード例 #16
0
ファイル: TwitchPlaysService.cs プロジェクト: ItzAtomikHD/old
    private void OnStateChange(KMGameInfo.State state)
    {
        CurrentState = state;
        if (!transform.gameObject.activeInHierarchy)
        {
            return;
        }

        StartCoroutine(StopEveryCoroutine());

        if (state != KMGameInfo.State.PostGame && _leaderboardDisplay != null)
        {
            DestroyObject(_leaderboardDisplay);
            _leaderboardDisplay = null;
        }

        twitchGame?.gameObject.SetActive(state == KMGameInfo.State.Gameplay);

        OtherModes.RefreshModes(state);

        switch (state)
        {
        case KMGameInfo.State.Gameplay:
            DefaultCamera();
            break;

        case KMGameInfo.State.Setup:
            DefaultCamera();
            _coroutinesToStart.Enqueue(VanillaRuleModifier.Refresh());
            _coroutinesToStart.Enqueue(MultipleBombs.Refresh());
            _coroutinesToStart.Enqueue(FactoryRoomAPI.Refresh());
            _coroutinesToStart.Enqueue(FindSupportedModules());
            break;

        case KMGameInfo.State.PostGame:
            DefaultCamera();
            if (_leaderboardDisplay == null)
            {
                _leaderboardDisplay = Instantiate(TwitchLeaderboardPrefab);
            }
            Leaderboard.Instance.SaveDataToFile();
            break;

        case KMGameInfo.State.Transitioning:
            ModuleData.LoadDataFromFile();
            TwitchPlaySettings.LoadDataFromFile();
            break;
        }
    }
コード例 #17
0
 private void OnGameStateChanged(KMGameInfo.State state)
 {
     if (state == KMGameInfo.State.Gameplay)
     {
         StartCoroutine(SetupGameplay());
     }
     else
     {
         Debug.Log("[Extended Mission Settings] Cleaning up.");
         StopAllCoroutines();
         if (state == KMGameInfo.State.Setup)
         {
             StartCoroutine(SetupSetupRoom());
         }
     }
 }
コード例 #18
0
    private MessageResponder GetActiveResponder(KMGameInfo.State state)
    {
        switch (state)
        {
            case KMGameInfo.State.Gameplay:
                return bombMessageResponder;

            case KMGameInfo.State.Setup:
                return missionMessageResponder;

            case KMGameInfo.State.PostGame:
                return postGameMessageResponder;

            default:
                return null;
        }
    }
コード例 #19
0
    private void OnStateChange(KMGameInfo.State state)
    {
        if (AddWidget != null)
        {
            StopCoroutine(AddWidget);
            AddWidget = null;
        }

        if (FixMorseCode != null)
        {
            StopCoroutine(FixMorseCode);
            FixMorseCode = null;
        }

        //DebugLog("Transitioning from {1} to {0}", state, CurrentState);
        //if((_prevState == KMGameInfo.State.Setup || _prevState == KMGameInfo.State.PostGame) && CurrentState == KMGameInfo.State.Transitioning && state == KMGameInfo.State.Transitioning)
        if (CurrentState == KMGameInfo.State.Setup && state == KMGameInfo.State.Transitioning)
        {
            _modSettings.ReadSettings();
            var seed = _modSettings.Settings.RuleSeed;

            if (_modSettings.Settings.RandomRuleSeed)
            {
                seed = new System.Random().Next(_modSettings.Settings.MaxRandomSeed < 0 ? int.MaxValue : _modSettings.Settings.MaxRandomSeed);
            }

            _currentSeed       = seed;
            _currentRandomSeed = _modSettings.Settings.RandomRuleSeed;

            DebugLog("Generating Rules based on Seed {0}", seed);
            GenerateRules(seed);
            ManualGenerator.Instance.WriteManual(seed);
        }
        else if ((_prevState == KMGameInfo.State.Setup || _prevState == KMGameInfo.State.PostGame) && CurrentState == KMGameInfo.State.Transitioning && state == KMGameInfo.State.Transitioning)
        {
            AddWidget = StartCoroutine(AddWidgetToBomb(RuleSeedWidget));
        }
        else if (state == KMGameInfo.State.Gameplay)
        {
            FixMorseCode = StartCoroutine(FixMorseCodeModule());
        }

        _prevState   = CurrentState;
        CurrentState = state;
    }
コード例 #20
0
 private void OnStateChange(KMGameInfo.State state)
 {
     if (AddWidget != null)
     {
         StopCoroutine(AddWidget);
         AddWidget = null;
     }
     if ((prevState == KMGameInfo.State.Setup || prevState == KMGameInfo.State.PostGame) && CurrentState == KMGameInfo.State.Transitioning && state == KMGameInfo.State.Transitioning)
     {
         AddWidget = StartCoroutine(AddWidgetToBomb(dayTimeWidget, startTimeWidget.GetComponent <KMWidget>()));
         if (Settings != modConfig.Settings)
         {
             ReadSettings();
         }
     }
     prevState    = CurrentState;
     CurrentState = state;
 }
コード例 #21
0
        private void OnStateChange(KMGameInfo.State state)
        {
            switch (state)
            {
            case KMGameInfo.State.Setup:
                Logging.Log("State Change: Setup");

                InvoiceData.Enabled = false;
                InvoiceData.ClearData();

                MultipleBombsInterface.RediscoverMultipleBombs();
                FactoryGameModePicker.UpdateCompatibleMissions();
                _fromSetupRoom = true;

                _binderConverter.Revert();
                break;

            case KMGameInfo.State.Gameplay:
                Logging.Log("State Change: Gameplay");

                if (GameplayState.MissionToLoad == ModMission.CUSTOM_MISSION_ID && _fromSetupRoom)
                {
                    FactoryGameModePicker.UpdateMission(GameplayState.CustomMission, true, false, true);

                    StartCoroutine(FixCustomMission());
                }
                _fromSetupRoom = false;

                _binderConverter.Revert();
                break;

            case KMGameInfo.State.PostGame:
                Logging.Log("Stage Change: PostGame");

                if (InvoiceData.Enabled)
                {
                    _binderConverter.Convert();
                }
                break;

            default:
                break;
            }
        }
コード例 #22
0
    // ========== Callback Functions ========== //


    // Called when game state changes between gameplay, setup, postgame and loading
    // 0 [Gameplay] The gameplay state where defusing happens
    // 1 [Setup] The setup state in the office where options are chosen
    // 2 [PostGame] The state where results are shown
    // 3 [Transitioning] No current state, transitioning to a new state
    // 4 [Unlock] The unlock state where manual verification and tutorial take place
    // 5 [Quitting] Game is exiting
    protected void OnStateChange(KMGameInfo.State state)
    {
        if (state_game != state)
        {
            state_game = state;
            if (state_game.ToString() == "Quitting")
            {
                if (set_uart_enable)
                {
                    writeLine("!PORT-CLSE");
                }
                if (set_uart_enable)
                {
                    uart.Close();
                }
                if (set_log_enable)
                {
                    Log("UART:Closed");
                }
                if (set_debug_log_enable)
                {
                    Debug.Log("UART:Closed");
                }
            }
            else
            {
                if (set_uart_enable)
                {
                    writeLine("!KM-STATE" + ((int)state_game).ToString());
                }
            }
            if (set_log_enable)
            {
                Log("OnStateChange:" + ((int)state_game).ToString() + " " + state_game.ToString());
            }
            if (set_debug_log_enable)
            {
                Debug.Log("OnStateChange:" + ((int)state_game).ToString() + " " + state_game.ToString());
            }
        }
    }
コード例 #23
0
 private void KMGameInfo_OnStateChange(KMGameInfo.State state)
 {
     if (state == KMGameInfo.State.Gameplay)
     {
         // Enabling Show Module Names is considered an advantageous feature, so disable records in that case.
         // This code is based on the Tweaks mod.
         if (this.config.ShowModuleNames)
         {
             LeaderboardController.DisableLeaderboards();
         }
         this.StartCoroutine(this.CheckForBombs());
     }
     else if (state == KMGameInfo.State.Transitioning && this.gameState == KMGameInfo.State.Setup)
     {
         this.KMModSettings.RefreshSettings();
         this.RefreshConfig();
     }
     else if (state == KMGameInfo.State.Setup)
     {
         this.popups.Clear();
         if (this.tweaksService == null)
         {
             Debug.Log("[Profile Revealer] Looking for Tweaks service...");
             var obj = GameObject.Find("Tweaks(Clone)");
             if (obj != null)
             {
                 this.tweaksService = obj.GetComponent("Tweaks");
             }
             if (this.tweaksService != null)
             {
                 Debug.Log("[Profile Revealer] Found Tweaks service.");
             }
             else
             {
                 Debug.Log("[Profile Revealer] Did not find Tweaks service.");
                 LeaderboardController.Install();
             }
         }
     }
     this.gameState = state;
 }
コード例 #24
0
    private void OnStateChange(KMGameInfo.State state)
    {
        if (_ircConnection == null)
        {
            return;
        }

        StartCoroutine(StopEveryCoroutine());

        if (_activeMessageResponder != null)
        {
            _activeMessageResponder.gameObject.SetActive(false);
        }

        _activeMessageResponder = GetActiveResponder(state);

        if (_activeMessageResponder != null)
        {
            _activeMessageResponder.gameObject.SetActive(true);
        }        
    }
コード例 #25
0
        private void StateChange(KMGameInfo.State state)
        {
            switch (state)
            {
            case KMGameInfo.State.Gameplay:
                StartCoroutine(CheckForBomb());
                break;

            case KMGameInfo.State.Setup:
            case KMGameInfo.State.Quitting:
            case KMGameInfo.State.PostGame:
                Modules.Clear();
                BombActive = false;
                StopCoroutine(CheckForBomb());
                Bombs.Clear();
                Modules.Clear();
                BombCommanders.Clear();
                ChangeLeaderboard(false);
                break;
            }
        }
コード例 #26
0
    private void OnStateChange(KMGameInfo.State state)
    {
        if (!transform.gameObject.activeInHierarchy)
        {
            return;
        }

        StartCoroutine(StopEveryCoroutine());

        if (_activeMessageResponder != null)
        {
            _activeMessageResponder.gameObject.SetActive(false);
        }

        _activeMessageResponder = GetActiveResponder(state);

        if (_activeMessageResponder != null)
        {
            _activeMessageResponder.gameObject.SetActive(true);
        }
        TwitchComponentHandle.ClaimedList.Clear();
    }
コード例 #27
0
    private void OnStateChange(KMGameInfo.State state)
    {
        if (_addWidget != null)
        {
            StopCoroutine(_addWidget);
            _addWidget = null;
        }

        DebugLog("Transitioning from {1} to {0}", state, CurrentState);
        if ((_prevState == KMGameInfo.State.Setup || _prevState == KMGameInfo.State.PostGame) && CurrentState == KMGameInfo.State.Transitioning && state == KMGameInfo.State.Transitioning)
        {
            _modSettings.ReadSettings();
            _addWidget = StartCoroutine(AddWidgetToBomb());
        }

        if (CurrentState == KMGameInfo.State.Gameplay && state == KMGameInfo.State.Transitioning)
        {
            RemoveCapturedSerialTag();
        }

        _prevState   = CurrentState;
        CurrentState = state;
    }
コード例 #28
0
    private MessageResponder GetActiveResponder(KMGameInfo.State state)
    {
        switch (state)
        {
        case KMGameInfo.State.Gameplay:
            return(bombMessageResponder);

        case KMGameInfo.State.Setup:
            StartCoroutine(VanillaRuleModifier.Refresh());
            StartCoroutine(MultipleBombs.Refresh());
            return(missionMessageResponder);

        case KMGameInfo.State.PostGame:
            return(postGameMessageResponder);

        case KMGameInfo.State.Transitioning:
            ModuleData.LoadDataFromFile();
            TwitchPlaySettings.LoadDataFromFile();
            return(null);

        default:
            return(null);
        }
    }
コード例 #29
0
    private void OnStateChange(KMGameInfo.State state)
    {
        if (AddWidget != null)
        {
            StopCoroutine(AddWidget);
            AddWidget = null;
        }

        DebugLog("Transitioning from {1} to {0}", state, CurrentState);
        if ((_prevState == KMGameInfo.State.Setup || _prevState == KMGameInfo.State.PostGame) && CurrentState == KMGameInfo.State.Transitioning && state == KMGameInfo.State.Transitioning)
        {
            _modSettings.ReadSettings();
            var seed = _modSettings.Settings.RuleSeed;
            DebugLog("Generating Rules based on Seed {0}", seed);
            GenerateRules(seed);
            ManualGenerator.Instance.WriteManual(seed);
            if (seed != 1)
            {
                AddWidget = StartCoroutine(AddWidgetToBomb(RuleSeedWidget));
            }
        }
        _prevState   = CurrentState;
        CurrentState = state;
    }
コード例 #30
0
        private void Start()
        {
            Instance = this;

            StartCoroutine(FindModSelector());

            Directory.CreateDirectory(MissionsFolder);
            GetComponent <KMGameInfo>().OnStateChange += state =>
            {
                // If we are leaving the gameplay room, clear room override.
                if (currentState == KMGameInfo.State.Gameplay && state != KMGameInfo.State.Gameplay && MissionInputPage.GameplayRoomOverride != null)
                {
                    MissionInputPage.GameplayRoomOverride = null;
                    ReflectionHelper.FindType("GameplayState").SetValue("GameplayRoomPrefabOverride", null);
                }

                currentState = state;

                if (state == KMGameInfo.State.Setup)
                {
                    StartCoroutine(RestoreSettingsLate());
                }
            };
        }