Esempio n. 1
0
    protected internal override IEnumerator RespondToCommandInternal(string inputCommand)
    {
        inputCommand = inputCommand.Trim();
        if (!inputCommand.StartsWith("move ", StringComparison.InvariantCultureIgnoreCase))
        {
            yield break;
        }

        inputCommand = inputCommand.Substring(5);
        MatchCollection matches = Regex.Matches(inputCommand, @"[udlr]", RegexOptions.IgnoreCase);

        if (matches.Count > 35)
        {
            yield return(null);

            yield return("elevator music");
        }

        foreach (Match move in matches)
        {
            KeypadButton button = _buttons[buttonIndex[move.Value.ToLowerInvariant()]];

            if (button != null)
            {
                yield return(move.Value);

                yield return("trycancel");

                yield return(DoInteractionClick(button));
            }
        }
    }
Esempio n. 2
0
 void OnTriggerEnter(Collider col)
 {
     if (col.tag == "KeypadButton" && !m_button) {
         m_button = col.gameObject.GetComponent<KeypadButton>();
         m_button.SetHighlight(true);
     }
 }
Esempio n. 3
0
    public bool ButtonPushed(int index)
    {
        KeypadButton pressedButton = buttons [index];

        if (pressedButton.isPressed)
        {
            return(false);
        }
        List <string> solutionOrder = GetSolutionOrder();
        int           solutionValue = solutionOrder.IndexOf(pressedButton.GetText());
        int           numPressed    = 0;

        foreach (KeypadButton button in buttons)
        {
            int otherSolVal = solutionOrder.IndexOf(button.GetText());
            if (button.isPressed)
            {
                numPressed++;
            }

            else if (otherSolVal < solutionValue)
            {
                SceneManager.Instance.Bomb.OnStrike();
                return(false);
            }
        }
        if (numPressed == 3)
        {
            SceneManager.Instance.Bomb.OnPass();
        }
        return(true);
    }
 public void StopEditKeybind(KeypadButton whichButton)
 {
     if (buttonBeingEdited == whichButton)
     {
         buttonBeingEdited = KeypadButton.None;
     }
     NotifyAllProperties();
 }
Esempio n. 5
0
 void OnTriggerExit(Collider col)
 {
     if (m_button && col.gameObject == m_button.gameObject)
     {
         m_button.SetHighlight(false);
         m_button = null;
     }
 }
Esempio n. 6
0
    void OnTriggerExit(Collider col)
    {
        if (m_button && col.gameObject == m_button.gameObject) {

            m_button.SetHighlight(false);
            m_button = null;
        }
    }
Esempio n. 7
0
 void OnTriggerEnter(Collider col)
 {
     if (col.tag == "KeypadButton" && !m_button)
     {
         m_button = col.gameObject.GetComponent <KeypadButton>();
         m_button.SetHighlight(true);
     }
 }
Esempio n. 8
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;
    }
Esempio n. 9
0
        public void Simple_Keypad(VTSmartObject SmartObject, KeypadButton Button)
        {
            switch (Button)
            {
            case KeypadButton.Misc_1:
                throw new NotImplementedException();
                break;

            case KeypadButton.Num_0:
                //ControlSystem._videoServer.KeypadNumber(0);
                break;

            case KeypadButton.Num_1:
                //ControlSystem._videoServer.KeypadNumber(1);
                break;

            case KeypadButton.Num_2:
                //ControlSystem._videoServer.KeypadNumber(2);
                break;

            case KeypadButton.Num_3:
                //ControlSystem._videoServer.KeypadNumber(3);
                break;

            case KeypadButton.Num_4:
                //ControlSystem._videoServer.KeypadNumber(4);
                break;

            case KeypadButton.Num_5:
                //ControlSystem._videoServer.KeypadNumber(5);
                break;

            case KeypadButton.Num_6:
                //ControlSystem._videoServer.KeypadNumber(6);
                break;

            case KeypadButton.Num_7:
                //ControlSystem._videoServer.KeypadNumber(7);
                break;

            case KeypadButton.Num_8:
                //ControlSystem._videoServer.KeypadNumber(8);
                break;

            case KeypadButton.Num_9:
                //ControlSystem._videoServer.KeypadNumber(9);
                break;

            case KeypadButton.Misc_2:
                break;

            case KeypadButton.Null:
                break;
            }
        }
Esempio n. 10
0
        public KeypadButton GetAdjacentButton(KeypadButton currentButton, MoveDirection direction)
        {
            var dict = DirectionsMap[currentButton];

            KeypadButton newButton;

            if (!dict.TryGetValue(direction, out newButton))
            {
                newButton = currentButton;
            }

            return(newButton);
        }
Esempio n. 11
0
    private IEnumerator CycleCharacterSpinnerCoroutine(CharSpinner spinner)
    {
        yield return("cycle");

        KeypadButton downButton = spinner.DownButton;

        for (int hitCount = 0; hitCount < 6; ++hitCount)
        {
            yield return(DoInteractionClick(downButton));

            yield return("trywaitcancel 1.0");
        }
    }
Esempio n. 12
0
    // Use this for initialization
    void Start()
    {
        List <string> symbolsClone = new List <string>(symbols);

        for (int i = 0; i < buttons.Length; i++)
        {
            KeypadButton button = buttons[i];
            int          rand   = (int)(Random.value * symbolsClone.Count);
            button.SetText(symbolsClone[rand]);
            button.parentComponent = this;
            button.buttonIndex     = i;
            symbolsClone.RemoveAt(rand);
        }
    }
Esempio n. 13
0
    public IEnumerator HandleButton(KeypadButton button, KeyCode keyCode, PushEvent handler)
    {
        var delay = startDelay;

        while (Input.GetKey(keyCode) || IsHeld(button))
        {
            MasterAudio.PlaySound3DFollowTransformAndForget("singlebeep", FreeplayDevice.transform, 1f, null);
            handler.Invoke();

            yield return(new WaitForSeconds(Mathf.Max(delay, minDelay)));

            delay -= Acceleration;
        }
    }
Esempio n. 14
0
    protected override IEnumerator RespondToCommandInternal(string inputCommand)
    {
        string[] commandParts = inputCommand.ToLowerInvariant().Split(' ');

        if (commandParts.Length != 2 || !commandParts[0].EqualsAny("transmit", "trans", "xmit", "tx", "submit") || commandParts[1].Length != 3)
        {
            yield break;
        }

        if (!int.TryParse(commandParts[1], out int targetFrequency) || !Frequencies.Contains(targetFrequency))
        {
            yield break;
        }

        int          initialFrequency = CurrentFrequency;
        KeypadButton buttonToShift    = targetFrequency < initialFrequency ? _downButton : _upButton;

        while (CurrentFrequency != targetFrequency && (CurrentFrequency == initialFrequency || Mathf.Sign(CurrentFrequency - initialFrequency) != Mathf.Sign(CurrentFrequency - targetFrequency)))
        {
            yield return("change frequency");

            if (Canceller.ShouldCancel)
            {
                Canceller.ResetCancel();
                yield break;
            }
            int lastFrequency = CurrentFrequency;
            yield return(DoInteractionClick(buttonToShift));

            if (lastFrequency == CurrentFrequency)
            {
                break;
            }
        }

        if (CurrentFrequency == targetFrequency)
        {
            yield return("transmit");

            yield return(DoInteractionClick(_transmitButton));
        }
        else
        {
            yield return("unsubmittablepenalty");
        }
    }
    private IEnumerator CycleCharacterSpinnerCoroutine(CharSpinner spinner)
    {
        yield return("cycle");

        KeypadButton downButton = spinner.DownButton;

        for (int hitCount = 0; hitCount < 6; ++hitCount)
        {
            if (Canceller.ShouldCancel)
            {
                Canceller.ResetCancel();
                yield break;
            }

            yield return(DoInteractionClick(downButton));

            yield return(new WaitForSeconds(1.0f));
        }
    }
Esempio n. 16
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;
    }
        protected override void AwakeLive()
        {
#if (!DEBUG)
            using var wrapper = this.InstantiateComponent <PasswordComponent>();
            this.layout       = wrapper.Component.CurrentLayout = wrapper.Component.transform.Find("Layout_DEFAULT").GetComponent <PasswordLayout>();
            this.layout.transform.SetParent(this.transform, false);
            this.spinners     = wrapper.Component.Spinners;
            this.submitButton = wrapper.Component.SubmitButton;
            this.submitButton.transform.SetParent(this.transform, false);
            //this.submitButton.transform.Rotate(new Vector3(0, 180, 0));
            this.displayGlow = wrapper.Component.DisplayGlow;
            this.displayGlow.transform.SetParent(this.transform, false);
            this.displayGlow.SetActive(false);

            var keypadEventConnector = new KeypadEventConnector();
            keypadEventConnector.ButtonPressed += this.KeypadEventConnector_ButtonPressed;
            keypadEventConnector.Attach(this.submitButton);

            FixKeypadButtons(this.GetComponentsInChildren <KeypadButton>());
#endif
        }
        public void SetKeybind(KeypadButton whichButton, KeybindEventArgs e)
        {
            switch (whichButton)
            {
            case KeypadButton.Left:
                Keybinds.LeftButtonScanCode = e.ScanCode;
                break;

            case KeypadButton.Right:
                Keybinds.RightButtonScanCode = e.ScanCode;
                break;

            case KeypadButton.Side:
                Keybinds.SideButtonScanCode = e.ScanCode;
                break;
            }
            if (!Keybinds.PushAllValues())
            {
                Console.WriteLine("Readback failed");
            }
            NotifyAllProperties();
        }
    protected internal override IEnumerator RespondToCommandInternal(string inputCommand)
    {
        inputCommand = inputCommand.Trim();
        if (!inputCommand.RegexMatch(out Match match,
                                     "^(?:tx|trans(?:mit)?|submit|xmit) (?:3.)?(5[0-9][25]|600)( ?mhz)?$") ||
            !int.TryParse(match.Groups[1].Value, out int targetFrequency))
        {
            yield break;
        }

        int          initialFrequency = CurrentFrequency;
        KeypadButton buttonToShift    = targetFrequency < initialFrequency ? _downButton : _upButton;

        while (CurrentFrequency != targetFrequency && (CurrentFrequency == initialFrequency || Math.Sign(CurrentFrequency - initialFrequency) != Math.Sign(CurrentFrequency - targetFrequency)))
        {
            yield return("change frequency");

            yield return("trycancel");

            int lastFrequency = CurrentFrequency;
            yield return(DoInteractionClick(buttonToShift));

            if (lastFrequency == CurrentFrequency)
            {
                break;
            }
        }

        if (CurrentFrequency == targetFrequency)
        {
            yield return("transmit");

            yield return(DoInteractionClick(_transmitButton));
        }
        else
        {
            yield return("unsubmittablepenalty");
        }
    }
Esempio n. 20
0
    public IEnumerator SetBombModules(string mods)
    {
        if (!int.TryParse(mods, out int moduleCount))
        {
            yield break;
        }

        FreeplaySettings currentSettings = FreeplayDevice.CurrentSettings;
        int          currentModuleCount  = currentSettings.ModuleCount;
        KeypadButton button           = moduleCount > currentModuleCount ? FreeplayDevice.ModuleCountIncrement : FreeplayDevice.ModuleCountDecrement;
        Selectable   buttonSelectable = button.GetComponent <Selectable>();

        for (int hitCount = 0; hitCount < Mathf.Abs(moduleCount - currentModuleCount); ++hitCount)
        {
            int lastModuleCount = currentSettings.ModuleCount;
            SelectObject(buttonSelectable);
            yield return(new WaitForSeconds(0.01f));

            if (lastModuleCount == currentSettings.ModuleCount)
            {
                yield break;
            }
        }
    }
Esempio n. 21
0
 public bool IsHeld(KeypadButton button)
 {
     return((bool)(typeof(KeypadButton).GetField("isBeingPushed", BindingFlags.NonPublic | BindingFlags.Instance)?.GetValue(button) ?? false));
 }
Esempio n. 22
0
    public void StartBomb()
    {
        KeypadButton startButton = FreeplayDevice.StartButton;

        SelectObject(startButton.GetComponent <Selectable>());
    }
Esempio n. 23
0
 public KeypadClicker(IKeypad keypad, KeypadButton startButton = KeypadButton.Button5)
 {
     _keypad       = keypad;
     CurrentButton = startButton;
 }
Esempio n. 24
0
 public void Move(MoveDirection moveDirection)
 {
     CurrentButton = _keypad.GetAdjacentButton(CurrentButton, moveDirection);
 }
Esempio n. 25
0
 /// <summary>Attaches this instance to the specified <see cref="KeypadButton"/>, allowing events to be received from the button.</summary>
 public void Attach(KeypadButton button)
 {
     button.ParentComponent = this;
     this.buttons.Add(button);
 }
Esempio n. 26
0
 /// <summary>Attaches this instance to the specified <see cref="KeypadButton"/> and sets its <see cref="KeypadButton.ButtonIndex"/>.</summary>
 public void Attach(KeypadButton button, int index)
 {
     this.Attach(button);
     button.ButtonIndex = index;
 }
 // common
 public void BeginEditKeybind(KeypadButton whichButton)
 {
     buttonBeingEdited = whichButton;
     NotifyAllProperties();
 }