Exemplo n.º 1
0
    private void Awake()
    {
        selectedItemScript = GameObject.Find("SelectedItems").GetComponent <UIItemScript>();
        tooltipScript      = GameObject.Find("Tooltip").GetComponent <TooltipScript>();


        spriteImage = GetComponent <Image>();
        UpdateItemFunction(null);
    }
Exemplo n.º 2
0
    //Adds a resource to the dictionary, and to the UI
    public void AddResource(string resourceType, int pickedUpAmount, Sprite graphics)
    {
        if (resourcesDict.ContainsKey(resourceType))
        {
            //update the dictionary key
            int newAmount = resourcesDict[resourceType].amount + pickedUpAmount;
            resourcesDict[resourceType].UIItem.ShowNumber(newAmount);
            resourcesDict[resourceType].amount = newAmount;
        }
        else
        {
            //create the UIItemScript and display the icon
            UIItemScript newUIItem = Instantiate <GameObject>(resourceItemPrefab).GetComponent <UIItemScript>();
            newUIItem.transform.SetParent(inventory, false);

            resourcesDict.Add(resourceType, new ResourceStruct(pickedUpAmount, newUIItem));

            resourcesDict[resourceType].UIItem.ShowNumber(pickedUpAmount);
            resourcesDict[resourceType].UIItem.DisplayIcon(graphics);
        }
    }
Exemplo n.º 3
0
 public ResourceStruct(int a, UIItemScript uiRef)
 {
     amount = a;
     UIItem = uiRef;
 }