public void AddToList(PushPointClass pointDataParams) { if (pointDataParams.msgs.Count != 0) { radiusDistance = int.Parse(pointDataParams.radius); foreach (PushMsg item in pointDataParams.msgs) { PushItem pushItemMsg = new PushItem(); pushItemMsg.id = item.id; float XX = float.Parse(item.locationX); float yy = float.Parse(item.locationY); pushItemMsg.locationX = item.locationX; pushItemMsg.locationY = item.locationY; pushItemMsg.height = item.height; pushItemMsg.title = item.title; pushItemMsg.msg = item.msg; pushItemMsg.distance = 10000; pushItemMsg.pos = new Vector2(XX, yy); pushItemMsg.dbid = item.dbid; pushItemMsg.type = item.type; // Debug.Log("pointdata====" + pushItemMsg.title+"--"+ pushItemMsg.msg + "--" + pushItemMsg.pos); pushPointIndexV2Dic.Add(int.Parse(pushItemMsg.id), pushItemMsg); } } }
public PushItem GetAchieveStatus() { uint achieve_id = 0; PushItem pushItem = null; string strName = ""; Dictionary <uint, AchieveData> .Enumerator iter = achievementServerData.GetEnumerator(); while (iter.MoveNext()) { AchievementDataBase achievementData = GetAchievementTableData(iter.Current.Key); if (achievementData != null && iter.Current.Value.status == (uint)AchieveStatus.AchieveStatus_CanReceive) { achieve_id = iter.Current.Key; strName = achievementData.name; } } if (achieve_id != 0) { pushItem = new PushItem() { pushType = PushType.Achievement, strName = strName, thisID = achieve_id, }; } return(pushItem); }
private void PushPointinformation() { if (nearIndexList.Count != 0) { PushItem newPushMsg = pushPointIndexV2Dic[int.Parse(nearIndexList[0].id)]; if (GlobalParameter.lastPushId != int.Parse(newPushMsg.id)) { NotifyCallBack notifyCallBack = new NotifyCallBack() { dbid = newPushMsg.dbid, type = newPushMsg.type }; #if UNITY_ANDROID AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); AndroidJavaObject jo = jc.GetStatic <AndroidJavaObject>("currentActivity"); jo.Call("notifySimpleMessage", newPushMsg.title, newPushMsg.msg, JsonMapper.ToJson(notifyCallBack)); GlobalParameter.lastPushId = int.Parse(newPushMsg.id); #elif UNITY_IOS || UNITY_IPHONE pushState = 0; LocalNotifyStyle style = new LocalNotifyStyle(); Hashtable args = new Hashtable(); args["dbid"] = newPushMsg.dbid; args["type"] = newPushMsg.type; style.setContent(newPushMsg.msg); style.setTitle(newPushMsg.title); style.addHashParams(args); mobPush.setMobPushLocalNotification(style); GlobalParameter.lastPushId = int.Parse(newPushMsg.id); #endif } } }
public bool AddPush(string title, string sendDate, string channels) { var item = new PushItem { Badge = 0, BundleId = this.bundleId, Channels = channels, // "1,15,0" ContentAvailable = false, ExtraData = "15255", IsSandBox = false, Link = "", SendDate = sendDate, // "20141225120000" Sound = "", Text = title, Passwd = this.password, User = this.userName }; var sett = new JsonSerializerSettings(); sett.ContractResolver = new LowercaseContractResolver(); string json = JsonConvert.SerializeObject(item, Formatting.Indented, sett); var res = NetFunc.MakeRequest(json, this.pushUrl, "POST"); return(res.IsValid); }
/// <summary> /// 读取表数据,生成对应的数组 /// </summary> /// <param name="filePath">excel文件全路径</param> /// <returns>Item数组</returns> public static PushItem[] CreateItemArrayWithExcel(string filePath) { //获得表数据 int columnNum = 0, rowNum = 0; DataRowCollection collect = ReadExcel(filePath, ref columnNum, ref rowNum); //根据excel的定义,第二行开始才是数据 PushItem[] array = new PushItem[rowNum - 1]; for (int i = 1; i < rowNum; i++) { PushItem item = new PushItem(); //解析每列的数据 item.id = collect[i][0].ToString(); // item.name= collect[i][1].ToString(); item.locationX = collect[i][2].ToString(); item.locationY = collect[i][3].ToString(); item.height = collect[i][4].ToString(); item.title = collect[i][5].ToString(); item.msg = collect[i][6].ToString(); item.dbid = collect[i][7].ToString(); item.type = collect[i][8].ToString(); item.pos = new Vector2(float.Parse(item.locationX), float.Parse(item.locationY)); item.distance = 100000; array[i - 1] = item; } return(array); }
public void PopPushPanel() { if (pushQueue.Count != 0) { if (DataManager.Manager <UIPanelManager>().IsShowPanel(PanelID.CommonPushPanel)) { return; } PushItem item = pushQueue.Dequeue(); if (item != null) { DataManager.Manager <UIPanelManager>().ShowPanel(PanelID.CommonPushPanel, panelShowAction: (pb) => { if (null != pb && pb is CommonPushPanel) { CommonPushPanel panel = pb as CommonPushPanel; panel.InitPushItem(item); m_uCurrentPushItem = item; if (!TimerAxis.Instance().IsExist(m_uPushTimerID, this)) { TimerAxis.Instance().SetTimer(m_uPushTimerID, 1000, this); } } }); } } else { if (!DataManager.Manager <UIPanelManager>().IsShowPanel(PanelID.CommonPushPanel)) { TimerAxis.Instance().KillTimer(m_uPushTimerID, this); } } }
void InitPushList(BaseItem baseItem = null) { List <uint> equipList = GetPushList(baseItem); if (equipList != null) { for (int i = 0; i < equipList.Count; i++) { PushItem item = new PushItem(); item.thisID = equipList[i]; item.pushType = PushType.Equip; PushEnqueue(item); } } if (baseItem != null) { if (baseItem.BaseType == GameCmd.ItemBaseType.ItemBaseType_Consumption) { if (baseItem.UseLv <= MainPlayerHelper.GetPlayerLevel()) { if (baseItem.BaseData != null) { if (baseItem.BaseData.IsPush) { PushItem item = new PushItem(); item.thisID = baseItem.QWThisID; item.pushType = PushType.Consum; PushEnqueue(item); } } } } } else { List <BaseItem> consumList = GetConsumList(); if (consumList != null) { for (int i = 0; i < consumList.Count; i++) { BaseItem bi = consumList[i]; PushItem item = new PushItem(); item.thisID = bi.QWThisID; item.pushType = PushType.Consum; PushEnqueue(item); } } } }
void StructAchievePushItem() { bool achievementIsOpen = MainPlayerHelper.GetPlayerLevel() >= achievementOpenLv; if (!achievementIsOpen) { return; } PushItem item = DataManager.Manager <AchievementManager>().GetAchieveStatus(); if (item != null) { PushEnqueue(item); } }
void PushEnqueue(PushItem item) { if (item == null) { return; } BaseItem bi = DataManager.Manager <ItemManager>().GetBaseItemByQwThisId(item.thisID); if (bi != null) { if (bi.BaseType == ItemBaseType.ItemBaseType_Consumption) { if (!DataManager.Manager <ItemManager>().CanUseConsumerItem(bi.BaseId)) { return; } } } if (m_uCurrentPushItem != null) { if (item.thisID == m_uCurrentPushItem.thisID) { return; } } if (!pushQueue.Contains(item)) { pushQueue.Enqueue(item); // if (item.pushType == PushType.Achievement) // { // pushQueue.Insert(0, item); // } // else // { // pushQueue.Add(item); // } } }
public void ApplyData(PushItem data) { _data = data; if (data != null) { if (!ContentTxt.gameObject.activeSelf) { ContentTxt.gameObject.SetActive(true); } ContentTxt.text = data.content; var prepayment = data.type == PushItemType.Prepayment; var vip = data.type == PushItemType.Vip; var exchange = data.type == PushItemType.RecheckinCard || data.type == PushItemType.CardRecorder; var activity = data.type == PushItemType.UserTask; var isEnableVip = false; var featureSwitch = GetDataRepository().GetContainer <FeatureSwitch>(DataKey.FeatureSwitch).Read(); if (featureSwitch == null) { isEnableVip = false; } else { isEnableVip = featureSwitch.vip; } if (!isEnableVip) { vip = false; } if (ChargeBtn.gameObject.activeSelf != prepayment) { ChargeBtn.gameObject.SetActive(prepayment); } if (VipBtn.gameObject.activeSelf != vip) { VipBtn.gameObject.SetActive(vip); } if (ExchangeBtn.gameObject.activeSelf != exchange) { ExchangeBtn.gameObject.SetActive(exchange); } if (ActivityBtn.gameObject.activeSelf != activity) { ActivityBtn.gameObject.SetActive(activity); } // 统计。 var eventId = string.Format("pushitem_{0}_{1}_show", PushItemType.IdOf(data.type), data.code); Dictionary <string, string> attrs = null; if (prepayment) { attrs = new Dictionary <string, string>(); var p = data.prepayment; attrs.Add("prepayment", p != null ? p.name : "NULL"); } var analyticManager = GetAnalyticManager(); if (attrs != null) { analyticManager.Event(eventId, attrs); } else { analyticManager.Event(eventId); } } else { if (ContentTxt.gameObject.activeSelf) { ContentTxt.gameObject.SetActive(false); } if (ChargeBtn.gameObject.activeSelf) { ChargeBtn.gameObject.SetActive(false); } if (VipBtn.gameObject.activeSelf) { VipBtn.gameObject.SetActive(false); } } }
public void InitPushItem(PushItem item) { if (item == null) { return; } m_pushType = item.pushType; m_uThisID = item.thisID; //是不是成就推送 bool isAchievementPush = m_pushType == PushType.Achievement; m_trans_NormalRoot.gameObject.SetActive(!isAchievementPush); m_trans_AchievementRoot.gameObject.SetActive(isAchievementPush); if (isAchievementPush) { m_nCountDown = GameTableManager.Instance.GetGlobalConfig <int>("AchievementCountDown"); m_label_AchievementName.text = item.strName; UIEventListener.Get(m_label_ClickLabel.gameObject).onClick = OnClickLabel; } else { if (item.pushType == PushType.Equip) { m_trans_EffectContent.gameObject.SetActive(true); BaseEquip be = DataManager.Manager <ItemManager>().GetBaseItemByQwThisId <BaseEquip>(item.thisID); if (be != null) { m_label_power.text = be.Power.ToString(); } m_nCountDown = GameTableManager.Instance.GetGlobalConfig <int>("EquipUseCountDown"); } else if (item.pushType == PushType.Consum) { m_trans_EffectContent.gameObject.SetActive(false); m_nCountDown = GameTableManager.Instance.GetGlobalConfig <int>("DanyaoUseCountDown"); } BaseItem bi = DataManager.Manager <ItemManager>().GetBaseItemByQwThisId(item.thisID); if (bi != null) { ItemDataBase db = GameTableManager.Instance.GetTableItem <ItemDataBase>(bi.BaseId); if (db != null) { m_label_Name.text = db.itemName; UIManager.GetTextureAsyn(db.itemIcon, ref m_curIconAsynSeed, () => { if (null != m__Icon) { m__Icon.mainTexture = null; } }, m__Icon); UIManager.GetAtlasAsyn(bi.BorderIcon, ref m_curQualityAsynSeed, () => { if (null != m_sprite_qualityIcon) { m_sprite_qualityIcon.atlas = null; } }, m_sprite_qualityIcon); } } } }
public void ReadConfig() { if (isLoadFinish == false) { return; } isLoadFinish = false; lock (LockObject) { GameSystem.Instance.readConfigCnt += 1; } string text = ResourceLoadManager.Instance.GetConfigText(name); if (text == null) { Debug.LogError("LoadConfig failed: " + name); return; } Debug.Log("Config reading " + name); _items.Clear(); //读取以及处理XML文本的类 XmlDocument xmlDoc = CommonFunction.LoadXmlConfig(GlobalConst.DIR_XML_PUSH, text); //解析xml的过程 XmlNodeList nodelist = xmlDoc.SelectSingleNode("Data").ChildNodes; foreach (XmlElement xe in nodelist) { XmlNode comment = xe.SelectSingleNode(GlobalConst.CONFIG_SWITCH_COLUMN); if (comment != null && comment.InnerText == GlobalConst.CONFIG_SWITCH) { continue; } PushItem item = new PushItem(); foreach (XmlElement xel in xe) { // Debug.Log("read push config "+xel.Name+","+xel.InnerText); uint value = 0; if (xel.Name == "id") { uint.TryParse(xel.InnerText, out value); item.id = value; } else if (xel.Name == "type") { uint.TryParse(xel.InnerText, out value); item.type = value; } else if (xel.Name == "date") { item.date = xel.InnerText; } else if (xel.Name == "time") { item.time = xel.InnerText; } else if (xel.Name == "online") { uint.TryParse(xel.InnerText, out value); item.online = value; } else if (xel.Name == "content") { item.content = xel.InnerText; } } if (!_items.ContainsKey(item.id)) { if (item.date != "0") { System.DateTime Now = System.DateTime.Now; System.DateTime CDt = System.DateTime.Parse(item.date); // Debug.Log("Now "+Now.ToShortDateString()+" cdt "+CDt.ToShortDateString()); if (Now.CompareTo(CDt.AddDays(30)) < 0 && Now.AddDays(30).CompareTo(CDt) > 0) { // Debug.Log("add item id to list "+item.date); _items.Add(item.id, item); } } else { _items.Add(item.id, item); } } } }
/// <summary> /// 设置推送消息 /// </summary> /// <param name="id">Identifier.</param> /// <param name="type">Type.</param> /// <param name="online">Online.</param> /// <param name="date">Date.</param> /// <param name="time">Time.</param> /// <param name="content">Content.</param> public void SetPushInfo(int id /*推送ID*/ , int type /*推送类型*/ , int online /*离线提示或者游戏内提示*/ , int date /*推送日期*/ , int time /*推送时间(剩余时间/s)*/ , string content /*推送文本*/ ) { string s_date = "" + date; // System.DateTime dt = System.DateTime.Now; // dt = dt.AddSeconds(time); string s_time = "" + time; //dt.GetDateTimeFormats('t')[0].ToString()"; // Debug.Log("s_timet "+s_time); PushItem pi; //modify exist element bool configAlreadyRead = false; foreach (PushItem item in _items.Values) { //已经读取了配置从配置设置数据直接发送 if (item.type == type) { configAlreadyRead = true; content = item.content; online = (int)item.online; id = (int)item.id; break; } } if (!configAlreadyRead) { //如果已经发送过一次,通过配置来重置时间再次发送 if (_pushInfos.ContainsKey((uint)type)) { pi = _pushInfos[(uint)type]; pi.time = s_time; content = pi.content; online = (int)pi.online; id = (int)pi.id; } else { //还未读取配置,设置配置时间 pi = new PushItem(); pi.id = (uint)id; pi.date = s_date; pi.online = (uint)online; pi.time = s_time; pi.content = content; pi.type = (uint)type; _pushInfos.Add(pi.type, pi); Debug.Log("send push info after config read."); return; } } Debug.Log("send push info directly."); #if ANDROID_SDK if (Application.platform == RuntimePlatform.Android) { AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); AndroidJavaObject jo = jc.GetStatic <AndroidJavaObject>("currentActivity"); object[] datas = new object[] { id, online, time, content }; // Debug.Log("SetLocalPush push config "+time+","+type+","+content); jo.Call("SetLocalPush", datas); } #endif #if IOS_SDK // Debug.Log("PushConfig recvPush Start called"); // recvPush(id, type, s_date,time,online,content ); // Debug.Log("PushConfig recvPush End called"); // if( type == 4) // { // _hpStr = content; // _hpId = id; // } #endif }
public void SetConfigForPhoneSys() { // all config read finish then call this function. #if ANDROID_SDK if (Application.platform == RuntimePlatform.Android) { AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); AndroidJavaObject jo = jc.GetStatic <AndroidJavaObject>("currentActivity"); object[] datas = new object[] { (int)GameSystem.Instance.CommonConfig.GetUInt("gHpRestoreTime") }; jo.Call("setHpRestoreTime", datas); } #endif #if IOS_SDK setHpRestoreTime((int)GameSystem.Instance.CommonConfig.GetUInt("gHpRestoreTime")); #endif foreach (PushItem item in _items.Values) { switch (item.type) { // first win push info modify case 5: { PushItem pi = null; if (_pushInfos.TryGetValue(item.type, out pi)) { item.date = pi.date; item.time = pi.time; //将信息存储到pushInfo里面,获得首胜后再次推送 pi = item; // _pushInfos.Remove(pi.type); #if ANDROID_SDK if (Application.platform == RuntimePlatform.Android) { AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); AndroidJavaObject jo = jc.GetStatic <AndroidJavaObject>("currentActivity"); int id = (int)item.id; int type = (int)item.type; int online = (int)item.online; /* * public void SetLocalPush(int id, int online, int second, String content ) */ int time; if (!int.TryParse(item.time, out time)) { time = 0; } object[] datas = new object[] { id, online, time, item.content }; // Debug.Log("SetLocalPush push config "+time+","+type+","+item.content); jo.Call("SetLocalPush", datas); } #endif #if IOS_SDK // int id = (int)item.id; // int type = (int)item.type; // int online = (int)item.online; // Debug.Log("PushConfig recvPush Start called"); // recvPush(id, type, item.date,item.time,online,item.content ); // Debug.Log("PushConfig SetLocalPush End called"); #endif } break; } default: { #if ANDROID_SDK if (Application.platform == RuntimePlatform.Android) { AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); AndroidJavaObject jo = jc.GetStatic <AndroidJavaObject>("currentActivity"); int id = (int)item.id; int type = (int)item.type; int online = (int)item.online; // Debug.Log("recvPush push config "+item.time+","+item.type+","+item.content); object[] datas = new object[] { id, type, item.date, item.time, online, item.content }; jo.Call("RecvPush", datas); if (type == 4) { _hpStr = item.content; _hpId = (int)item.id; } } #endif #if IOS_SDK int id = (int)item.id; int type = (int)item.type; int online = (int)item.online; Debug.Log("PushConfig recvPush Start called"); recvPush(id, type, item.date, item.time, online, item.content); Debug.Log("PushConfig recvPush End called"); if (type == 4) { _hpStr = item.content; _hpId = (int)item.id; } #endif break; } } } }