/// <summary> /// 显示合成路径 /// </summary> /// <param name="_items">选中的物品</param> public void showCompositePath(items _items, Slot.itemOwn _itemOwn) { //把之前的物品存入对象池 itemObjectpoolManager.instance.setCompositechildslotpool(); //把合成连接线存入对象池 itemObjectpoolManager.instance.setLinepool(); m_fatherItem = new itemLeaf(); Debug.Log("实例化了"); m_fatherItem.FatherItem = _items; //fatherGameObject.transform.Find("Image").GetComponentInChildren<Image>().sprite = _itemImage.sprite; //fixstring(_items); if (m_fatherGameObject.GetComponent <CompositeChildslot>() == null) { m_fatherGameObject.AddComponent <CompositeChildslot>(); } m_fatherGameObject.GetComponent <CompositeChildslot>().setItem(_items, m_fatherItem, CompositeChildslot.cenCI.One); if (_itemOwn == Slot.itemOwn.None) { m_goldText.text = showGoldText(); } else { m_goldText.text = m_item.SellPrice.ToString(); } }
/// <summary> /// 根据合成路径加载物品 /// </summary> /// <param name="v">合成路径</param> private void getChildSlot(string[] v) { dic = InventroyManager.instance.getItemDic(); for (int i = 0; i < v.Length; i++) { foreach (var value in dic) { for (int j = 0; j < value.Value.Count; j++) { if (v[i] == value.Value[j].Id.ToString()) { childItem = new itemLeaf(); childItem.FatherItem = value.Value[j]; fatherItem.addList(childItem); } } } } if (!isPointDown) { for (int i = 0; i < fatherItem.getList().Count; i++) { itemQueue.Add(getchildSlot()); } } }
public void setPrepurchase(itemLeaf _itemLeaf) { tempList = new List <items>(); isFound = false; tempList.Add(_itemLeaf.FatherItem); if (_itemLeaf.getList().Count != 0) { fatherItemLeaf = _itemLeaf.getList(); for (int j = 0; j < fatherItemLeaf.Count; j++) { tempList.Add(fatherItemLeaf[j].FatherItem); if (fatherItemLeaf[j].getList().Count != 0) { childItemLeaf = fatherItemLeaf[j].getList(); for (int n = 0; n < childItemLeaf.Count; n++) { tempList.Add(childItemLeaf[n].FatherItem); } } } } childItemLeaf = null; for (int i = 0; i < tempList.Count; i++) { isFound = false; if (prepurchase.Count == 0) { prepurchase.Add(tempList[i]); continue; } for (int j = 0; j < prepurchase.Count; j++) { if (isFound) { continue; } if (prepurchase[j].Id == tempList[i].Id) { isFound = true; continue; } } if (!isFound) { prepurchase.Add(tempList[i]); } } if (itemDic.ContainsKey("推荐")) { itemDic["推荐"] = prepurchase; } else { itemDic.Add("推荐", prepurchase); } }
/// <summary> /// 物品格子的初始化 /// </summary> /// <param name="childGameObject">物品格</param> /// <param name="vector">位置</param> /// <param name="items">物品属性</param> /// <param name="itemLeaf">合成树</param> private void setSlotPos(GameObject childGameObject, Vector2 vector, items items, itemLeaf itemLeaf) { childGameObject.SetActive(true); //Debug.Log(this.transform.parent.name); childGameObject.transform.parent = this.transform.parent; childGameObject.transform.localScale = Vector3.one; childGameObject.transform.localPosition = vector; childGameObject.GetComponent <CompositeChildslot>().setItem(items, itemLeaf, cenCI.Two); setVerticalline(childGameObject); }
/// <summary> /// 初始化物品 /// </summary> /// <param name="_item">选中的物品</param> /// <param name="itemLeaf">物品合成树</param> /// <param name="cI">物品的层次</param> public void setItem(items _item, itemLeaf itemLeaf, cenCI cI) { //itemQueue.Clear(); cen = cI; own = itemOwn.None; m_itemss = _item; m_image = transform.Find("Image").gameObject; //Debug.Log(_image); m_image.GetComponent <Image>().sprite = Resources.Load <Sprite>(_item.Sprite); m_image.transform.parent = this.transform; m_image.transform.localPosition = Vector3.zero; m_image.transform.localScale = Vector3.one; //设置合成树第一个物品 fatherItem = itemLeaf; //显示合成树 showCompositePath(m_itemss); }
// Update is called once per frame #region 面板的显示和隐藏 /// <summary> /// 显示物品提示面板 /// </summary> /// <param name="_image">选中物品的图标</param> /// <param name="_itemOwn">选中物品格子的所有权</param> /// <param name="_item">选中的物品</param> /// <param name="_itemLeaf">选中物品的子物品</param> public void showTool(Image _image, Slot.itemOwn _itemOwn, items _item, itemLeaf _itemLeaf) { m_item = _item; //显示面板 this.gameObject.SetActive(true); //根据物品栏所有权加载按钮 switch (_itemOwn) { case Slot.itemOwn.None: m_caozuo.GetComponentInChildren <Text>().text = "预购"; m_buy.gameObject.SetActive(true); m_buy.GetComponentInChildren <Text>().text = "购买"; break; case Slot.itemOwn.ownerplayer: m_caozuo.GetComponentInChildren <Text>().text = "出售"; m_sellItem = _image.transform.parent.gameObject; m_buy.gameObject.SetActive(false); break; default: break; } //存入对象池 itemObjectpoolManager.instance.setCompositeslotpool(); //物品名字的显示 m_name.text = _item.Name; //物品说名的显示 m_Explain.text = Processingstrings(_item.Explain); //显示可合成物品 showCompositeSlot(_item); //根据是否有物品树显示金钱 if (_itemLeaf != null) { m_fatherItem = _itemLeaf; m_goldText.text = showGoldText(); } m_itemImage.sprite = _image.sprite; }