public Program() { soundBlock = (IMySoundBlock)GridTerminalSystem.GetBlockWithName(nameSoundBlock); lightBlocks = new List <IMyInteriorLight> { (IMyInteriorLight)GridTerminalSystem.GetBlockWithName(nameLightBlocks[0]), (IMyInteriorLight)GridTerminalSystem.GetBlockWithName(nameLightBlocks[1]) }; lcdPanel = (IMyTextPanel)GridTerminalSystem.GetBlockWithName(nameLCDPanel); bigBadAlertLight = new AlertLight(lightBlocks[0], Color.Yellow, true); biggerBadderAlertLight = new AlertLight(lightBlocks[1]); bigBadAlertSound = new AlertSound(soundBlock); bigBadAlertMessage = new AlertText(lcdPanel, warningMessage, 2f, Color.Blue, Color.Yellow); biggerBadderAlertMessage = new AlertText(lcdPanel, warningMessage2, 3f, Color.Cyan, Color.Red); bigBadAlert = new Alert(new List <AlertObject> { bigBadAlertLight, bigBadAlertMessage, bigBadAlertSound }); biggerBadderAlert = new Alert(new List <AlertObject> { biggerBadderAlertLight, bigBadAlertLight, biggerBadderAlertMessage, bigBadAlertSound }); alertSystemManager = new AlertSystemManager <int>(new Dictionary <int, Alert> { { 0, bigBadAlert }, { 1, biggerBadderAlert } }); }
public IEnumerator ShowAlertMessage(AlertText CurrentAlert) { var CurrentTime = 0f; var tmp = Instantiate(AlertPrefab, transform.GetChild(0).transform); tmp.GetComponent <Text>().text = CurrentAlert.AlertMessage; while (CurrentTime < CurrentAlert.AlertDuration) { CurrentTime += Time.deltaTime; var Fraction = (CurrentTime / CurrentAlert.AlertDuration); var TextColor = CurrentAlert.GetAlertTextColor(); TextColor.a = TextOpacityAnimation.Evaluate(Fraction); tmp.GetComponent <Text>().color = TextColor; yield return(null); } Destroy(tmp); yield return(null); }
// Print alert text public void printAlertText(string message) { Vector3 spawnLocation = Vector3.zero; // If the player's location is greater than 0 on the z-axis // Set the spawn location to be the left side if (player.transform.position.z > 0) { spawnLocation = alertTextSpawnPoints[0].position; } // Otherwise set the spawn location to be the right side else { spawnLocation = alertTextSpawnPoints[1].position; } AlertText spawnedText = Instantiate(alertTextPrefab, spawnLocation, Quaternion.identity); spawnedText.setTextContent(message); spawnedText.gameObject.transform.SetParent(this.transform); spawnedText.gameObject.transform.localScale = Vector3.one; Destroy(spawnedText.gameObject, 20.0f); }
public LowHydrogenWarningSystem(List <IMyGasTank> h2TankBlocks, IMyInteriorLight warningLightBlock, IMyTextPanel warningLCDBlock, IMySoundBlock warningSoundBlock) { gasTanksManager = new GasTanksManager(h2TankBlocks); AlertLight warningLight = new AlertLight(warningLightBlock); AlertLight warningLCD = new AlertText(warningLCDBlock, "Low H2!"); AlertLight warningSound = new AlertSound(warningSoundBlock); listAlertObjects = new List <AlertLight> { warningLight, warningLCD, warningSound }; }
void DrawAlert() { string[] lines = AlertText.Split('\n'); int longestLine = 0; foreach (string l in lines) { if (longestLine < l.Length) { longestLine = l.Length; } } if (AlertOptions != null) { foreach (string l in AlertOptions.Values) { if (longestLine < l.Length + 3) { longestLine = l.Length + 3; } } } if (AlertTitle.Length > longestLine) { longestLine = AlertTitle.Length; } int height = 3 + lines.Count() + (AlertTextBox ? 2 : 0); if (AlertOptions != null) { height += AlertOptions.Count * 2; } int upper = WindowHeight / 2 - height / 2; int width = 4 + longestLine; int left = WindowWidth / 2 - (width) / 2; // clear space for (int y = upper; y < (upper + height); y++) { for (int x = left; x < (left + width); x++) { Screen[x, y] = ' '; ScreenForeground[x, y] = AlertFG; ScreenBackground[x, y] = AlertBG; } } // draw alert title bar for (int x = left; x < (left + width); x++) { Screen[x, upper] = '-'; ScreenForeground[x, upper] = (int)ConsoleColor.Black; ScreenBackground[x, upper] = (int)ConsoleColor.Cyan; } // draw title text WriteCentered(AlertTitle, upper); // draw message for (int i = 0; i < lines.Count(); i++) { WriteUpperLeft(lines[i], left + 2, upper + 2 + i); } // draw options if (AlertOptions != null) { int y = upper + 3 + lines.Count(); foreach (var opt in AlertOptions) { ScreenForeground[left + 3, y] = (int)ConsoleColor.Black; ScreenForeground[left + 4, y] = (int)ConsoleColor.Black; ScreenBackground[left + 3, y] = (int)ConsoleColor.Yellow; ScreenBackground[left + 4, y] = (int)ConsoleColor.Yellow; Screen[left + 3, y] = opt.Key; Screen[left + 4, y] = '.'; WriteUpperLeft(opt.Value, left + 7, y); y += 2; } } // draw text box if (AlertTextBox) { for (int x = left + 1; x < (left + width - 1); x++) { ScreenForeground[x, upper + height - 2] = (int)ConsoleColor.White; ScreenBackground[x, upper + height - 2] = (int)ConsoleColor.Black; } AlertTextBoxX = left + 1; AlertTextBoxY = upper + height - 2; } }
public static void AddAlertToQueue(AlertText alert) { Alerts.Enqueue(alert); }
void Start() { scaleMode = 0; newScaling = Vector3.one; newRotate = new Vector3 (90, 0, 0); vc = volumeController.GetComponent<VolumeControl> (); at = alertObj.GetComponent<AlertText> (); if (blueprints.Length > 0) { mode = 0; setCurrSel (mode); } }