Exemple #1
0
    void Awake()
    {
        Debug.Log("test");
        var gbxmap = new GbxMap();

        gbxmap.Load();
        foreach (var block in gbxmap.mapBlocks)
        {
            if (!stats.ContainsKey(block.BlockName))
            {
                stats.Add(block.BlockName, null);
            }
        }
        foreach (var b in stats.ToDictionary())
        {
            if (b.Value == null)
            {
                var o = ml.models.FirstOrDefault(a => a.name.ToLower().Contains(b.Key.ToLower().Substring(7)));
                if (o != null)
                {
                    var replace = o.path.Substring(0, o.path.LastIndexOf('.')).Replace('\\', '/');
                    stats[b.Key] = (GameObject)Resources.Load(replace);
                    Debug.Log("Found " + o.name);
                }
            }
        }
    }
    public static string Save(Dictionary <string, float> incoming)
    {
        StatDictonary stat = new StatDictonary();
        string        data = "";

        foreach (KeyValuePair <string, float> kvp in incoming)
        {
            stat.Add(kvp.Key, kvp.Value);
            data += " POST: " + kvp.Key + " LIKE: " + kvp.Value;
        }
        //Debug.Log (data);
        string json = JsonUtility.ToJson(stat);

        //Debug.Log (json);
        return(json);
    }
Exemple #3
0
    void OnGUI()
    {
        float lastVital = 0;

        for (int i = 0; i < vitals.Count; i++)
        {
            lastVital = 10 + 20 * i;
            GUI.Label(new Rect(10, lastVital, 100, 20), vitals[i].Key + ":");
            GUI.Label(new Rect(110, lastVital, 100, 20), vitals[i].Value.current.ToString() + "/" + vitals[i].Value.max.ToString());
            if (GUI.RepeatButton(new Rect(210, lastVital, 20, 20), "-"))
            {
                vitals[i].Value.current -= 1;
            }
            if (GUI.RepeatButton(new Rect(230, lastVital, 20, 20), "+"))
            {
                vitals[i].Value.current += 1;
            }
        }
        if (GUI.Button(new Rect(10, lastVital + 20, 200, 20), "Add Vital"))
        {
            vitals.Add("Stamina", new Vital(200, 170));
        }

        float lastStat = lastVital + 40;

        for (int i = 0; i < stats.Count; i++)
        {
            lastStat += 20;
            GUI.Label(new Rect(10, lastStat, 100, 20), stats[i].Key + ":");
            GUI.Label(new Rect(110, lastStat, 100, 20), stats[i].Value.ToString());
            if (GUI.Button(new Rect(210, lastStat, 20, 20), "X"))
            {
                stats.RemoveAt(i);
            }
        }
        if (GUI.Button(new Rect(10, lastStat + 20, 200, 20), "Add Stat"))
        {
            stats.Add("Agility", 60);
        }
    }