public void PrepareAutoTransferTarget()
 {
     // set auto transfer target parent, so the auto transfer from the inventory knows where to put items when this canvas has been opened
     if (itemAutoTransferTargetParent != null)
     {
         // Debug.Log("AUTOPARENT FATHER SET");
         InventoryItemHandler.SetAutoTransferTargetParent(itemAutoTransferTargetParent);
     }
 }
Ejemplo n.º 2
0
    public ItemAmountSuitable CheckItemAmoundSuitable(InventoryItemHandler item)
    {
        if (item.ingredientTypeAmounts.Sum() < requestedAmount)
        {
            return(ItemAmountSuitable.TOO_LITTLE);
        }

        if (item.ingredientTypeAmounts.Sum() == requestedAmount)
        {
            return(ItemAmountSuitable.CORRECT);
        }

        return(ItemAmountSuitable.TOO_MUCH);
    }
Ejemplo n.º 3
0
    public void CloseContainerView()
    {
        //Debug.Log("close cauld");
        transform.GetChild(0).localScale = new Vector3(0, 0, 0);
        GameObject.Find("PanelInventory").GetComponent <RectTransform>().anchorMin = new Vector2(0.5f, 1);
        GameObject.Find("PanelInventory").GetComponent <RectTransform>().anchorMax = new Vector2(0.5f, 1);
        GameObject.Find("PanelInventory").GetComponent <RectTransform>().pivot     = new Vector2(0.5f, 0.5f);
        LeanTween.moveX(GameObject.Find("PanelInventory").GetComponent <RectTransform>(), 35, 0);
        inventoryUIBehaviour.isLocked = false;
        inventoryUIBehaviour.CloseInventory();
        inventoryUIBehaviour.ShowButton();
        GameObject.Find("PanelTransferAmount").transform.localScale = new Vector3(0, 0, 0);

        InventoryItemHandler.ResetAutoTransferTargetParent();
    }
Ejemplo n.º 4
0
 void Start()
 {
     InventoryItemHandler.ResetAutoTransferTargetParent();
 }
Ejemplo n.º 5
0
    public ItemTypeSuitable CheckItemTypeSuitable(InventoryItemHandler item)
    {
        if (requestedIngredientType != null)
        {
            if (requestedIngredientType == item.ingredientTypes[0] && item.ingredientTypes.Count == 1)
            {
                return(ItemTypeSuitable.CORRECT_INVENTORYITEM);
            }
            else
            {
                return(ItemTypeSuitable.WRONG_INVENTORYITEM);
            }
        }
        else
        {
            for (int i = 0; i < requestedEffects.Count; i++)
            {
                IngredientEffect tempJobeffect = requestedEffects[i];
                Debug.Log("Effect loop for effect: " + tempJobeffect.effectName + "checking if there is a fitting item effect. Loop: " + i + " / " + requestedEffects.Count);

                // if an effect is missing or to weak: WRONG EFFECT
                if (item.IngredientEffects.Contains(tempJobeffect))
                {
                    Debug.Log("Effect " + tempJobeffect.effectName + "is present in the item. Intensity check following.");
                    // if one of the requested effect intensities is not being met --> WRONG EFFECT

                    Debug.Log("Effect " + tempJobeffect.effectName + "; requested intensity: " + /*(int)*/ requestedEffectIntensities[i] + "; requested intensity operator: " + requestedEffectIntensityOperators[i] + "; item intensity: " + IngredientEffect.IntensityTypeIntToEnum(item.IngredientEffectIntensities[item.IngredientEffects.FindIndex(s => s.Equals(tempJobeffect))]));

                    float itemIntensity = item.IngredientEffectIntensities[item.IngredientEffects.FindIndex(s => s.Equals(tempJobeffect))];

                    Debug.Log(itemIntensity);
                    Debug.Log((int)requestedEffectIntensities[i]);

                    switch (requestedEffectIntensityOperators[i])
                    {
                    case ExpectedEffectIntensityOperator.LOWER_OR_EQUAL:


                        if ((int)IngredientEffect.IntensityTypeIntToEnum(itemIntensity) > (int)requestedEffectIntensities[i])
                        {
                            Debug.Log("Effect " + tempJobeffect.effectName + "intensity not fitting lower or equal not met");
                            return(ItemTypeSuitable.WRONG_EFFECT);
                        }

                        break;

                    case ExpectedEffectIntensityOperator.EXACTLY_EQUAL:

                        if (IngredientEffect.IntensityTypeIntToEnum(itemIntensity) != requestedEffectIntensities[i])
                        {
                            Debug.Log("Effect " + tempJobeffect.effectName + "intensity not fitting equal not met");
                            return(ItemTypeSuitable.WRONG_EFFECT);
                        }

                        break;

                    case ExpectedEffectIntensityOperator.HIGHER_OR_EQUAL:

                        if ((int)IngredientEffect.IntensityTypeIntToEnum(itemIntensity) < (int)requestedEffectIntensities[i])
                        {
                            Debug.Log("Effect " + tempJobeffect.effectName + "intensity not fitting because higher or equal not met");
                            return(ItemTypeSuitable.WRONG_EFFECT);
                        }

                        break;
                    }
                }
                // effect not present at all --> fail
                else
                {
                    Debug.Log("Effect " + tempJobeffect.effectName + "not found at all in item effects");
                    return(ItemTypeSuitable.WRONG_EFFECT);
                }

                Debug.Log("All effects are there in the correct intensity");
            }
            // if we got this far then the requested effects are being met. time to see if there are sideeffects.
            if (ignoreSideffectsForItemSuitableChecks)
            {
                Debug.Log("Side effects are being ignored.");
                return(ItemTypeSuitable.CORRECT_EFFECT_WITHOUT_UNWANTED_HARMFUL_SIDEFFECTS);
            }
            else
            {
                Debug.Log("Side effects are not being ignored. Now iterating through all present item effects, to see if any are harmful");
                for (int e = 0; e < item.IngredientEffects.Count; e++)
                {
                    Debug.Log("effect: " + item.IngredientEffects[e].effectName);
                    Debug.Log((requestedEffects.Contains(item.IngredientEffects[e])));
                    if (requestedEffects.Contains(item.IngredientEffects[e]))
                    {
                        Debug.Log(e + " Effect is present in job effects, and therefore not relevant for side effect determination");
                    }
                    else
                    {
                        Debug.Log(e + " Effect is not present in job effects --> check if it is a relevant side effect");
                        if (item.IngredientEffectIntensities[e] != 0)
                        {
                            IngredientEffect effect = item.IngredientEffects[e];

                            Debug.Log(" effect type: " + effect.intensityType + "; intensity: " + item.IngredientEffectIntensities[e]);

                            switch (effect.intensityType)
                            {
                            case IngredientEffect.IntensityType.IRRELEVANT:
                                Debug.Log(e + " effect type irrelevant");
                                break;

                            case IngredientEffect.IntensityType.ZERO_IS_HEALTHY:
                                if (item.IngredientEffectIntensities[e] == 0)
                                {
                                }

                                else
                                {
                                    return(ItemTypeSuitable.CORRECT_EFFECT_WITH_UNWANTED_HARMFUL_SIDEFFECTS);
                                }
                                break;

                            case IngredientEffect.IntensityType.MAXIMUM_IS_HEALTHY:
                                if (item.IngredientEffectIntensities[e] >= 0)
                                {
                                }

                                else
                                {
                                    return(ItemTypeSuitable.CORRECT_EFFECT_WITH_UNWANTED_HARMFUL_SIDEFFECTS);
                                }
                                break;

                            case IngredientEffect.IntensityType.MINIMUM_IS_HEALTHY:
                                if (item.IngredientEffectIntensities[e] <= 0)
                                {
                                }

                                else
                                {
                                    return(ItemTypeSuitable.CORRECT_EFFECT_WITH_UNWANTED_HARMFUL_SIDEFFECTS);
                                }
                                break;
                            }
                        }
                    }
                }
            }
        }
        return(ItemTypeSuitable.CORRECT_EFFECT_WITHOUT_UNWANTED_HARMFUL_SIDEFFECTS);
    }
Ejemplo n.º 6
0
    public void PutItemIntoSlot(InventoryItemHandler incomingItem)
    {
        GameObject incomingItemOriginalSlot = incomingItem.transform.parent.gameObject;

        // Put item in slot if slot is empty
        if (transform.childCount == 0)
        {
            incomingItem.transform.SetParent(transform);
            incomingItem.GetComponent <RectTransform>().anchoredPosition = new Vector3(0, 0, 0);
        }

        // if itemslot is not empty, check if a merge is appicable (1 ingredient incoming, 1 ingredient existing, same ingredients incoming and existing)
        else
        {
            if
            (
                (incomingItem.GetComponent <InventoryItemHandler>().ingredientTypes.Count == 1)
                &&
                (transform.GetChild(0).gameObject.GetComponent <InventoryItemHandler>().ingredientTypes.Count == 1)
                &&
                (incomingItem.GetComponent <InventoryItemHandler>().ingredientTypes[0] == transform.GetChild(0).gameObject.GetComponent <InventoryItemHandler>().ingredientTypes[0])
            )
            {   // its the same ingredient type: merge items
                //Debug.Log("FIT FOR MERGE");
                int   amountIncoming      = incomingItem.GetComponent <InventoryItemHandler>().ingredientTypeAmounts[0];
                int   amountInSlot        = transform.GetChild(0).gameObject.GetComponent <InventoryItemHandler>().ingredientTypeAmounts[0];
                int   amountTotal         = amountInSlot + amountIncoming;
                float temperatureIncoming = incomingItem.GetComponent <InventoryItemHandler>().temperature;
                float temperatureInSlot   = transform.GetChild(0).gameObject.GetComponent <InventoryItemHandler>().temperature;

                // set temperature
                transform.GetChild(0).gameObject.GetComponent <InventoryItemHandler>().temperature = temperatureIncoming * ((float)amountIncoming / (float)amountTotal) + temperatureInSlot * ((float)amountInSlot / (float)amountTotal);

                // set amount
                transform.GetChild(0).gameObject.GetComponent <InventoryItemHandler>().ingredientTypeAmounts[0] = amountTotal;

                // delete the incoming object if incoming item != the existing item in slot
                //if(incomingItem.gameObject != transform.GetChild(0).gameObject)
                incomingItem.gameObject.GetComponent <InventoryItemHandler>().DeleteInstanceOfInventoryItem();

                // update item in slot

                transform.GetChild(0).gameObject.GetComponent <InventoryItemHandler>().UpdateItemContent();
            }
            else
            {   // its not the same ingredient type or there are mixtures involved: switch items around if slot already is full (and its two different items)
                //Debug.Log("NOT FIT FOR MERGE");

                originalSlotItem = transform.GetChild(0);
                originalSlotItem.transform.SetParent(incomingItem.GetComponent <DragAndDrop>().startParent);
                originalSlotItem.GetComponent <RectTransform>().anchoredPosition = new Vector3(0, 0, 0);

                // scale item
                Debug.Log(originalSlotItem);
                float uiScaleOriginalSlot = originalSlotItem.transform.parent.gameObject.GetComponent <ItemSlotHandler>().uiScale;


                if (uiScaleOriginalSlot != 0)
                {
                    originalSlotItem.gameObject.GetComponent <RectTransform>().localScale = new Vector3(uiScaleOriginalSlot, uiScaleOriginalSlot, uiScaleOriginalSlot);
                }
                else
                {
                    originalSlotItem.gameObject.GetComponent <RectTransform>().localScale = new Vector3(1, 1, 1);
                }


                // move incoming item into this slot
                incomingItem.transform.SetParent(transform);
                incomingItem.GetComponent <RectTransform>().anchoredPosition = new Vector3(0, 0, 0);
            }
        }

        // scale item

        if (uiScale != 0)
        {
            incomingItem.GetComponent <RectTransform>().localScale = new Vector3(uiScale, uiScale, uiScale);
        }
        else
        {
            incomingItem.GetComponent <RectTransform>().localScale = new Vector3(1, 1, 1);
        }


        // update transfer buttons of origin (if applicable)
        //Debug.Log(incomingItemOriginalSlot);
        //Debug.Log(incomingItemOriginalSlot.transform.parent);

        if (incomingItemOriginalSlot.name != "CanvasDragItem")
        {
            foreach (Transform child in incomingItemOriginalSlot.transform.parent)
            {
                //Debug.Log(child.gameObject);
                if (child.gameObject.name == "ButtonTransferIntoContainer")
                {
                    child.gameObject.GetComponent <TransferIntoContainerHandler>().updateButtonActive();
                }

                if (child.gameObject.name == "ButtonTransferOutOfContainer")
                {
                    child.gameObject.GetComponent <TransferOutOfContainerHandler>().updateButtonActive();
                }

                if (child.gameObject.name == "ButtonStartCentrifuge")
                {
                    child.gameObject.GetComponent <CentrifugeHandler>().updateButtonActive();
                }

                if (child.gameObject.name == "ButtonSubmitInventoryItem")
                {
                    //Debug.Log("Origin");
                    child.gameObject.GetComponent <SubmitAlchemicumButton>().canvas.GetComponent <JobDetails>().UpdateSubmitButton();
                    child.gameObject.GetComponent <SubmitAlchemicumButton>().canvas.GetComponent <JobDetails>().UpdateItemSubmissionInfoText();
                }
            }

            incomingItemOriginalSlot.GetComponent <ItemSlotHandler>().UpdateSlotVisibility();

            // update button if quick takeout from the output itemslot happens
            //Debug.Log(incomingItemOriginalSlot.transform.parent.parent.parent.gameObject);
            foreach (Transform child in incomingItemOriginalSlot.transform.parent.parent.parent)
            {
                if (child.gameObject.name == "PanelTransfer")
                {
                    foreach (Transform child2 in child)
                    {
                        if (child2.gameObject.name == "ButtonStartCentrifuge")
                        {
                            child2.gameObject.GetComponent <CentrifugeHandler>().updateButtonActive();
                        }
                    }
                }
            }
        }



        // update transfer buttons of target (if applicable)
        foreach (Transform child in transform.parent)
        {
            if (child.gameObject.name == "ButtonTransferIntoContainer")
            {
                child.gameObject.GetComponent <TransferIntoContainerHandler>().updateButtonActive();
            }

            if (child.gameObject.name == "ButtonTransferOutOfContainer")
            {
                child.gameObject.GetComponent <TransferOutOfContainerHandler>().updateButtonActive();
            }

            if (child.gameObject.name == "ButtonStartCentrifuge")
            {
                child.gameObject.GetComponent <CentrifugeHandler>().updateButtonActive();
            }

            if (child.gameObject.name == "ButtonSubmitInventoryItem")
            {
                Debug.Log("Target");
                child.gameObject.GetComponent <SubmitAlchemicumButton>().canvas.GetComponent <JobDetails>().UpdateSubmitButton();
                child.gameObject.GetComponent <SubmitAlchemicumButton>().canvas.GetComponent <JobDetails>().UpdateItemSubmissionInfoText();
            }
        }

        UpdateSlotVisibility();
    }
Ejemplo n.º 7
0
 public static void CompleteJob(JobHandler job, InventoryItemHandler inventoryItem)
 {
     Debug.Log("job completed: " + job.title);
     Debug.Log(inventoryItem);
 }