コード例 #1
0
ファイル: InteractScript.cs プロジェクト: VFlyer/EmikModules
 internal KMSelectable.OnInteractHandler OnInteract(TheOctadecayottonScript octadecayotton, bool checkForTP, int dimension)
 {
     return(Init(octadecayotton, checkForTP, dimension) + (() =>
     {
         _octadecayotton.ModuleSelectable.AddInteractionPunch();
         _octadecayotton.PlaySound(Sounds.Oct.InteractInterrupt);
         if (!isActive || _octadecayotton.IsSolved)
         {
             return false;
         }
         if (isRotating)
         {
             isSubmitting = true;
         }
         return HandleSubmission();
     }));
 }
コード例 #2
0
ファイル: ModSettingsJSON.cs プロジェクト: VFlyer/EmikModules
        /// <summary>
        /// Gets the value from ModSettings.
        /// </summary>
        /// <param name="octadecayotton">The instance of the module.</param>
        /// <param name="dimension">The amount of dimensions.</param>
        /// <param name="rotation">The amount of rotations.</param>
        public static void Get(TheOctadecayottonScript octadecayotton, out int dimension, out int rotation, out bool colorAssist, out bool isUsingBounce, out bool stretchToFit)
        {
            // Default values.
            dimension     = 9;
            rotation      = 3;
            colorAssist   = false;
            isUsingBounce = false;
            stretchToFit  = false;

            try
            {
                // Try loading settings.
                var settings = JsonConvert.DeserializeObject <ModSettingsJSON>(octadecayotton.ModSettings.Settings);

                // Do settings exist?
                if (settings != null)
                {
                    dimension     = Mathf.Clamp(settings.Dimension, Min, Max);
                    rotation      = Mathf.Clamp(settings.Rotation, 0, 255);
                    colorAssist   = settings.ColorAssist;
                    isUsingBounce = settings.IsUsingBounce;
                    stretchToFit  = settings.StretchToFit;

                    Debug.LogFormat("[The Octadecayotton #{0}]: JSON loaded successfully, values are: (Dimensions = {1}), (Rotations = {2}), (ColorAssist: {3}), (InOutBounce: {4}), and (StretchToFit: {5}).",
                                    octadecayotton.moduleId,
                                    dimension,
                                    rotation,
                                    colorAssist,
                                    isUsingBounce,
                                    stretchToFit);
                }

                else
                {
                    Debug.LogFormat("[The Octadecayotton #{0}]: JSON is null, resorting to default values.", octadecayotton.moduleId);
                }
            }
            catch (JsonReaderException e)
            {
                // In the case of catastrophic failure and devastation.
                Debug.LogFormat("[The Octadecayotton #{0}]: JSON error: \"{1}\", resorting to default values.", octadecayotton.moduleId, e.Message);
            }
        }
コード例 #3
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;
        });
    }
コード例 #4
0
 internal static void PlaySound(this TheOctadecayottonScript octadecayotton, string sound)
 {
     octadecayotton.Audio.PlaySoundAtTransform(sound, octadecayotton.transform);
 }
コード例 #5
0
ファイル: Animate.cs プロジェクト: VFlyer/EmikModules
 internal Animate(InteractScript interact, TheOctadecayottonScript octadecayotton)
 {
     _interact       = interact;
     _octadecayotton = octadecayotton;
 }