protected void S2C_ReplyBoxData(Pt _msg) { //Debug.Log("S2C_ReplyBoxData"); pt_reply_royal_box_list_d941 msg = _msg as pt_reply_royal_box_list_d941; if (msg != null) { royalTreasureDic.Clear(); restActiveTimes = (int)msg.rest_acc_times; isOpeningBox = false; for (int i = 0; i < msg.box_list.Count; i++) { royal_box_info data = msg.box_list[i]; //Debug.Log(ConfigMng.Instance.GetRoyalBoxRef((int)data.type).boxItemID); if (data.active == 1)//当前有一个宝箱正在开启 { //Debug.Log("已经开启剩余时间=" + data.rest_time); timeGap = Time.realtimeSinceStartup; if (data.rest_time > 0.00) { isOpeningBox = true; } RoyalBoxRef royalBoxRef = ConfigMng.Instance.GetRoyalBoxRef((int)data.type); //发送消息推送(只发送一次,就在刚开启的时候发送) if (royalBoxRef != null && data.rest_time == royalBoxRef.time) { DateTime newServerTime = GameCenter.instance.CurServerTime; DateTime endTime = newServerTime.AddSeconds((int)data.rest_time); string time = string.Format("{0:D2}:{1:D2}:{2:D2}", endTime.Hour, endTime.Minute, endTime.Second); GameCenter.messageMng.SendPushInfo(2, 1, time); } } if (!royalTreasureDic.ContainsKey(data.id)) { RoyalTreaureData royalData = new RoyalTreaureData(data); royalTreasureDic[data.id] = royalData; } //if(royalTreasureDic.Count>=4)//宝箱位只有4个超过4个提示宝箱格已满 //{ // GameCenter.messageMng.AddClientMsg(486); //} } } if (OnRoyalBoxUpdate != null) { OnRoyalBoxUpdate(); } }
public void CreateRewardItem(List <EquipmentInfo> _list, RoyalTreaureData _data = null) { infoList = _list; if (_data == null) { IniteUi(); ShowItem(); } else { CancelInvoke("ShowItem"); IniteUi(); RoyalBoxRef refData = ConfigMng.Instance.GetRoyalBoxRef(_data.ItemID); if (refData != null) { //if (spIcon != null) spIcon.spriteName = refData.haveOpenIcon; if (nameLabel != null) { EquipmentInfo info = _data.RoyalTreasueInfo; if (info != null) { nameLabel.text = info.ItemStrColor + info.ItemName; } } for (int i = 0, max = openEffects.Length; i < max; i++) { if (refData.effect == openEffects[i].name) { //if (spIcon != null) spIcon.gameObject.SetActive(false); NsEffectManager.RunReplayEffect(openEffects[i], true); Invoke("ShowItem", 1.2f); break; } } } } }
protected void S2C_CollectRoyalBoxData(Pt _msg) { //Debug.Log("收到拾取宝箱协议"); pt_add_royal_box_d944 msg = _msg as pt_add_royal_box_d944; if (msg != null) { RoyalBoxRef royalBoxRef = ConfigMng.Instance.GetRoyalBoxRef((int)msg.type); if (royalBoxRef != null) { //EquipmentRef equipmentRef = ConfigMng.Instance.GetEquipmentRef(royalBoxRef.boxItemID); EquipmentInfo equip = new EquipmentInfo(royalBoxRef.boxItemID, EquipmentBelongTo.PREVIEW); if (equip != null) { string name = equip.ItemStrColor + equip.ItemName + "[-]"; //Debug.Log("掉落的宝箱的名字:"+name); MessageST mst = new MessageST(); mst.messID = 506; mst.words = new string[] { name }; GameCenter.messageMng.AddClientMsg(mst); //Debug.logger.Log("拾取到宝箱的提示" + mst.words); if (OnGetNewTreasureBoxEvent != null) { OnGetNewTreasureBoxEvent(); } } else { Debug.LogError("找不到ID为" + royalBoxRef.boxItemID + "的物品配置"); } } else { Debug.LogError("找不到ID为" + (int)msg.type + "的宝箱配置"); } } }
public void RefreshTreasureItem(RoyalTreaureData _data) { if (haveItemGo != null) { haveItemGo.SetActive(_data != null); } if (notHaveItemGo != null) { notHaveItemGo.SetActive(_data == null); } if (vipGo != null) { vipGo.SetActive(GameCenter.vipMng.VipData.vLev < 2); if (notHaveItemGo != null) { notHaveItemGo.SetActive(_data == null && !vipGo.activeSelf); } } if (_data != null) { data = _data; refData = ConfigMng.Instance.GetRoyalBoxRef(_data.ItemID); if (timeCountDown != null) { timeCountDown.SetActive(_data.curState); } if (timeGo != null) { timeGo.SetActive(!_data.curState); } //当没有宝箱在开启时,显示开启宝箱按钮 if (openBtn != null) { openBtn.gameObject.SetActive(!GameCenter.royalTreasureMng.isOpeningBox && _data.curState); } if (rightAwayBtn != null) { rightAwayBtn.gameObject.SetActive(!_data.curState); } //当有宝箱在开启时,另外的宝箱显示立即领取按钮 if (quickenBtn != null) { quickenBtn.gameObject.SetActive(GameCenter.royalTreasureMng.isOpeningBox && _data.curState); } if (getRewardBtn != null) { getRewardBtn.gameObject.SetActive(false); } //宝箱未开启 if (_data.curState && refData != null) { //Debug.Log("开启时间="+ refData.time); float hours = (refData.time / 3600.0f); //Debug.Log("开启时间:小时="+hours); if (timeCount != null) { timeCount.text = hours.ToString("0.00").TrimEnd('.', '0'); } int mins = (int)(refData.time / 60.0f); needGold = (int)(mins /*/ 3.0f*/); beishu = 2; } //宝箱正在开启状态 if (!_data.curState) { if (timer != null && GameCenter.royalTreasureMng.timeGap != 0.0) { timer.StartIntervalTimer((int)(_data.restTime)); timer.onTimeOut = delegate { if (rightAwayBtn != null) { rightAwayBtn.gameObject.SetActive(false); } if (getRewardBtn != null) { getRewardBtn.gameObject.SetActive(true); } }; InvokeRepeating("SetDimano", 180.0f, 180.0f); } if (dimanoNum != null) { //double temp =Convert.ToDouble(GameCenter.royalTreasureMng.timeGap + _data.restTime)/60.0f; needGold = (int)Math.Ceiling(Convert.ToDouble((GameCenter.royalTreasureMng.timeGap + _data.restTime - Time.realtimeSinceStartup) / 60.0f)); //needGold = (int)(mins/3.0f); if (needGold == 0) { needGold = 1; } dimanoNum.text = needGold.ToString(); } if (rewardBeiShu != null) { if (refData != null) { bool isInStepOne = _data.restTime >= refData.time * 0.8; bool isInStepTwo = _data.restTime >= refData.time * 0.5 && _data.restTime < refData.time * 0.8; bool isInStepThree = _data.restTime >= 0 && _data.restTime < refData.time * 0.5; beishu = isInStepOne ? 2 : (isInStepTwo ? 1.5f : (isInStepThree ? 1 : 1)); rewardBeiShu.text = beishu.ToString(); } } } if (nameLabel != null && _data.RoyalTreasueInfo != null) { nameLabel.text = _data.RoyalTreasueInfo.ItemStrColor + _data.RoyalTreasueInfo.ItemName; } if (treasureSp != null && _data.RoyalTreasueInfo != null) { treasureSp.spriteName = refData.notOpenIcon; } } }