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); }
public void UpdateIngredientDetails() { effects = ingredient.effects; effectIntensities = ingredient.effectIntensities; UIname.GetComponent <UnityEngine.UI.Text>().text = ingredient.ingredientName; if (ingredient.description == "") { UIdescription.transform.localScale = new Vector3(0, 0, 0); UIimage_noDescription.GetComponent <UnityEngine.UI.Image>().sprite = ingredient.inventorySprite; UIimage_withDescription.transform.localScale = new Vector3(0, 0, 0); UIimage_noDescription.transform.localScale = new Vector3(1, 1, 1); } else { UIimage_withDescription.GetComponent <UnityEngine.UI.Image>().sprite = ingredient.inventorySprite; UIimage_withDescription.transform.localScale = new Vector3(1, 1, 1); UIimage_noDescription.transform.localScale = new Vector3(0, 0, 0); UIdescription.transform.localScale = new Vector3(1, 1, 1); UIdescription.GetComponent <UnityEngine.UI.Text>().text = ingredient.description; } // adjust the graphical intensity indicators for (int i = 0; i < effectPanels.Count; i++) { effectPanels[i].localScale = new Vector3(0, 0, 0); //Debug.Log(i); //Debug.Log(JobsManagement.activeJobList.Count); if (i < effects.Count) { effectPanels[i].localScale = new Vector3(1, 1, 1); //Debug.Log(i + "set to visible, local scale: " + effectPanels[i].localScale); //Debug.Log(i); // CAREFUL: THIS STUFF IS ORDERING SENSITIVE. YOU MESS WITH THE ORDERING, YOU MESS WITH THE CONTENTS, YO! //Debug.Log(i); effectPanels[i].GetChild(1).gameObject.GetComponent <UnityEngine.UI.Text>().text = effects[i].effectName + ": "; switch (IngredientEffect.IntensityTypeIntToEnum(effectIntensities[i])) { case IngredientEffect.EffectIntensity.EXTREME_NEGATIVE: effectPanels[i].GetChild(1).gameObject.GetComponent <UnityEngine.UI.Text>().text += effects[i].stringLowerM100; break; case IngredientEffect.EffectIntensity.STRONG_NEGATIVE: effectPanels[i].GetChild(1).gameObject.GetComponent <UnityEngine.UI.Text>().text += effects[i].stringM100ToM50; break; case IngredientEffect.EffectIntensity.SLIGHT_NEGATIVE: effectPanels[i].GetChild(1).gameObject.GetComponent <UnityEngine.UI.Text>().text += effects[i].stringM50To0; break; case IngredientEffect.EffectIntensity.EXTREME_POSITIVE: effectPanels[i].GetChild(1).gameObject.GetComponent <UnityEngine.UI.Text>().text += effects[i].stringHigher100; break; case IngredientEffect.EffectIntensity.STRONG_POSITIVE: effectPanels[i].GetChild(1).gameObject.GetComponent <UnityEngine.UI.Text>().text += effects[i].string50To100; break; case IngredientEffect.EffectIntensity.SLIGHT_POSITIVE: effectPanels[i].GetChild(1).gameObject.GetComponent <UnityEngine.UI.Text>().text += effects[i].string0To50; break; } //adjust fill amount and transparency if (effectIntensities[i] > 0) { Debug.Log(effectPanels[i].GetChild(3)); Debug.Log(i + "positive"); effectPanels[i].GetChild(2).GetChild(0).gameObject.GetComponent <UnityEngine.UI.Image>().color = new Color(0.6603774f, 0.6375712f, 0.5326629f, 0.3f); effectPanels[i].GetChild(2).GetChild(1).gameObject.GetComponent <UnityEngine.UI.Image>().fillAmount = 0f; effectPanels[i].GetChild(2).GetChild(2).gameObject.GetComponent <UnityEngine.UI.Image>().color = new Color(1f, 1f, 1f, 0.3f); effectPanels[i].GetChild(3).GetChild(0).gameObject.GetComponent <UnityEngine.UI.Image>().color = new Color(0.6603774f, 0.6375712f, 0.5326629f, 1f); effectPanels[i].GetChild(3).GetChild(1).gameObject.GetComponent <UnityEngine.UI.Image>().fillAmount = (Mathf.Abs((float)effectIntensities[i])) / 100; effectPanels[i].GetChild(3).GetChild(2).gameObject.GetComponent <UnityEngine.UI.Image>().color = new Color(1f, 1f, 1f, 1f); } else { Debug.Log(effectPanels[i].GetChild(2)); Debug.Log(i + "negative"); effectPanels[i].GetChild(2).GetChild(0).gameObject.GetComponent <UnityEngine.UI.Image>().color = new Color(0.6603774f, 0.6375712f, 0.5326629f, 1f); effectPanels[i].GetChild(2).GetChild(1).gameObject.GetComponent <UnityEngine.UI.Image>().fillAmount = (Mathf.Abs((float)effectIntensities[i])) / 100; effectPanels[i].GetChild(2).GetChild(2).gameObject.GetComponent <UnityEngine.UI.Image>().color = new Color(1f, 1f, 1f, 1f); effectPanels[i].GetChild(3).GetChild(0).gameObject.GetComponent <UnityEngine.UI.Image>().color = new Color(0.6603774f, 0.6375712f, 0.5326629f, 0.3f); effectPanels[i].GetChild(3).GetChild(1).gameObject.GetComponent <UnityEngine.UI.Image>().fillAmount = 0f; effectPanels[i].GetChild(3).GetChild(2).gameObject.GetComponent <UnityEngine.UI.Image>().color = new Color(1f, 1f, 1f, 0.3f); } // adjust foreground fill colors effectPanels[i].GetChild(2).GetChild(1).gameObject.GetComponent <UnityEngine.UI.Image>().color = effects[i].negativeColor; effectPanels[i].GetChild(3).GetChild(1).gameObject.GetComponent <UnityEngine.UI.Image>().color = effects[i].positiveColor; //adjust indicator icon float adjustedOffset; adjustedOffset = effectIntensities[i]; if (adjustedOffset < -100) { adjustedOffset = -100; } if (adjustedOffset > 100) { adjustedOffset = 100; } effectPanels[i].GetChild(4).gameObject.GetComponent <RectTransform>().anchoredPosition = new Vector2(375 + adjustedOffset * 375 / 100, effectPanels[i].GetChild(4).gameObject.GetComponent <RectTransform>().anchoredPosition.y); } } }