Exemple #1
0
    // Use this for initialization
    void Awake()
    {
        segmentCodings = new SevenSegmentCodings();
        curModID       = ++modID;
        for (int x = 0; x < segments.Length; x++)
        {
            segments[x].material      = matSwitch[0];
            colorblindTextSeg[x].text = "";
        }
        for (int x = 0; x < colorTriangles.Length; x++)
        {
            colorTriangles[x].material = matSwitch[0];
            colorblindTextTri[x].text  = "";
        }
        LEDMesh.material = matSwitch[0];
        stageIndc.text   = "";
        try {
            ModConfig <FlyersOtherSettings> universalConfig = new ModConfig <FlyersOtherSettings>("FlyersOtherSettings");
            universalSettings        = universalConfig.Settings;
            universalConfig.Settings = universalSettings;

            uncapAll       = !universalSettings.SevenHardCapStageGeneration;
            fastReads      = universalSettings.SevenForceFastReads;
            PPAScaling     = universalSettings.SevenPPAScale;
            maxPPA         = universalSettings.SevenMaxPPA;
            disableUncapTP = universalSettings.SevenNoTPUncapping;
        }
        catch {
            Debug.LogWarningFormat("<7 #{0}>: Settings for 7 do not work as intended! Using default settings instead!", curModID);
            uncapAll       = false;
            fastReads      = false;
            PPAScaling     = 1f;
            maxPPA         = -1;
            disableUncapTP = false;
        }
        finally
        {
            try
            {
                colorblinddetected = colorblindMode.ColorblindModeActive;
            }
            catch
            {
                colorblinddetected = false;
            }
        }
        colorblindIndc.text = "";
    }
Exemple #2
0
 // Use this for initialization
 void Awake()
 {
     segmentHandling = new SevenSegmentCodings();
 }
Exemple #3
0
    // Use this for initialization
    void Awake()
    {
        segmentCodings = new SevenSegmentCodings();
        curModID       = ++modID;

        for (int x = 0; x < segmentSelectables.Length; x++)
        {
            int y = x;
            segmentSelectables[x].OnInteract += delegate {
                segmentSelectables[y].AddInteractionPunch();
                audioMod.PlaySoundAtTransform(soundsPressNames[Random.Range(0, soundsPressNames.Length)], transform);
                if (isSubmitting && interactable)
                {
                    segmentsColored[y] = curSelectedColor;
                    UpdateSegments(false);
                }
                return(false);
            };
            segmentSelectables[x].OnHighlight += delegate {
                if (isSubmitting)
                {
                    return;
                }
                //Debug.LogFormat("segment {0} Highlighted", y);
                Color segmentColor = segments[y].material.color;
                int   idx          = Mathf.RoundToInt(segmentColor.r)
                                     + Mathf.RoundToInt(segmentColor.g) * 2
                                     + Mathf.RoundToInt(segmentColor.b) * 4;
                if (idx >= 0 && idx < colorTrianglesHL.Length)
                {
                    colorTrianglesHL[idx].enabled      = true;
                    colorTriangles[idx].material.color = new Color(idx % 2, idx / 2 % 2, idx / 4 % 2);
                }
            };
            segmentSelectables[x].OnHighlightEnded += delegate {
                if (isSubmitting)
                {
                    return;
                }
                //Debug.LogFormat("segment {0} Dehighlighted", y);
                for (int z = 0; z < colorTrianglesHL.Length; z++)
                {
                    colorTrianglesHL[z].enabled      = false;
                    colorTriangles[z].material.color = Color.black;
                }
            };
        }

        for (int x = 0; x < colorTriangleSelectables.Length; x++)
        {
            int y = x;
            colorTriangleSelectables[x].OnInteract += delegate {
                colorTriangleSelectables[y].AddInteractionPunch();
                audioMod.PlaySoundAtTransform("tick", transform);
                audioMod.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonRelease, transform);
                if (isSubmitting && interactable)
                {
                    curSelectedColor = y;
                    for (int idx = 0; idx < colorTrianglesHL.Length; idx++)
                    {
                        colorTrianglesHL[idx].enabled = y == idx;
                    }
                    UpdateSegments(false);
                }
                return(false);
            };
        }

        LED.OnInteract += delegate {
            LED.AddInteractionPunch();
            audioMod.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonRelease, transform);
            if (hasStarted && interactable)
            {
                if (!isSubmitting)
                {
                    curIdx++;
                    if (curIdx >= displayedValues.Count)
                    {
                        curIdx = 0;
                    }
                    DisplayGivenValue(displayedValues[curIdx]);
                }
                else
                {
                    curStrikeCount = info.GetStrikes();
                    if (zenDetected || (timeDetected && localStrikes > 0) || (!zenDetected && !timeDetected && curStrikeCount > 0))
                    {
                        isSubmitting = false;
                        for (int x = 0; x < colorTriangles.Length; x++)
                        {
                            colorTriangles[x].material.color = Color.black;
                        }
                        DisplayGivenValue(displayedValues[curIdx]);
                        for (int z = 0; z < colorTrianglesHL.Length; z++)
                        {
                            colorTrianglesHL[z].enabled = false;
                        }
                    }
                }
            }
            return(false);
        };

        stageDisplay.OnInteract += delegate {
            stageDisplay.AddInteractionPunch(2);
            audioMod.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, transform);
            if (hasStarted && interactable)
            {
                if (!isSubmitting)
                {
                    isSubmitting = true;
                    UpdateSegments(false);
                    LEDMesh.material.color = Color.black;
                    colorblindIndc.text    = "";
                    stageIndc.text         = "SUB";
                    for (int x = 0; x < colorTriangles.Length; x++)
                    {
                        colorTriangles[x].material.color = new Color(x % 2, x / 2 % 2, x / 4 % 2);
                    }
                    for (int idx = 0; idx < colorTrianglesHL.Length; idx++)
                    {
                        colorTrianglesHL[idx].enabled = idx == curSelectedColor;
                    }
                }
                else
                {
                    if (segmentsColored.SequenceEqual(segmentsSolution))
                    {
                        audioMod.PlaySoundAtTransform("InputCorrect", transform);
                        Debug.LogFormat("[7 #{0}]: Correct segment colors submitted. Module passed.", curModID);
                        interactable = false;
                        modSelf.HandlePass();
                        for (int x = 0; x < colorTrianglesHL.Length; x++)
                        {
                            colorTrianglesHL[x].enabled = false;
                        }
                        stageIndc.text = "";
                        StartCoroutine(PlaySolveAnim());
                    }
                    else
                    {
                        modSelf.HandleStrike();
                        Debug.LogFormat("[7 #{0}]: Strike! You submitted the following segment colors in reading order: {1}", curModID, segmentsColored.Select(a => colorList[a]).Join(", "));
                        UpdateSegments(true);
                        localStrikes   += timeDetected ? 1 : 0;
                        segmentsColored = new int[7];
                        if (currentHandler != null)
                        {
                            StopCoroutine(currentHandler);
                        }
                        currentHandler = AnimateText();
                        StartCoroutine(currentHandler);
                    }
                }
            }
            return(false);
        };
        for (int x = 0; x < segments.Length; x++)
        {
            segments[x].material = matSwitch[0];
        }
        for (int x = 0; x < colorTriangles.Length; x++)
        {
            colorTriangles[x].material = matSwitch[0];
        }
        LEDMesh.material = matSwitch[0];
        stageIndc.text   = "";

        try
        {
            colorblinddetected = colorblindMode.ColorblindModeActive;
        }
        catch
        {
            colorblinddetected = false;
        }
        colorblindIndc.text = "";
    }