public void AddToCart(ItemConf itemConf, CostConf itemCost) { Sprite sprite; GameObject item; if (!GetAllIcons.icons.TryGetValue(itemConf.icon, out sprite)) { return; } bool exists = m_items.TryGetValue(itemConf.name, out item); if (!exists) { // new cart item item = GameObject.Instantiate(CartItem); if (item == null) { return; } item.transform.SetParent(transform, false); item.SetActive(true); m_items.Add(itemConf.name, item); } CartItemUI handler = item.GetComponent <CartItemUI>(); if (exists) { handler.Increase(); } else { handler.Init(itemConf, itemCost); } }
public void SetInfo(ItemConf item, CostConf cost) { itemConf = item; itemCost = cost; CostImg.GetComponent <Image>().color = new Color(1, 1, cost.costType == CostType.Silver ? 1 : 0); SetInfo(item.name, item.icon, item.type, cost.cost); }
public void Init(ItemConf itemConf, CostConf itemCost) { item = itemConf; cost = itemCost; itemName = itemConf.name; button.image.sprite = GetAllIcons.icons[item.icon]; CostImg.GetComponent <Image>().color = new Color(1, 1, cost.costType == CostType.Silver ? 1 : 0); Increase(); }
public void Set(string name, int cost, CostType costType) { ItemName.GetComponent <Text>().text = name; ItemCost.GetComponent <Text>().text = cost.ToString(); if (ItemType != null) { ItemType.GetComponent <Image>().color = new Color(1, 1, costType == CostType.Gold ? 0 : 1); } costConf = new CostConf(); costConf.cost = cost; costConf.costType = costType; }
private void OnRecvGetTmallItems(IChannel channel, Message message) { SGetTmallItems response = new SGetTmallItems(); var items = FrontEnd.Item.FItem.itemConfs; List <KeyValuePair <ItemConf, CostConf> > item_price = new List <KeyValuePair <ItemConf, CostConf> >(); foreach (var item in items) { CostConf costConf = new CostConf { cost = 5, costType = CostType.Gold }; if (item.name == "HealthElixir") { costConf.costType = CostType.Silver; } item_price.Add(new KeyValuePair <ItemConf, CostConf>(item, costConf)); } response.TmallItems = item_price.ToArray(); channel.Send(response); System.Console.WriteLine("GetTmallItems"); }