コード例 #1
0
ファイル: InteractScript.cs プロジェクト: VFlyer/EmikModules
    internal KMSelectable.OnInteractHandler Init(TheOctadecayottonScript octadecayotton, bool checkForTP, int dimension)
    {
        return(() =>
        {
            if (isStarting || isActive || octadecayotton.IsSolved || (checkForTP && octadecayotton.TwitchPlaysActive))
            {
                return true;
            }

            isStarting = true;
            rotationProgress = 0;

            _octadecayotton = octadecayotton;
            _animate = new Animate(this, _octadecayotton);
            _moduleId = octadecayotton.moduleId;
            isUsingBounce = octadecayotton.isUsingBounce;

            if (octadecayotton.DimensionOverride != default(byte))
            {
                octadecayotton.dimensionOverride = octadecayotton.DimensionOverride;
            }

            if (Dimension == 0)
            {
                TheOctadecayottonScript.Activated++;
            }

            Dimension = _octadecayotton.dimensionOverride == 0 ? dimension + TheOctadecayottonScript.Activated : octadecayotton.dimensionOverride;

            StartCoroutine(_animate.CreateHypercube(Dimension));

            octadecayotton.PlaySound(Dimension > 9 ? Sounds.Oct.StartupHard : Sounds.Oct.Startup);
            octadecayotton.ModuleSelectable.AddInteractionPunch(Dimension > 9 ? 64 : 32);

            Rotations = !Application.isEditor || octadecayotton.ForceRotation.IsNullOrEmpty()
                      ? TheOctadecayottonExtensions.GetRandomRotations(new RotationOptions(dimension: Dimension, rotationCount: octadecayotton.RotationOverride != default(byte) ? octadecayotton.RotationOverride : octadecayotton.rotation))
                      : octadecayotton.ForceRotation.ToRotations();

            Debug.LogFormat("[The Octadecayotton #{0}]: Initializing with {1} dimensions and {2} rotation{3}.",
                            _moduleId,
                            Dimension,
                            octadecayotton.rotation,
                            octadecayotton.rotation == 1 ? "" : "s");
            Debug.LogFormat("[The Octadecayotton #{0}]: NOTE: Rotations are cyclic, meaning that +X-Y+Z is the same as -Y+Z+X and +Z+X-Y! Commas (,) separate different subrotations, and ampersands (&) separate different rotations.", _moduleId);
            Debug.LogFormat("[The Octadecayotton #{0}]: The rotation{1} {2}.",
                            _moduleId,
                            octadecayotton.rotation == 1 ? " is" : "s are",
                            Rotations.ToLog());

            AnchorSphere = Rotations.Get(Dimension, _moduleId);
            Debug.LogFormat("[The Octadecayotton #{0}]: The anchor sphere is in {1}. ({2}-ordered)",
                            _moduleId,
                            AnchorSphere.Select(a => a.Value ? "+" : "-").Join(""),
                            _allAxes.Substring(0, Dimension));

            CreateStartingSphere();
            Debug.LogFormat("[The Octadecayotton #{0}]: To solve this module, press anywhere to enter submission, submit the digits from left-to-right when the {1} matches the digit shown, then submit on every digit from {2} down to 0.",
                            _moduleId,
                            Dimension > 10 ? "timer modulo 20" : "last digit of the timer",
                            Dimension - 1);
            Debug.LogFormat("[The Octadecayotton #{0}]: Example full solution (not knowing axes) => {1}.",
                            _moduleId,
                            startingSphere.GetAnswer(AnchorSphere, _axesUsed, _order, true).Select(i => i.Join(Dimension > 9 ? " " : "")).Join(", "));
            Debug.LogFormat("[The Octadecayotton #{0}]: Quickest solution (knowing axes) => {1}.",
                            _moduleId,
                            startingSphere.GetAnswer(AnchorSphere, _axesUsed, _order, false).Select(i => i.Join(Dimension > 9 ? " " : "")).Join(", "));

            return true;
        });
    }