예제 #1
0
    private void initIngredientLineItem(IngredientType type)
    {
        GameObject display = Instantiate(lineItem);

        display.transform.SetParent(transform);

        setSprite(display, "Ingredient", IngredientRenderer.instance().getSprite(type));

        initAspect(type, display, "Dairy", Aspects.Primary.DAIRY);
        initAspect(type, display, "Veggie", Aspects.Primary.PLANT);
        initAspect(type, display, "Meat", Aspects.Primary.MEAT);
        initAspect(type, display, "Grain", Aspects.Primary.GRAIN);

        initAspect(type, display, "Fire", Aspects.Secondary.FIRE);
        initAspect(type, display, "Water", Aspects.Secondary.WATER);
        initAspect(type, display, "Void", Aspects.Secondary.VOID);
        initAspect(type, display, "Slime", Aspects.Secondary.SLIME);
        initAspect(type, display, "Decay", Aspects.Secondary.DECAY);
        initAspect(type, display, "Beast", Aspects.Secondary.BEAST);
        initAspect(type, display, "Seductive", Aspects.Secondary.SEDUCTIVE);

        display.transform.Find("Warning").GetComponent <Button>().onClick.AddListener(() => {
            showHelp();
        });
        updateWarningIcon(Ingredients.instance().getIngredient(type), display);
    }
예제 #2
0
 public void InitializeGameObject()
 {
     GetComponent <SpriteRenderer>().sprite = IngredientRenderer.instance().getSprite(type);
     if (gameObject.GetComponent <PolygonCollider2D>())
     {
         Destroy(gameObject.GetComponent <PolygonCollider2D>());
     }
     gameObject.AddComponent <PolygonCollider2D>();
 }
    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;
    }
예제 #4
0
    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();
            });
        }
    }
예제 #5
0
 private void Awake()
 {
     _ingredientRenderer              = new IngredientRenderer();
     _ingredientRenderer.meshFilter   = _ingredientMesh.GetComponent <MeshFilter>();
     _ingredientRenderer.meshRenderer = _ingredientMesh.GetComponent <MeshRenderer>();
 }