public void showInfo(Vector3 location, Aspects.Primary primary, Aspects.Secondary secondary) { panel.transform.position = new Vector3(location.x, location.y, panel.transform.position.z); this.primary.sprite = Aspects.instance().getNormalSprite(primary); this.secondary.sprite = Aspects.instance().getNormalSprite(secondary); panel.SetActive(true); }
private void initAspect(IngredientType ingredient, GameObject lineItemInstance, String childName, Aspects.Primary aspect) { GameObject iconButton = lineItemInstance.transform.Find(childName).gameObject; iconButton.GetComponent <Image>().sprite = Aspects.instance().getGreyedSprite(aspect); IngredientData.GuessState currentGuess = Ingredients.instance().getIngredient(ingredient).getGuessState(aspect); switch (currentGuess) { case IngredientData.GuessState.UNKNOWN: iconButton.GetComponent <Image>().sprite = Aspects.instance().getGreyedSprite(aspect); break; case IngredientData.GuessState.HAS: iconButton.GetComponent <Image>().sprite = Aspects.instance().getNormalSprite(aspect); break; case IngredientData.GuessState.NOT_HAS: iconButton.GetComponent <Image>().sprite = Aspects.instance().getDisabledSprite(aspect); break; } iconButton.GetComponent <Button>().onClick.AddListener(() => { IngredientData data = Ingredients.instance().getIngredient(ingredient); IngredientData.GuessState guess = data.getGuessState(aspect); IngredientData.GuessState next = IngredientData.GuessState.UNKNOWN; Image icon = iconButton.GetComponent <Image>(); switch (guess) { case IngredientData.GuessState.UNKNOWN: next = IngredientData.GuessState.HAS; icon.sprite = Aspects.instance().getNormalSprite(aspect); break; case IngredientData.GuessState.HAS: next = IngredientData.GuessState.NOT_HAS; icon.sprite = Aspects.instance().getDisabledSprite(aspect); break; case IngredientData.GuessState.NOT_HAS: next = IngredientData.GuessState.UNKNOWN; icon.sprite = Aspects.instance().getGreyedSprite(aspect); break; } data.setGuessState(aspect, next); updateWarningIcon(data, lineItemInstance); }); }
public void notifyIngredientAdded(List <IngredientType> ingredients) { for (int i = 0; i < ingredients.Count && i < 3; i++) { Slot slot = slots[i]; IngredientType type = ingredients[i]; slot.ingredient.sprite = IngredientRenderer.instance().getSprite(type); slot.ingredient.color = Color.white; IngredientData ingredient = Ingredients.instance().getIngredient(type); slot.primary.sprite = Aspects.instance().getNormalSprite(ingredient.getPrimaryGuess()); slot.primary.color = Color.white; slot.secondary.sprite = Aspects.instance().getNormalSprite(ingredient.getSecondaryGuess()); slot.secondary.color = Color.white; } nFilledSlots = ingredients.Count; }
public void showPotionsTab() { foreach (Transform child in gameObject.transform) { Destroy(child.gameObject); } foreach (CreatedPotion potion in Potions.instance().getLoggedPotions()) { GameObject potionDisplay; MultiSet <Aspects.Secondary> secondaries = potion.getPotion().getSecondaries(); if (secondaries.Count == 0) { // Potion has no secondaries potionDisplay = Instantiate(lineItemPrefab); } else { // Potion has secondaries potionDisplay = Instantiate(lineItemWithSecondariesPrefab); int i = 0; foreach (Aspects.Secondary aspect in secondaries) { GameObject icon = potionDisplay.transform.Find("Potion Details/Aspect Icons Secondary/Aspect " + (i + 1)).gameObject; icon.GetComponent <Image>().sprite = Aspects.instance().getNormalSprite(aspect); i++; } while (i < 3) { GameObject icon = potionDisplay.transform.Find("Potion Details/Aspect Icons Secondary/Aspect " + (i + 1)).gameObject; Destroy(icon); i++; } } potionDisplay.transform.SetParent(transform); List <IngredientType> ingredients = potion.getIngredients(); for (int i = 0; i < 3; i++) { potionDisplay.transform.Find("Ingredient Image " + (i + 1)).gameObject.GetComponent <Image>().sprite = IngredientRenderer.instance().getSprite(ingredients[i]); } Image bodyPartImage1 = potionDisplay.transform.Find("Potion Details/Potion Image").gameObject.GetComponent <Image>(); Image bodyPartImage2 = potionDisplay.transform.Find("Potion Details/Potion Image 2").gameObject.GetComponent <Image>(); bodyPartImage1.sprite = dudPotionSprite; bodyPartImage2.gameObject.SetActive(false); BodyPart[] parts = potion.getPotion().getAffectedBodyParts(); if (parts.Length > 0) { Sprite sprite = PlayerSprites.instance().getSprite(potion.getPotion().getType(), parts[0]); // Special cases for wings and tail if (sprite == null && parts[0] == BodyPart.WINGS) { sprite = noWingsSprite; } else if (sprite == null && parts[0] == BodyPart.TAIL) { sprite = noTailSprite; } else { bodyPartImage1.gameObject.SetActive(sprite != null); } bodyPartImage1.sprite = sprite; } if (parts.Length > 1) { bodyPartImage2.sprite = PlayerSprites.instance().getSprite(potion.getPotion().getType(), parts[1]); bodyPartImage2.gameObject.SetActive(bodyPartImage2.sprite != null); } int j = 1; foreach (Aspects.Primary primary in potion.getPotion().getPrimaries()) { potionDisplay.transform.Find("Potion Details/Aspect Icons/Aspect " + j).gameObject.GetComponent <Image>().sprite = Aspects.instance().getNormalSprite(primary); j++; } CreatedPotion potion2 = potion; potionDisplay.transform.Find("Remove Button").GetComponent <Button>().onClick.AddListener(() => { Potions.instance().removeLoggedPotion(potion2); showPotionsTab(); }); } }