Ejemplo n.º 1
0
    protected void LoadPropertyData()
    {
        if (properties != null)
        {
            foreach (Stat stat in statsToDisplay)
            {
                if (stat != null && stat.key != null && stat.key.Length > 0)
                {
                    Roar.DomainObjects.PlayerAttribute userStat = properties.GetProperty(stat.key);
                    stat.UserStat = userStat;

                    if (stat.valueFormat.Length > 0)
                    {
                        stat.Value = string.Format("{0:" + stat.valueFormat + "}", userStat != null ? userStat.value : "null");
                    }
                    //stat.Value = string.Format("{0:"+stat.valueFormat+"}", properties.GetValue(stat.key));
                    else
                    {
                        stat.Value = userStat != null ? userStat.value : null;
                    }
                    //stat.Value = properties.GetValue(stat.key);

                    if (stat.title == null || stat.title.Length == 0)
                    {
                        stat.title = userStat != null ? userStat.label : "UNKNOWN";

                        /*
                         * object statProperty = properties.GetProperty(stat.key);
                         * if (statProperty is Hashtable)
                         * {
                         *      Hashtable property = (Hashtable)statProperty;
                         *      if (property.ContainsKey("label"))
                         *      {
                         *              stat.title = (string)property["label"];
                         *      }
                         * }
                         */
                    }
                    else
                    {
                        //TODO: Why was this here?
                        //userStat.Title = stat.title;
                    }
                }
            }
        }
    }
Ejemplo n.º 2
0
    protected override void OnEnable()
    {
        base.OnEnable ();
        properties = DefaultRoar.Instance.Properties;
        if (Debug.isDebugBuild && properties == null)
        {
            Debug.LogWarning("Properties is null; unable to render stats widget");
        }

        if (properties != null)
        {
            foreach (Stat stat in statsToDisplay)
            {
                if (stat != null && stat.key != null && stat.key.Length > 0)
                {
                    if (stat.valueFormat.Length > 0)
                        stat.Value = string.Format("{0:"+stat.valueFormat+"}", properties.GetValue(stat.key));
                    else
                        stat.Value = properties.GetValue(stat.key);

                    if (stat.title == null || stat.title.Length == 0)
                    {
                        object statProperty = properties.GetProperty(stat.key);
                        if (statProperty is Hashtable)
                        {
                            Hashtable property = (Hashtable)statProperty;
                            if (property.ContainsKey("label"))
                            {
                                stat.title = (string)property["label"];
                            }
                        }
                    }
                }
            }
        }
    }