Exemple #1
0
    public IEnumerator SetBombTimer(string hours, string mins, string secs)
    {
        DebugHelper.Log("Time parsing section");
        int hoursInt = 0;

        if (!string.IsNullOrEmpty(hours) && !int.TryParse(hours, out hoursInt))
        {
            yield break;
        }

        if (!int.TryParse(mins, out int minutes))
        {
            yield break;
        }

        int seconds = 0;

        if (!string.IsNullOrEmpty(secs) &&
            (!int.TryParse(secs, out seconds) || seconds >= 60))
        {
            yield break;
        }

        int timeIndex = (hoursInt * 120) + (minutes * 2) + (seconds / 30);

        DebugHelper.Log("Freeplay time doubling section");
        //Double the available free play time. (The doubling stacks with the Multiple bombs module installed)
        float originalMaxTime = FreeplayDevice.MAX_SECONDS_TO_SOLVE;
        int   maxModules      = (int)_maxModuleField.GetValue(FreeplayDevice);
        int   multiplier      = MultipleBombs.Installed() ? (MultipleBombs.GetMaximumBombCount() * 2) - 1 : 1;
        float newMaxTime      = 600f + ((maxModules - 1) * multiplier * 60);

        FreeplayDevice.MAX_SECONDS_TO_SOLVE = newMaxTime;


        DebugHelper.Log("Freeplay settings reading section");
        FreeplaySettings currentSettings = FreeplayDevice.CurrentSettings;
        float            currentTime     = currentSettings.Time;
        int          currentTimeIndex    = Mathf.FloorToInt(currentTime) / 30;
        KeypadButton button           = timeIndex > currentTimeIndex ? FreeplayDevice.TimeIncrement : FreeplayDevice.TimeDecrement;
        Selectable   buttonSelectable = button.GetComponent <Selectable>();

        DebugHelper.Log("Freeplay time setting section");
        for (int hitCount = 0; hitCount < Mathf.Abs(timeIndex - currentTimeIndex); ++hitCount)
        {
            currentTime = currentSettings.Time;
            SelectObject(buttonSelectable);
            yield return(new WaitForSeconds(0.01f));

            if (Mathf.FloorToInt(currentTime) == Mathf.FloorToInt(currentSettings.Time))
            {
                break;
            }
        }

        //Restore original max time, just in case Multiple bombs module was NOT installed, to avoid false detection.
        FreeplayDevice.MAX_SECONDS_TO_SOLVE = originalMaxTime;
    }
Exemple #2
0
    private static IEnumerator SetBombTimer(FloatingHoldable holdable, int hours, int minutes, int seconds)
    {
        if (seconds >= 60)
        {
            yield break;
        }

        var device    = holdable.GetComponent <FreeplayDevice>();
        int timeIndex = (hours * 120) + (minutes * 2) + (seconds / 30);

        DebugHelper.Log("Freeplay time doubling section");
        //Double the available free play time. (The doubling stacks with the Multiple bombs module installed)
        float originalMaxTime = FreeplayDevice.MAX_SECONDS_TO_SOLVE;
        int   maxModules      = (int)_maxModuleField.GetValue(device);
        int   multiplier      = MultipleBombs.Installed() ? (MultipleBombs.GetMaximumBombCount() * 2) - 1 : 1;
        float newMaxTime      = 600f + (maxModules - 1) * multiplier * 60;

        FreeplayDevice.MAX_SECONDS_TO_SOLVE = newMaxTime;

        DebugHelper.Log("Freeplay settings reading section");
        float        currentTime      = device.CurrentSettings.Time;
        int          currentTimeIndex = Mathf.FloorToInt(currentTime) / 30;
        KeypadButton button           = timeIndex > currentTimeIndex ? device.TimeIncrement : device.TimeDecrement;
        Selectable   buttonSelectable = button.GetComponent <Selectable>();

        DebugHelper.Log("Freeplay time setting section");
        for (int hitCount = 0; hitCount < Mathf.Abs(timeIndex - currentTimeIndex); ++hitCount)
        {
            currentTime = device.CurrentSettings.Time;
            buttonSelectable.Trigger();
            yield return(new WaitForSeconds(0.01f));

            if (Mathf.FloorToInt(currentTime) == Mathf.FloorToInt(device.CurrentSettings.Time))
            {
                break;
            }
        }

        //Restore original max time, just in case Multiple bombs module was NOT installed, to avoid false detection.
        FreeplayDevice.MAX_SECONDS_TO_SOLVE = originalMaxTime;
    }