// Use this for initialization void Start() { float scalar = transform.lossyScale.x;// Account for scale factor for this module being smaller, check KTANE official discord in #modding foreach (Light onelight in lights) { onelight.range *= scalar; } animLight.range *= scalar; TileAnim.SetActive(false); Generate4x4Puzzle(); for (int selidx = 0; selidx < tileSelectables.Length; selidx++) { int y = selidx; tileSelectables[selidx].OnInteract += delegate { tileSelectables[y].AddInteractionPunch(); kMAudio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonRelease, transform); if (!solved) { inputsOverall.Add(y); } return(false); }; } bombInfo.OnBombExploded += delegate { if (solved || isGenerating) { return; } string debugMoves = ""; foreach (int inIdx in inputsOverall) { debugMoves += debugCoordCol[inIdx % 4] + debugCoordRow[inIdx / 4 % 4] + " "; } debugMoves.Trim(); Debug.LogFormat("[15 Mystic Lights #{0}]: The following moves used on the given board when the bomb blew were {1}", curmodid, debugMoves); }; moduleSelf.OnActivate += delegate { if (TwitchPlaysActive) { StatusLight.SetActive(true); } else { StatusLight.SetActive(false); } }; //StatusLight.SetActive(false); }
IEnumerator PlaySolveAnim(int ycor, int xcor) { playingAnim = true; kMAudio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.WireSequenceMechanism, transform); Vector3 pointTL = AnimPointTL.transform.localPosition; Vector3 pointBR = AnimPointBR.transform.localPosition; Vector3 pointD = AnimPointD.transform.localPosition; //Vector3 LastStatLightScale = new Vector3(StatusLight.transform.localScale.x, StatusLight.transform.localScale.y, StatusLight.transform.localScale.z); bool lgtSteSgl = (bool)GetFirstNonNullTileState(); for (int idx = 0; idx < textMeshes.Length; idx++) { textMeshes[idx].gameObject.SetActive(false); } float localX = pointBR.x * xcor / 3f + pointTL.x * (3 - xcor) / 3f; float localY = pointBR.y * ycor / 3f + pointTL.y * (3 - ycor) / 3f; for (float x = 1; x >= 0; x -= Time.deltaTime) { float localZ = pointD.z * x; TileAnim.SetActive(true); StatusLight.SetActive(true); TileAnim.transform.localPosition = new Vector3(localX, localY, localZ); StatusLight.transform.localPosition = new Vector3(localX, localY, localZ + .005f); AnimRenderer.material = lgtSteSgl ? materials[0] : materials[1]; animLight.color = lgtSteSgl ? Color.yellow : Color.blue; animLight.enabled = true; yield return(null); } StatusLight.transform.localPosition = new Vector3(localX, localY, .005f); TileAnim.SetActive(false); int tileIndex = xcor + 4 * ycor; tiles[tileIndex].SetActive(true); meshRenderers[tileIndex].material = lgtSteSgl ? materials[0] : materials[1]; lights[tileIndex].enabled = true; lights[tileIndex].color = lgtSteSgl ? Color.yellow : Color.blue; moduleSelf.HandlePass(); yield return(null); }
public static int ConvertFromRedGreen(StatusLight value) { return(value == StatusLight.Green ? 1 : 0); }
private void StatisticSubscriptionMetaDataReceived(object sender, EventArgs <DataSet> e) { LogStatusMessage("Loading received meta-data...", logToClient: false); DataSet dataSet = e.Argument; m_deviceDetails.Clear(); m_measurementDetails.Clear(); m_phasorDetails.Clear(); m_schemaVersion.Clear(); m_powerCalculation.Clear(); m_statusLights.Clear(); foreach (DataTable table in dataSet.Tables) { if (table.TableName == "DeviceDetail") { foreach (DataRow row in table.Rows) { DeviceDetail deviceDetail = new DeviceDetail { NodeID = row.ConvertField <Guid>("NodeID"), UniqueID = row.ConvertField <Guid>("UniqueID"), OriginalSource = row.ConvertField <string>("OriginalSource"), IsConcentrator = row.ConvertField <bool>("IsConcentrator"), Acronym = row.ConvertField <string>("Acronym"), Name = row.ConvertField <string>("Name"), AccessID = row.ConvertField <int>("AccessID"), ParentAcronym = row.ConvertField <string>("ParentAcronym"), ProtocolName = row.ConvertField <string>("ProtocolName"), FramesPerSecond = row.ConvertField <int>("FramesPerSecond"), CompanyAcronym = row.ConvertField <string>("CompanyAcronym"), VendorAcronym = row.ConvertField <string>("VendorAcronym"), VendorDeviceName = row.ConvertField <string>("VendorDeviceName"), Longitude = row.ConvertField <decimal>("Longitude"), Latitude = row.ConvertField <decimal>("Latitude"), InterconnectionName = row.ConvertField <string>("InterconnectionName"), ContactList = row.ConvertField <string>("ContactList"), Enabled = row.ConvertField <bool>("Enabled"), UpdatedOn = row.ConvertField <DateTime>("UpdatedOn") }; if (row.ConvertField <bool>("Enabled")) { StatusLight statusLight = new StatusLight { DeviceAcronym = row.ConvertField <string>("Acronym"), Timestamp = DateTime.MinValue, GoodData = false }; m_statusLights.Add(statusLight); } m_deviceDetails.Add(deviceDetail); } } else if (table.TableName == "MeasurementDetail") { foreach (DataRow row in table.Rows) { MeasurementDetail measurementDetail = new MeasurementDetail { DeviceAcronym = row.ConvertField <string>("DeviceAcronym"), ID = row.ConvertField <string>("ID"), SignalID = row.ConvertField <Guid>("SignalID"), PointTag = row.ConvertField <string>("PointTag"), SignalReference = row.ConvertField <string>("SignalReference"), SignalAcronym = row.ConvertField <string>("SignalAcronym"), PhasorSourceIndex = row.ConvertField <int>("PhasorSourceIndex"), Description = row.ConvertField <string>("Description"), Internal = row.ConvertField <bool>("Internal"), Enabled = row.ConvertField <bool>("Enabled"), UpdatedOn = row.ConvertField <DateTime>("UpdatedOn") }; m_measurementDetails.Add(measurementDetail); } } else if (table.TableName == "PhasorDetail") { foreach (DataRow row in table.Rows) { PhasorDetail phasorDetail = new PhasorDetail { DeviceAcronym = row.ConvertField <string>("DeviceAcronym"), Label = row.ConvertField <string>("Label"), Type = row.ConvertField <string>("Type"), Phase = row.ConvertField <string>("Phase"), SourceIndex = row.ConvertField <int>("SourceIndex"), UpdatedOn = row.ConvertField <DateTime>("UpdatedOn") }; m_phasorDetails.Add(phasorDetail); } } else if (table.TableName == "SchemaVersion") { foreach (DataRow row in table.Rows) { SchemaVersion schemaVersion = new SchemaVersion { VersionNumber = row.ConvertField <int>("VersionNumber") }; m_schemaVersion.Add(schemaVersion); } } else if (table.TableName == "PowerCalculation") { foreach (DataRow row in table.Rows) { PowerCalculation powerCalculation = new PowerCalculation() { VoltageAngleID = row.ConvertField <Guid>("VoltageAngleSignalID"), CurrentAngleID = row.ConvertField <Guid>("CurrentAngleSignalID") }; m_powerCalculation.Add(powerCalculation); } } } try { string appData = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); string ecaClientDataPath = Path.Combine(appData, "Grid Protection Alliance", "openECAClient"); string metadataCache = Path.Combine(ecaClientDataPath, "Metadata.xml"); Directory.CreateDirectory(ecaClientDataPath); if (FilePath.TryGetWriteLock(metadataCache)) { dataSet.WriteXml(metadataCache, XmlWriteMode.WriteSchema); Program.LogStatus($"Data set serialized with {dataSet.Tables.Count} tables..."); } } catch (Exception ex) { Program.LogException(new InvalidOperationException($"Failed to serialize dataset: {ex.Message}", ex)); } try { ClientScript?.metaDataReceived(); } catch (NullReferenceException) { // Client script unavailable for self-created hub instances } MetadataReceived?.Invoke(this, EventArgs.Empty); }
IEnumerator ShowFinalColor(string split4) { Color finalColor = RGBColor(desiredred, desiredgreen, desiredblue); for (int i = 0; i <= 255; i++) { for (int index = 0; index < 3; index++) { int newRed = UnityEngine.Random.Range(desiredred - (255 - i), desiredred + (255 - i)); int newGreen = UnityEngine.Random.Range(desiredgreen - (255 - i), desiredgreen + (255 - i)); int newBlue = UnityEngine.Random.Range(desiredblue - (255 - i), desiredblue + (255 - i)); Materials[index].color = Color.Lerp(DefaultColors[index], finalColor, (float)i / 100); displayText.color = RGBColor(newRed, newGreen, newBlue); if (newRed < 0) { newRed = 0; } if (newGreen < 0) { newGreen = 0; } if (newBlue < 0) { newBlue = 0; } displayText.text = "#" + newRed.ToString("X2") + newGreen.ToString("X2") + newBlue.ToString("X2"); } yield return(new WaitForSeconds(0.01f)); } displayText.text = displayAnswer; displayText.color = finalColor; Audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.CorrectChime, transform); BombModule.HandlePass(); StatusLight light = RealBombModule.StatusLightParent.StatusLight; switch (split4) { case "red": light.StrikeLight.SetActive(true); light.InactiveLight.SetActive(false); light.PassLight.SetActive(false); break; case "off": light.StrikeLight.SetActive(false); light.InactiveLight.SetActive(true); light.PassLight.SetActive(false); break; case "random": var lightColor = UnityEngine.Random.value; if (lightColor < (1 / 3f)) { goto case "red"; } if (lightColor < (2 / 3f)) { goto case "off"; } break; } }
private void StatisticSubscriptionMetaDataReceived(object sender, EventArgs <DataSet> e) { LogStatusMessage("Loading received meta-data...", logToClient: false); DataSet dataSet = e.Argument; m_deviceDetails.Clear(); m_measurementDetails.Clear(); m_phasorDetails.Clear(); m_schemaVersion.Clear(); m_statusLights.Clear(); foreach (DataTable table in dataSet.Tables) { if (table.TableName == "DeviceDetail") { foreach (DataRow row in table.Rows) { DeviceDetail deviceDetail = new DeviceDetail { NodeID = row.ConvertField <Guid>("NodeID"), UniqueID = row.ConvertField <Guid>("UniqueID"), OriginalSource = row.ConvertField <string>("OriginalSource"), IsConcentrator = row.ConvertField <bool>("IsConcentrator"), Acronym = row.ConvertField <string>("Acronym"), Name = row.ConvertField <string>("Name"), AccessID = row.ConvertField <int>("AccessID"), ParentAcronym = row.ConvertField <string>("ParentAcronym"), ProtocolName = row.ConvertField <string>("ProtocolName"), FramesPerSecond = row.ConvertField <int>("FramesPerSecond"), CompanyAcronym = row.ConvertField <string>("CompanyAcronym"), VendorAcronym = row.ConvertField <string>("VendorAcronym"), VendorDeviceName = row.ConvertField <string>("VendorDeviceName"), Longitude = row.ConvertField <decimal>("Longitude"), Latitude = row.ConvertField <decimal>("Latitude"), InterconnectionName = row.ConvertField <string>("InterconnectionName"), ContactList = row.ConvertField <string>("ContactList"), Enabled = row.ConvertField <bool>("Enabled"), UpdatedOn = row.ConvertField <DateTime>("UpdatedOn") }; if (row.ConvertField <bool>("Enabled")) { StatusLight statusLight = new StatusLight { DeviceAcronym = row.ConvertField <string>("Acronym"), Timestamp = DateTime.MinValue, GoodData = false }; m_statusLights.Add(statusLight); } m_deviceDetails.Add(deviceDetail); } } else if (table.TableName == "MeasurementDetail") { foreach (DataRow row in table.Rows) { MeasurementDetail measurementDetail = new MeasurementDetail { DeviceAcronym = row.ConvertField <string>("DeviceAcronym"), ID = row.ConvertField <string>("ID"), SignalID = row.ConvertField <Guid>("SignalID"), PointTag = row.ConvertField <string>("PointTag"), SignalReference = row.ConvertField <string>("SignalReference"), SignalAcronym = row.ConvertField <string>("SignalAcronym"), PhasorSourceIndex = row.ConvertField <int>("PhasorSourceIndex"), Description = row.ConvertField <string>("Description"), Internal = row.ConvertField <bool>("Internal"), Enabled = row.ConvertField <bool>("Enabled"), UpdatedOn = row.ConvertField <DateTime>("UpdatedOn") }; m_measurementDetails.Add(measurementDetail); } } else if (table.TableName == "PhasorDetail") { foreach (DataRow row in table.Rows) { PhasorDetail phasorDetail = new PhasorDetail { DeviceAcronym = row.ConvertField <string>("DeviceAcronym"), Label = row.ConvertField <string>("Label"), Type = row.ConvertField <string>("Type"), Phase = row.ConvertField <string>("Phase"), SourceIndex = row.ConvertField <int>("SourceIndex"), UpdatedOn = row.ConvertField <DateTime>("UpdatedOn") }; m_phasorDetails.Add(phasorDetail); } } else if (table.TableName == "SchemaVersion") { foreach (DataRow row in table.Rows) { SchemaVersion schemaVersion = new SchemaVersion { VersionNumber = row.ConvertField <int>("VersionNumber") }; m_schemaVersion.Add(schemaVersion); } } } ClientScript?.metaDataReceived(); }
IEnumerator PlaySolveAnim(int ycor, int xcor) { playingAnim = true; kMAudio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.WireSequenceMechanism, transform); Vector3 pointTL = AnimPointTL.transform.localPosition; Vector3 pointBR = AnimPointBR.transform.localPosition; Vector3 pointD = AnimPointD.transform.localPosition; //Vector3 LastStatLightScale = new Vector3(StatusLight.transform.localScale.x, StatusLight.transform.localScale.y, StatusLight.transform.localScale.z); bool lgtSteSgl = (bool)GetFirstNonNullTileState(); for (int idx = 0; idx < textMeshes.Length; idx++) { textMeshes[idx].gameObject.SetActive(false); } for (int x = animDelay * 2; x >= 0; x--) { float localX = 0; float localY = 0; float localZ = 0; for (int p = 0; p < 3; p++) { // Grab end points of the animation if (xcor > p) { localX += pointBR.x; } else { localX += pointTL.x; } if (ycor > p) { localY += pointBR.y; } else { localY += pointTL.y; } } for (int y = 0; y < x; y++) { localZ += pointD.z; } localZ /= animDelay * 2; localX /= 3; localY /= 3; TileAnim.SetActive(true); StatusLight.SetActive(true); TileAnim.transform.localPosition = new Vector3(localX, localY, localZ); StatusLight.transform.localPosition = new Vector3(localX, localY, localZ + .005f); AnimRenderer.material = lgtSteSgl ? materials[0] : materials[1]; animLight.color = lgtSteSgl ? Color.yellow : Color.blue; animLight.enabled = true; yield return(new WaitForSeconds(0)); } TileAnim.SetActive(false); int tileIndex = xcor + 4 * ycor; tiles[tileIndex].SetActive(true); meshRenderers[tileIndex].material = lgtSteSgl ? materials[0] : materials[1]; lights[tileIndex].enabled = true; lights[tileIndex].color = lgtSteSgl ? Color.yellow : Color.blue; moduleSelf.HandlePass(); yield return(null); }