示例#1
0
文件: LinqSelect.cs 项目: Emik03/Linq
        private void Generate()
        {
            do
            {
                initialButtonStates = Function.RandomBools(6);
            }while (initialButtonStates.Distinct().Count() == 1);
            Array.Copy(initialButtonStates, buttonStates, 6);
            UpdateButtons();

            parameter = null;
            switch (functions[currentStage])
            {
            case LinqFunctions.Skip:
            case LinqFunctions.SkipLast:
            case LinqFunctions.Take:
            case LinqFunctions.TakeLast:
            case LinqFunctions.ElementAt:
                parameter = Rnd.Range(0, buttonStates.Where(b => b).Count());
                break;

            case LinqFunctions.Except:
            case LinqFunctions.Intersect:
            case LinqFunctions.Concat:
            case LinqFunctions.Append:
            case LinqFunctions.Prepend:
                parameter = _linq.Info.GetSerialNumber().Take(Rnd.Range(1, 5)).ToArray().Shuffle().Join("");
                break;
            }

            _linq.Text.text = functions[currentStage].ToString() + "\n(" + parameter + ")";

            bool[] answer = LinqValidate.Run(_linq.Info.GetSerialNumber(), initialButtonStates, functions[currentStage], parameter);
            Debug.LogFormat("[Linq #{0}]: {1}Calling function {2} on {3} returns {4}.", _linq.ModuleId, MaxStage > 1 ? "Entering stage " + (currentStage + 1) + ". " : string.Empty, functions[currentStage] + "(" + parameter + ")", initialButtonStates.Select(b => b ? "O" : "-").Join(""), answer.Select(b => b ? "O" : "-").Join(""));
        }
示例#2
0
        internal void TextPress()
        {
            if (_linq.IsSolved)
            {
                return;
            }

            bool[] answer = LinqValidate.Run(_linq.Get <KMBombInfo>().GetSerialNumber(), initialButtonStates, functions[currentStage], parameter);

            _linq.ButtonEffect(_linq.TextSelectable, 0.5f, KMSoundOverride.SoundEffect.TypewriterKey, Sounds.Linq.Id(answer.SequenceEqual(buttonStates) ? 8 : 7));

            if (answer.SequenceEqual(buttonStates))
            {
                currentStage++;

                if (currentStage == MaxStage)
                {
                    _linq.StartCoroutine(Solve());
                }

                else
                {
                    Generate();
                }
            }
            else
            {
                Array.Copy(initialButtonStates, buttonStates, 6);
                UpdateButtons();
                _linq.Strike("Strike! Expected {0} but received {1}.".Form(answer.Select(b => b ? "O" : "-").Join(""), buttonStates.Select(b => b ? "O" : "-").Join("")));
            }

            return;
        }
示例#3
0
文件: LinqSelect.cs 项目: Emik03/Linq
        internal KMSelectable.OnInteractHandler TextPress()
        {
            return(delegate()
            {
                if (_linq.IsSolved)
                {
                    return false;
                }

                bool[] answer = LinqValidate.Run(_linq.Info.GetSerialNumber(), initialButtonStates, functions[currentStage], parameter);

                _linq.TextSelectable.AddInteractionPunch(2);
                _linq.Audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.TypewriterKey, _linq.TextSelectable.transform);
                _linq.Audio.PlaySoundAtTransform(answer.SequenceEqual(buttonStates) ? "8" : "7", _linq.TextSelectable.transform);

                if (answer.SequenceEqual(buttonStates))
                {
                    currentStage++;

                    if (currentStage == MaxStage)
                    {
                        _linq.StartCoroutine(Solve());
                    }

                    else
                    {
                        Generate();
                    }
                }

                else
                {
                    Debug.LogFormat("[Linq #{0}]: Strike! Expected {1} but received {2}.", _linq.ModuleId, answer.Select(b => b ? "O" : "-").Join(""), buttonStates.Select(b => b ? "O" : "-").Join(""));
                    Array.Copy(initialButtonStates, buttonStates, 6);
                    UpdateButtons();
                    _linq.Module.HandleStrike();
                }

                return false;
            });
        }