예제 #1
0
    public void ToggleIndex()
    {
        object currentSettings    = _currentSettingsField.GetValue(FreeplayDevice, null);
        int    currentModuleCount = (int)_moduleCountField.GetValue(currentSettings);
        int    currentBombsCount  = MultipleBombs.GetBombCount();
        float  currentTime        = (float)_timeField.GetValue(currentSettings);
        bool   onlyMods           = (bool)_onlyModsField.GetValue(currentSettings);

        switch (_index)
        {
        case freeplaySelection.Timer:
            try
            {
                MonoBehaviour timerUp   = (MonoBehaviour)_timeIncrementField.GetValue(FreeplayDevice);
                MonoBehaviour timerDown = (MonoBehaviour)_timeDecrementField.GetValue(FreeplayDevice);
                SelectObject((MonoBehaviour)timerUp.GetComponent(_selectableType));
                if (Mathf.FloorToInt(currentTime) == Mathf.FloorToInt((float)_timeField.GetValue(currentSettings)))
                {
                    break;
                }
                SelectObject((MonoBehaviour)timerDown.GetComponent(_selectableType));
            }
            catch (Exception ex)
            {
                DebugLog("Failed to Select the Timer buttons due to Exception: {0}, Stack Trace: {1}", ex.Message, ex.StackTrace);
            }
            break;

        case freeplaySelection.Bombs:
            try
            {
                if (!MultipleBombs.Installed())
                {
                    break;
                }
                MonoBehaviour bombsUp   = SelectableChildren[3];
                MonoBehaviour bombsDown = SelectableChildren[2];
                SelectObject(bombsUp);
                if (currentBombsCount == MultipleBombs.GetBombCount())
                {
                    break;
                }
                SelectObject(bombsDown);
            }
            catch (Exception ex)
            {
                DebugLog("Failed to Select the Bomb count buttons due to Exception: {0}, Stack Trace: {1}", ex.Message, ex.StackTrace);
            }
            break;

        case freeplaySelection.Modules:
            try
            {
                MonoBehaviour moduleUp   = (MonoBehaviour)_moduleCountIncrementField.GetValue(FreeplayDevice);
                MonoBehaviour moduleDown = (MonoBehaviour)_moduleCountDecrementField.GetValue(FreeplayDevice);
                SelectObject((MonoBehaviour)moduleUp.GetComponent(_selectableType));
                if (currentModuleCount == (int)_moduleCountField.GetValue(currentSettings))
                {
                    break;
                }
                SelectObject((MonoBehaviour)moduleDown.GetComponent(_selectableType));
            }
            catch (Exception ex)
            {
                DebugLog("Failed to Select the Module count buttons due to Exception: {0}, Stack Trace: {1}", ex.Message, ex.StackTrace);
            }
            break;

        case freeplaySelection.Needy:
            try
            {
                MonoBehaviour needyToggle = (MonoBehaviour)_needyToggleField.GetValue(FreeplayDevice);
                SelectObject((MonoBehaviour)needyToggle.GetComponent(_selectableType));
                SelectObject((MonoBehaviour)needyToggle.GetComponent(_selectableType));
            }
            catch (Exception ex)
            {
                DebugLog("Failed to Select the Needy toggle due to Exception: {0}, Stack Trace: {1}", ex.Message, ex.StackTrace);
            }
            break;

        case freeplaySelection.Hardcore:
            try
            {
                MonoBehaviour hardcoreToggle = (MonoBehaviour)_hardcoreToggleField.GetValue(FreeplayDevice);
                SelectObject((MonoBehaviour)hardcoreToggle.GetComponent(_selectableType));
                SelectObject((MonoBehaviour)hardcoreToggle.GetComponent(_selectableType));
            }
            catch (Exception ex)
            {
                DebugLog("Failed to Select the Hardcore toggle due to Exception: {0}, Stack Trace: {1}", ex.Message, ex.StackTrace);
            }
            break;

        case freeplaySelection.ModsOnly:
            try
            {
                MonoBehaviour modsToggle = (MonoBehaviour)_modsOnlyToggleField.GetValue(FreeplayDevice);
                SelectObject((MonoBehaviour)modsToggle.GetComponent(_selectableType));
                bool onlyModsCurrent = (bool)_onlyModsField.GetValue(currentSettings);
                SelectObject((MonoBehaviour)modsToggle.GetComponent(_selectableType));
                if (onlyMods == onlyModsCurrent)
                {
                    if (Input.GetKey(KeyCode.DownArrow))
                    {
                        _index = freeplaySelection.Timer;
                        goto case freeplaySelection.Timer;
                    }
                    else
                    {
                        _index = freeplaySelection.Hardcore;
                        goto case freeplaySelection.Hardcore;
                    }
                }
            }
            catch (Exception ex)
            {
                DebugLog("Failed to Select the Mods only toggle due to Exception: {0}, Stack Trace: {1}", ex.Message, ex.StackTrace);
            }
            break;
        }
    }
예제 #2
0
    public IEnumerator HandleInput()
    {
        Selectable         = (MonoBehaviour)FreeplayDevice.GetComponent(_selectableType);
        SelectableChildren = (MonoBehaviour[])_childrenField.GetValue(Selectable);

        if (!Input.GetKeyDown(KeyCode.LeftArrow) && !Input.GetKeyDown(KeyCode.RightArrow) &&
            !Input.GetKeyDown(KeyCode.UpArrow) && !Input.GetKeyDown(KeyCode.DownArrow) &&
            !Input.GetKeyDown(KeyCode.Return) && !Input.GetKeyDown(KeyCode.KeypadEnter))
        {
            yield break;
        }
        int holdState = (int)_holdStateProperty.GetValue(FloatingHoldable, null);

        if (holdState != 0)
        {
            _index = 0;
            IEnumerator hold = HoldFreeplayDevice();
            while (hold.MoveNext())
            {
                yield return(hold.Current);
            }
            ToggleIndex();
            yield break;
        }
        if (Input.GetKeyDown(KeyCode.KeypadEnter) || Input.GetKeyDown(KeyCode.Return))
        {
            StartBomb();
            yield break;
        }
        if (Input.GetKeyDown(KeyCode.UpArrow))
        {
            _index--;
            if (_index == freeplaySelection.Bombs && !MultipleBombs.Installed())
            {
                _index = freeplaySelection.Timer;
            }
            if (_index < freeplaySelection.Timer)
            {
                _index = freeplaySelection.ModsOnly;
            }
            ToggleIndex();
            yield break;
        }
        if (Input.GetKeyDown(KeyCode.DownArrow))
        {
            _index++;
            if (_index == freeplaySelection.Bombs && !MultipleBombs.Installed())
            {
                _index = freeplaySelection.Modules;
            }
            if (_index > freeplaySelection.ModsOnly)
            {
                _index = freeplaySelection.Timer;
            }
            ToggleIndex();
            yield break;
        }
        if (Input.GetKeyDown(KeyCode.LeftArrow) || Input.GetKeyDown(KeyCode.RightArrow))
        {
            IEnumerator handler = null;
            switch (_index)
            {
            case freeplaySelection.Timer:
                handler = Input.GetKeyDown(KeyCode.LeftArrow) ? DecrementBombTimer() : IncrementBombTimer();
                break;

            case freeplaySelection.Bombs:
                handler = Input.GetKeyDown(KeyCode.LeftArrow) ? DecrementBombCount() : IncrementBombCount();
                break;

            case freeplaySelection.Modules:
                handler = Input.GetKeyDown(KeyCode.LeftArrow) ? DecrementModuleCount() : IncrementModuleCount();
                break;

            case freeplaySelection.Needy:
                handler = SetNeedy();
                break;

            case freeplaySelection.Hardcore:
                handler = SetHardcore();
                break;

            case freeplaySelection.ModsOnly:
                handler = SetModsOnly();
                break;
            }
            if (handler == null)
            {
                yield break;
            }
            while (handler.MoveNext())
            {
                yield return(handler.Current);
            }
        }
    }