예제 #1
0
    public void setSelected(BuildingBase entity)
    {
        this.clearSelected();

        if (entity != null)
        {
            this.selected = entity;
            this.selected.outlineHelper.setVisible("selected");
        }

        this.setUIVisible(this.selected != null);

        // UI setup for specific buildings.
        if (this.selected is BuildingQueuedProducerBase)
        {
            BuildingQueuedProducerBase producer = (BuildingQueuedProducerBase)this.selected;
            int slots = producer.getQueueSize();
            for (int i = 0; i < 3; i++)
            {
                this.icons[i].setVisible(i < slots);
            }
        }
        else
        {
            for (int i = 0; i < this.icons.Length; i++)
            {
                this.icons[i].setVisible(false);
            }
        }
    }
예제 #2
0
    private void Update()
    {
        if (Pause.isPaused())
        {
            return;
        }

        if (this.selected)
        {
            string s = this.selected.getHealth() + "/" + this.selected.getMaxHealth() + (this.selected.isConstructing() ? " (Building)" : string.Empty);
            this.infoText.text = this.selected.getData().getName() + "\n" + s;

            if (this.selected is BuildingQueuedProducerBase)
            {
                BuildingQueuedProducerBase producer = (BuildingQueuedProducerBase)this.selected;

                float trainTime  = 0;
                int   queueCount = producer.trainingQueue.Count;
                for (int i = 0; i < 3; i++)
                {
                    if (i < queueCount)
                    {
                        /*
                         * ed = producer.trainingQueue[i].getPrefab().GetComponent<UnitBase>().getData();
                         * if(i == 0) {
                         *  trainTime = ed.getProductionTime();
                         * }
                         * this.icons[i].setText(ed.getUnitTypeName());
                         */
                    }
                    else
                    {
                        this.icons[i].setText(null);
                    }
                }

                this.otherText.text = queueCount == 0 ? "Empty" : Mathf.Floor(trainTime - producer.getTrainingProgress()) + 1 + " Seconds";
            }
            else if (this.selected is IResourceHolder)
            {
                IResourceHolder holder = (IResourceHolder)this.selected;
                int             held   = holder.getHeldResources();
                int             limit  = holder.getHoldLimit();
                string          color  = held >= limit ? "red" : "black";
                this.otherText.text = "<color=" + color + ">Storage:\n" + held + "/" + limit + "</color>";
            }
            else
            {
                this.otherText.text = string.Empty;
            }
        }
        else
        {
            this.setUIVisible(false);
            this.selected = null; // Be sure to set selected at null if it's dead.
        }
    }