void OnClickTypeBtn(ButtonScript obj, object args, int param1, int param2) { switch ((TypeType)param1) { case TypeType.TT_Collection: int index = typeListGrid_.GetIndex(obj.transform); if (typeFlag[(int)TypeType.TT_Collection] && param2 != 1) { for (int i = 0; i < collectItemCache.Length; ++i) { if (collectItemCache[i] != null) { //typeListGrid_.RemoveChild(index + 1); typeListGrid_.RemoveChild(collectItemCache[i].transform); UIManager.RemoveButtonEventHandler(collectItemCache[i], EnumButtonEvent.OnClick); collectItemCache[i].SetActive(false); } } typeFlag[(int)TypeType.TT_Collection] = false; } else { GameObject colItem = null; for (int i = 0; i < AuctionHouseSystem.CollectionMax; ++i) { if (i < AuctionHouseSystem.collectionList_.Count) { string[] infos = AuctionHouseSystem.collectionList_[i].Split('|'); int id = int.Parse(infos[0]); int isItem = bool.Parse(infos[1]) == true? 1: 0; if (collectItemCache[i] == null) { colItem = GameObject.Instantiate(collectItem_) as GameObject; typeListGrid_.AddChild(colItem.transform, index + 1 + i); colItem.SetActive(true); colItem.transform.localScale = Vector3.one; colItem.GetComponent <CollectGood>().SetData(AuctionHouseSystem.collectionList_[i]); UIManager.SetButtonEventHandler(colItem, EnumButtonEvent.OnClick, OnCollectionSearch, id, isItem); UIManager.SetButtonEventHandler(colItem.GetComponent <CollectGood>().cancelCollectBtn_.gameObject, EnumButtonEvent.OnClick, OnUnCollect, i, isItem); collectItemCache[i] = colItem; } else { typeListGrid_.AddChild(collectItemCache[i].transform, index + 1 + i); collectItemCache[i].SetActive(true); collectItemCache[i].GetComponent <CollectGood>().SetData(AuctionHouseSystem.collectionList_[i]); UIManager.SetButtonEventHandler(collectItemCache[i].GetComponent <CollectGood>().cancelCollectBtn_.gameObject, EnumButtonEvent.OnClick, OnUnCollect, i, isItem); UIManager.SetButtonEventHandler(collectItemCache[i], EnumButtonEvent.OnClick, OnCollectionSearch, id, isItem); } } else { if (collectItemCache[i] != null) { UIManager.RemoveButtonEventHandler(collectItemCache[i], EnumButtonEvent.OnClick); collectItemCache[i].SetActive(false); } } } typeFlag[(int)TypeType.TT_Collection] = true; } //typeListGrid_.Reposition(); obj.GetComponent <MainGood>().SetTriangle(typeFlag[(int)TypeType.TT_Collection]); break; case TypeType.TT_Equip: index = typeListGrid_.GetIndex(obj.transform); if (typeFlag[(int)TypeType.TT_Equip]) { for (int i = 0; i < equipItemCache.Length; ++i) { if (equipItemCache[i] != null) { typeListGrid_.RemoveChild(index + 1); UIManager.RemoveButtonEventHandler(equipItemCache[i], EnumButtonEvent.OnClick); equipItemCache[i].SetActive(false); } } typeFlag[(int)TypeType.TT_Equip] = false; } else { GameObject subItem = null; for (int i = (int)ItemSubType.IST_None; i < (int)ItemSubType.IST_EquipMax - 1; ++i) { if (equipItemCache[i] == null) { subItem = GameObject.Instantiate(subItem_) as GameObject; typeListGrid_.AddChild(subItem.transform, index + 1 + i); subItem.transform.localScale = Vector3.one; SubGood sg = subItem.GetComponent <SubGood>(); sg.SetType(SubGood.GoodType.GT_Item); sg.SetData(LanguageManager.instance.GetValue(((ItemSubType)i + 1).ToString())); UIManager.SetButtonEventHandler(subItem, EnumButtonEvent.OnClick, OnSubTypeSearch, i + 1, 1); subItem.SetActive(true); equipItemCache[i] = subItem; } else { typeListGrid_.AddChild(equipItemCache[i].transform, index + 1 + i); UIManager.SetButtonEventHandler(equipItemCache[i], EnumButtonEvent.OnClick, OnSubTypeSearch, i + 1, 1); equipItemCache[i].SetActive(true); } } typeFlag[(int)TypeType.TT_Equip] = true; } typeListGrid_.Reposition(); obj.GetComponent <MainGood>().SetTriangle(typeFlag[(int)TypeType.TT_Equip]); break; case TypeType.TT_Baby: index = typeListGrid_.GetIndex(obj.transform); if (typeFlag[(int)TypeType.TT_Baby]) { for (int i = 0; i < babyItemCache.Length; ++i) { if (babyItemCache[i] != null) { typeListGrid_.RemoveChild(index + 1); UIManager.RemoveButtonEventHandler(babyItemCache[i], EnumButtonEvent.OnClick); babyItemCache[i].SetActive(false); } } typeFlag[(int)TypeType.TT_Baby] = false; } else { GameObject subItem = null; for (int i = (int)RaceType.RT_None; i < (int)RaceType.RT_Max - 1; ++i) { if (babyItemCache[i] == null) { subItem = GameObject.Instantiate(subItem_) as GameObject; typeListGrid_.AddChild(subItem.transform, index + 1 + i); subItem.transform.localScale = Vector3.one; SubGood sg = subItem.GetComponent <SubGood>(); sg.SetType(SubGood.GoodType.GT_Baby); string nameType = ((RaceType)i + 1).ToString(); sg.SetData(LanguageManager.instance.GetValue(((RaceType)i + 1).ToString()), BabyData.GetRaceIconByType((RaceType)i + 1)); UIManager.SetButtonEventHandler(subItem, EnumButtonEvent.OnClick, OnSubTypeSearch, i + 1, 0); subItem.SetActive(true); babyItemCache[i] = subItem; if (RaceType.RT_Human.ToString().Equals(nameType) || RaceType.RT_Metal.ToString().Equals(nameType)) { sg.dikuangSp.spriteName = "webzudidilan"; } if (RaceType.RT_Insect.ToString().Equals(nameType) || RaceType.RT_Animal.ToString().Equals(nameType)) { sg.dikuangSp.spriteName = "webzudihuang"; } if (RaceType.RT_Dragon.ToString().Equals(nameType) || RaceType.RT_Extra.ToString().Equals(nameType) || RaceType.RT_Undead.ToString().Equals(nameType)) { sg.dikuangSp.spriteName = "webzudihong"; } if (RaceType.RT_Fly.ToString().Equals(nameType) || RaceType.RT_Plant.ToString().Equals(nameType)) { sg.dikuangSp.spriteName = "webzudilv"; } } else { typeListGrid_.AddChild(babyItemCache[i].transform, index + 1 + i); UIManager.SetButtonEventHandler(babyItemCache[i], EnumButtonEvent.OnClick, OnSubTypeSearch, i + 1, 0); babyItemCache[i].SetActive(true); } } typeFlag[(int)TypeType.TT_Baby] = true; } typeListGrid_.Reposition(); obj.GetComponent <MainGood>().SetTriangle(typeFlag[(int)TypeType.TT_Baby]); break; case TypeType.TT_Item: index = typeListGrid_.GetIndex(obj.transform); if (typeFlag[(int)TypeType.TT_Item]) { for (int i = 0; i < consumItemCache.Length; ++i) { if (consumItemCache[i] != null) { typeListGrid_.RemoveChild(index + 1); UIManager.RemoveButtonEventHandler(consumItemCache[i], EnumButtonEvent.OnClick); consumItemCache[i].SetActive(false); } } typeFlag[(int)TypeType.TT_Item] = false; } else { GameObject subItem = null; for (int i = (int)ItemSubType.IST_None; i < (int)ItemSubType.IST_ConsEnd - (int)ItemSubType.IST_ConsBegin - 1; ++i) { if (consumItemCache[i] == null) { subItem = GameObject.Instantiate(subItem_) as GameObject; typeListGrid_.AddChild(subItem.transform, index + 1 + i); subItem.transform.localScale = Vector3.one; SubGood sg = subItem.GetComponent <SubGood>(); sg.SetType(SubGood.GoodType.GT_Item); sg.SetData(LanguageManager.instance.GetValue(((ItemSubType)i + (int)ItemSubType.IST_ConsBegin + 1).ToString())); UIManager.SetButtonEventHandler(subItem, EnumButtonEvent.OnClick, OnSubTypeSearch, i + (int)ItemSubType.IST_ConsBegin + 1, 1); subItem.SetActive(true); consumItemCache[i] = subItem; } else { typeListGrid_.AddChild(consumItemCache[i].transform, index + 1 + i); UIManager.SetButtonEventHandler(consumItemCache[i], EnumButtonEvent.OnClick, OnSubTypeSearch, i + (int)ItemSubType.IST_ConsBegin + 1, 1); consumItemCache[i].SetActive(true); } } typeFlag[(int)TypeType.TT_Item] = true; } typeListGrid_.Reposition(); obj.GetComponent <MainGood>().SetTriangle(typeFlag[(int)TypeType.TT_Item]); break; default: break; } }