Пример #1
0
    public void DemolishActionSelected(string s)
    {
        //Debug.Log("DemolishActionSelected");
        // Delete buttons
        //Debug.Log("Clear UI");
        ClearUIObjects();

        string txt = "Demolition\nTears down the current structure\n";

        if (jobDescriptionText == null)
        {
            jobDescriptionText = UIElementFunctions.TextOnly(jobsPanel.transform, txt, new Vector3(180, -50), new Vector2(300, 100));
        }
        else
        {
            jobDescriptionText.textGo.text = txt;
        }
        // Add prerequisites, colored, here

        // Buttons to make it go
        //Debug.Log("ResourceDropdownCreator");
        resourceChoiceDropdown = ResourceDropdownCreator.CreateNoResourceDropdown(tileDetailUiPanel.transform, new Vector3(-200, -185), "Demolition", ManagerBase.domain, null);
        resourceChoiceDropdown.jobStartButton.buttonGo.onClick.AddListener(delegate() { StartDemolitionJobButton(); });
        //Debug.Log("Done DemolishActionSelected");
    }
Пример #2
0
    public void BuildActionSelected(string s)
    {
        // Delete buttons
        ClearUIObjects();

        BuildingDef buildingSelected = ManagerBase.buildingDefinitions[ManagerBase.buildingIndexOf[s]];

        if (buildingSelected == null)
        {
            Debug.LogError("Should not have an unbuildable building here: " + s);
        }

        string txt = buildingSelected.name + "\n" + buildingSelected.description + "\n";

        if (jobDescriptionText == null)
        {
            jobDescriptionText = UIElementFunctions.TextOnly(jobsPanel.transform, txt, new Vector3(180, -50), new Vector2(300, 100));
        }
        else
        {
            jobDescriptionText.textGo.text = txt;
        }
        // Add prerequisites, colored, here

        // Figure out what the building needs
        resourceChoiceDropdown = ResourceDropdownCreator.CreateResourceChoiceDropdown(tileDetailUiPanel.transform, new Vector3(-200, -185), buildingSelected.resourcesToBuild, buildingSelected.name, ManagerBase.domain, buildingSelected.sprite);

        resourceChoiceDropdown.jobStartButton.buttonGo.onClick.AddListener(delegate() { StartConstructionJobButton(); });
    }
Пример #3
0
    public void ProcessJobComplete(DomainEventArg de)
    {
        CustomUIElement newEvent = UIElementFunctions.ButtonImageText(eventVlgRect.transform, null, de.message, new Vector3(0, 0, 0), new Vector2(0, 0));
        LayoutElement   element  = newEvent.thisGo.AddComponent <LayoutElement>();

        element.minHeight = this.jobEventHeight;
        uiElements.Add(new EventPanelButton(newEvent, jobEventPersistWallClockSec));
    }
    public static CustomUIElement ImageOnly(Transform parent, Sprite img, Vector3 localPosition, Vector2 size)
    {
        // Rect
        RectTransform   rect = AddRect(parent, localPosition, size);
        CustomUIElement uie  = rect.gameObject.AddComponent <CustomUIElement>();

        uie.rectGo = rect;
        // Component Image
        uie.imageGo = AddImage(uie.rectGo.transform, img);
        return(uie);
    }
    public static CustomUIElement TextOnly(Transform parent, string txt, Vector3 localPosition, Vector2 size)
    {
        // Rect
        RectTransform   rect = AddRect(parent, localPosition, size);
        CustomUIElement uie  = rect.gameObject.AddComponent <CustomUIElement>();

        uie.rectGo = rect;
        // Component Text
        uie.textGo = AddText(uie.rectGo.transform, txt);
        return(uie);
    }
    public static CustomUIElement ImageText(Transform parent, Sprite img, string txt, Vector3 localPosition, Vector2 size)
    {
        // Rect
        RectTransform   rect = AddRect(parent, localPosition, size);
        CustomUIElement uie  = rect.gameObject.AddComponent <CustomUIElement>();

        uie.rectGo = rect;
        // Component Image
        uie.imageGo = AddImage(uie.rectGo.transform, img);
        // Child Rect
        RectTransform chRect = AddTextRect(uie.rectGo.transform);

        // Child Rect's Text
        uie.textGo = AddText(chRect.transform, txt);
        return(uie);
    }
    public static CustomUIElement ButtonTextColor(Transform parent, string txt, Color c, Vector3 localPosition, Vector2 size)
    {
        // Rect
        RectTransform   rect = AddRect(parent, localPosition, size);
        CustomUIElement uie  = rect.gameObject.AddComponent <CustomUIElement>();

        uie.rectGo = rect;
        // Component Image
        uie.imageGo       = AddImage(uie.rectGo.transform);
        uie.imageGo.color = c;
        // Button
        uie.buttonGo = AddButton(uie.rectGo.transform);
        // Child Rect
        RectTransform chRect = AddTextRect(uie.rectGo.transform);

        // Child Rect's Text
        uie.textGo = AddText(chRect.transform, txt);
        return(uie);
    }
Пример #8
0
    public void NewJobActionSelected(System.Guid jobGuid)
    {
        JobDef jobSelected = JobQueries.ByGuid(ManagerBase.jobDefinitions, jobGuid);

        if (jobSelected == null)
        {
            Debug.LogError("Should not have an empty job here");
        }

        string txt = jobSelected.name + "\n" + jobSelected.description + "\n";

        if (jobDescriptionText == null)
        {
            jobDescriptionText = UIElementFunctions.TextOnly(jobsPanel.transform, txt, new Vector3(180, -50), new Vector2(300, 100));
        }
        else
        {
            jobDescriptionText.textGo.text = txt;
        }
        // Add prerequisites, colored, here

        // Figure out what the building needs
        Sprite output1Sprite = ManagerBase.resourceDefinitions[ManagerBase.resourceIndexOf[jobSelected.outputName[0]]].image;

        if (jobSelected.inputResources.rqqList.Count > 0) // Has inputs
        {
            resourceChoiceDropdown = ResourceDropdownCreator.CreateResourceChoiceDropdown(tileDetailUiPanel.transform, new Vector3(-200, -185), jobSelected.inputResources, jobSelected.name, ManagerBase.domain, output1Sprite);
        }
        else
        {
            resourceChoiceDropdown = ResourceDropdownCreator.CreateNoResourceDropdown(tileDetailUiPanel.transform, new Vector3(-200, -185), jobSelected.name, ManagerBase.domain, output1Sprite);
        }


        resourceChoiceDropdown.jobStartButton.buttonGo.onClick.AddListener(delegate() { StartJobButton(jobSelected); });
    }
Пример #9
0
 public EventPanelButton(CustomUIElement uie, float persistDuration)
 {
     this.uiElement    = uie;
     this.removeAtTime = Time.time + persistDuration;
 }
Пример #10
0
    private static ResourceDropdown Create(Transform parent, Vector3 localPosition, ResourceQuantityQualityList choiceRqqList, string taskName, Domain domain, bool isStatic)
    {
        GameObject       newGo            = new GameObject("Resource Dropdown");
        ResourceDropdown resourceDropdown = newGo.AddComponent <ResourceDropdown>();

        resourceDropdown.choiceRqqList = choiceRqqList;
        resourceDropdown.taskName      = taskName;
        resourceDropdown.domain        = domain;

        int resInd = 0;

        foreach (ResourceQuantityQuality rqq in choiceRqqList.rqqList)
        {
            Dictionary <string, Sprite> stringSprite = rqq.GetImageOptions(rqq.minTier);

            // Create the button
            resourceDropdown.elements.Add(UIElementFunctions.Dropdown(parent, null, "", localPosition, new Vector2(64, 64)));
            //resourceDropdown[resInd].transform.localPosition = localPosition;

            localPosition.x += imageSize * 3 / 2;
            resourceDropdown.elements[resInd].thisGo.name = "Resource Dropdown Item";
            resourceDropdown.elements[resInd].childHeight = imageSize;

            int ind = 0;
            foreach (KeyValuePair <string, Sprite> entry in stringSprite)
            {
                ResourceNameQuantityQuality nqq = new ResourceNameQuantityQuality(entry.Key, QualityEnum.any, rqq.quantity);

                if (ind == 0)
                {
                    resourceDropdown.elements[resInd].imageGo.sprite = entry.Value;
                    resourceDropdown.elements[resInd].textGo.text    = "";
                    resourceDropdown.elements[resInd].defName        = entry.Key;
                }
                if (!isStatic)
                {
                    resourceDropdown.elements[resInd].AddChild();
                    resourceDropdown.elements[resInd].children[ind].tooltipData    = entry.Key;
                    resourceDropdown.elements[resInd].children[ind].defName        = entry.Key;
                    resourceDropdown.elements[resInd].children[ind].imageGo.sprite = entry.Value;
                }

                if (!nqq.CheckResource(domain.stock))
                {
                    if (ind == 0)
                    {
                        resourceDropdown.elements[resInd].imageGo.color = Color.red;
                        resourceDropdown.elements[resInd].allowed       = false;
                    }
                    if (!isStatic)
                    {
                        resourceDropdown.elements[resInd].children[ind].imageGo.color         = Color.red;
                        resourceDropdown.elements[resInd].children[ind].buttonGo.interactable = false;
                        resourceDropdown.elements[resInd].children[ind].allowed = false;
                    }
                }
                if (!isStatic)
                {
                    resourceDropdown.elements[resInd].children[ind].textGo.text = "";
                }

                // Add a quantity text
                string          quantityString = rqq.quantity.ToString();
                CustomUIElement temp           = UIElementFunctions.TextOnly(resourceDropdown.elements[resInd].thisGo.transform, quantityString, new Vector3(0, imageSize - 20), new Vector2(imageSize, 20F));
                temp.textGo.alignment = TextAnchor.MiddleCenter;

                ind++;
            }
            resInd++;
        }
        return(resourceDropdown);
    }