Exemplo n.º 1
0
    public void ShowUI(BaseObject baseObject)
    {
        if (baseObject == null)
        {
            return;
        }

        UIManager.instance.infoText.text = "";
        if (String.IsNullOrEmpty(baseObject.ownerUser.name) == false)
        {
            UIManager.instance.infoText.text = "<color=#" + GameManager.instance.ColorToHex(baseObject.ownerUser.teamColor) + ">Owner - " + baseObject.ownerUser.name + "</color>\n";
        }
        if (baseObject.objectType == BaseObject.ObjectType.Building)
        {
            BuildingObject buildingObject = baseObject.GetComponent <BuildingObject>();

            // Info
            UIManager.instance.infoText.text += "<b>" + buildingObject.buildingType + "</b> \n"
                                                + "Health: " + (int)buildingObject.health + "/" + (int)buildingObject.maxHealth
                                                + ((buildingObject.damage > 0) ? "Damage: " + buildingObject.damage : "");
        }
        else if (baseObject.objectType == BaseObject.ObjectType.Resource)
        {
            ResourceObject resourceObject = baseObject.GetComponent <ResourceObject>();
            // Info
            UIManager.instance.infoText.text += "<b>" + resourceObject.resourceType + "</b> \n"
                                                + "Health: " + resourceObject.health + "/" + resourceObject.maxHealth + "\n"
                                                + "Resources: " + resourceObject.GetCurrentResources() + "/" + resourceObject.GetBeginningResources();
        }
        else if (baseObject.objectType == BaseObject.ObjectType.Unit)
        {
            UnitObject unitObject = baseObject.GetComponent <UnitObject>();
            // Info
            UIManager.instance.infoText.text += "<b>" + unitObject.unitType + "</b> \n"
                                                + "Damage: " + unitObject.damage + "\n"
                                                + "Health: " + unitObject.health + "/" + unitObject.maxHealth + "\n"
                                                + (String.IsNullOrEmpty(unitObject.GetResourcesString()) ? "" : "Resources:" + unitObject.GetResourcesString());
        }
    }