public void SetInfo() { ///设置已签到的对象 foreach (var data in PlayerData.Signs) { GameObject signItem = singIned[data.signId.ToString()]; ResourceMgr.CreateUIPrefab("GUIs/SignIn/siged", signItem.transform); Utility.FindChild <Button>(signItem.transform, "icon").interactable = false; } ///设置过期对象 for (int i = 0; i < TimeSystem.GetCurrentDay - 1; i++) { GameObject signItem = signs[i]; if (signItem.transform.childCount == 3) { ResourceMgr.CreateUIPrefab("GUIs/SignIn/passed", signs[i].transform); Utility.FindChild <Button>(signItem.transform, "icon").interactable = false; } } GameObject today = signs[TimeSystem.GetCurrentDay - 1]; ResourceMgr.CreateUIPrefab("GUIs/SignIn/SignInSelect", today.transform); for (int i = TimeSystem.GetCurrentDay; i < TimeSystem.DaysInMonth(); i++) { GameObject signItem = signs[i]; Utility.FindChild <Button>(signItem.transform, "icon").interactable = false; } }
public void CreateSignItems() { int count = 1; foreach (var sign in ConfigInfo.Instance.SignIn) { if (count > days) { break; } var sg = ResourceMgr.CreateUIPrefab("GUIs/SignIn/SignIn", layout); sg.name = sign.Key.ToString(); signs.Add(sg); singIned.Add(sign.Key, sg); Button btn = Utility.FindChild <Button>(sg.transform, "icon"); btn.onClick.AddListener(() => { SendSignedRequest(Convert.ToInt32(sg.name)); }); string Icon = ConfigInfo.GetProp(ConfigInfo.Instance.GetPropId(sign.Key, days)).Icon; btn.GetComponent <Image>().sprite = ResourceMgr.Load <Sprite>("Sprites/Props/" + Icon); Utility.FindChild <Text>(sg.transform, "num").text = ConfigInfo.Instance.GetNum(sign.Key, days).ToString(); Utility.FindChild <Text>(sg.transform, "day").text = count.ToString(); count++; } }
/// <summary> /// 接收签到数据 /// </summary> /// <param name="res"></param> private void OnSignRes(byte[] res) { SignInRes response = ProtoBufUtils.Deserialize <SignInRes>(res); GameObject today = signs[TimeSystem.GetCurrentDay - 1]; GameObject signed = ResourceMgr.CreateUIPrefab("GUIs/SignIn/siged", today.transform); signed.transform.localScale = Vector3.one * 2; Tweener tween = signed.transform.DOScale(Vector3.one, 1); }
public void CreateDungeousItems() { foreach (var data in ConfigInfo.Instance.Dungeous.Values) { var item = ResourceMgr.CreateUIPrefab("GUIs/Dungeous/DungeousItem", content); Button btn = item.GetComponent <Button>(); Text btnName = Utility.FindChild <Text>(item.transform, "name"); items.Add(item); Image btnIcon = item.GetComponent <Image>(); btnIcon.sprite = ResourceMgr.LoadSpriteFromAtals(Utility.CTInt(data.Index), "Sprites/Dungeous"); btnName.text = data.Name; btn.name = data.Id; btn.onClick.AddListener(() => { currentSelect.transform.SetParent(btn.transform, false); MUIMgr.Instance.ShowAlert(OpenType.TwoButton, () => { SceneMgr.Instance.LoadSceneAsync(btn.name); }, null, "进入地下城", "是否进入" + btn.name, "确定", "取消"); }); } currentSelect = ResourceMgr.CreateUIPrefab("GUIs/Dungeous/DungeousSelect", items[0].transform); }
/// <summary> /// 刷新商店道具UI的功能 /// </summary> /// <param name="parms"></param> public override void Refresh(params object[] parms) { base.Refresh(parms); props = ConfigInfo.Instance.ShopConfigs[((int)currentSelectGroup).ToString()]; //每次刷新UI之前把之前的UI清空掉 for (int i = 0; i < items.Count; i++) { Destroy(items[i]); } items.Clear(); for (int i = 0; i < props.Count; i++) { //go每一个道具的UI预制体 var go = ResourceMgr.CreateUIPrefab("GUIs/Shop/ShopItem", content); go.name = props[i].Id; items.Add(go); ShopConfig shopConfig = props[i]; PropInfoConfig propConfig = ConfigInfo.Instance.Props[shopConfig.PropId]; Text nameText = Utility.FindChild <Text>(go.transform, "Text_itemName"); Image icon = Utility.FindChild <Image>(go.transform, "Icon"); Text costText = Utility.FindChild <Text>(go.transform, "cost"); nameText.text = propConfig.Name; icon.sprite = ResourceMgr.Load <Sprite>("Sprites/Props/" + propConfig.Icon); icon.gameObject.AddComponent <Button>(); icon.gameObject.GetComponent <Button>().onClick.AddListener(() => { BuyPropReq req = new BuyPropReq(); req.id = PlayerData.Me.info.id; req.num = 1; req.storeId = Convert.ToInt32(go.name); MobaNetwork.Send((ushort)MessageId.EBuyPropReq, req); }); Image coin = Utility.FindChild <Image>(go.transform, "coin"); coin.sprite = ResourceMgr.LoadSpriteFromAtals(Utility.CTInt(shopConfig.Cost_Type), "Sprites/Coins"); costText.text = shopConfig.Cost_Num; } }
public override void Refresh(params object[] parms) { base.Refresh(parms); content.text = string.Format(text, PlayerData.Me.info.name, PlayerData.myRole.Atk, PlayerData.myRole.Def, PlayerData.myRole.Adv, PlayerData.myRole.Cri, PlayerData.myRole.MaxHp, PlayerData.myRole.MaxMp, PlayerData.myRole.MoveSpeed, PlayerData.myRole.AtkSpeed); for (int i = 0; i < props.Count; i++) { Destroy(props[i]); } props.Clear(); foreach (var data in PlayerData.BagInfos) { if (slots.ContainsKey(data.Value.slot)) { Transform grid = slots[data.Value.slot].transform; var item = ResourceMgr.CreateUIPrefab("GUIs/Bag/Prop", grid); item.GetComponent <Image>().sprite = ResourceMgr.Load <Sprite>("Sprites/Props/" + ConfigInfo.GetProp(data.Value.propId.ToString()).Icon); Utility.FindChild <Text>(item.transform, "num").gameObject.SetActive(false); item.name = data.Key.ToString(); props.Add(item); } } }