コード例 #1
0
    public TranslatedPasswordComponentSolver(TwitchModule module) :
        base(module)
    {
        _component    = module.BombComponent.GetComponent(PasswordComponentType);
        _downButtons  = (KMSelectable[])DownButtonField.GetValue(_component);
        _submitButton = (MonoBehaviour)SubmitButtonField.GetValue(_component);
        _display      = (TextMesh[])DisplayField.GetValue(_component);
        ModInfo       = ComponentSolverFactory.GetModuleInfo(GetModuleType(), "!{0} cycle 1 3 5 [cycle through the letters in columns 1, 3, and 5] | !{0} toggle [move all columns down one letter] | !{0} world [try to submit a word]").Clone();

        string language = TranslatedModuleHelper.GetManualCodeAddOn(_component, PasswordComponentType);

        if (language != null)
        {
            ManualCode = $"Password{language}";
        }
        ModInfo.moduleDisplayName = $"Passwords Translated{TranslatedModuleHelper.GetModuleDisplayNameAddon(_component, PasswordComponentType)}";
        Module.HeaderText         = ModInfo.moduleDisplayName;
    }
コード例 #2
0
    public TranslatedMorseCodeComponentSolver(TwitchModule module) :
        base(module)
    {
        _component      = module.BombComponent.GetComponent(MorseCodeComponentType);
        _upButton       = (MonoBehaviour)UpButtonField.GetValue(_component);
        _downButton     = (MonoBehaviour)DownButtonField.GetValue(_component);
        _transmitButton = (MonoBehaviour)TransmitButtonField.GetValue(_component);
        ModInfo         = ComponentSolverFactory.GetModuleInfo(GetModuleType(), "!{0} transmit 3.573, !{0} trans 573, !{0} transmit 3.573 MHz, !{0} tx 573 [transmit frequency 3.573]").Clone();

        string language = TranslatedModuleHelper.GetManualCodeAddOn(_component, MorseCodeComponentType);

        if (language != null)
        {
            ManualCode = $"Morse%20Code{language}";
        }
        ModInfo.moduleDisplayName = $"Morse Code Translated{TranslatedModuleHelper.GetModuleDisplayNameAddon(_component, MorseCodeComponentType)}";
        Module.HeaderText         = ModInfo.moduleDisplayName;
    }
コード例 #3
0
    public bool TryViewModule(TwitchModule module)
    {
        if (module == null)
        {
            return(false);
        }

        module.LastUsed = DateTime.UtcNow;

        // Is the module already viewed?
        int existingCamera = CurrentModulesContains(module);

        if (existingCamera > -1)
        {
            return(false);
        }

        // Find a camera
        var camera = AvailableCamera(module.CameraPriority);

        if (camera == null)
        {
            return(false);
        }

        // If we can replace a LOWER-priority camera (or an unused slot), do so before enabling the camera wall.
        if (camera.Module == null || camera.Module.CameraPriority < module.CameraPriority)
        {
            camera.ViewModule(module);
        }
        // If we can and should enable the camera wall, enable it and then view the module.
        else if (AutomaticCameraWallEnabled && !CameraWallEnabled && TwitchGame.Instance.Modules.Count(twitchModule => twitchModule.Claimed && !twitchModule.Solved) >= 7)
        {
            EnableCameraWall();
            TryViewModule(module);
        }
        // If the camera is already enabled, replace a suitable SAME-priority camera.
        else
        {
            camera.ViewModule(module);
        }
        return(true);
    }
コード例 #4
0
    public static void Take(TwitchModule module, string user, bool isWhisper)
    {
        if (isWhisper)
        {
            IRCConnection.SendMessageFormat("Sorry {0}, taking modules is not allowed in whispers.", user);
        }
        else if (TwitchPlaySettings.data.AnarchyMode)
        {
            IRCConnection.SendMessageFormat("Sorry {0}, taking modules is not allowed in anarchy mode.", user);
        }

        // Attempt to take over from another user
        else if (module.PlayerName != null && user != module.PlayerName)
        {
            module.AddToClaimQueue(user);
            if (module.TakeInProgress == null)
            {
                IRCConnection.SendMessageFormat(TwitchPlaySettings.data.TakeModule, module.PlayerName, user, module.Code, module.HeaderText);
                module.TakeInProgress = module.TakeModule();
                module.StartCoroutine(module.TakeInProgress);
            }
            else
            {
                IRCConnection.SendMessageFormat(TwitchPlaySettings.data.TakeInProgress, user, module.Code, module.HeaderText);
            }
        }

        // Module is already claimed by the same user
        else if (module.PlayerName != null)
        {
            if (!module.PlayerName.Equals(user))
            {
                module.AddToClaimQueue(user);
            }
            IRCConnection.SendMessageFormat(TwitchPlaySettings.data.ModuleAlreadyOwned, user, module.Code, module.HeaderText);
        }

        // Module is not claimed at all: just claim it
        else
        {
            IRCConnection.SendMessage(module.ClaimModule(user).Second);
        }
    }
コード例 #5
0
 public CoroutineModComponentSolver(TwitchModule module, ComponentSolverFields componentSolverFields) :
     base(module, componentSolverFields.HookUpEvents)
 {
     ProcessMethod      = componentSolverFields.Method;
     ForcedSolveMethod  = componentSolverFields.ForcedSolveMethod;
     CommandComponent   = componentSolverFields.CommandComponent;
     TryCancelField     = componentSolverFields.CancelField;
     ZenModeField       = componentSolverFields.ZenModeField;
     TimeModeField      = componentSolverFields.TimeModeField;
     AbandonModuleField = componentSolverFields.AbandonModuleField;
     TwitchPlaysField   = componentSolverFields.TwitchPlaysField;
     SkipTimeField      = componentSolverFields.TwitchPlaysSkipTimeField;
     HelpMessageField   = componentSolverFields.HelpMessageField;
     ManualCodeField    = componentSolverFields.ManualCodeField;
     TwitchPlays        = true;
     ZenMode            = OtherModes.Unexplodable;
     TimeMode           = OtherModes.TimeModeOn;
     ModInfo            = ComponentSolverFactory.GetModuleInfo(GetModuleType());
 }
コード例 #6
0
    public static List <ScoreMethod> ConvertScoreString(string scoreString, TwitchModule module)
    {
        // UN and T is for unchanged and temporary score which are read normally.
        scoreString = Regex.Replace(scoreString, @"(?:UN )?(\d+)T?", "$1");

        var methods = new List <ScoreMethod>();

        foreach (var factor in scoreString.SplitFull("+"))
        {
            if (factor == "TBD")
            {
                continue;
            }

            var split = factor.SplitFull(" ");
            if (!split.Length.EqualsAny(1, 2))
            {
                DebugHelper.Log("Unknown score string:", scoreString);
                continue;
            }

            var numberString = split[split.Length - 1];
            if (numberString.EndsWith("x"))             // To parse "5x" we need to remove the x.
            {
                numberString = numberString.Substring(0, numberString.Length - 1);
            }

            if (!float.TryParse(numberString, out float number))
            {
                DebugHelper.Log("Unknown number:", numberString);
                continue;
            }

            var moduleID          = module?.Solver.ModInfo.moduleID;
            var moduleDisplayName = module?.Solver.ModInfo.moduleDisplayName;
            switch (split.Length)
            {
            case 1:
                methods.Add(new BaseScore(number));
                break;

            // S is for special modules which we parse out the multiplier and put it into a dictionary and use later.
            case 2 when split[0] == "S":
コード例 #7
0
    public TranslatedButtonComponentSolver(TwitchModule module) :
        base(module)
    {
        var component = module.BombComponent.GetComponent(ComponentType);

        _button = (KMSelectable)ButtonField.GetValue(component);
        ModInfo = ComponentSolverFactory.GetModuleInfo(GetModuleType(), "!{0} tap [tap the button] | !{0} hold [hold the button] | !{0} release 7 [release when the digit shows 7]").Clone();
        Selectable selectable = module.BombComponent.GetComponent <Selectable>();

        selectable.OnCancel += () => { SelectedField.SetValue(component, false); return(true); };

        LanguageCode = TranslatedModuleHelper.GetLanguageCode(component, ComponentType);
        ModInfo.moduleDisplayName = $"Big Button Translated{TranslatedModuleHelper.GetModuleDisplayNameAddon(component, ComponentType)}";
        Module.HeaderText         = ModInfo.moduleDisplayName;

        var mat = (Material)StripMaterialField.GetValue(component);

        StripMaterialField.SetValue(component, Object.Instantiate(mat));
    }
コード例 #8
0
    public ListeningComponentSolver(TwitchModule module) :
        base(module)
    {
        Component component = module.BombComponent.GetComponent("Listening");

        if (component == null)
        {
            throw new NotSupportedException("Could not get Listening Component from bombComponent");
        }
        _component = component;

        Type componentType = component.GetType();

        if (componentType == null)
        {
            throw new NotSupportedException("Could not get componentType from Listening Component");
        }

        FieldInfo playField      = componentType.GetField("PlayButton", BindingFlags.Public | BindingFlags.Instance);
        FieldInfo dollarField    = componentType.GetField("DollarButton", BindingFlags.Public | BindingFlags.Instance);
        FieldInfo poundField     = componentType.GetField("PoundButton", BindingFlags.Public | BindingFlags.Instance);
        FieldInfo starField      = componentType.GetField("StarButton", BindingFlags.Public | BindingFlags.Instance);
        FieldInfo ampersandField = componentType.GetField("AmpersandButton", BindingFlags.Public | BindingFlags.Instance);

        if (playField == null || dollarField == null || poundField == null || starField == null || ampersandField == null)
        {
            throw new NotSupportedException("Could not find the KMSelectable fields in component Type");
        }

        _buttons    = new MonoBehaviour[4];
        _play       = (MonoBehaviour)playField.GetValue(component);
        _buttons[0] = (MonoBehaviour)dollarField.GetValue(component);
        _buttons[1] = (MonoBehaviour)poundField.GetValue(component);
        _buttons[2] = (MonoBehaviour)starField.GetValue(component);
        _buttons[3] = (MonoBehaviour)ampersandField.GetValue(component);
        if (_play == null || _buttons.Any(x => x == null))
        {
            throw new NotSupportedException("Component had null KMSelectables.");
        }

        ModInfo = ComponentSolverFactory.GetModuleInfo(GetModuleType(), "Listen to the sound with !{0} press play. Enter the response with !{0} press $ & * * #.");
    }
コード例 #9
0
    public static IEnumerator Show(TwitchModule module)
    {
        IEnumerator focusCoroutine = module.Bomb.Focus(module.Selectable, module.FocusDistance, module.FrontFace);

        while (focusCoroutine.MoveNext())
        {
            yield return(focusCoroutine.Current);
        }

        yield return(new WaitForSeconds(0.5f));

        IEnumerator defocusCoroutine = module.Bomb.Defocus(module.Selectable, module.FrontFace);

        while (defocusCoroutine.MoveNext())
        {
            yield return(defocusCoroutine.Current);
        }

        yield return(new WaitForSeconds(0.5f));
    }
コード例 #10
0
    public static void Assign(TwitchModule module, string user, [Group(1)] string targetUser)
    {
        if (TwitchPlaySettings.data.AnarchyMode)
        {
            IRCConnection.SendMessageFormat("Sorry {0}, assigning modules is not allowed in anarchy mode.", user);
            return;
        }

        if (module.TakeInProgress != null)
        {
            module.StopCoroutine(module.TakeInProgress);
            module.TakeInProgress = null;
        }

        module.PlayerName = targetUser;
        module.RemoveFromClaimQueue(user);
        module.CanClaimNow(user, true, true);
        module.SetBannerColor(module.ClaimedBackgroundColour);
        IRCConnection.SendMessageFormat(TwitchPlaySettings.data.AssignModule, module.Code, module.PlayerName, user, module.HeaderText);
    }
コード例 #11
0
ファイル: TwitchGame.cs プロジェクト: Timwi/KtaneTwitchPlays
    public void CreateComponentHandlesForBomb(TwitchBomb bomb)
    {
        foreach (var component in bomb.Bomb.BombComponents)
        {
            if (component.ComponentType.EqualsAny(ComponentTypeEnum.Empty, ComponentTypeEnum.Timer))
            {
                continue;
            }

            TwitchModule module = Instantiate(twitchModulePrefab, component.transform, false);
            module.Bomb          = bomb;
            module.BombComponent = component;
            module.BombID        = _currentBomb == -1 ? -1 : Bombs.Count - 1;

            module.transform.SetParent(component.transform.parent, true);
            module.BasePosition = module.transform.localPosition;

            Modules.Add(module);
        }
    }
コード例 #12
0
    public static void CancelTake(TwitchModule module, string user, bool isWhisper)
    {
        if (module.TakeInProgress == null)
        {
            IRCConnection.SendMessage($"@{user}, there are no takeover attempts on module {module.Code} ({module.HeaderText}).", user, !isWhisper);
            return;
        }

        if (!UserAccess.HasAccess(user, AccessLevel.Mod, true) && module.TakeUser != user)
        {
            IRCConnection.SendMessage($"@{user}, if you’re not a mod, you can only cancel your own takeover attempts.");
            return;
        }

        // Cancel the takeover attempt
        IRCConnection.SendMessage($"{module.TakeUser}’s takeover of module {module.Code} ({module.HeaderText}) was cancelled by {user}.");
        module.StopCoroutine(module.TakeInProgress);
        module.TakeInProgress = null;
        module.TakeUser       = null;
    }
コード例 #13
0
    private static IEnumerator RunModuleCommand(TwitchModule module, string user, string cmd, bool zoom)
    {
        if (module.Solver == null)
        {
            yield break;
        }

        if (module.Solved && !TwitchPlaySettings.data.AnarchyMode)
        {
            IRCConnection.SendMessageFormat(TwitchPlaySettings.data.AlreadySolved, module.Code, module.PlayerName, user, module.HeaderText);
            yield break;
        }

        // We’re allowed to interact with this module if either:
        if (
            // the module is unclaimed;
            module.PlayerName == null ||
            // the module is claimed by the player;
            module.PlayerName == user ||
            // anarchy mode is on;
            TwitchPlaySettings.data.AnarchyMode ||
            // there is less than X time left on the clock;
            module.Bomb.CurrentTimer <= TwitchPlaySettings.data.MinTimeLeftForClaims ||
            // there are only X unsolved modules left.
            TwitchGame.Instance.Modules.Count(x => !x.Solved && GameRoom.Instance.IsCurrentBomb(x.BombID)) < TwitchPlaySettings.data.MinUnsolvedModulesLeftForClaims
            )
        {
            yield return(new WaitForSeconds(0.1f));

            var response = module.Solver.RespondToCommand(user, cmd, zoom);
            while (response.MoveNext())
            {
                yield return(response.Current);
            }
            yield return(new WaitForSeconds(0.1f));
        }
        else
        {
            IRCConnection.SendMessageFormat(TwitchPlaySettings.data.AlreadyClaimed, module.Code, module.PlayerName, user, module.HeaderText);
        }
    }
コード例 #14
0
    public NeedyMathComponentSolver(TwitchModule module)
        : base(module, "NeedyMathModule", "Submit an answer with !{0} submit -47.")
    {
        LogSelectables();

        buttonMap = new Dictionary <string, int>()
        {
            { "1", 0 },
            { "2", 1 },
            { "3", 2 },
            { "0", 3 },
            { "4", 4 },
            { "5", 5 },
            { "6", 6 },
            { "-", 7 },
            { "7", 8 },
            { "8", 9 },
            { "9", 10 },
            { "Enter", 11 },
        };
    }
コード例 #15
0
    public static void Assign(TwitchModule module, string user, [Group(1)] string targetUser)
    {
        targetUser = targetUser.FormatUsername();
        if (module.PlayerName == targetUser)
        {
            IRCConnection.SendMessage($"{user}, the module is already assigned to {targetUser}.");
            return;
        }

        if (TwitchPlaySettings.data.AnarchyMode)
        {
            IRCConnection.SendMessage($"{user}, assigning modules is not allowed in anarchy mode.");
            return;
        }

        if (!UserAccess.HasAccess(user, AccessLevel.Mod, true))
        {
            if (module.PlayerName != user || !module.ClaimQueue.Any(q => q.UserNickname == targetUser))
            {
                IRCConnection.SendMessage($"{user}, {module.Code} can only be reassigned if you have it claimed and the other user is in its claim queue.");
                return;
            }
            if (TwitchGame.Instance.Modules.Count(md => !md.Solved && targetUser.EqualsIgnoreCase(md.PlayerName)) >= TwitchPlaySettings.data.ModuleClaimLimit)
            {
                IRCConnection.SendMessage($"{user}, {module.Code} cannot be reassigned because it would take the other user above their claim limit.");
                return;
            }
        }

        if (module.TakeInProgress != null)
        {
            module.StopCoroutine(module.TakeInProgress);
            module.TakeInProgress = null;
            module.TakeUser       = null;
        }

        module.SetClaimedBy(targetUser);
        IRCConnection.SendMessageFormat(TwitchPlaySettings.data.AssignModule, module.Code, module.PlayerName, user, module.HeaderText);
    }
コード例 #16
0
    public static void Take(TwitchModule module, string user, bool isWhisper)
    {
        if (isWhisper)
        {
            IRCConnection.SendMessage($"@{user}, taking modules is not allowed in whispers.");
        }
        else if (TwitchPlaySettings.data.AnarchyMode)
        {
            IRCConnection.SendMessage($"@{user}, taking modules is not allowed in anarchy mode.");
        }

        // Module is already claimed by the same user
        else if (module.PlayerName == user)
        {
            IRCConnection.SendMessageFormat(TwitchPlaySettings.data.ModuleAlreadyOwned, user, module.Code, module.HeaderText);
        }

        // Module is not claimed at all: just claim it
        else if (module.PlayerName == null)
        {
            IRCConnection.SendMessage(module.TryClaim(user).Message);
        }

        // Attempt to take over from another user
        else
        {
            module.AddToClaimQueue(user);
            if (module.TakeInProgress != null)
            {
                IRCConnection.SendMessageFormat(TwitchPlaySettings.data.TakeInProgress, user, module.Code, module.HeaderText);
            }
            else
            {
                IRCConnection.SendMessageFormat(TwitchPlaySettings.data.TakeModule, module.PlayerName, user, module.Code, module.HeaderText);
                module.TakeUser       = user;
                module.TakeInProgress = module.StartCoroutine(module.ProcessTakeover());
            }
        }
    }
コード例 #17
0
    public UnsupportedModComponentSolver(TwitchModule module, ComponentSolverFields componentSolverFields = null)
        : base(module, componentSolverFields == null || componentSolverFields.HookUpEvents)
    {
        _bombModule  = module.BombComponent.GetComponent <KMBombModule>();
        _needyModule = module.BombComponent.GetComponent <KMNeedyModule>();

        ModInfo = new ModuleInformation {
            moduleScore = 0, builtIntoTwitchPlays = true, DoesTheRightThing = true, helpText = $"Solve this {(_bombModule != null ? "module" : "needy")} with !{{0}} solve", moduleDisplayName = $"Unsupported Twitchplays Module  ({module.BombComponent.GetModuleDisplayName()})", moduleID = "UnsupportedTwitchPlaysModule"
        };

        UnsupportedModule = true;

        Selectable selectable = module.BombComponent.GetComponent <Selectable>();

        Selectable[]         selectables       = module.BombComponent.GetComponentsInChildren <Selectable>();
        HashSet <Selectable> selectableHashSet = new HashSet <Selectable>(selectables)
        {
            selectable
        };

        selectable.OnInteract += () => { if (Module != null && Module.CanvasGroupUnsupported != null)
                                         {
                                             Module.CanvasGroupUnsupported.gameObject.SetActive(false);
                                         }
                                         return(true); };
        selectable.OnDeselect += (x) => { if (Module != null && Module.CanvasGroupUnsupported != null)
                                          {
                                              Module.CanvasGroupUnsupported.gameObject.SetActive(x == null || !selectableHashSet.Contains(x));
                                          }
        };

        if (componentSolverFields == null)
        {
            return;
        }
        CommandComponent  = componentSolverFields.CommandComponent;
        ForcedSolveMethod = componentSolverFields.ForcedSolveMethod;
    }
コード例 #18
0
    public static IEnumerator Zoom(TwitchModule module, string user, object yield)
    {
        var zoomCoroutine = TwitchGame.ModuleCameras?.ZoomCamera(module, 1);

        if (zoomCoroutine != null)
        {
            while (zoomCoroutine.MoveNext())
            {
                yield return(zoomCoroutine.Current);
            }
        }

        yield return(yield is int delay ? new WaitForSecondsWithCancel(delay, false, module.Solver) : yield);

        var unzoomCoroutine = TwitchGame.ModuleCameras?.UnzoomCamera(module, 1);

        if (unzoomCoroutine != null)
        {
            while (unzoomCoroutine.MoveNext())
            {
                yield return(unzoomCoroutine.Current);
            }
        }
    }
コード例 #19
0
 public NyaComponentSolver(TwitchModule module) :
     base(module, "TDSNyaScript", "!{0} press <nya/nah> [Presses the nya or nah button]")
 {
 }
コード例 #20
0
 public CryptographyComponentSolver(TwitchModule module) :
     base(module)
 {
     _buttons = (KMSelectable[])KeysField.GetValue(module.BombComponent.GetComponent(ComponentType));
     ModInfo  = ComponentSolverFactory.GetModuleInfo(GetModuleType(), "Solve the cryptography puzzle with !{0} press N B V T K.");
 }
コード例 #21
0
ファイル: GameCommands.cs プロジェクト: ItzAtomikHD/old
 public static void SolveUnsupportedModules()
 {
     IRCConnection.SendMessage("Solving unsupported modules.");
     TwitchModule.SolveUnsupportedModules();
 }
コード例 #22
0
 // Ignore initial “the” in module names
 static string SanitizedName(TwitchModule handle) => Regex.Replace(handle.BombComponent.GetModuleDisplayName(), @"^the\s+", "", RegexOptions.IgnoreCase);
コード例 #23
0
    private IEnumerator CheckForBomb()
    {
        yield return(new WaitUntil(() => SceneManager.Instance.GameplayState.Bombs != null && SceneManager.Instance.GameplayState.Bombs.Count > 0));

        yield return(null);

        var bombs = SceneManager.Instance.GameplayState.Bombs;

        try
        {
            ModuleCameras = Instantiate(moduleCamerasPrefab);
        }
        catch (Exception ex)
        {
            DebugHelper.LogException(ex, "Failed to instantiate the module camera system due to an exception:");
            ModuleCameras = null;
        }

        if (GameRoom.GameRoomTypes.Where((t, i) => t() != null && GameRoom.CreateRooms[i](FindObjectsOfType(t()), out GameRoom.Instance)).Any())
        {
            GameRoom.Instance.InitializeBombs(bombs);
        }
        ModuleCameras?.ChangeBomb(Bombs[0]);

        try
        {
            GameRoom.Instance.InitializeBombNames();
        }
        catch (Exception ex)
        {
            DebugHelper.LogException(ex, "An exception has occurred while setting the bomb names");
        }
        StartCoroutine(GameRoom.Instance.ReportBombStatus());
        StartCoroutine(GameRoom.Instance.InterruptLights());

        try
        {
            if (GameRoom.Instance.HoldBomb)
            {
                StartCoroutine(BombCommands.Hold(Bombs[0]));
            }
        }
        catch (Exception ex)
        {
            DebugHelper.LogException(ex, "An exception has occurred attempting to hold the bomb.");
        }

        NotesDictionary.Clear();
        CommandQueue.Clear();
        ModuleCameras?.SetNotes();

        if (EnableDisableInput())
        {
            TwitchModule.SolveUnsupportedModules(true);
        }

        // Set up some stuff for the !unclaimed command.
        GameCommands.unclaimedModules     = Modules.Where(h => h.CanBeClaimed).Shuffle().ToList();
        GameCommands.unclaimedModuleIndex = 0;

        while (OtherModes.Unexplodable)
        {
            foreach (var bomb in Bombs)
            {
                if (bomb.Bomb.GetTimer() != null && bomb.Bomb.GetTimer().GetRate() > 0)
                {
                    bomb.Bomb.GetTimer().SetRateModifier(-bomb.Bomb.GetTimer().GetRate());
                }
            }
            yield return(null);
        }

        TwitchPlaysService.Instance.UpdateUiHue();
    }
コード例 #24
0
    private void OnDisable()
    {
        GameRoom.ShowCamera();
        BombActive = false;
        EnableDisableInput();
        bool claimsEnabled = TwitchModule.ClaimsEnabled;

        TwitchModule.ClearUnsupportedModules();
        if (!claimsEnabled)
        {
            TwitchModule.ClaimsEnabled = true;
        }
        StopAllCoroutines();
        GoodPlayers.Clear();
        EvilPlayers.Clear();
        VSSetFlag    = false;
        QueueEnabled = false;
        Leaderboard.Instance.BombsAttempted++;
        // ReSharper disable once DelegateSubtraction
        ParentService.GetComponent <KMGameInfo>().OnLightsChange -= OnLightsChange;
        ParentService.AddStateCoroutine(ParentService.AnimateHeaderVisibility(false));

        LogUploader.Instance.GetBombUrl();
        ParentService.AddStateCoroutine(DelayBombResult());
        if (!claimsEnabled)
        {
            ParentService.AddStateCoroutine(SendDelayedMessage(1.1f, "Claims have been enabled."));
        }

        if (ModuleCameras != null)
        {
            ModuleCameras.StartCoroutine(ModuleCameras.DisableCameras());
        }

        // Award users who maintained modules.
        var methods       = Modules.SelectMany(module => module.ScoreMethods);
        var awardedPoints = new Dictionary <string, int>();

        foreach (var player in methods.SelectMany(method => method.Players).Distinct())
        {
            int points = (methods.Sum(method => method.CalculateScore(player)) * OtherModes.ScoreMultiplier).RoundToInt();
            if (points != 0)
            {
                awardedPoints[player] = points;
                Leaderboard.Instance.AddScore(player, points);
            }
        }

        if (awardedPoints.Count > 0)
        {
            IRCConnection.SendMessage($"These players have been awarded points for managing a needy: {awardedPoints.Select(pair => $"{pair.Key} ({pair.Value})").Join(", ")}");
        }

        GameCommands.unclaimedModules = null;
        DestroyComponentHandles();

        MusicPlayer.StopAllMusic();

        GameRoom.Instance?.OnDisable();

        try
        {
            string path = Path.Combine(Application.persistentDataPath, "TwitchPlaysLastClaimed.json");
            File.WriteAllText(path, SettingsConverter.Serialize(LastClaimedModule));
        }
        catch (Exception ex)
        {
            DebugHelper.LogException(ex, "Couldn't write TwitchPlaysLastClaimed.json:");
        }
    }
コード例 #25
0
 public EmojiMathComponentSolver(TwitchModule module) :
     base(module)
 {
     _buttons = (KMSelectable[])_buttonsField.GetValue(module.BombComponent.GetComponent(_componentType));
     ModInfo  = ComponentSolverFactory.GetModuleInfo(GetModuleType(), "Submit an answer using !{0} submit -47.");
 }
コード例 #26
0
    private void OnDisable()
    {
        GameRoom.ShowCamera();
        BombActive = false;
        EnableDisableInput();
        bool claimsEnabled = TwitchModule.ClaimsEnabled;

        TwitchModule.ClearUnsupportedModules();
        if (!claimsEnabled)
        {
            TwitchModule.ClaimsEnabled = true;
        }
        StopAllCoroutines();
        Leaderboard.Instance.BombsAttempted++;
        // ReSharper disable once DelegateSubtraction
        ParentService.GetComponent <KMGameInfo>().OnLightsChange -= OnLightsChange;
        TwitchPlaysService.Instance.SetHeaderVisbility(false);

        LogUploader.Instance.GetBombUrl();
        ParentService.StartCoroutine(DelayBombResult());
        if (!claimsEnabled)
        {
            ParentService.StartCoroutine(SendDelayedMessage(1.1f, "Claims have been enabled."));
        }

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

        // Award users who maintained needy modules.
        if (!OtherModes.ZenModeOn)
        {
            Dictionary <string, int> AwardedNeedyPoints = new Dictionary <string, int>();
            foreach (TwitchModule twitchModule in Modules)
            {
                ModuleInformation ModInfo     = twitchModule.Solver.ModInfo;
                ScoreMethod       scoreMethod = ModInfo.scoreMethod;
                if (scoreMethod == ScoreMethod.Default)
                {
                    continue;
                }

                foreach (var pair in twitchModule.PlayerNeedyStats)
                {
                    string playerName = pair.Key;
                    var    needyStats = pair.Value;

                    int points = Mathf.RoundToInt((scoreMethod == ScoreMethod.NeedySolves ? needyStats.Solves : needyStats.ActiveTime) * ModInfo.moduleScore);
                    if (points != 0)
                    {
                        if (!AwardedNeedyPoints.ContainsKey(playerName))
                        {
                            AwardedNeedyPoints[playerName] = 0;
                        }

                        AwardedNeedyPoints[playerName] += points;
                        Leaderboard.Instance.AddScore(playerName, points);
                    }
                }
            }

            if (AwardedNeedyPoints.Count > 0)
            {
                IRCConnection.SendMessage($"These players have been awarded points for managing a needy: {AwardedNeedyPoints.Select(pair => $"{pair.Key} ({pair.Value})").Join(", ")}");
            }
        }

        GameCommands.unclaimedModules = null;
        DestroyComponentHandles();

        MusicPlayer.StopAllMusic();

        GameRoom.Instance?.OnDisable();

        try
        {
            string path = Path.Combine(Application.persistentDataPath, "TwitchPlaysLastClaimed.json");
            File.WriteAllText(path, SettingsConverter.Serialize(LastClaimedModule));
        }
        catch (Exception ex)
        {
            DebugHelper.LogException(ex, "Couldn't write TwitchPlaysLastClaimed.json:");
        }
    }
コード例 #27
0
 public LetterKeysComponentSolver(TwitchModule module) :
     base(module)
 {
     _buttons = module.BombComponent.GetComponent <KMSelectable>().Children;
     ModInfo  = ComponentSolverFactory.GetModuleInfo(GetModuleType(), "!{0} press b");
 }
コード例 #28
0
 public PerModule(float points, TwitchModule module) : base(points)
 {
     this.module = module;
 }
コード例 #29
0
 public SphereShim(TwitchModule module)
     : base(module, "sphere")
 {
     ModInfo = ComponentSolverFactory.GetModuleInfo(GetModuleType());
 }
 public StateOfAggregationComponentSolver(TwitchModule module) :
     base(module, "StateOfAggregation", "!{0} cycle temp [Cycles through all temperatures in the temperature display] | !{0} submit <group> <temp> [Submits the specified chemical group and temperature]")
 {
 }