// Use this for initialization void Awake() { m_TempColor = Color.white; m_TestItem = null; m_Renderer = GetComponent<MeshRenderer>(); gameObject.SetActive(false); }
public void SetItemData(Item item) { m_Icon.texture = item.ItemTex; m_Name.text = item.Name; m_Info.text = item.Info; m_Price.text = item.Price.ToString(); m_SelfItem = item; }
/// <summary> /// 设置该3D物品的参数 /// </summary> public void SetItem3D(Item item, Vector3 pos) { transform.position = pos; m_TempColor.a = 1.0f; m_TestItem = item; m_Renderer.material.mainTexture = item.ItemTex; m_Renderer.material.SetColor("_Color", m_TempColor); m_IsPicked = false; gameObject.SetActive(true); }
// Update is called once per frame public void OnTriggerEnter(Collider colli) { if(colli.tag == "Player" && m_TestItem != null) { DungonManager.Inst.Player.PackageManager.AddItem(m_TestItem); gameObject.SetActive(false); m_IsPicked = true; // 既然当前的ITEM已经传入了背包中,则当前的Item必须重新产生, // 否则下一次对该Item的修改,将会影响背包中对应的Item m_TestItem = null; m_TestItem = new ItemTest(); } }
public void SetAItem(Item item, Vector3 pos) { if(m_CurUseCount >= m_Item3DList.Count) { Debug.Log("物品掉落不够用了"); return; } if(item == null) { return; } m_Item3DList[m_CurUseCount].SetItem3D(item, pos); ++m_CurUseCount; }
/// <summary> /// 处理购买物品的情况 /// </summary> public void OnBuy(Item item) { if(item.Price > m_Data.gold) { return; } m_Data.gold -= item.Price; if(m_PackageManager.AddItem(item)) { HintTextManager.Inst.ShowHintText("购买了" + item.Name, 2f ); } }
public void SetItem(Item item, int index) { m_SelfIcon.texture = item.ItemTex; m_ItemIndexInPackge = index; }
public void AddItem(Item item) { m_ItemDict.Add(item.Id, item); }