/// <summary> /// Event handler /// </summary> /// <param name="eventType"></param> /// <param name="Sender"></param> /// <param name="Param"></param> public void OnEvent(EventType eventType, Component Sender, object Param = null) { //Detect event type switch (eventType) { case EventType.AISideTabOpen: OpenSideTab(); break; case EventType.AISideTabClose: CloseSideTab(); break; case EventType.AISendSideData: AISideTabData data = Param as AISideTabData; UpdateSideTab(data); break; default: Debug.LogError(string.Format("Invalid eventType {0}{1}", eventType, "\n")); break; } }
/// <summary> /// update data on side tab (sent from AIManager.cs -> UpdateSideTabData) & GenericTooltipUI data /// </summary> /// <param name="data"></param> private void UpdateSideTab(AISideTabData data) { if (data != null) { //'A.I' if (string.IsNullOrEmpty(data.topText) == false) { topText.text = data.topText; } else { topText.text = "?"; } //cost in Power if (string.IsNullOrEmpty(data.bottomText) == false) { bottomText.text = data.bottomText; } else { bottomText.text = "?"; } //hacking Status hackingStatus = data.status; //alert flasher if (hackingStatus == HackingStatus.Possible && sideTabImage.gameObject.activeSelf == true) { if (myCoroutine == null) { myCoroutine = StartCoroutine("ShowAlertFlash"); } } else { if (myCoroutine != null) { StopCoroutine(myCoroutine); myCoroutine = null; isFading = false; //reset opacity back to zero tempColour = alertFlasher.color; tempColour.a = 0.0f; alertFlasher.color = tempColour; } } //tooltip data if (string.IsNullOrEmpty(data.tooltipMain) == false) { tooltip.tooltipMain = data.tooltipMain; if (string.IsNullOrEmpty(data.tooltipDetails) == false) { tooltip.tooltipDetails = data.tooltipDetails; } } else { tooltip.tooltipMain = "Unknown Data"; } } else { Debug.LogWarning("Invalid AISideTabData (Null)"); } }