public void Init(SlgPB.Notify notify) { if (notify != null) { _notify = notify; } }
public void UpdateData(SlgPB.Notify notify) { if (notify != null) { this.gameObject.SetActive(true); _notify = notify; _model_notificationGroup = InstancePlayer.instance.model_User.model_notificationGroup; List <PrizeItem> prizeItems = new List <PrizeItem>(); _Grid.DestoryAllChildren(); if (_model_notificationGroup.HasBonus(_notify.notifyId)) { prizeItems = _notify.prizeItems; CreateItem(prizeItems); _get_Btn.gameObject.SetActive(true); } else { _get_Btn.gameObject.SetActive(false); } } else { this.gameObject.SetActive(false); } }
public bool HasBonus(int id) { SlgPB.Notify n = notificationsMap [id]; if (n.prizeItems.Count > 0) { return(!IsDisposed(id)); } return(false); }
void OnMailItem(Notification data) { if (data != null) { SlgPB.Notify notify = data._data as SlgPB.Notify; foreach (KeyValuePair <int, MailItem> kvp in _mailItemDic) { if (notify.notifyId != kvp.Value._notify.notifyId) { kvp.Value._iconLine.gameObject.SetActive(false); kvp.Value.IsChecked = false; } } _mailInfo.UpdateData(notify); } }
void OnMailInfo(Notification data) { if (data != null) { SlgPB.Notify notify = data._data as SlgPB.Notify; foreach (KeyValuePair <int, MailItem> kvp in _mailItemDic) { if (notify.notifyId == kvp.Key) { NGUITools.Destroy(kvp.Value.gameObject); _Grid.Reposition(); _mailItemDic.Remove(kvp.Key); return; } } } }
public void Add(SlgPB.Notify n) { notificationsMap [n.notifyId] = n; }
public static bool SaveNotification(List <SlgPB.Notify> notifications) { // XmlSerializer xmlFormat = GetXmlSerializer(); BinaryFormatter binFormatter = GetBinaryFormatter(); try { string localUrl = GetLocalDynamicUrl(); FileStream stream = new FileStream(localUrl, FileMode.OpenOrCreate); if (notifications.Count > 0) { SlgPB.Notify lastNotification = notifications[notifications.Count - 1]; _gotNotificationId = Mathf.Max(_gotNotificationId, lastNotification.notifyId); } // xmlFormat.Serialize(stream, notifications); binFormatter.Serialize(stream, notifications); StreamWriter streamWriter = new StreamWriter(stream); streamWriter.WriteLine(EXPECT_VERSION); streamWriter.WriteLine(_gotNotificationId); streamWriter.Flush(); // streamWriter.Close(); stream.Close(); Trace.trace( "save local notifications, count = " + notifications.Count + ", gotNotificationId = " + _gotNotificationId, Trace.CHANNEL.IO); return(true); } catch (System.Exception e) { Trace.trace(e.ToString(), Trace.CHANNEL.IO); return(false); } /* * * Stream fStream = new FileStream(fileName, FileMode.Create, FileAccess.ReadWrite); * * XmlSerializer xmlFormat = new XmlSerializer( * * typeof(List<Programmer>), * * new Type[] { typeof(Programmer),typeof(Person) } * * );//创建XML序列化器,需要指定对象的类型 * * xmlFormat.Serialize(fStream, list); * * * * System.IO.MemoryStream stream = new System.IO.MemoryStream (); * xmlFormat.Serialize(stream, notifications); * string content = stream.ToString (); * PlayerPrefs.SetString ("notificationDatabase", content); */ }