void Init() { // Set up which pattern we're using, along with what solutions exist sequenceIndex = Random.Range(0, NUM_SEQUENCES); initialOffset = Random.Range(0, SEQUENCE_LENGTH); Debug.LogFormat("[Binary LEDs #{0}] Using sequence number {1} with offset {2}", _moduleId, sequenceIndex, initialOffset); // Set up the LED blink pattern. counterStartTime = Time.time; int timeIndex = GetIndexFromTime(Time.time, blinkDelay); // ApplyToLeds (sequences[sequenceIndex, timeIndex]); // Prep the wires ShuffleColorArray(colorIndices); for (int i = 0; i < wires.Length; i++) { // Set up an object we can pass down to our delegates. Must be by reference WireDelegateInfo info = new WireDelegateInfo(); info.wire = wires [i]; info.color = colorIndices [i]; info.isCut = false; SetWireColor(wires [i], wireColors [(int)colorIndices[i]]); wires[i].OnInteract += delegate() { SnipWire(info); OnCutLogic(info, this); CheckThreeWires(this); return(false); }; TwitchPlayWires[i] = info; } }
void SnipWire(WireDelegateInfo wireInfo) { Renderer wireRend = wireInfo.wire.GetComponent <Renderer>(); wireRend.enabled = false; GetBrokenWireOfWire(wireInfo.wire).GetComponent <MeshRenderer>().enabled = true; }
void OnCutLogic(WireDelegateInfo info, BinaryLeds scriptObj) { if (info.isCut) // Don't do anything if you already cut the wire { return; } int timeIndex = GetIndexFromTime(Time.time, blinkDelay); Debug.LogFormat("[Binary LEDs #{0}] Cutting wire {1}. Required time index is {2}, current time is {3}", _moduleId, info.color, solutions[sequenceIndex, (int)info.color], timeIndex); scriptObj.cutWires++; if (!isActivated) { Debug.LogFormat("[Binary LEDs #{0}] Cut wire before module has been activated!", _moduleId); GetComponent <KMBombModule>().HandleStrike(); ReduceBlinkDelay(); } else { if (solutions[sequenceIndex, (int)info.color] == timeIndex) { GetComponent <KMBombModule>().HandlePass(); solved = true; } else { GetComponent <KMBombModule>().HandleStrike(); ReduceBlinkDelay(); } } GetComponent <KMAudio>().PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.WireSnip, transform); GetComponent <KMSelectable>().AddInteractionPunch(); info.isCut = true; }