Inheritance: Recipe
示例#1
0
    // Properties

    // Components

    // Events

    #endregion

    #region Unity Messages

    private void Awake()
    {
        type      = GetType();
        character = FindObjectOfType <Character>();
        crafting  = FindObjectOfType <Crafting>();
        inventory = character.GetComponent <Inventory>();
    }
示例#2
0
        public static void CraftList(PlayerSetup.Player player)
        {
            if (player.CraftingRecipes == null || player.CraftingRecipes.Count == 0)
            {
                HubContext.Instance.SendToClient("You don't know how to craft anything.", player.HubGuid);
                return;
            }

            var craftlist = "<table><thead><tr><td>Craft Item</td><td>Required</td></tr></thead><tbody>";

            HubContext.Instance.SendToClient("<p>You can craft:</p>", player.HubGuid);

            foreach (var craft in player.CraftingRecipes)
            {
                var canCraft = Crafting.CraftList().FirstOrDefault(x => x.Name.Equals(craft));
                var required = string.Empty;

                if (canCraft?.Materials != null)
                {
                    foreach (var materials in canCraft.Materials)
                    {
                        required += materials.Name + " x" + materials.Count + ",";
                    }

                    craftlist += "<tr><td>" + canCraft.Name + "</td><td>" + required + "</td></tr>";
                }
            }
            craftlist += "</tbody></table>";

            HubContext.Instance.SendToClient(craftlist, player.HubGuid);
        }
示例#3
0
    private void Craft()
    {
        bool crafted      = false;
        var  createdItems = Crafting.Craft(ref crafted);

        // add all items to list, and update inventory

        foreach (var item in createdItems)
        {
            for (int i = 0; i < item.Value; i++)
            {
                Player.ItemCollected(item.Key);
            }
        }

        for (int i = 0; i < 3 && i < CraftingPopup.GetChild(0).childCount; i++)
        {
            var display = CraftingPopup.GetChild(0).GetChild(i);
            display.GetComponentInChildren <Text>().text       = "0";
            display.GetComponentInChildren <Image>().color     = new Color(0.2f, 0.2f, 0.2f);
            display.GetComponentsInChildren <Image>()[1].color = new Color(0, 0, 0, 0);
        }

        CraftingPopup.gameObject.SetActive(false);

        ToggleInventory(Player.transform);
        ToggleInventory(Player.transform);
    }
示例#4
0
    void Open()
    {
        GameObject cam = mov.camera;

        RaycastHit hit;

        if (Physics.Raycast(cam.transform.position, cam.transform.forward, out hit, 14))
        {
            try
            {
                Opened = null;
                Opened = hit.transform.gameObject.GetComponent <Crafting>();

                if (Opened != null)
                {
                    SideTabOpen = !SideTabOpen;

                    if (open == false)
                    {
                        OpenInventory();
                    }

                    Opened.Toggle(inv);
                    CraftingTabEmpty.SetActive(!SideTabOpen);
                    MapEmpty.SetActive(!SideTabOpen);
                }
            }
            catch (NullReferenceException) {}
        }
    }
示例#5
0
    public void Start()
    {
        world    = GameObject.Find("World").GetComponent <World>();
        crafting = GameObject.Find("Crafting").GetComponent <Crafting>();

        icon.sprite = world.blocktypes[recipe.outputItem].icon;
    }
示例#6
0
    // Update is called once per frame
    public void Update()
    {
        Handwerk   = GameObject.Find("Handwerk");
        myCrafting = Handwerk.GetComponent <Crafting>();

        // Stack und Icons im Handwerk anzeigen


        childcounter = this.transform.childCount;
        int        childcountertxt = childcounter - 1;
        string     childcounterstr = childcountertxt.ToString();
        GameObject Slot            = GameObject.Find(this.name);

        if (slot)
        {
            if (this.GetComponent <Image>() != null)
            {
                Name = this.GetComponent <Image>().sprite.name;
            }
        }


        if (childcounter > 1)
        {
            Slot.GetComponentsInChildren <Text>()[0].text = childcounterstr;
            Transform ChildthisSlot = this.gameObject.transform.GetChild(1);
            Sprite    Spritereader  = ChildthisSlot.gameObject.GetComponent <Items>().Icon;
            Slot.gameObject.GetComponent <Image>().sprite = Spritereader;
        }
        if (childcounter == 1 && !Name.Contains("grey"))
        {
            Slot.gameObject.GetComponent <Image>().sprite = SlotItem;
            Slot.GetComponentsInChildren <Text>()[0].text = "0";
        }
    }
示例#7
0
    void Crafters(AllData allData)
    {
        if (allData.crafter != null)
        {
            float[]    craftersData  = allData.crafter.stats;
            int        num           = allData.crafter.numStats;
            int        crafterAmount = craftersData.Length / num;//because every n'th element starts a new box
            string[][] items         = allData.crafter.allItems;
            for (int i = 0; i < crafterAmount; i++)
            {
                Crafting crafter = Instantiate(crafterPrefab, new Vector3(0, 0, 0), Quaternion.identity);
                crafter.GetComponent <Price>().byPass = true;
                crafter.transform.position            = new Vector3(craftersData[(i * num)], craftersData[(i * num) + 1], 0);
                crafter.transform.rotation            = Quaternion.Euler(0, 0, craftersData[(i * num) + 2]);
                crafter.ChangeRecipe(StaticFunctions.GetRecipeFromIndex(Mathf.RoundToInt(craftersData[(i * num) + 3])));

                //now give it items
                for (int j = 0; j < items[i].Length; j++)
                {
                    Item it = Instantiate(StaticFunctions.GetItemFromString(items[i][j]), transform.position, Quaternion.identity);
                    crafter.AddItemToCrafter(it);
                }
            }
        }
    }
示例#8
0
 void Start()
 {
     craftingScript = GameObject.FindObjectOfType <Crafting>();
     Icon           = GetComponent <Image>();
     Text           = transform.GetChild(0).GetComponent <Text>();
     ShowUI();
 }
示例#9
0
 // Use this for initialization
 void Start()
 {
     craftableItems = Crafting.getCraftableItems(PlayerCharacter.Inventory);
     fuelRect       = new Rect(100, 50, buttonWidth, buttonHeight);
     foodRect       = new Rect(50, 100, buttonWidth, buttonHeight);
     cookedRect     = new Rect(150, 100, buttonWidth, buttonHeight);
 }
示例#10
0
 void Awake()
 {
     crafting   = new Crafting(transform, this, splashTextPrefab);
     belt       = transform.Find("Belt");
     health     = GameObject.Find("Canvas/Health").gameObject;
     healthText = new Text[] { health.GetComponent <Text>(), health.transform.GetChild(0).GetComponent <Text>() };
     cellItems  = new Item[cells];
     itemSlots  = new GameObject[cells];
     for (int i = 0; i < cellItems.Length; i++)
     {
         cellItems[i] = items[ID_NULL];
     }
     loadUI();
     loadedItems = Resources.LoadAll("Items/Info", typeof(Item));
     items       = new Item[loadedItems.Length];
     for (int i = 0; i < items.Length; i++)
     {
         items[i] = (Item)loadedItems[i];
     }
     loadedRecipes = Resources.LoadAll("Recipes", typeof(Recipe));
     recipes       = new Recipe[loadedRecipes.Length];
     for (int i = 0; i < recipes.Length; i++)
     {
         recipes[i] = (Recipe)loadedRecipes[i];
     }
 }
 public void UpdateItemWeapon()
 {
     if (ActiveWeapon)
     {
         Crafting.UpdateItemWeapon();
     }
 }
    // Start is called before the first frame update
    void Awake()
    {
        EventTrigger_Init();

        m_Inven    = GameObject.Find("Inven").GetComponent <Inven>();
        m_Crafting = GameObject.Find("Crafting").GetComponent <Crafting>();
    }
    private CaseInsensitiveHashSet GetFavoriteRecipes(Farmer who, bool cooking)
    {
        long id = who.UniqueMultiplayerID;
        CaseInsensitiveHashSet?result;

        if (cooking)
        {
            UserFavorites !.Cooking.TryGetValue(id, out result);
        }
        else
        {
            UserFavorites !.Crafting.TryGetValue(id, out result);
        }

        if (result == null)
        {
            result = new();
            if (cooking)
            {
                UserFavorites !.Cooking.Add(id, result);
            }
            else
            {
                UserFavorites !.Crafting.Add(id, result);
            }
        }

        return(result);
    }
示例#14
0
    private void CraftingWindow(int id)
    {
        if (GUI.Button(new Rect(_craftingWindowRect.width - 22, 2, closeButtonWidth, closeButtonHeight), "", "X Button"))
        {
            _displayCraftingWindow = false;
        }
        _craftingWindowSlider = GUI.BeginScrollView(new Rect(10, 30, _craftingWindowRect.width - 10, (_craftingButtonHeight * craftableItems.Count) + _craftingWindowRect.height), _craftingWindowSlider, new Rect(10, 40, _craftingButtonWidth - 20, _craftingWindowRect.height));


        for (int i = 0; i < craftableItems.Count; i++)
        {
            GUI.Label(new Rect(20, 45 + (32 * i), _craftingWindowRect.width - 30, 24), "Craft: " + craftableItems[i].Name.ToString());
            if (GUI.Button(new Rect(10, 40 + (32 * i), _craftingWindowRect.width - 30, 32), ""))
            {
                for (int j = 0; j < Crafting.recipeList.Count; j++)
                {
                    if (Crafting.recipeList[j].CraftedItem.Id == craftableItems[i].Id)
                    {
                        Crafting.getRecipeItemsAndRemove(Crafting.recipeList[j]);
                        Debug.Log("Removed Items");
                        Crafting.givePlayerItem((Crafting.ItemName)craftableItems[i].Id, 1);
                        craftableItems = Crafting.getCraftableItems(PlayerCharacter.Inventory);
                    }
                }
            }
        }
        GUI.EndScrollView();
        GUI.DragWindow();
    }
示例#15
0
    void Awake()
    {
        crafting = this.GetComponent <Crafting>();

        CraftingPanel  = GameObject.Find(CraftingPath);
        CraftingButton = GameObject.Find(CraftingButtonPath).GetComponent <Button>();
        CraftingButton.onClick.AddListener(() => CraftingControls());
    }
示例#16
0
 void Awake()
 {
     if (instance != null)
     {
         Debug.LogWarning("More than one instance of Inventory found!");
     }
     instance = this;
 }
示例#17
0
 void Start()
 {
     if (CraftingPrefab == null)
     {
         CraftingPrefab = UIModule.UIRoot.GetScreen <Crafting>();
     }
     canCraft = false;
 }
示例#18
0
 void Awake()
 {
     if (instance != null)
     {
         print("More than one instance found");
     }
     instance = this;
 }
示例#19
0
    void Start()
    {
        inventory = Inventory.instance;
        crafting  = Crafting.instance;
        inventory.onItemChangedCallback += UpdateUI;

        slots = itemsParent.GetComponentsInChildren <InventorySlot> ();
    }
示例#20
0
        public async void Start(Canvas Tela)
        {
            await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
            {
                //Debug.WriteLine("Criando HuD");
                // Interface
                interfaceManager = new InterfaceManager(Tela);
                //Debug.WriteLine("HuD Criada");

                // Carregando itens
                Encyclopedia.LoadEncyclopedia();
                QuestList.LoadQuests();

                // Criar o scenario e instanciar o player
                scene = new LevelScene(interfaceManager.CanvasChunck01);

                // Banco de dados
                //Debug.WriteLine("Carregando banco de dados");
                QuestList.LoadQuests();
                Encyclopedia.LoadNPC();
                CraftingEncyclopedia.LoadCraftings();
                // Quests
                player._Questmanager.ReceiveNewQuest(QuestList.allquests[1]);
                player._Questmanager.ReceiveNewQuest(QuestList.allquests[2]);
                player._Questmanager.actualQuest = player._Questmanager.allQuests[1];

                // Criando HuD
                interfaceManager.GenerateHUD();

                // Crafting
                CraftingStation = new Crafting();

                player._Inventory.AddToBag(new Slot(2, 90));
                player._Inventory.AddToBag(new Slot(13, 1));
                player._Inventory.AddToBag(new Slot(21, 1));
                player._Inventory.AddToBag(new Slot(22, 1));
                player._Inventory.AddToBag(new Slot(23, 1));
                player._Inventory.AddToBag(new Slot(24, 1));
                player._Inventory.AddToBag(new Slot(18, 2));

                foreach (Mob mob in mobs)
                {
                    mob.Start();
                }
                // Update
                TUpdate = new Task(Update);
                TUpdate.Start();
            });

            // Carrega interface



            // Draw
            //TDraw = new Task(Draw);
            //TDraw.Start();
        }
示例#21
0
 public void Merge(LootTracking other)
 {
     Magical.Merge(other.Magical);
     Rare.Merge(other.Rare);
     Legendary.Merge(other.Legendary);
     Gems.Merge(other.Gems);
     Crafting.Merge(other.Crafting);
     Keys.Merge(other.Keys);
 }
    // Start is called before the first frame update
    void Start()
    {
        if (_instance != null && _instance != this)
            Destroy(this.gameObject);
        else
            _instance = this;

        InitItemSlots();
    }
示例#23
0
    void Awake()
    {
        Instance = this;

        inventory = FindObjectOfType <Inventory>();
        hotbar    = FindObjectOfType <Hotbar>();
        crafting  = FindObjectOfType <Crafting>();

        cam = Camera.main;
    }
    void Awake()       // Start of game
    {
        if (instance != null)
        {
            print("More than once instance of Crafting found!");
            return;
        }

        instance = this;
    }
示例#25
0
 // Use this for initialization
 void Start()
 {
     Rightarm   = GameObject.Find("Rightarm");
     Leftarm    = GameObject.Find("Leftarm");
     Mouse      = GameObject.Find("Mouse");
     myMouse    = Mouse.GetComponent <Mouse>();
     Handwerk   = GameObject.Find("Handwerk");
     myCrafting = Handwerk.GetComponent <Crafting>();
     myInventar = Handwerk.GetComponent <Inventar>();
 }
示例#26
0
 void Start()
 {
     once = true;
     item_ingredient1_name = setName((int)item_ingredient1);
     item_ingredient2_name = setName((int)item_ingredient2);
     item_ingredient3_name = setName((int)item_ingredient3);
     updateText();
     details = GameObject.FindGameObjectWithTag("DetailsPanel").GetComponent <UpdateDetails>();
     crafter = GameObject.FindGameObjectWithTag("CraftingPanel").GetComponent <Crafting>();
 }
示例#27
0
    private void Awake()
    {
        if (instance != null)
        {
            Debug.LogWarning("WARNNG! There is more that 1 crafing script in this scene!");
            return;
        }

        instance = this;
    }
示例#28
0
 void Start()
 {
     if (myItem == null)
     {
         Destroy(gameObject);
     }
     craftingScript = GameObject.FindObjectOfType <Crafting>();
     Icon           = GetComponent <Image>();
     Icon.sprite    = myItem.itemIcon;
 }
示例#29
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.CompareTag("Enemy"))
     {
         station = collision.GetComponent <Crafting>();
     }
     if (collision.CompareTag("Target") && !pickUp)
     {
         pickUp = collision.gameObject.GetComponent <Log>();
     }
 }
示例#30
0
文件: LootStats.cs 项目: Nksn22/Funky
 public void Merge(LootTracking other)
 {
     Magical.Merge(other.Magical);
     Rare.Merge(other.Rare);
     Legendary.Merge(other.Legendary);
     Gems.Merge(other.Gems);
     Crafting.Merge(other.Crafting);
     Keys.Merge(other.Keys);
     KeyStoneFragments.Merge(other.KeyStoneFragments);
     HoradricCache.Merge(other.HoradricCache);
 }
示例#31
0
 void Awake()
 {
     instance = this;
 }
 void Awake()
 {
     inventoryManager = this;
     crafting = GetComponent<Crafting> ();
 }
 private void Awake()
 {
     InventoryManager = GameObject.FindWithTag("InventoryManager").GetComponent<InventoryManager>();
     Inventory = InventoryManager.Inventory;
     Crafting = InventoryManager.Crafting;
 }
示例#34
0
    public void Populate(int amout, Crafting.ItemName item)
    {
        Item tempItem = Crafting.getItem(item);
        if (amout > 1)
        {
            if (tempItem.Stackable)
            {
                tempItem.ItemsInStack = amout;
            }
        }
        loot.Add(tempItem);
        Debug.Log("Item: " + tempItem.Name);

        _populated = true;
    }