/// <summary> /// 显示猫内容 /// </summary> /// <param name="data"></param> public void ShowCatGroupInfo(object data) { JsonData cats = (JsonData)data; int count = (int)cats["count"]; for (int i = 0; i < count; i++) { JsonData catInfo = cats[i]; GameObject obj = NGUITools.AddChild(catGrid, catItem); CatInfo cat = obj.GetComponent <CatInfo>(); if (cat == null) { cat = obj.AddComponent <CatInfo>(); } cat.Id = (int)catInfo["id"]; cat.CatTypeid = (int)catInfo["cattypeid"]; cat.Name = (string)catInfo["catName"]; cat.Level = (int)catInfo["lv"]; cat.Atk = (int)catInfo["atk"]; cat.GroupId = (int)catInfo["groupId"]; UIEventListener.Get(obj).onClick = ShowCatInfo; UIToggle toggle = obj.transform.Find("SelectButton").GetComponent <UIToggle>(); EventDelegate ed = new EventDelegate(this, "OnSelectClicked"); ed.parameters[0].obj = obj; toggle.onChange.Add(ed); obj.transform.Find("NameLabel").GetComponent <UILabel>().text = obj.GetComponent <CatInfo>().Name; } catGrid.GetComponent <UIGrid>().repositionNow = true; }
public void Init(CatInfo info) { m_catInfo = info; idInput.text = info.id; kindInput.text = info.kind; nameInput.text = info.nickname; colorInput.text = info.color; genderDropdown.value = info.gender; birthInput.text = info.birth; reasonInput.text = info.reason; }
/// <summary> /// 更新ui /// </summary> /// <param name="info"></param> public void UpdateUi(CatInfo info) { m_info = info; idText.text = info.id; nameText.text = info.nickname; kindText.text = info.kind; colorText.text = info.color; genderText.text = 0 == info.gender ? "母" : "公"; birthText.text = info.birth; resonText.text = info.reason; }
/// <summary> /// 新增或修改数据 /// </summary> /// <param name="info"></param> public static void AddOrModify(CatInfo info) { if (s_datas.ContainsKey(info.uuid)) { s_datas[info.uuid] = info; } else { s_datas.Add(info.uuid, info); } SaveData(); }
/// <summary> /// 创建信息列表的一行ui /// </summary> /// <param name="info"></param> void CreateItem(CatInfo info) { var obj = Instantiate(catItemObj); obj.SetActive(true); obj.transform.SetParent(listRoot, false); var itemUi = obj.GetComponent <CatListItem>(); // 使用数据更新ui itemUi.UpdateUi(info); // 缓存,方便后面更新ui m_catUiList[info.uuid] = itemUi; }
private CatInfo MakeCatInfo() { if (null == m_catInfo) { m_catInfo = new CatInfo(); } m_catInfo.id = idInput.text; m_catInfo.kind = kindInput.text; m_catInfo.nickname = nameInput.text; m_catInfo.color = colorInput.text; m_catInfo.gender = genderDropdown.value; m_catInfo.birth = birthInput.text; m_catInfo.reason = reasonInput.text; return(m_catInfo); }
private void ShowCatInfo(GameObject sender) { if (sender == null) { for (int i = 0; i < infoPanel.transform.childCount; i++) { infoPanel.transform.GetChild(i).gameObject.SetActive(false); } CancelBtn.SetActive(true); return; } else { for (int i = 0; i < infoPanel.transform.childCount; i++) { infoPanel.transform.GetChild(i).gameObject.SetActive(true); } } CatInfo cat = sender.GetComponent <CatInfo>(); Transform modelpos = infoPanel.transform.Find("ModelPos").GetComponent <Transform>(); if (modelpos.childCount > 0) { GameObject catmodelbefore = modelpos.GetChild(0).gameObject; catmodelbefore.layer = 8; catmodelbefore.transform.SetChildLayer(8); Destroy(catmodelbefore.GetComponent <EmployeeRandomAnimation>()); catmodelbefore.SetActive(false); } GameObject catmodel = CatPool.GetInstance().GetCatPool(cat.CatTypeid).CreateObject(modelpos.position); catmodel.layer = 9; catmodel.transform.SetChildLayer(9); catmodel.AddComponent <EmployeeRandomAnimation>(); catmodel.transform.rotation = modelpos.rotation; catmodel.transform.parent = modelpos; infoPanel.transform.Find("CatName").GetComponent <UILabel>().text = cat.Name; infoPanel.transform.Find("CatInfo").GetComponent <UILabel>().text = ( "lv:" + cat.Level + "\n" + "atk:" + cat.Atk + "\n" + "groupId:" + cat.GroupId ) ; }
/// <summary> /// 新增或修改猫信息 /// </summary> /// <param name="info"></param> public void AddOrModify(CatInfo info) { CatDataBase.AddOrModify(info); // 抛出事件,更新界面 EventDispatcher.instance.DispatchEvent(EventNameDef.EVENT_ADD_OR_MODIFY_CAT, info); }
public bool Equals(CatInfo other) { return(string.Equals(Category, other.Category) && string.Equals(SubCategory, other.SubCategory) && string.Equals(SubSubCatergory, other.SubSubCatergory)); }