void Start() { InvManager = FindObjectOfType(typeof(InventoryManager)) as InventoryManager; //Get the Inventory Manager object/script. CustomEvents = FindObjectOfType(typeof(InventoryEvents)) as InventoryEvents; MsgUI = FindObjectOfType(typeof(NotificationUI)) as NotificationUI; MyTransform = gameObject.transform; //Set the object tranform. }
public void ClearNotifications() { foreach (Transform child in eventListGrid.transform) { NotificationUI n = child.gameObject.GetComponent <NotificationUI>(); n.CloseNotification(); } }
public void AddNotification(string text, int day) { NotificationUI ui = GetFreeNotification(); ui.baseText = text; ui.dayOfExpiration = day; notifications.Add(ui); }
void DisposeNotification(NotificationUI ui) { ui.gameObject.SetActive(false); freeNotifications.Add(ui); if (notifications.Contains(ui)) { notifications.Remove(ui); } }
public void UpdateBanner() { CloseBanners(); if (bannerDisplayTime > 0) { Notification n = Events[Events.Count - 1]; NotificationUI banner = buttons[(int)n.type]; banner.gameObject.SetActive(true); banner.Controller = this; banner.Event = n; banner.Index = Events.Count - 1; bannerDisplayTime--; } }
public void OnMessageReceived(object sender, Firebase.Messaging.MessageReceivedEventArgs e) { if (e.Message == null) { Debug.Log("Null message received"); return; } Debug.Log("Received a new message from: " + e.Message.From); //e.Message.data; ->dict //e.Message.Notification.Title; //e.Message.Notification.Body; if (e.Message.Notification == null) { Debug.Log("Got message with data only? "); } eventDesc newEvent = tryLoadingEventDesc(e.Message.Data); if (newEvent == null) { Debug.Log("Malformed data in message"); return; } if (e.Message.Notification != null) { NotificationUI.spawnNotification(e.Message.Notification.Title, e.Message.Notification.Body, newEvent); if (EventRestAPI.Instance != null) { EventRestAPI.Instance.processNewNotification(newEvent, false); } else { //we are asleep? EventRestAPI.notificationsWoken.Add(newEvent); } } else { //probably means that you got message from clicking on notification outside //do not spawn notification, just process data... EventRestAPI.notificationsWoken.Add(newEvent); //no guarantee this will fire first... if (EventRestAPI.Instance != null && EventRestAPI.Instance.lifecycleReady) { EventRestAPI.Instance.reloadNotified(); } } }
protected override void Awake() { base.Awake(); healthInfo = GameObject.FindObjectOfType <HealthUI>(); ammoInfo = GameObject.FindObjectOfType <BulletUI>(); activeItemInfo = GameObject.FindObjectOfType <ActiveItemUI>(); notificationPanel = GameObject.FindObjectOfType <NotificationUI>(); deathPanel = GameObject.FindObjectOfType <DeathPanel>(); notificationPanel.gameObject.SetActive(false); EventManager.Instance.OnNotifyChange += SendNotification; EventManager.Instance.onAmmoChange += updateAmmoUI; EventManager.Instance.onHealthTrigger += updatehealthUI; EventManager.Instance.onMaxHealthTrigger += updateMaxHealthUI; EventManager.Instance.onItemPickupTrigger += updateActiveItemPickupUI; EventManager.Instance.onItemActivateTrigger += updateActiveItemUseUI; }
NotificationUI GetFreeNotification() { NotificationUI ui = null; if (freeNotifications.Count == 0) { ui = Instantiate(notificationPrefab).GetComponent <NotificationUI>(); ui.transform.SetParent(container); ui.transform.localScale = Vector3.one; } else { ui = freeNotifications[freeNotifications.Count - 1]; freeNotifications.RemoveAt(freeNotifications.Count - 1); } ui.gameObject.SetActive(true); return(ui); }
public static void spawnNotification(string title, string body, eventDesc ev) { if (notifications == null) { notifications = new List <NotificationUI>(); } if (prefab == null) { prefab = Resources.Load <NotificationUI>("Prefabs/Notification"); } if (prefab == null) { Debug.Log("Fix notification prefab Prefabs/Notification"); return; } NotificationUI newNote = Instantiate <NotificationUI>(prefab); GameObject canv = GameObject.FindGameObjectWithTag("Canvas"); if (canv == null) { Debug.Log("Add canvas tag to your canvas"); return; } newNote.gameObject.transform.SetParent(canv.transform, false); if (ev != null) { string date = ev.eventDate; if (date == null) { date = ""; } newNote.textbox.text = string.Format("{0}: ( {1} {2} / {3} : {4} ) \n {5}", title, date, ev.run, ev.evn, ev.baseDesc, body); } else { Debug.Log("Event not parsed?"); newNote.textbox.text = string.Format("{0}: InValid event", title); } newNote.ev = ev; notifications.Add(newNote); newNote.updateLocation = true; newNote.updatePos(); }
public void RefreshNotificaitons(int currentDay) { int showing = 0; for (int i = 0; i < notifications.Count; i++) { NotificationUI ui = notifications[i]; if (ui.dayOfExpiration <= currentDay) { DisposeNotification(ui); i--; } else { ui.rect.anchoredPosition = new Vector2(0, -showing * ui.rect.sizeDelta.y); showing++; string notificationText = String.Format(ui.baseText, ui.dayOfExpiration - currentDay); ui.textField.text = notificationText; } } title.SetActive(notifications.Count != 0); }
void Awake() { InvManager = FindObjectOfType(typeof(InventoryManager)) as InventoryManager; //Get the Inventory Manager object/script. MsgUI = FindObjectOfType(typeof(NotificationUI)) as NotificationUI; ActiveItemGroup = null; //Set the active vendor to null on start. //Setting up rect transforms for the vendor's UI panel and main canvas object: UICanvasTrans = UICanvas.GetComponent <RectTransform>(); PanelTrans = Panel.GetComponent <RectTransform>(); SetItemGroupPosition(); Panel.SetActive(false); //Disabling the panel. if (Items.Length > 0) { for (int i = 0; i < Items.Length; i++) { Items[i].Icon.gameObject.GetComponent <SlotUI>().SlotID = i; } } }
public void NewNotification(Notification n) { if (eventListGrid == null) { return; } Events.Add(n); GameObject go = Instantiate(UIObjectDatabase.GetUIElement("NotificationListItem")); go.transform.SetParent(eventListGrid.transform); go.transform.SetAsFirstSibling(); go.transform.localScale = new Vector3(1, 1, 1); NotificationUI listitem = go.GetComponent <NotificationUI>(); listitem.gameObject.SetActive(true); listitem.Controller = this; listitem.Event = n; listitem.Index = Events.Count - 1; listitem.PrintEvent(true); listitem.Camera = cameraController; listitem.CityMenu = cityMenu; listitem.NotificationMenu = notificationMenu; NotificationUI banner = buttons[(int)n.type]; notificationMenu.OpenMenu(banner.gameObject); banner.NotificationMenu = notificationMenu; banner.CityMenu = cityMenu; banner.Event = n; banner.Camera = cameraController; banner.PrintEvent(false); bannerDisplayTime = 24; UpdateBanner(); }
public void NewNotification(Notification n) { if (eventListGrid == null) { return; } Events.Add(n); bannerDisplayTime = 5; UpdateBanner(); GameObject go = Instantiate(uiDatabase.notificationListItem); go.transform.SetParent(eventListGrid.transform); go.transform.SetAsFirstSibling(); go.transform.localScale = new Vector3(1, 1, 1); NotificationUI banner = go.GetComponent <NotificationUI>(); banner.gameObject.SetActive(true); banner.Controller = this; banner.Event = n; banner.Index = Events.Count - 1; }
//public Transform StartingItem; /*-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ public void Awake() { InvUI = FindObjectOfType(typeof(InventoryUI)) as InventoryUI; CustomEvents = FindObjectOfType(typeof(InventoryEvents)) as InventoryEvents; MyTransform = gameObject.transform; //Set the inventory transform. Items = 0; //Setting the inventory size: Slots = new Slot[MaxItems]; for (int i = 0; i < MaxItems; i++) { Slots[i] = new Slot(); } InvUI.CreateSlots(); //Create all slots. if (SaveAndLoad == true) { LoadCurrencies(); LoadItems(); } InvUI.RefreshItems(); MsgUI = FindObjectOfType(typeof(NotificationUI)) as NotificationUI; /*if(PlayerPrefs.GetInt("HasStartingItedm",0) == 0) * { * PlayerPrefs.SetInt("HasStartingItem",1); * Transform StartingItemInstance = Instantiate(StartingItem, new Vector3 (0, 0, 10), Quaternion.identity) as Transform; * AddItem(StartingItemInstance); * InvUI.MoveToSkill(StartingItemInstance, -1); * }*/ }
//Starts and handles the connection public static void StartConnection() { CancellationToken token = source.Token; if (!token.IsCancellationRequested) { //Starts the connection task on a new thread Task.Factory.StartNew(() => { //Keep making new pipes while (!token.IsCancellationRequested) { //Catch any errors try { //pipeName is the same as your subfolder name in the Integrations folder of the app using (NamedPipeClientStream client = new NamedPipeClientStream(".", "SlimeRancher", PipeDirection.In)) { using (StreamReader reader = new StreamReader(client)) { //Keep trying to connect while (!token.IsCancellationRequested && !client.IsConnected) { try { client.Connect(1000);//Don't wait too long, so mod can shut down quickly if still trying to connect } catch (TimeoutException) { //Ignore } catch (System.ComponentModel.Win32Exception) { //Ignore and sleep for a bit, since the connection didn't time out Thread.Sleep(500); } } //Keep trying to read while (!token.IsCancellationRequested && client.IsConnected && !reader.EndOfStream) { //Read line from stream string line = reader.ReadLine(); if (line != null) { if (line.StartsWith("Action: ")) { string[] data = line.Substring(8).Split(' '); rewardsQueue.Enqueue(new RewardData(data[0], data.Skip(1).ToArray())); //Handle action message. This is what was generated by your IntegrationAction Execute method //Make sure you handle it on the correct thread } else if (line.StartsWith("Message: ")) { string message = line.Substring(9); NotificationUI.addChatMessage(message); } } //Only read every 50ms Thread.Sleep(50); } } } } catch (Exception) { //Ignore } } }, token); } }