Example #1
0
    //
    // Constructor that takes the data returned by the
    // GDEDataManager.Get() method and will now pull out the
    // individual fields using the TryGet() methods.
    //
    public Character(Dictionary<string, object> data)
    {
        if (data != null)
        {
            // Pull out the individual fields and load our Character stats.
            data.TryGetString("name", out Name);
            data.TryGetInt("hp", out baseHP);
            data.TryGetInt("mana", out baseMana);
            data.TryGetInt("damage", out baseDamage);

            //
            // Get the Buff list
            //
            // First get a string list of the buffs using TryGetStringList
            List<string> buffKeyList;
            if (data.TryGetStringList("buffs", out buffKeyList))
            {
                //
                // Spin through each of the Buff names and pull out
                // the data with the GDEDataManager.Get() method.
                //
                Buffs = new List<Buff>();
                foreach(string buffKey in buffKeyList)
                {
                    //
                    // Pull out Buff data with Get() method and pass
                    // it down to the Buff classes constructor where
                    // it will pull out the individual fields and set
                    // it's properties.
                    //
                    Buff curBuff;
                    Dictionary<string, object> curBuffData;
                    GDEDataManager.Instance.Get(buffKey, out curBuffData);

                    //
                    // For each Buff in the string list create a new
                    // object passing it the data from the Get()
                    // method and add it to the Buff's list.
                    //
                    curBuff = new Buff(curBuffData);
                    Buffs.Add(curBuff);

                    //
                    // Now that the Buff's properties have been set
                    // from the data in the Buff's constructor add the
                    // bonuses to the HP, Mana, and Damage.
                    //
                    bonusHP += curBuff.HPDelta;
                    bonusMana += curBuff.ManaDelta;
                    bonusDamage += curBuff.DamageDelta;
                }
            }
        }
    }
        public override void LoadFromDict(string dataKey, Dictionary<string, object> dict)
        {
            _key = dataKey;

            if (dict == null)
                LoadFromSavedData(dataKey);
            else
            {
                dict.TryGetStringList(cust_string_listKey, out cust_string_list);
                LoadFromSavedData(dataKey);
            }
        }
Example #3
0
        public override void LoadFromDict(string dataKey, Dictionary<string, object> dict)
        {
            _key = dataKey;

            if (dict == null)
                LoadFromSavedData(dataKey);
            else
            {
                dict.TryGetBoolList(bool_list_fieldKey, out bool_list_field);
                dict.TryGetIntList(int_list_fieldKey, out int_list_field);
                dict.TryGetFloatList(float_list_fieldKey, out float_list_field);
                dict.TryGetStringList(string_list_fieldKey, out string_list_field);
                dict.TryGetVector2List(vector2_list_fieldKey, out vector2_list_field);
                dict.TryGetVector3List(vector3_list_fieldKey, out vector3_list_field);
                dict.TryGetVector4List(vector4_list_fieldKey, out vector4_list_field);
                dict.TryGetColorList(color_list_fieldKey, out color_list_field);

                dict.TryGetCustomList(custom_list_fieldKey, out custom_list_field);
                LoadFromSavedData(dataKey);
            }
        }
        public override void LoadFromDict(string dataKey, Dictionary<string, object> dict)
        {
            _key = dataKey;

            if (dict == null)
                LoadFromSavedData(dataKey);
            else
            {
                dict.TryGetBool(bool_fieldKey, out _bool_field);
                dict.TryGetInt(int_fieldKey, out _int_field);
                dict.TryGetFloat(float_fieldKey, out _float_field);
                dict.TryGetString(string_fieldKey, out _string_field);
                dict.TryGetVector2(vector2_fieldKey, out _vector2_field);
                dict.TryGetVector3(vector3_fieldKey, out _vector3_field);
                dict.TryGetVector4(vector4_fieldKey, out _vector4_field);
                dict.TryGetColor(color_fieldKey, out _color_field);

                string customDataKey;
                dict.TryGetString(custom_fieldKey, out customDataKey);
                GDEDataManager.DataDictionary.TryGetCustom(customDataKey, out _custom_field);

                dict.TryGetBoolList(bool_list_fieldKey, out bool_list_field);
                dict.TryGetIntList(int_list_fieldKey, out int_list_field);
                dict.TryGetFloatList(float_list_fieldKey, out float_list_field);
                dict.TryGetStringList(string_list_fieldKey, out string_list_field);
                dict.TryGetVector2List(vector2_list_fieldKey, out vector2_list_field);
                dict.TryGetVector3List(vector3_list_fieldKey, out vector3_list_field);
                dict.TryGetVector4List(vector4_list_fieldKey, out vector4_list_field);
                dict.TryGetColorList(color_list_fieldKey, out color_list_field);
                LoadFromSavedData(dataKey);
            }
        }