public override void ProcessNPCResponse(UNPCResponseData data) { m_Title.text = data.npcResp.NpcName; m_Dialog.text = data.npcResp.NpcDialog; // 清空Topic列表 for (int i = m_TopicListTrans.childCount - 1; i >= 0; --i) { var temp = m_TopicListTrans.GetChild(i).gameObject; ResNode.DestroyRes(ref temp); } // 解析生成Topic列表,即NPC功能列表按钮 foreach (var topic in data.npcResp.NPCTopicList) { GameObject topicObj = ResNode.InstantiateRes(DefaultTopicBtn); if (topicObj == null) { continue; } topicObj.SetActive(true); topicObj.transform.SetParent(m_TopicListTrans, false); Button topicBtn = topicObj.GetComponent <Button>(); topicBtn.transform.FindChild("Text").GetComponent <Text>().text = topic.Text; string url = topic.Link; topicBtn.onClick.AddListener(delegate { onClickNPCFunc(url); }); } }
// 处理NPC回应:以Button的方式触发Topic public void processNPCResponse(UNPCResponseData data) { // 显示对话框内容 m_wnd.SetVisible(true); m_CurNPCUID = data.npcResp.NpcUID; int frameType; switch (data.npcResp.NpcViewType) { case (int)NPC_VIEW_TYPE.NPC_VIEW_WAR_WING: { frameType = (int)ESubViewFrame.WING_FRAME; } break; case (int)NPC_VIEW_TYPE.NPC_VIEW_WAR_GOODS_SHOP: { frameType = (int)ESubViewFrame.GOOODS_SHOP_FRAME; } break; default: Debug.LogWarningFormat("NPCWnd:not match view type({0}).", data.npcResp.NpcViewType); return; } SwitchFrame(frameType); arraySubViewFrame[frameType].ProcessNPCResponse(data); }
// 触发NPC后得到回应 public void recvNPCResponse(string strRes) { if (strRes == null) { return; } // 处理NPC返回的数据 NPCResponse res = new NPCResponse(strRes); UNPCResponseData data = new UNPCResponseData(); data.msgID = (int)WndMsgID.WND_MSG_NPC_RESPONSE; data.npcResp = res; UISystem.Instance.SendWndMessage(WndMsgID.WND_MSG_NPC_RESPONSE, data); }
public override void ProcessNPCResponse(UNPCResponseData data) { m_responseData = data; m_Title.text = data.npcResp.NpcName; ObservableList <UNPCGoodsItem> dataSource = new ObservableList <UNPCGoodsItem>(); bool allFree = true; foreach (var item in data.npcResp.NPCTopicList) { if (item.ParamList.Length > 6) { int goodsID; int goodsCost; int lastBuyTime; int coolTime; if (!Int32.TryParse(item.ParamList[4], out goodsID)) { return; } if (!Int32.TryParse(item.ParamList[5], out goodsCost)) { return; } if (!Int32.TryParse(item.ParamList[6], out lastBuyTime)) { return; } if (!Int32.TryParse(item.ParamList[7], out coolTime)) { return; } SSchemeMobaGoods schemeGoods = new SSchemeMobaGoods(); if (GoodsSchemesDataManager.Instance.GetMobaGoods_Ref(goodsID, ref schemeGoods)) { UNPCGoodsItem goodItem = new UNPCGoodsItem(); goodItem.schemeGoods = schemeGoods; if (goodsCost >= 0) { goodItem.schemeGoods.GoodsCost = goodsCost; if (allFree && goodsCost > 0) { allFree = false; } } goodItem.nLastBuyTime = lastBuyTime; goodItem.nCoolTime = coolTime; goodItem.uidNPC = (int)data.npcResp.NpcUID; dataSource.Add(goodItem); } else { Debug.LogWarningFormat("not find goods by goodsID={0}", goodsID); } } } goodsTile.SetAllDeselect(); goodsTile.DataSource = dataSource; if (goodsTile.DataSource.Count > 0) { goodsTile.Select(0); } if (buyGoodsBtnDesc != null) { if (allFree && data.npcResp.TopicCount == 1) { buyGoodsBtnDesc.text = "拾取"; } else { buyGoodsBtnDesc.text = "购买"; } } InvokeRepeating("SetGoodsMask", 0.1f, 0.5f); }
public abstract void ProcessNPCResponse(UNPCResponseData data);
public void onNPCResponse(UNPCResponseData data) { processNPCResponse(data); }