コード例 #1
0
ファイル: InventoryUI.cs プロジェクト: dhog10/LightGame
    void UpdateRecipeSlots()
    {
        int index = 0;

        foreach (InventoryRecipeSlot recipeSlot in recipeSlots)
        {
            bool recipeExists = GameManager.instance.recipes.Length > index;

            InventoryRecipe recipe = null;

            if (recipeExists)
            {
                recipe = GameManager.instance.recipes[index];
            }

            if (recipeExists)
            {
                recipeSlot.hasRecipe = true;
                recipeSlot.recipe    = recipe;
            }
            else
            {
                recipeSlot.hasRecipe = false;
            }

            recipeSlot.UpdateSlot();

            index++;
        }
    }
コード例 #2
0
    public void SetLinkedMachine(GameObject machine)
    {
        CraftingManagerRecipe craftingManagerRecipe;
        CraftingManagerFixed  craftingManagerFixed;

        if (machine == null)
        {
            this.craftingManagerFixed  = null;
            this.craftingManagerRecipe = null;
            this.inventoryFixed        = null;
            this.inventoryRecipe       = null;
            GetComponent <MenuSlideOut>().TogglePanel(MenuSlideOut.PanelState.panelIn);
        }
        else if (machine.TryGetComponent(out craftingManagerFixed))
        {
            this.craftingManagerRecipe = null;
            this.craftingManagerFixed  = craftingManagerFixed;
            recipeSelector.SetActive(false);
            inventoryFixed  = machine.GetComponent <InventoryFixed>();
            inventoryRecipe = null;
            GetComponent <MenuSlideOut>().TogglePanel(MenuSlideOut.PanelState.panelOut);
        }
        else if (machine.TryGetComponent(out craftingManagerRecipe))
        {
            this.craftingManagerFixed  = null;
            this.craftingManagerRecipe = craftingManagerRecipe;
            recipeSelector.SetActive(true);
            inventoryRecipe = machine.GetComponent <InventoryRecipe>();
            inventoryFixed  = null;
            GetComponent <MenuSlideOut>().TogglePanel(MenuSlideOut.PanelState.panelOut);
            recipePanel.GetComponent <CraftingUI>().SetLinkedInventory(inventoryRecipe);
        }
    }
コード例 #3
0
    // Start is called before the first frame update
    void Start()
    {
        inventoryRecipe = GetComponent <InventoryRecipe>();
        ContactFilter2D filter;

        filter              = new ContactFilter2D();
        filter.layerMask    = mask;
        filter.useTriggers  = true;
        filter.useLayerMask = true;
        Collider2D[] collider = new Collider2D[1];
        if (Physics2D.OverlapBox(transform.position, GetComponent <BoxCollider2D>().size, 0, filter, collider) == 1)
        {
            warehouse = collider[0].gameObject.transform.parent.GetComponent <WarehouseManager>();
        }
    }
コード例 #4
0
 // Start is called before the first frame update
 void Start()
 {
     inventory = GetComponent <InventoryRecipe>();
     TryGetComponent(out animator);
     TryGetComponent(out spriteRenderer);
     if (idleSprite != "")
     {
         idleSpriteCode = Animator.StringToHash(idleSprite);
     }
     if (animationSprite != "")
     {
         animationSpriteCode = Animator.StringToHash(animationSprite);
     }
     if (animator != null)
     {
         animator.speed = 0;
     }
     if (inventory == null) //if there is no inventory, this can't do anything and should not exist
     {
         Destroy(this);
     }
 }