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 Buff(Dictionary<string, object> data)
 {
     if (data != null)
     {
         data.TryGetString("name", out Name);
         data.TryGetInt("hp_delta", out HPDelta);
         data.TryGetInt("mana_delta", out ManaDelta);
         data.TryGetInt("damage_delta", out DamageDelta);
     }
 }
Example #2
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.TryGetInt(KnockbackKey, out _Knockback);
                dict.TryGetInt(AttackRangeKey, out _AttackRange);
                dict.TryGetInt(CostOfUseKey, out _CostOfUse);
                dict.TryGetInt(numberOfUsesKey, out _numberOfUses);
                dict.TryGetString(itemTypeKey, out _itemType);
                dict.TryGetGameObject(ItemModelKey, out _ItemModel);
                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);
                LoadFromSavedData(dataKey);
            }
        }
Example #5
0
        public override void LoadFromDict(string dataKey, Dictionary<string, object> dict)
        {
            _key = dataKey;

            if (dict == null)
                LoadFromSavedData(dataKey);
            else
            {
                dict.TryGetBool(show_remain_fuelKey, out _show_remain_fuel);
                dict.TryGetBool(long_tap_stage_record_clearKey, out _long_tap_stage_record_clear);
                dict.TryGetBool(soundKey, out _sound);
                dict.TryGetBool(musicKey, out _music);
                dict.TryGetInt(world_countKey, out _world_count);
                dict.TryGetString(versionKey, out _version);
                dict.TryGetString(auto_selected_stage_idKey, out _auto_selected_stage_id);

                dict.TryGetCustomList(stageKey, out stage);
                LoadFromSavedData(dataKey);
            }
        }
    protected override void DrawEntry(string schemaKey, Dictionary<string, object> schemaData)
    {
        float beginningHeight = drawHelper.CurrentHeight();

        // Start drawing below
        bool isOpen = DrawFoldout(GDEConstants.SchemaLbl + " ", schemaKey, schemaKey, schemaKey, RenameSchema);
        drawHelper.NewLine();

        if (isOpen)
        {
            bool shouldDrawSpace = false;
            bool didDrawSpaceForSection = false;
            bool isFirstSection = true;
            int listDimension = 0;

            // Draw the basic types
            foreach(BasicFieldType fieldType in GDEItemManager.BasicFieldTypes)
            {
                List<string> fieldKeys = GDEItemManager.SchemaFieldKeysOfType(schemaKey, fieldType.ToString(), 0);
                foreach(string fieldKey in fieldKeys)
                {
                    drawHelper.CurrentLinePosition += GDEConstants.Indent;
                    DrawSingleField(schemaKey, fieldKey, schemaData);
                    shouldDrawSpace = true;
                    isFirstSection = false;
                }
            }

            // Draw the custom types
            foreach(string fieldKey in GDEItemManager.SchemaCustomFieldKeys(schemaKey, 0))
            {
                if (shouldDrawSpace && !didDrawSpaceForSection && !isFirstSection)
                {
                    drawHelper.NewLine(0.5f);
                }

                drawHelper.CurrentLinePosition += GDEConstants.Indent;
                DrawSingleField(schemaKey, fieldKey, schemaData);

                shouldDrawSpace = true;
                isFirstSection = false;
                didDrawSpaceForSection = true;
            }
            didDrawSpaceForSection = false;

            // Draw the lists
            for(int dimension=1;  dimension <=2;  dimension++)
            {
                foreach(BasicFieldType fieldType in GDEItemManager.BasicFieldTypes)
                {
                    List<string> fieldKeys = GDEItemManager.SchemaFieldKeysOfType(schemaKey, fieldType.ToString(), dimension);
                    foreach(string fieldKey in fieldKeys)
                    {
                        string isListKey = string.Format(GDMConstants.MetaDataFormat, GDMConstants.IsListPrefix, fieldKey);
                        schemaData.TryGetInt(isListKey, out listDimension);

                        if (shouldDrawSpace && !didDrawSpaceForSection && !isFirstSection)
                        {
                            drawHelper.NewLine(0.5f);
                        }

                        drawHelper.CurrentLinePosition += GDEConstants.Indent;
                        if (listDimension == 1)
                            DrawListField(schemaKey, schemaData, fieldKey);
                        else
                            Draw2DListField(schemaKey, schemaData, fieldKey);

                        shouldDrawSpace = true;
                        didDrawSpaceForSection = true;
                        isFirstSection = false;
                    }
                }
                didDrawSpaceForSection = false;
            }

            // Draw the custom lists
            for(int dimension=1;  dimension <=2;  dimension++)
            {
                foreach(string fieldKey in GDEItemManager.SchemaCustomFieldKeys(schemaKey, dimension))
                {
                    if (shouldDrawSpace && !didDrawSpaceForSection && !isFirstSection)
                    {
                        drawHelper.NewLine(0.5f);
                    }

                    drawHelper.CurrentLinePosition += GDEConstants.Indent;
                    if (dimension == 1)
                        DrawListField(schemaKey, schemaData, fieldKey);
                    else
                        Draw2DListField(schemaKey, schemaData, fieldKey);

                    shouldDrawSpace = true;
                    didDrawSpaceForSection = true;
                    isFirstSection = false;
                }
            }
            didDrawSpaceForSection = false;

            drawHelper.NewLine();

            DrawAddFieldSection(schemaKey, schemaData);

            drawHelper.NewLine(2f);

            DrawEntryFooter(GDEConstants.CloneSchema, GDEConstants.SizeCloneSchemaKey, schemaKey);

            // Remove any fields that were deleted above
            foreach(string deletedKey in deletedFields)
                RemoveField(schemaKey, schemaData, deletedKey);
            deletedFields.Clear();

            // Rename any fields that were renamed
            string error;
            string oldFieldKey;
            string newFieldKey;
            foreach(KeyValuePair<List<string>, Dictionary<string, object>> pair in renamedFields)
            {
                oldFieldKey = pair.Key[0];
                newFieldKey = pair.Key[1];
                if (!GDEItemManager.RenameSchemaField(oldFieldKey, newFieldKey, schemaKey, pair.Value, out error))
                    EditorUtility.DisplayDialog(GDEConstants.ErrorLbl, string.Format(GDEConstants.CouldNotRenameFormat, oldFieldKey, newFieldKey, error), GDEConstants.OkLbl);
            }
            renamedFields.Clear();
        }

        float newGroupHeight = drawHelper.CurrentHeight() - beginningHeight;
        float currentGroupHeight;

        groupHeights.TryGetValue(schemaKey, out currentGroupHeight);

        if (!newGroupHeight.NearlyEqual(currentGroupHeight))
        {
            currentGroupHeightTotal -= currentGroupHeight;
            currentGroupHeightTotal += newGroupHeight;
        }

        SetGroupHeight(schemaKey, newGroupHeight);
    }
        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(descriptionKey, out _description);
                dict.TryGetString(string_fieldKey, out _string_field);
                dict.TryGetVector2(vector2_fieldKey, out _vector2_field);
                dict.TryGetVector3(vector3_fieldKey, out _vector3_field);
                dict.TryGetColor(color_fieldKey, out _color_field);
                LoadFromSavedData(dataKey);
            }
        }
        public override void LoadFromDict(string dataKey, Dictionary<string, object> dict)
        {
            _key = dataKey;

            if (dict == null)
                LoadFromSavedData(dataKey);
            else
            {
                dict.TryGetInt(projectileRangeKey, out _projectileRange);
                dict.TryGetInt(numberOfUsesKey, out _numberOfUses);
                dict.TryGetInt(CostOfUseKey, out _CostOfUse);
                dict.TryGetFloat(itemDurationKey, out _itemDuration);
                dict.TryGetString(itemTypeKey, out _itemType);
                dict.TryGetGameObject(ItemModelKey, out _ItemModel);
                LoadFromSavedData(dataKey);
            }
        }
Example #9
0
        public override void LoadFromDict(string dataKey, Dictionary<string, object> dict)
        {
            _key = dataKey;

            if (dict == null)
                LoadFromSavedData(dataKey);
            else
            {
                dict.TryGetBool(stage_lockKey, out _stage_lock);
                dict.TryGetInt(base_scoreKey, out _base_score);
                dict.TryGetInt(high_scoreKey, out _high_score);
                dict.TryGetFloat(remain_fuelKey, out _remain_fuel);
                dict.TryGetFloat(base_fuelKey, out _base_fuel);
                dict.TryGetGameObject(game_objectKey, out _game_object);
                LoadFromSavedData(dataKey);
            }
        }