Exemple #1
0
    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");
    }
Exemple #2
0
 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;
         }
     }
 }
Exemple #3
0
 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);
 }
Exemple #4
0
    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;
            }
        }
    }
Exemple #5
0
 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;
         }
     }
 }
Exemple #6
0
 void Start()
 {
     selectedSpot = null;
     CM           = GameObject.FindObjectOfType <CraftingManager>();
     eqSpots      = GetComponentsInChildren <Button>();
 }