Пример #1
0
    void Awake()
    {
        if (UIRoot.GetPlayer() != null)
        {
            playerInventory = UIRoot.GetPlayer().GetComponent <ResourceInventory>();

            AddNewText("Select resource from dropdown to add 50 of that resource");

            var resourceDropDown = Instantiate(DropDown);
            resourceDropDown.transform.SetParent(vLayoutGroup.transform);

            foreach (var resource in resourceList)
            {
                resourceNamesList.Add(resource.DisplayName);

                if (resource.DisplayName == "Thruster Fuel")
                {
                    fuel = resource;
                }
            }

            resourceDropDown.options.Clear();

            resourceDropDown.AddOptions(resourceNamesList);
            resourceDropDown.onValueChanged.AddListener(evt =>
            {
                playerInventory.TryAdd(resourceList[resourceDropDown.value], 50);
            });

            AddNewButton("Kill Octo", () => { playerInventory.SetResource(fuel, 0f); });

            fuelStat = AddNewText("Fuel Stat: " + playerInventory.GetResource(fuel));
        }
    }