コード例 #1
0
    //using a generic OnClick() function to link the Button component's commands to this script. Useful for Computer & Touch Devices.
    public void OnClick()
    {
        //if our current ingredient IS the ingredient held, do NOTHING
        if (_slotIngredient.IngredientData == _craftingController.CurrIngredient)
        {
            return;
        }

        //otherwise (our ingredient is different than _crafting.controller's, make the swap
        Ingredients_sObj heldIngredient = _craftingController.CurrIngredient;

        if (heldIngredient.Quantity != 0)    //>0 would exclude our -1 values, which are our Infinite values
        {
            //give one back to previous "current" ingredient,
            _slotIngredient.IngredientData.IncreaseQuantity(1);

            //set our ingredient to the new Ingredient_sObj, then take 1 away
            _slotIngredient.SetIngredient(heldIngredient);
            heldIngredient.DecreaseQuantity(1);
        }
        else
        {
            //if our ingredient IS == 0, we have run out of a natural ingredient type
            //we force the _craftingController to "drop" the ingredient and return to NULL
            _craftingController.HoldIngredient(_nullIngredient);
            Debug.Log("Cannot use " + heldIngredient.Name);
        }
    }
コード例 #2
0
    public void SetIngredient(Ingredients_sObj ingredient)
    {
        _currentSold = 0;

        title.text       = ingredient.Name;
        price.text       = ingredient.Cost.ToString();
        itemImage.sprite = ingredient.Image;
        selfIngredient   = ingredient;

        _sellLimit = _sellFoundation - ingredient.Cost;
    }
コード例 #3
0
 public void HoldIngredient(Ingredients_sObj ingredient)
 {
     //called from the HotBar script, tells the controller to remember the data passed from the HotBar's _ingred
     CurrIngredient = ingredient;
 }
コード例 #4
0
 public void SetIngredient(Ingredients_sObj ingred)
 {
     display.SetIngredient(ingred);
 }
コード例 #5
0
 public void SetIngredientHistory(Ingredients_sObj ingred)
 {
     _ingredientHistory = ingred;
     CreateHistorySlots();
     UpdateHistories();
 }
コード例 #6
0
 override protected void Awake()
 {
     _nullIngredient = _slotIngredient.IngredientData;
 }
コード例 #7
0
    public void SetIngredient(Ingredients_sObj inputIngredient)
    {
        _ingredient = inputIngredient;

        Display();
    }
コード例 #8
0
 public void SetIngredient(Ingredients_sObj ingredient)
 {
     _ingredientData = ingredient;
     UpdateDisplaySprite();
 }