public void merge(ItemSpot is1, ItemSpot is2) { var i1 = is1.item; var i2 = is2.item; foreach (GameObject GO in allItems) { Item i = GO.GetComponent <Item>(); if ((i.child1Name == i1.name && i.child2Name == i2.name) || (i.child1Name == i2.name && i.child2Name == i1.name)) { GameObject g = Instantiate(GO);//TODO: handle weird unity naming convention (Clone) g.GetComponent <MeshRenderer>().enabled = false; g.GetComponent <MeshCollider>().enabled = false; g.name = GO.name; Debug.Log("Succesfully created " + i.name + " from " + i1.name + " and " + i2.name + ". Returning"); is2.fillItem(i); GameObject.FindObjectOfType <EQ>().refreshItemSpots(is1.item); is1.item = null; i.OnMerge.Invoke(); return; } } Debug.Log("Items " + i1.name + " and " + i2.name + " don't make anything. Returning"); }
public void refreshItemSpots(Item i) { Debug.Log("refreshing"); foreach (Button b in eqSpots) { ItemSpot IS = b.GetComponent <ItemSpot>(); if (IS.item == i) { IS.GetComponent <RawImage>().texture = basic; } } }
public bool PickUpItem(Item i) { foreach (Button b in eqSpots) { ItemSpot IS = b.GetComponent <ItemSpot>(); if (IS.item == null) { IS.fillItem(i); return(true); } } return(false); }
void Update() { if (Input.GetKeyDown(KeyCode.R)) { if (selectedSpot != null) { selectedSpot.item.ThrowOut(GameObject.FindObjectOfType <PlayerMovement>().transform.position); refreshItemSpots(selectedSpot.item); selectedSpot.item = null; selectedSpot = null; } } }
public void ItemSpotClicked(ItemSpot IS) { Debug.Log(IS.name + " clicked"); if (IS.item != null) { if (selectedSpot == null) { selectedSpot = IS; } else { CM.merge(selectedSpot, IS); selectedSpot = null; } } }
void Start() { selectedSpot = null; CM = GameObject.FindObjectOfType <CraftingManager>(); eqSpots = GetComponentsInChildren <Button>(); }