Example #1
0
    private void OnArrowPress(int i)
    {
        ArrowButtonDirection direction = ArrowButtonDirection.Up;

        switch (i)
        {
        case 0:
            direction = ArrowButtonDirection.Up;
            break;

        case 1:
            direction = ArrowButtonDirection.Left;
            break;

        case 2:
            direction = ArrowButtonDirection.Right;
            break;

        case 3:
            direction = ArrowButtonDirection.Down;
            break;

        default:
            throw new InvalidOperationException();
        }

        var nextButton = CrackboxLogic.GetNextIndex(currentlySelectedItem, gridItems, direction);

        BoxRenderers[currentlySelectedItem].material = gridItems[currentlySelectedItem].IsBlack ? GridBoxBlack : GridBoxNormal;
        BoxRenderers[nextButton].material            = GridBoxSelected;
        currentlySelectedItem = nextButton;
    }
Example #2
0
    private void InitGrid()
    {
        originalGridItems = null;
        var solutionFinder = new CrackboxSolutionFinder();

        while (originalGridItems == null)
        {
            originalGridItems = solutionFinder.FindSolution(CrackboxLogic.CreateGrid().ToArray());
        }

        Debug.LogFormat("[Crackbox #{0}] One possible solution:", _moduleId);
        GridDebugLog(originalGridItems, x => string.Format("{0}", (x.IsBlack ? "B" : x.Value.ToString())));

        CrackboxSolutionFinder.Anonymize(originalGridItems);
        gridItems = CrackboxGridItem.Clone(originalGridItems);

        Debug.LogFormat("[Crackbox #{0}] Initial grid:", _moduleId);
        GridDebugLog(originalGridItems, x => string.Format("{0}", (x.IsBlack ? "B" : (x.Value == 0 ? "*" : x.Value.ToString()))));
    }
Example #3
0
    void Activate()
    {
        InitGrid();
        ReinitializeGrid();

        for (int i = 0; i < 4; i++)
        {
            int j = i;
            ArrowButtons[i].OnInteract += delegate
            {
                Audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, transform);
                ArrowButtons[j].AddInteractionPunch(0.4f);
                if (isSolved || !interactable)
                {
                    return(false);
                }
                OnArrowPress(j);
                return(false);
            };
        }

        for (int i = 0; i < 10; i++)
        {
            int j = i;
            NumberedButtons[i].OnInteract += delegate
            {
                Audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, transform);
                NumberedButtons[j].AddInteractionPunch(0.4f);
                if (isSolved || !interactable)
                {
                    return(false);
                }
                OnNumberButtonPress(j);
                return(false);
            };
        }

        CheckButton.OnInteract += delegate
        {
            Audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, transform);
            CheckButton.AddInteractionPunch();
            if (isSolved || !interactable)
            {
                return(false);
            }
            var solved = CrackboxLogic.IsSolved(gridItems);
            Debug.LogFormat("[Crackbox #{0}] Submitted:", _moduleId);
            GridDebugLog(gridItems, x => string.Format("{0}", (x.IsBlack ? "B" : (x.Value == 0 ? "*" : x.Value.ToString()))));
            if (solved)
            {
                isSolved = true;
                Debug.LogFormat("[Crackbox #{0}] That is correct, module solved!", _moduleId);
                StartCoroutine("SolveAnimation", GridBoxSelected);
            }
            else
            {
                Debug.LogFormat("[Crackbox #{0}] That is incorrect, strike!", _moduleId);
                StartCoroutine("SolveAnimation", GridBoxWrong);
            }
            return(false);
        };
    }