Beispiel #1
0
        public override void LoadFromDict(string dataKey, Dictionary <string, object> dict)
        {
            _key = dataKey;

            if (dict == null)
            {
                LoadFromSavedData(dataKey);
            }
            else
            {
                dict.TryGetBool(lockedKey, out _locked);
                dict.TryGetInt(HashcodeKey, out _Hashcode);
                dict.TryGetInt(posInOwnerKey, out _posInOwner);
                dict.TryGetInt(qualityKey, out _quality);
                dict.TryGetInt(starKey, out _star);
                dict.TryGetInt(levelKey, out _level);
                dict.TryGetFloat(initalQualityKey, out _initalQuality);
                dict.TryGetString(idKey, out _id);
                dict.TryGetString(ownerIdKey, out _ownerId);

                string customDataKey;
                dict.TryGetString(attitubeKey, out customDataKey);
                _attitube = new GDEgoddessAttiData(customDataKey);
                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);
                _custom_field = new GDEReadSceneUnityTypesData(customDataKey);

                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);
            }
        }
Beispiel #3
0
 /// <summary>
 /// 创建所有角色
 /// </summary>
 /// <param name="playerStr"></param>
 public void CreateAllPlayer(object[] data)
 {
     for (int i = 0; i < data.Length; i++)
     {
         Dictionary <string, object> playerDic = data[i] as Dictionary <string, object>;
         int    roleId   = playerDic.TryGetInt("playerId");
         string roleName = playerDic.TryGetString("playerName");
         int    heroId   = int.Parse(playerDic.TryGetString("heroId"));
         int    campId   = int.Parse(playerDic.TryGetString("teamId"));
         campId = campId == 0 ? 1 : 2;
         PlayerData charData = new PlayerData(roleId, heroId, roleName, (CampType)campId, ObjectType.PLAYER);
         CreatePlayer(charData);
     }
     for (int i = 0; i < 2; i++)
     {
         int campId = i % 2 == 0 ? 1 : 2;
         CreateTower((CampType)campId, ObjectType.ARROW_TOWER);
     }
     for (int i = 0; i < 2; i++)
     {
         int campId = i % 2 == 0 ? 1 : 2;
         CreateTower((CampType)campId, ObjectType.CRYSTAL_TOWER);
     }
     m_GridManager.InitTowerGrid();
 }
Beispiel #4
0
        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);
                _custom_field = new GDESetCustomData(customDataKey);
                LoadFromSavedData(dataKey);
            }
        }
Beispiel #5
0
        public override void LoadFromDict(string dataKey, Dictionary <string, object> dict)
        {
            _key = dataKey;

            if (dict == null)
            {
                LoadFromSavedData(dataKey);
            }
            else
            {
                dict.TryGetInt(IDKey, out _ID);
                dict.TryGetInt(MagazineSizeKey, out _MagazineSize);
                dict.TryGetInt(ConsumePerHitKey, out _ConsumePerHit);
                dict.TryGetInt(DamageValKey, out _DamageVal);
                dict.TryGetFloat(AtkIntervalKey, out _AtkInterval);
                dict.TryGetFloat(ChargeTimeKey, out _ChargeTime);
                dict.TryGetFloat(ReloadTimeKey, out _ReloadTime);
                dict.TryGetFloat(ThrustKey, out _Thrust);
                dict.TryGetFloat(AlertRangeKey, out _AlertRange);
                dict.TryGetString(PrefabPathKey, out _PrefabPath);
                dict.TryGetString(SkinNameKey, out _SkinName);

                string customDataKey;
                dict.TryGetString(OpaTypeKey, out customDataKey);
                _OpaType = new GDEEnum_OpaTypeData(customDataKey);
                dict.TryGetString(AniTypeKey, out customDataKey);
                _AniType = new GDEEnum_WeaponAniTypeData(customDataKey);
                LoadFromSavedData(dataKey);
            }
        }
Beispiel #6
0
        public override void LoadFromDict(string dataKey, Dictionary <string, object> dict)
        {
            _key = dataKey;

            if (dict == null)
            {
                LoadFromSavedData(dataKey);
            }
            else
            {
                dict.TryGetInt(starKey, out _star);
                dict.TryGetInt(volumeKey, out _volume);
                dict.TryGetInt(expKey, out _exp);
                dict.TryGetInt(rune0Key, out _rune0);
                dict.TryGetInt(rune1Key, out _rune1);
                dict.TryGetInt(rune2Key, out _rune2);
                dict.TryGetInt(rune3Key, out _rune3);
                dict.TryGetInt(indexKey, out _index);
                dict.TryGetInt(skillGradeKey, out _skillGrade);
                dict.TryGetString(idKey, out _id);
                dict.TryGetString(NAMEKey, out _NAME);

                string customDataKey;
                dict.TryGetString(attitubeKey, out customDataKey);
                _attitube = new GDEgoddessAttiData(customDataKey);

                dict.TryGetIntList(UseTeamIdKey, out UseTeamId);
                LoadFromSavedData(dataKey);
            }
        }
Beispiel #7
0
        public override void LoadFromDict(string dataKey, Dictionary <string, object> dict)
        {
            _key = dataKey;

            if (dict == null)
            {
                LoadFromSavedData(dataKey);
            }
            else
            {
                dict.TryGetBool(hideHairKey, out _hideHair);
                dict.TryGetInt(requireWeightKey, out _requireWeight);
                dict.TryGetInt(healthPointKey, out _healthPoint);
                dict.TryGetInt(atkBonusKey, out _atkBonus);
                dict.TryGetInt(defBonusKey, out _defBonus);
                dict.TryGetInt(dmgClampMinKey, out _dmgClampMin);
                dict.TryGetInt(dmgClampMaxKey, out _dmgClampMax);
                dict.TryGetInt(dmgCountKey, out _dmgCount);
                dict.TryGetFloat(populationKey, out _population);
                dict.TryGetFloat(speedBonusKey, out _speedBonus);
                dict.TryGetFloat(visionRangeKey, out _visionRange);
                dict.TryGetFloat(atkRangeKey, out _atkRange);
                dict.TryGetFloat(atkSpeedKey, out _atkSpeed);
                dict.TryGetFloat(weightRobRateKey, out _weightRobRate);
                dict.TryGetString(nickNameKey, out _nickName);
                dict.TryGetString(raceNameKey, out _raceName);
                dict.TryGetString(ownerNameKey, out _ownerName);
                dict.TryGetString(shapePathKey, out _shapePath);
                dict.TryGetString(leftWeaponDataKey, out _leftWeaponData);
                dict.TryGetString(rightWeaponDataKey, out _rightWeaponData);
                dict.TryGetString(animPathKey, out _animPath);
                dict.TryGetString(fsmPathKey, out _fsmPath);
                LoadFromSavedData(dataKey);
            }
        }
Beispiel #8
0
        public override void LoadFromDict(string dataKey, Dictionary <string, object> dict)
        {
            _key = dataKey;

            if (dict == null)
            {
                LoadFromSavedData(dataKey);
            }
            else
            {
                dict.TryGetString(idKey, out _id);
                dict.TryGetString(nameKey, out _name);
                LoadFromSavedData(dataKey);
            }
        }
Beispiel #9
0
    public void SyncKey(Dictionary <string, object> data)
    {
        int serverFrameCount = 0;

        serverFrameCount     = data.TryGetInt("framecount");
        GameData.m_GameFrame = serverFrameCount;
        //补帧逻辑,后续添加
        //if (serverFrameCount >= GameData.m_GameFrame)
        //{
        FrameKeyData frameKeyData = new FrameKeyData();

        frameKeyData.m_KeyDataList = new List <KeyData>();
        frameKeyData.m_FrameCount  = serverFrameCount;
        GameData.m_OperationEventList.Add(frameKeyData);
        if (data["keydatalist"] == null)
        {
            return;
        }
        object[] keydataArray = data["keydatalist"] as object[];
        for (int i = 0; i < keydataArray.Length; i++)
        {
            Dictionary <string, object> keydata = keydataArray[i] as Dictionary <string, object>;
            KeyData m_KeyData = new KeyData();
            m_KeyData.m_RoleId    = keydata.TryGetInt("m_RoleId");
            m_KeyData.m_Cmd       = keydata.TryGetInt("m_Cmd");
            m_KeyData.m_Parameter = keydata.TryGetString("m_Parameter");
            frameKeyData.m_KeyDataList.Add(m_KeyData);
            m_BattleLogicManager.OnOperation(m_KeyData);
            LogMsg(string.Format("收到操作:{0},参数:{1},帧数:{2}", m_KeyData.m_Cmd.ToString(), m_KeyData.m_Parameter, GameData.m_GameFrame));
        }
        //GameData.m_GameFrame += 1;
        //}
    }
Beispiel #10
0
    //
    // Initialize the GUIText from the values in the GDEDataManager
    // using the TryGet() methods.
    //
    public void Init()
    {
        if (Data != null)
        {
            GUIText guiText = gameObject.GetComponent <GUIText>();

            // Pull out the text value from Game Data
            string text;
            Data.TryGetString("text", out text);

            if (text.Contains("{0}"))
            {
                guiText.text = string.Format(text, "/GameDataEditor/Scenes/SquareExample/Resources/" + GDEDataManager.Instance.DataFilePath + ".json");
            }
            else
            {
                guiText.text = text;
            }

            // Pull out the size value from Game Data
            int fontSize;
            Data.TryGetInt("size", out fontSize);
            guiText.fontSize = fontSize;

            // Pull out the color value from Game Data
            Color textColor;
            Data.TryGetColor("color", out textColor);
            guiText.color = textColor;

            // Pull out the position value from Game Data
            Vector3 position;
            Data.TryGetVector3("position", out position);
            transform.localPosition = position;
        }
    }
Beispiel #11
0
        public override void LoadFromDict(string dataKey, Dictionary <string, object> dict)
        {
            _key = dataKey;

            if (dict == null)
            {
                LoadFromSavedData(dataKey);
            }
            else
            {
                dict.TryGetString(shapePathKey, out _shapePath);
                dict.TryGetString(fsmPathKey, out _fsmPath);
                dict.TryGetVector3(localScaleKey, out _localScale);
                LoadFromSavedData(dataKey);
            }
        }
Beispiel #12
0
        public override void LoadFromDict(string dataKey, Dictionary <string, object> dict)
        {
            _key = dataKey;

            if (dict == null)
            {
                LoadFromSavedData(dataKey);
            }
            else
            {
                dict.TryGetString(raceNameKey, out _raceName);
                dict.TryGetString(typeNameKey, out _typeName);
                dict.TryGetString(shapePathKey, out _shapePath);
                LoadFromSavedData(dataKey);
            }
        }
Beispiel #13
0
    /// <summary>
    /// 匹配游戏成功
    /// </summary>
    /// <param name="data"></param>
    public void MatchGameSuccess(Dictionary <string, object> data)
    {
        int result = data.TryGetInt("ret");

        if (result != 0)
        {
            return;
        }
        string matchKey = data.TryGetString("matchKey");

        GameData.m_CampId   = (CampType)data.TryGetInt("teamId");
        GameData.m_MatchPos = data.TryGetInt("pos");
        GameData.m_MatchKey = matchKey;
        if (!data.ContainsKey("teamInfo"))
        {
            return;
        }
        object[] teamInfoArray = data["teamInfo"] as object[];
        List <MatchPlayerData> matchPlayerList = new List <MatchPlayerData>();

        for (int i = 0; i < teamInfoArray.Length; i++)
        {
            Dictionary <string, object> keydata     = teamInfoArray[i] as Dictionary <string, object>;
            MatchPlayerData             matchPlayer = new MatchPlayerData();
            matchPlayer.m_CampId = keydata.TryGetInt("teamId");
            matchPlayer.m_Pos    = keydata.TryGetInt("pos");
            matchPlayerList.Add(matchPlayer);
        }
        m_UIManager.m_UpdateMatchSuccessUICallback();
    }
        /// <summary>
        /// Builds the data keys by schema list for lookups by schema.
        /// </summary>
        private static void BuildDataKeysBySchemaList()
        {
            dataKeysBySchema = new Dictionary <string, List <string> >();
            foreach (KeyValuePair <string, object> pair in dataDictionary)
            {
                if (pair.Key.StartsWith(GDMConstants.SchemaPrefix))
                {
                    continue;
                }

                // Get the schema for the current data set
                string schema;
                Dictionary <string, object> currentDataSet = pair.Value as Dictionary <string, object>;
                currentDataSet.TryGetString(GDMConstants.SchemaKey, out schema);

                // Add it to the list of data keys by type
                List <string> dataKeyList;
                if (dataKeysBySchema.TryGetValue(schema, out dataKeyList))
                {
                    dataKeyList.Add(pair.Key);
                }
                else
                {
                    dataKeyList = new List <string>();
                    dataKeyList.Add(pair.Key);
                    dataKeysBySchema.Add(schema, dataKeyList);
                }
            }
        }
        private void GoThroughSchemas()
        {
            foreach (KeyValuePair <string, object> pair in GDEDataManager.DataDictionary)
            {
                if (pair.Key.StartsWith(GDMConstants.SchemaPrefix))
                {
                    continue;
                }

                //get all values of current Item
                Dictionary <string, object> currentDataSet = pair.Value as Dictionary <string, object>;

                //skip if current Item doesn't contain the specified String
                if (!itemNameContains.IsNone && string.IsNullOrEmpty(itemNameContains.Value))
                {
                    if (!pair.Key.Contains(itemNameContains.Value))
                    {
                        continue;
                    }
                }

                //skip if schema not specified
                if (!string.IsNullOrEmpty(searchInSchema.Value))
                {
                    //get Schema of current Item
                    currentDataSet.TryGetString(GDMConstants.SchemaKey, out currentSchema);
                    //check if current Schema equals specified one
                    if (currentSchema != searchInSchema.Value)
                    {
                        continue;
                    }
                }

                foreach (var currentData in currentDataSet)
                {
                    //skip if Field Name start with _gde (_gdeType_... or _gdeSchema)
                    if (currentData.Key.StartsWith("_gde"))
                    {
                        continue;
                    }

                    //skip if field name not specified
                    if (!string.IsNullOrEmpty(searchInField.Value))
                    {
                        if (currentData.Key != searchInField.Value)
                        {
                            continue;
                        }
                    }

                    if (currentData.Value.ToString() == _value.Value)
                    {
                        hasFound.Value  = true;
                        storeItem.Value = pair.Key;
                        return;
                    }
                }
            }
        }
Beispiel #16
0
    /// <summary>
    /// 进入匹配房间
    /// </summary>
    /// <param name="data"></param>
    public void JoinMatchHeroRoom(Dictionary <string, object> data)
    {
        int result = data.TryGetInt("ret");

        if (result != 0)
        {
            return;
        }
        string mobaKey = data.TryGetString("mobaKey");
        string udpIp   = data.TryGetString("ip");
        int    udpPort = data.TryGetInt("port");

        GameData.m_UdpIP   = udpIp;
        GameData.m_UdpPort = udpPort;
        GameData.m_MobaKey = mobaKey;
        m_UIManager.m_UpdateSelectHeroUI();
    }
Beispiel #17
0
        public override void LoadFromDict(string dataKey, Dictionary <string, object> dict)
        {
            _key = dataKey;

            if (dict == null)
            {
                LoadFromSavedData(dataKey);
            }
            else
            {
                dict.TryGetString(POLISHKey, out _POLISH);
                dict.TryGetString(ENGLISHKey, out _ENGLISH);
                dict.TryGetString(GERMANKey, out _GERMAN);
                dict.TryGetString(SPANISHKey, out _SPANISH);
                LoadFromSavedData(dataKey);
            }
        }
Beispiel #18
0
        public override void LoadFromDict(string dataKey, Dictionary <string, object> dict)
        {
            _key = dataKey;

            if (dict == null)
            {
                LoadFromSavedData(dataKey);
            }
            else
            {
                dict.TryGetInt(badgeKey, out _badge);
                dict.TryGetString(goddessKey, out _goddess);
                dict.TryGetString(idKey, out _id);
                dict.TryGetString(teamNameKey, out _teamName);
                LoadFromSavedData(dataKey);
            }
        }
Beispiel #19
0
        public override void LoadFromDict(string dataKey, Dictionary <string, object> dict)
        {
            _key = dataKey;

            if (dict == null)
            {
                LoadFromSavedData(dataKey);
            }
            else
            {
                dict.TryGetInt(minuteKey, out _minute);
                dict.TryGetInt(lotnumberKey, out _lotnumber);
                dict.TryGetInt(repeatnumberKey, out _repeatnumber);
                dict.TryGetString(idKey, out _id);
                dict.TryGetString(nameKey, out _name);
                LoadFromSavedData(dataKey);
            }
        }
        public override void LoadFromDict(string dataKey, Dictionary <string, object> dict)
        {
            _key = dataKey;

            if (dict == null)
            {
                LoadFromSavedData(dataKey);
            }
            else
            {
                dict.TryGetInt(spawnCountKey, out _spawnCount);
                dict.TryGetFloat(weightKey, out _weight);
                dict.TryGetString(typeNameKey, out _typeName);
                dict.TryGetString(nickNameKey, out _nickName);
                dict.TryGetString(spawnLevelKey, out _spawnLevel);
                dict.TryGetString(shapePathKey, out _shapePath);
                LoadFromSavedData(dataKey);
            }
        }
Beispiel #21
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);
     }
 }
Beispiel #22
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);
     }
 }
        public override void LoadFromDict(string dataKey, Dictionary <string, object> dict)
        {
            _key = dataKey;

            if (dict == null)
            {
                LoadFromSavedData(dataKey);
            }
            else
            {
                dict.TryGetInt(levelKey, out _level);
                dict.TryGetString(idKey, out _id);

                string customDataKey;
                dict.TryGetString(NPCKey, out customDataKey);
                _NPC = new GDENPCData(customDataKey);
                LoadFromSavedData(dataKey);
            }
        }
Beispiel #24
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;
                }
            }
        }
    }
Beispiel #25
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;
                }
            }
        }
    }
Beispiel #26
0
        public override void LoadFromDict(string dataKey, Dictionary <string, object> dict)
        {
            _key = dataKey;

            if (dict == null)
            {
                LoadFromSavedData(dataKey);
            }
            else
            {
                dict.TryGetInt(TestIntKey, out _TestInt);
                dict.TryGetString(TestStringKey, out _TestString);

                string customDataKey;
                dict.TryGetString(TestSchemaKey, out customDataKey);
                _TestSchema = new GDETest2SchemaData(customDataKey);

                dict.TryGetStringList(TestListKey, out TestList);
                LoadFromSavedData(dataKey);
            }
        }
Beispiel #27
0
        /// <summary>
        /// Builds the data keys by schema list for lookups by schema.
        /// </summary>
        static void BuildDataKeysBySchemaList()
            #endif
        {
            DataKeysBySchema = new Dictionary <string, HashSet <string> >();
            foreach (KeyValuePair <string, object> pair in masterData)
            {
                if (pair.Key.StartsWith(GDMConstants.SchemaPrefix))
                {
                    continue;
                }

                // Get the schema for the current data set
                string schema;
                Dictionary <string, object> currentDataSet = pair.Value as Dictionary <string, object>;
                currentDataSet.TryGetString(GDMConstants.SchemaKey, out schema);

                // Add it to the list of data keys by type
                HashSet <string> dataKeyList;
                if (DataKeysBySchema.TryGetValue(schema, out dataKeyList))
                {
                    dataKeyList.Add(pair.Key);
                }
                else
                {
                    dataKeyList = new HashSet <string>();
                    dataKeyList.Add(pair.Key);
                    DataKeysBySchema.Add(schema, dataKeyList);
                }
            }

            // Pull any keys from mod data
            #if !UNITY_WEBPLAYER
            foreach (var item in ModifiedData)
            {
                HashSet <string> keys;
                string           schema;

                if (item.Value.TryGetString(GDMConstants.SchemaKey, out schema))
                {
                    if (DataKeysBySchema.TryGetValue(schema, out keys))
                    {
                        keys.Add(item.Key);
                    }
                    else
                    {
                        var dataKeyList = new HashSet <string>();
                        dataKeyList.Add(item.Key);
                        DataKeysBySchema.Add(schema, dataKeyList);
                    }
                }
            }
            #endif
        }
        public override void LoadFromDict(string dataKey, Dictionary<string, object> dict)
        {
            _key = dataKey;

            if (dict == null)
                LoadFromSavedData(dataKey);
            else
            {
                dict.TryGetString(descriptionKey, out _description);
                LoadFromSavedData(dataKey);
            }
        }
Beispiel #29
0
        public override void LoadFromDict(string dataKey, Dictionary <string, object> dict)
        {
            _key = dataKey;

            if (dict == null)
            {
                LoadFromSavedData(dataKey);
            }
            else
            {
                dict.TryGetFloat(localScaleKey, out _localScale);
                dict.TryGetFloat(aggroKey, out _aggro);
                dict.TryGetFloat(counterKey, out _counter);
                dict.TryGetFloat(reflectKey, out _reflect);
                dict.TryGetFloat(stunKey, out _stun);
                dict.TryGetFloat(criticalKey, out _critical);
                dict.TryGetFloat(poisonKey, out _poison);
                dict.TryGetFloat(bleedKey, out _bleed);
                dict.TryGetFloat(slowKey, out _slow);
                dict.TryGetFloat(pierceKey, out _pierce);
                dict.TryGetFloat(flameKey, out _flame);
                dict.TryGetString(weaponNameKey, out _weaponName);
                dict.TryGetString(typeNameKey, out _typeName);
                dict.TryGetString(raceNameKey, out _raceName);
                dict.TryGetString(shapePathKey, out _shapePath);

                string customDataKey;
                dict.TryGetString(projectileKeyKey, out customDataKey);
                _projectileKey = new GDEProjectileData(customDataKey);
                dict.TryGetString(extraProjectileKeyKey, out customDataKey);
                _extraProjectileKey = new GDEProjectileData(customDataKey);
                LoadFromSavedData(dataKey);
            }
        }
Beispiel #30
0
    public override void ParseJson(object jd)
    {
        Dictionary <string, object> item = (Dictionary <string, object>)jd;

        released = item.TryGetInt("released");
        if (released == 1)
        {
            skinId = item.TryGetLong("skin_id");

            grade        = item.TryGetString("grade");
            commodity_id = item.TryGetInt("commodity_id");
            skin_cardId  = item.TryGetLong("skin_card");

            heroId          = item.TryGetLong("hero_id");
            skinName        = item.TryGetString("name");
            iconAtlas       = item.TryGetString("icon_atlas");
            head_icon_atlas = item.TryGetString("head_icon_atlas");
            skinCard        = item.TryGetString("original_painting");
            modelId         = item.TryGetInt("model");
            modelNode       = FSDataNodeTable <ModelNode> .GetSingleton().FindDataByType(modelId);

            path       = item.TryGetString("path");
            deathSound = item.TryGetString("death_sound");

            if (item.ContainsKey("hit_sound"))
            {
                hitSound = item["hit_sound"].ToString();
            }
            if (item.ContainsKey("dlgAmount"))
            {
                dlgAmount = item.TryGetInt("dlgAmount");
            }
            if (item.ContainsKey("icon_name"))
            {
                iconName = item["icon_name"].ToString();
            }
            if (item.ContainsKey("type"))
            {
                type = item.TryGetInt("type");
            }
            if (item.ContainsKey("property"))
            {
                property = item.TryGetFloat("property");
            }
            if (item.ContainsKey("price"))
            {
                price = item["price"] as int[];
            }
            if (item.ContainsKey("effectName"))
            {
                effectName = item["effectName"] == null ? null : item["effectName"].ToString();
            }
        }
    }
Beispiel #31
0
        public override void LoadFromDict(string dataKey, Dictionary <string, object> dict)
        {
            _key = dataKey;

            if (dict == null)
            {
                LoadFromSavedData(dataKey);
            }
            else
            {
                dict.TryGetFloat(HealthPointsKey, out _HealthPoints);
                dict.TryGetFloat(ExperienceKey, out _Experience);
                dict.TryGetFloat(LevelKey, out _Level);
                dict.TryGetFloat(BasicMeleeKey, out _BasicMelee);
                dict.TryGetFloat(BasicDistanceKey, out _BasicDistance);
                dict.TryGetFloat(BasicMagicKey, out _BasicMagic);
                dict.TryGetString(CharacterNameKey, out _CharacterName);
                dict.TryGetString(CharacterDescriptionKey, out _CharacterDescription);
                dict.TryGetString(DifficultyLevelKey, out _DifficultyLevel);
                LoadFromSavedData(dataKey);
            }
        }
Beispiel #32
0
        public override void LoadFromDict(string dataKey, Dictionary <string, object> dict)
        {
            _key = dataKey;

            if (dict == null)
            {
                LoadFromSavedData(dataKey);
            }
            else
            {
                dict.TryGetString(descriptionKey, out _description);
                LoadFromSavedData(dataKey);
            }
        }
        private static ProductMetadata DeserializeMetadata(Dictionary <string, object> data)
        {
            // We are seeing an occasional exception when converting a string to a decimal here. It may be related to
            // a mono bug with certain cultures' number formatters: https://bugzilla.xamarin.com/show_bug.cgi?id=4814
            //
            // It's not a great idea to set the price to 0 when this happens, but it's probably better than throwing
            // an exception. The best solution is to pass a number for localizedPrice when possible, to avoid any string
            // parsing issues.
            decimal localizedPrice = 0.0m;

            try {
                localizedPrice = Convert.ToDecimal(data["localizedPrice"]);
            } catch {
                localizedPrice = 0.0m;
            }

            return(new ProductMetadata(
                       data.TryGetString("localizedPriceString"),
                       data.TryGetString("localizedTitle"),
                       data.TryGetString("localizedDescription"),
                       data.TryGetString("isoCurrencyCode"),
                       localizedPrice));
        }
    void DrawListField(string schemaKey, string itemKey, string fieldKey, Dictionary<string, object> itemData)
    {
        try
        {
            string foldoutKey = string.Format(GDEConstants.MetaDataFormat, itemKey, fieldKey);
            bool newFoldoutState;
            bool currentFoldoutState = listFieldFoldoutState.Contains(foldoutKey);
            object defaultResizeValue = null;

            string fieldType;
            itemData.TryGetString(string.Format(GDEConstants.MetaDataFormat, GDEConstants.TypePrefix, fieldKey), out fieldType);

            BasicFieldType fieldTypeEnum = BasicFieldType.Undefined;
            if (Enum.IsDefined(typeof(BasicFieldType), fieldType))
            {
                fieldTypeEnum = (BasicFieldType)Enum.Parse(typeof(BasicFieldType), fieldType);
                if (!fieldTypeEnum.Equals(BasicFieldType.Vector2) &&
                    !fieldTypeEnum.Equals(BasicFieldType.Vector3) &&
                    !fieldTypeEnum.Equals(BasicFieldType.Vector4) &&
                    !fieldTypeEnum.Equals(BasicFieldType.Color))
                    fieldType = fieldType.ToLower();

                defaultResizeValue = GetDefaultValueForType(fieldTypeEnum);
            }

            float width = 120;
            newFoldoutState = EditorGUI.Foldout(new Rect(currentLinePosition, TopOfLine(), width, StandardHeight()), currentFoldoutState, string.Format("List<{0}>", fieldType), true);
            currentLinePosition += (width + 2);

            width = 120;
            EditorGUI.LabelField(new Rect(currentLinePosition, TopOfLine(), width, StandardHeight()), fieldKey.HighlightSubstring(filterText, highlightColor), labelStyle);
            currentLinePosition += (width + 2);

            if (newFoldoutState != currentFoldoutState)
            {
                if (newFoldoutState)
                    listFieldFoldoutState.Add(foldoutKey);
                else
                    listFieldFoldoutState.Remove(foldoutKey);
            }

            object temp = null;
            List<object> list = null;

            if (itemData.TryGetValue(fieldKey, out temp))
                list = temp as List<object>;

            GUIContent content = new GUIContent(GDEStrings.SizeLbl);
            width = GUI.skin.label.CalcSize(content).x;
            EditorGUI.LabelField(new Rect(currentLinePosition, TopOfLine(), width, StandardHeight()), content);
            currentLinePosition += (width + 2);

            int newListCount;
            string listCountKey = string.Format(GDEConstants.MetaDataFormat, itemKey, fieldKey);
            if (newListCountDict.ContainsKey(listCountKey))
            {
                newListCount = newListCountDict[listCountKey];
            }
            else
            {
                newListCount = list.Count;
                newListCountDict.Add(listCountKey, newListCount);
            }

            width = 40;
            newListCount = EditorGUI.IntField(new Rect(currentLinePosition, TopOfLine(), width, StandardHeight()), newListCount);
            currentLinePosition += (width + 4);

            content.text = GDEStrings.ResizeBtn;
            width = GUI.skin.button.CalcSize(content).x;
            newListCountDict[listCountKey] = newListCount;
            if (newListCount != list.Count && GUI.Button(new Rect(currentLinePosition, TopOfLine(), width, StandardHeight()), content))
            {
                ResizeList(list, newListCount, defaultResizeValue);
                newListCountDict[listCountKey] = newListCount;
                currentLinePosition += (width + 2);
            }

            NewLine();

            if (newFoldoutState)
            {
                for (int i = 0; i < list.Count; i++)
                {
                   currentLinePosition += GDEConstants.Indent*2;

                    switch (fieldTypeEnum) {
                        case BasicFieldType.Bool:
                        {
                            DrawListBool(i, Convert.ToBoolean(list[i]), list);
                            NewLine();
                            break;
                        }
                        case BasicFieldType.Int:
                        {
                            DrawListInt(i, Convert.ToInt32(list[i]), list);
                            NewLine();
                            break;
                        }
                        case BasicFieldType.Float:
                        {
                            DrawListFloat(i, Convert.ToSingle(list[i]), list);
                            NewLine();
                            break;
                        }
                        case BasicFieldType.String:
                        {
                            DrawListString(i, list[i] as string, list);
                            NewLine();
                            break;
                        }
                        case BasicFieldType.Vector2:
                        {
                            DrawListVector2(i, list[i] as Dictionary<string, object>, list);
                            NewLine(GDEConstants.VectorFieldBuffer+1);
                            break;
                        }
                        case BasicFieldType.Vector3:
                        {
                            DrawListVector3(i, list[i] as Dictionary<string, object>, list);
                            NewLine(GDEConstants.VectorFieldBuffer+1);
                            break;
                        }
                        case BasicFieldType.Vector4:
                        {
                            DrawListVector4(i, list[i] as Dictionary<string, object>, list);
                            NewLine(GDEConstants.VectorFieldBuffer+1);
                            break;
                        }
                        case BasicFieldType.Color:
                        {
                            DrawListColor(i, list[i] as Dictionary<string, object>, list);
                            NewLine();
                            break;
                        }
                        default:
                        {
                            List<string> itemKeys = GetPossibleCustomValues(schemaKey, fieldType);
                            DrawListCustom(i, list[i] as string, list, true, itemKeys);
                            NewLine();
                            break;
                        }
                    }
                }
            }
        }
        catch(Exception ex)
        {
            Debug.LogException(ex);
        }
    }
Beispiel #35
0
        private static void AppendLoadDictMethod(StringBuilder sb, string schemaKey, Dictionary<string, object> schemaData)
        {
            sb.Append("".PadLeft(GDECodeGenConstants.IndentLevel2));
            sb.Append(GDECodeGenConstants.LoadDictMethod);
            sb.Append("\n");

            bool shouldAppendSpace = false;
            bool didAppendSpaceForSection = false;
            bool isFirstSection = true;

            string variableType;

            // Append all the single variables first
            foreach(BasicFieldType fieldType in GDEItemManager.BasicFieldTypes)
            {
                variableType = fieldType.ToString();
                List<string> fieldKeys = GDEItemManager.SchemaFieldKeysOfType(schemaKey, fieldType.ToString(), 0);
                foreach(string fieldKey in fieldKeys)
                {
                    AppendLoadVariable(sb, variableType, fieldKey);
                    shouldAppendSpace = true;
                    isFirstSection = false;
                }
            }

            // Append the custom types
            bool appendTempKeyDeclaration = true;
            foreach(string fieldKey in GDEItemManager.SchemaCustomFieldKeys(schemaKey, 0))
            {
                if (shouldAppendSpace && !didAppendSpaceForSection && !isFirstSection)
                {
                    sb.Append("\n");
                }

                schemaData.TryGetString(string.Format(GDMConstants.MetaDataFormat, GDMConstants.TypePrefix, fieldKey), out variableType);
                variableType = string.Format(GDECodeGenConstants.DataClassNameFormat, variableType);

                if (appendTempKeyDeclaration)
                {
                    sb.Append("".PadLeft(GDECodeGenConstants.IndentLevel4));
                    sb.Append(GDECodeGenConstants.TempStringKeyDeclaration);
                    sb.Append("\n");
                    appendTempKeyDeclaration = false;
                }

                AppendLoadCustomVariable(sb, variableType, fieldKey);
                shouldAppendSpace = true;
                didAppendSpaceForSection = true;
                isFirstSection = false;
            }
            didAppendSpaceForSection = false;

            // Append the basic lists
            for(int dimension = 1;  dimension <= 2;  dimension++)
            {
                foreach(BasicFieldType fieldType in GDEItemManager.BasicFieldTypes)
                {
                    List<string> fieldKeys = GDEItemManager.SchemaFieldKeysOfType(schemaKey, fieldType.ToString(), dimension);
                    variableType = fieldType.ToString();

                    foreach(string fieldKey in fieldKeys)
                    {
                        if (shouldAppendSpace && !didAppendSpaceForSection && !isFirstSection)
                        {
                            sb.Append("\n");
                        }

                        AppendLoadListVariable(sb, variableType, fieldKey, dimension);
                        shouldAppendSpace = true;
                        didAppendSpaceForSection = true;
                        isFirstSection = false;
                    }
                }
                didAppendSpaceForSection = false;
            }

            // Append the custom lists
            for(int dimension = 1;  dimension <= 2;  dimension++)
            {
                foreach(string fieldKey in GDEItemManager.SchemaCustomFieldKeys(schemaKey, dimension))
                {
                    if (shouldAppendSpace && !didAppendSpaceForSection && !isFirstSection)
                    {
                        sb.Append("\n");
                    }

                    schemaData.TryGetString(string.Format(GDMConstants.MetaDataFormat, GDMConstants.TypePrefix, fieldKey), out variableType);
                    variableType = "Custom";
                    AppendLoadListVariable(sb, variableType, fieldKey, dimension);

                    shouldAppendSpace = true;
                    isFirstSection = false;
                    didAppendSpaceForSection = true;
                }
            }

            sb.Append("".PadLeft(GDECodeGenConstants.IndentLevel4));
            sb.Append(GDECodeGenConstants.LoadDictMethodEnd);
            sb.Append("\n");
        }
    void DrawSingleField(string schemaKey, string itemKey, string fieldKey, Dictionary<string, object> itemData)
    {
        string fieldPreviewKey = schemaKey+"_"+itemKey+"_"+fieldKey;
        string fieldType;
        itemData.TryGetString(string.Format(GDMConstants.MetaDataFormat, GDMConstants.TypePrefix, fieldKey), out fieldType);

        BasicFieldType fieldTypeEnum = BasicFieldType.Undefined;
        if (Enum.IsDefined(typeof(BasicFieldType), fieldType))
        {
            fieldTypeEnum = (BasicFieldType)Enum.Parse(typeof(BasicFieldType), fieldType);
            fieldType = GDEItemManager.GetVariableTypeFor(fieldTypeEnum);
        }

        content.text = fieldType;
        drawHelper.TryGetCachedSize(schemaKey+fieldKey+GDEConstants.TypeSuffix, content, labelStyle, out size);
        size.x = Math.Max(size.x, GDEConstants.MinLabelWidth);

        GUI.Label(new Rect(drawHelper.CurrentLinePosition, drawHelper.TopOfLine(), size.x, size.y), content, labelStyle);
        drawHelper.CurrentLinePosition += (size.x + 2);

        content.text = fieldKey.HighlightSubstring(filterText, highlightColor);
        drawHelper.TryGetCachedSize(schemaKey+fieldKey+GDEConstants.LblSuffix, content, labelStyle, out size);
        size.x = Math.Max(size.x, GDEConstants.MinLabelWidth);

        GUI.Label(new Rect(drawHelper.CurrentLinePosition, drawHelper.TopOfLine(), size.x, size.y), content, labelStyle);
        drawHelper.CurrentLinePosition += (size.x + 2);

        switch(fieldTypeEnum)
        {
            case BasicFieldType.Bool:
            {
                DrawBool(fieldKey, itemData, GDEConstants.ValueLbl);
                drawHelper.NewLine();
                break;
            }
            case BasicFieldType.Int:
            {
                DrawInt(fieldKey, itemData, GDEConstants.ValueLbl);
                drawHelper.NewLine();
                break;
            }
            case BasicFieldType.Float:
            {
                DrawFloat(fieldKey, itemData, GDEConstants.ValueLbl);
                drawHelper.NewLine();
                break;
            }
            case BasicFieldType.String:
            {
                DrawString(fieldKey, itemData, GDEConstants.ValueLbl);
                drawHelper.NewLine();
                break;
            }
            case BasicFieldType.Vector2:
            {
                DrawVector2(fieldKey, itemData, GDEConstants.ValueLbl);
                drawHelper.NewLine(GDEConstants.VectorFieldBuffer+1);
                break;
            }
            case BasicFieldType.Vector3:
            {
                DrawVector3(fieldKey, itemData, GDEConstants.ValueLbl);
                drawHelper.NewLine(GDEConstants.VectorFieldBuffer+1);
                break;
            }
            case BasicFieldType.Vector4:
            {
                DrawVector4(fieldKey, itemData, GDEConstants.ValueLbl);
                drawHelper.NewLine(GDEConstants.VectorFieldBuffer+1);
                break;
            }
            case BasicFieldType.Color:
            {
                DrawColor(fieldKey, itemData, GDEConstants.ValueLbl);
                drawHelper.NewLine();
                break;
            }
            case BasicFieldType.GameObject:
            {
                DrawObject<GameObject>(fieldPreviewKey, fieldKey, itemData, GDEConstants.ValueLbl);
                drawHelper.NewLine();
                break;
            }
            case BasicFieldType.Texture2D:
            {
                DrawObject<Texture2D>(fieldPreviewKey, fieldKey, itemData, GDEConstants.ValueLbl);
                drawHelper.NewLine();
                break;
            }
            case BasicFieldType.Material:
            {
                DrawObject<Material>(fieldPreviewKey, fieldKey, itemData, GDEConstants.ValueLbl);
                drawHelper.NewLine();
                break;
            }
            case BasicFieldType.AudioClip:
            {
                DrawAudio(fieldPreviewKey, fieldKey, itemData, GDEConstants.ValueLbl);
                drawHelper.NewLine();
                break;
            }
            default:
            {
                List<string> itemKeys = GetPossibleCustomValues(schemaKey, fieldType);
                DrawCustom(fieldKey, itemData, true, itemKeys);
                drawHelper.NewLine();
                break;
            }
        }
    }
    void DrawListField(string schemaKey, string itemKey, string fieldKey, Dictionary<string, object> itemData)
    {
        try
        {
            string foldoutKey = string.Format(GDMConstants.MetaDataFormat, itemKey, fieldKey);
            bool newFoldoutState;
            bool currentFoldoutState = listFieldFoldoutState.Contains(foldoutKey);
            object defaultResizeValue = null;

            string fieldType;
            itemData.TryGetString(string.Format(GDMConstants.MetaDataFormat, GDMConstants.TypePrefix, fieldKey), out fieldType);

            BasicFieldType fieldTypeEnum = BasicFieldType.Undefined;
            if (Enum.IsDefined(typeof(BasicFieldType), fieldType))
            {
                fieldTypeEnum = (BasicFieldType)Enum.Parse(typeof(BasicFieldType), fieldType);
                fieldType = GDEItemManager.GetVariableTypeFor(fieldTypeEnum);
                defaultResizeValue = GDEItemManager.GetDefaultValueForType(fieldTypeEnum);
            }

            content.text = string.Format("List<{0}>", fieldType);
            drawHelper.TryGetCachedSize(schemaKey+fieldKey+GDEConstants.TypeSuffix, content, EditorStyles.foldout, out size);
            size.x = Math.Max(size.x, GDEConstants.MinLabelWidth);
            newFoldoutState = EditorGUI.Foldout(new Rect(drawHelper.CurrentLinePosition, drawHelper.TopOfLine(), size.x, size.y), currentFoldoutState, content);
            drawHelper.CurrentLinePosition += (size.x + 2);

            content.text = fieldKey.HighlightSubstring(filterText, highlightColor);
            drawHelper.TryGetCachedSize(schemaKey+fieldKey+GDEConstants.LblSuffix, content, labelStyle, out size);
            size.x = Math.Max(size.x, GDEConstants.MinLabelWidth);
            GUI.Label(new Rect(drawHelper.CurrentLinePosition, drawHelper.TopOfLine(), size.x, size.y), fieldKey.HighlightSubstring(filterText, highlightColor), labelStyle);
            drawHelper.CurrentLinePosition += (size.x + 2);

            if (newFoldoutState != currentFoldoutState)
            {
                if (newFoldoutState)
                    listFieldFoldoutState.Add(foldoutKey);
                else
                    listFieldFoldoutState.Remove(foldoutKey);
            }

            object temp = null;
            IList list = null;

            if (itemData.TryGetValue(fieldKey, out temp))
                list = temp as IList;

            content.text = GDEConstants.SizeLbl;
            drawHelper.TryGetCachedSize(GDEConstants.SizeSizeLblKey, content, EditorStyles.label, out size);
            EditorGUI.LabelField(new Rect(drawHelper.CurrentLinePosition, drawHelper.TopOfLine(), size.x, size.y), content);
            drawHelper.CurrentLinePosition += (size.x + 2);

            int newListCount;
            string listCountKey = string.Format(GDMConstants.MetaDataFormat, itemKey, fieldKey);
            if (newListCountDict.ContainsKey(listCountKey))
            {
                newListCount = newListCountDict[listCountKey];
            }
            else
            {
                newListCount = list.Count;
                newListCountDict.Add(listCountKey, newListCount);
            }

            size.x = 40;
            newListCount = EditorGUI.IntField(new Rect(drawHelper.CurrentLinePosition, drawHelper.TopOfLine(), size.x, drawHelper.StandardHeight()), newListCount);
            drawHelper.CurrentLinePosition += (size.x + 4);

            content.text = GDEConstants.ResizeBtn;
            drawHelper.TryGetCachedSize(GDEConstants.SizeResizeBtnKey, content, GUI.skin.button, out size);
            newListCountDict[listCountKey] = newListCount;
            if (newListCount != list.Count && GUI.Button(new Rect(drawHelper.CurrentLinePosition, drawHelper.TopOfLine(), size.x, size.y), content))
            {
                ResizeList(list, newListCount, defaultResizeValue);
                newListCountDict[listCountKey] = newListCount;
                drawHelper.CurrentLinePosition += (size.x + 2);
            }

            drawHelper.NewLine();

            if (newFoldoutState)
            {
                for (int i = 0; i < list.Count; i++)
                {
                    drawHelper.CurrentLinePosition += GDEConstants.Indent*2;
                    content.text = string.Format("[{0}]:", i);

                    switch (fieldTypeEnum) {
                        case BasicFieldType.Bool:
                        {
                            DrawListBool(content, i, Convert.ToBoolean(list[i]), list);
                            drawHelper.NewLine();
                            break;
                        }
                        case BasicFieldType.Int:
                        {
                            DrawListInt(content, i, Convert.ToInt32(list[i]), list);
                            drawHelper.NewLine();
                            break;
                        }
                        case BasicFieldType.Float:
                        {
                            DrawListFloat(content, i, Convert.ToSingle(list[i]), list);
                            drawHelper.NewLine();
                            break;
                        }
                        case BasicFieldType.String:
                        {
                            DrawListString(content, i, list[i] as string, list);
                            drawHelper.NewLine();
                            break;
                        }
                        case BasicFieldType.Vector2:
                        {
                            DrawListVector2(content, i, list[i] as Dictionary<string, object>, list);
                            drawHelper.NewLine(GDEConstants.VectorFieldBuffer+1);
                            break;
                        }
                        case BasicFieldType.Vector3:
                        {
                            DrawListVector3(content, i, list[i] as Dictionary<string, object>, list);
                            drawHelper.NewLine(GDEConstants.VectorFieldBuffer+1);
                            break;
                        }
                        case BasicFieldType.Vector4:
                        {
                            DrawListVector4(content, i, list[i] as Dictionary<string, object>, list);
                            drawHelper.NewLine(GDEConstants.VectorFieldBuffer+1);
                            break;
                        }
                        case BasicFieldType.Color:
                        {
                            DrawListColor(content, i, list[i] as Dictionary<string, object>, list);
                            drawHelper.NewLine();
                            break;
                        }
                        case BasicFieldType.GameObject:
                        {
                            DrawListObject<GameObject>(foldoutKey+i, content, i, list[i] as GameObject, list);
                            drawHelper.NewLine();
                            break;
                        }
                        case BasicFieldType.Texture2D:
                        {
                            DrawListObject<Texture2D>(foldoutKey+i, content, i, list[i] as Texture2D, list);
                            drawHelper.NewLine();
                            break;
                        }
                        case BasicFieldType.Material:
                        {
                            DrawListObject<Material>(foldoutKey+i, content, i, list[i] as Material, list);
                            drawHelper.NewLine();
                            break;
                        }
                        case BasicFieldType.AudioClip:
                        {
                            DrawListAudio(foldoutKey+i, content, i, list[i] as AudioClip, list);
                            drawHelper.NewLine();
                            break;
                        }
                        default:
                        {
                            List<string> itemKeys = GetPossibleCustomValues(schemaKey, fieldType);
                            DrawListCustom(content, i, list[i] as string, list, true, itemKeys);
                            drawHelper.NewLine();
                            break;
                        }
                    }
                }
            }
        }
        catch(Exception ex)
        {
            Debug.LogError(ex);
        }
    }
    void Draw2DListField(string schemaKey, string itemKey, string fieldKey, Dictionary<string, object> itemData)
    {
        try
        {
            string foldoutKey = string.Format(GDMConstants.MetaDataFormat, itemKey, fieldKey);
            object defaultResizeValue;

            string fieldType;
            itemData.TryGetString(string.Format(GDMConstants.MetaDataFormat, GDMConstants.TypePrefix, fieldKey), out fieldType);

            BasicFieldType fieldTypeEnum = BasicFieldType.Undefined;
            if (Enum.IsDefined(typeof(BasicFieldType), fieldType))
            {
                fieldTypeEnum = (BasicFieldType)Enum.Parse(typeof(BasicFieldType), fieldType);
                fieldType = GDEItemManager.GetVariableTypeFor(fieldTypeEnum);
            }

            content.text = string.Format("List<List<{0}>>", fieldType);
            bool isOpen = DrawFoldout(content.text, foldoutKey, string.Empty, string.Empty, null);

            drawHelper.CurrentLinePosition = Math.Max(drawHelper.CurrentLinePosition, GDEConstants.MinLabelWidth+GDEConstants.Indent+4);
            content.text = fieldKey.HighlightSubstring(filterText, highlightColor);
            drawHelper.TryGetCachedSize(schemaKey+fieldKey+GDEConstants.LblSuffix, content, labelStyle, out size);

            size.x = Math.Max(size.x, GDEConstants.MinLabelWidth);
            EditorGUI.LabelField(new Rect(drawHelper.CurrentLinePosition, drawHelper.TopOfLine(), size.x, size.y), fieldKey.HighlightSubstring(filterText, highlightColor), labelStyle);
            drawHelper.CurrentLinePosition += (size.x + 2);

            object temp = null;
            IList list = null;

            if (itemData.TryGetValue(fieldKey, out temp))
                list = temp as IList;

            content.text = GDEConstants.SizeLbl;
            drawHelper.TryGetCachedSize(GDEConstants.SizeSizeLblKey, content, EditorStyles.label, out size);
            EditorGUI.LabelField(new Rect(drawHelper.CurrentLinePosition, drawHelper.TopOfLine(), size.x, size.y), content);
            drawHelper.CurrentLinePosition += (size.x + 2);

            int newListCount;
            string listCountKey = string.Format(GDMConstants.MetaDataFormat, itemKey, fieldKey);
            if (newListCountDict.ContainsKey(listCountKey))
            {
                newListCount = newListCountDict[listCountKey];
            }
            else
            {
                newListCount = list.Count;
                newListCountDict.Add(listCountKey, newListCount);
            }

            size.x = 40;
            newListCount = EditorGUI.IntField(new Rect(drawHelper.CurrentLinePosition, drawHelper.TopOfLine(), size.x, drawHelper.StandardHeight()), newListCount);
            drawHelper.CurrentLinePosition += (size.x + 4);

            content.text = GDEConstants.ResizeBtn;
            drawHelper.TryGetCachedSize(GDEConstants.SizeResizeBtnKey, content, GUI.skin.button, out size);
            newListCountDict[listCountKey] = newListCount;
            if (list != null && newListCount != list.Count && GUI.Button(new Rect(drawHelper.CurrentLinePosition, drawHelper.TopOfLine(), size.x, size.y), content))
            {
                if (GDEItemManager.IsUnityType(fieldTypeEnum))
                    defaultResizeValue = Activator.CreateInstance(list.GetType().GetGenericArguments()[0]);
                else
                    defaultResizeValue = new List<object>();

                ResizeList(list, newListCount, defaultResizeValue);
                newListCountDict[listCountKey] = newListCount;
                drawHelper.CurrentLinePosition += (size.x + 2);
            }

            drawHelper.NewLine();

            if (isOpen)
            {
                defaultResizeValue = GDEItemManager.GetDefaultValueForType(fieldTypeEnum);
                for (int index = 0; index < list.Count; index++)
                {
                    IList subList = list[index] as IList;

                    drawHelper.CurrentLinePosition += GDEConstants.Indent*2;
                    content.text = string.Format("[{0}]:    List<{1}>", index, fieldType);

                    isOpen = DrawFoldout(content.text, foldoutKey+"_"+index, string.Empty, string.Empty, null);
                    drawHelper.CurrentLinePosition += 4;

                    // Draw resize
                    content.text = GDEConstants.SizeLbl;
                    drawHelper.TryGetCachedSize(GDEConstants.SizeSizeLblKey, content, EditorStyles.label, out size);
                    EditorGUI.LabelField(new Rect(drawHelper.CurrentLinePosition, drawHelper.TopOfLine(), size.x, size.y), content);
                    drawHelper.CurrentLinePosition += (size.x + 2);

                    listCountKey = string.Format(GDMConstants.MetaDataFormat, schemaKey, fieldKey)+"_"+index;
                    if (newListCountDict.ContainsKey(listCountKey))
                    {
                        newListCount = newListCountDict[listCountKey];
                    }
                    else
                    {
                        newListCount = subList.Count;
                        newListCountDict.Add(listCountKey, newListCount);
                    }

                    size.x = 40;
                    newListCount = EditorGUI.IntField(new Rect(drawHelper.CurrentLinePosition, drawHelper.TopOfLine(), size.x, drawHelper.StandardHeight()), newListCount);
                    drawHelper.CurrentLinePosition += (size.x + 2);

                    newListCountDict[listCountKey] = newListCount;

                    content.text = GDEConstants.ResizeBtn;
                    drawHelper.TryGetCachedSize(GDEConstants.SizeResizeBtnKey, content, GUI.skin.button, out size);
                    if (newListCount != subList.Count)
                    {
                        if (GUI.Button(new Rect(drawHelper.CurrentLinePosition, drawHelper.TopOfLine(), size.x, size.y), content))
                            ResizeList(subList, newListCount, defaultResizeValue);
                        drawHelper.CurrentLinePosition += (size.x + 2);
                    }

                    drawHelper.NewLine();

                    if (isOpen)
                    {
                        for (int x = 0; x < subList.Count; x++)
                        {
                            drawHelper.CurrentLinePosition += GDEConstants.Indent*3;
                            content.text = string.Format("[{0}][{1}]:", index, x);

                            switch (fieldTypeEnum)
                            {
                                case BasicFieldType.Bool:
                                {
                                    DrawListBool(content, x, Convert.ToBoolean(subList[x]), subList);
                                    drawHelper.NewLine();
                                    break;
                                }
                                case BasicFieldType.Int:
                                {
                                    DrawListInt(content, x, Convert.ToInt32(subList[x]), subList);
                                    drawHelper.NewLine();
                                    break;
                                }
                                case BasicFieldType.Float:
                                {
                                    DrawListFloat(content, x, Convert.ToSingle(subList[x]), subList);
                                    drawHelper.NewLine();
                                    break;
                                }
                                case BasicFieldType.String:
                                {
                                    DrawListString(content, x, subList[x] as string, subList);
                                    drawHelper.NewLine();
                                    break;
                                }
                                case BasicFieldType.Vector2:
                                {
                                    DrawListVector2(content, x, subList[x] as Dictionary<string, object>, subList);
                                    drawHelper.NewLine(GDEConstants.VectorFieldBuffer+1);
                                    break;
                                }
                                case BasicFieldType.Vector3:
                                {
                                    DrawListVector3(content, x, subList[x] as Dictionary<string, object>, subList);
                                    drawHelper.NewLine(GDEConstants.VectorFieldBuffer+1);
                                    break;
                                }
                                case BasicFieldType.Vector4:
                                {
                                    DrawListVector4(content, x, subList[x] as Dictionary<string, object>, subList);
                                    drawHelper.NewLine(GDEConstants.VectorFieldBuffer+1);
                                    break;
                                }
                                case BasicFieldType.Color:
                                {
                                    DrawListColor(content, x, subList[x] as Dictionary<string, object>, subList);
                                    drawHelper.NewLine();
                                    break;
                                }
                                case BasicFieldType.GameObject:
                                {
                                    DrawListObject<GameObject>(foldoutKey+index+"_"+x, content, x, subList[x] as GameObject, subList);
                                    drawHelper.NewLine();
                                    break;
                                }
                                case BasicFieldType.Texture2D:
                                {
                                    DrawListObject<Texture2D>(foldoutKey+index+"_"+x, content, x, subList[x] as Texture2D, subList);
                                    drawHelper.NewLine();
                                    break;
                                }
                                case BasicFieldType.Material:
                                {
                                    DrawListObject<Material>(foldoutKey+index+"_"+x, content, x, subList[x] as Material, subList);
                                    drawHelper.NewLine();
                                    break;
                                }
                                case BasicFieldType.AudioClip:
                                {
                                    DrawListAudio(foldoutKey+index+"_"+x, content, x, subList[x] as AudioClip, subList);
                                    drawHelper.NewLine();
                                    break;
                                }
                                default:
                                {
                                    List<string> itemKeys = GetPossibleCustomValues(schemaKey, fieldType);
                                    DrawListCustom(content, x, subList[x] as string, subList, true, itemKeys);
                                    drawHelper.NewLine();
                                    break;
                                }
                            }
                        }
                    }
                }
            }
        }
        catch(Exception ex)
        {
            Debug.LogError(ex);
        }
    }
    protected override bool ShouldFilter(string itemKey, Dictionary<string, object> itemData)
    {
        if (itemData == null)
            return true;

        string schemaType = "<unknown>";
        itemData.TryGetString(GDMConstants.SchemaKey, out schemaType);

        // Return if we don't match any of the filter types
        if (GDEItemManager.FilterSchemaKeyArray.IsValidIndex(filterSchemaIndex) &&
            !GDEItemManager.FilterSchemaKeyArray[filterSchemaIndex].Equals(GDEConstants._AllLbl) &&
            !schemaType.Equals(GDEItemManager.FilterSchemaKeyArray[filterSchemaIndex]))
            return true;
        else if (!GDEItemManager.FilterSchemaKeyArray[filterSchemaIndex].Equals(GDEConstants._AllLbl) &&
                 schemaType.Equals(GDEItemManager.FilterSchemaKeyArray[filterSchemaIndex]) &&
                 string.IsNullOrEmpty(filterText))
            return false;

        bool schemaKeyMatch = schemaType.ToLower().Contains(filterText.ToLower());
        bool fieldKeyMatch = !GDEItemManager.ShouldFilterByField(schemaType, filterText);
        bool itemKeyMatch = itemKey.ToLower().Contains(filterText.ToLower());

        // Return if the schema keys don't contain the filter text or
        // if the schema fields don't contain the filter text
        if (!schemaKeyMatch && !fieldKeyMatch && !itemKeyMatch)
            return true;

        return false;
    }
        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(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);
            }
        }
    void DrawSingleField(string schemaKey, string fieldKey, Dictionary<string, object> schemaData)
    {
        string fieldPreviewKey = schemaKey+"_"+fieldKey;
        string fieldType;
        schemaData.TryGetString(string.Format(GDMConstants.MetaDataFormat, GDMConstants.TypePrefix, fieldKey), out fieldType);

        BasicFieldType fieldTypeEnum = BasicFieldType.Undefined;
        if (Enum.IsDefined(typeof(BasicFieldType), fieldType))
        {
            fieldTypeEnum = (BasicFieldType)Enum.Parse(typeof(BasicFieldType), fieldType);
            fieldType = GDEItemManager.GetVariableTypeFor(fieldTypeEnum);
        }

        content.text = fieldType;
        drawHelper.TryGetCachedSize(schemaKey+fieldKey+GDEConstants.TypeSuffix, content, labelStyle, out size);

        size.x = Math.Max(size.x, GDEConstants.MinLabelWidth);
        GUI.Label(new Rect(drawHelper.CurrentLinePosition, drawHelper.TopOfLine(), size.x, size.y), content, labelStyle);
        drawHelper.CurrentLinePosition += (size.x + 2);

        string editFieldKey = string.Format(GDMConstants.MetaDataFormat, schemaKey, fieldKey);
        DrawEditableLabel(fieldKey, editFieldKey, RenameSchemaField, schemaData);

        switch(fieldTypeEnum)
        {
            case BasicFieldType.Bool:
                DrawBool(fieldKey, schemaData, GDEConstants.DefaultValueLbl);
                break;
            case BasicFieldType.Int:
                DrawInt(fieldKey, schemaData, GDEConstants.DefaultValueLbl);
                break;
            case BasicFieldType.Float:
                DrawFloat(fieldKey, schemaData, GDEConstants.DefaultValueLbl);
                break;
            case BasicFieldType.String:
                DrawString(fieldKey, schemaData, GDEConstants.DefaultValueLbl);
                break;

            case BasicFieldType.Vector2:
                DrawVector2(fieldKey, schemaData, GDEConstants.DefaultValueLbl);
                break;
            case BasicFieldType.Vector3:
                DrawVector3(fieldKey, schemaData, GDEConstants.DefaultValueLbl);
                break;
            case BasicFieldType.Vector4:
                DrawVector4(fieldKey, schemaData, GDEConstants.DefaultValueLbl);
                break;

            case BasicFieldType.Color:
                DrawColor(fieldKey, schemaData, GDEConstants.DefaultValueLbl);
                break;

            case BasicFieldType.GameObject:
                DrawObject<GameObject>(fieldPreviewKey, fieldKey, schemaData, GDEConstants.DefaultValueLbl);
                break;

            case BasicFieldType.Texture2D:
                DrawObject<Texture2D>(fieldPreviewKey, fieldKey, schemaData, GDEConstants.DefaultValueLbl);
                break;

            case BasicFieldType.Material:
                DrawObject<Material>(fieldPreviewKey, fieldKey, schemaData, GDEConstants.DefaultValueLbl);
                break;

            case BasicFieldType.AudioClip:
                DrawAudio(fieldPreviewKey, fieldKey, schemaData, GDEConstants.DefaultValueLbl);
                break;

            default:
                DrawCustom(fieldKey, schemaData, false);
                break;
        }

        content.text = GDEConstants.DeleteBtn;
        drawHelper.TryGetCachedSize(GDEConstants.SizeDeleteBtnKey, content, GUI.skin.button, out size);
        if (fieldTypeEnum.Equals(BasicFieldType.Vector2) ||
            fieldTypeEnum.Equals(BasicFieldType.Vector3) ||
            fieldTypeEnum.Equals(BasicFieldType.Vector4))
        {
            if (GUI.Button(new Rect(drawHelper.CurrentLinePosition, drawHelper.VerticalMiddleOfLine(), size.x, size.y), content))
                deletedFields.Add(fieldKey);

            drawHelper.NewLine(GDEConstants.VectorFieldBuffer+1);
        }
        else
        {
            if (GUI.Button(new Rect(drawHelper.CurrentLinePosition, drawHelper.TopOfLine(), size.x, size.y), content))
                deletedFields.Add(fieldKey);

            drawHelper.NewLine();
        }
    }
Beispiel #44
0
        private static void AppendResetVariableMethods(StringBuilder sb, string schemaKey, Dictionary<string, object> schemaData)
        {
            bool shouldAppendSpace = false;
            bool didAppendSpaceForSection = false;
            bool isFirstSection = true;

            string variableType;

            // Append all the single variables first
            foreach(BasicFieldType fieldType in GDEItemManager.BasicFieldTypes)
            {
                variableType = fieldType.ToString();
                List<string> fieldKeys = GDEItemManager.SchemaFieldKeysOfType(schemaKey, fieldType.ToString(), 0);
                foreach(string fieldKey in fieldKeys)
                {
                    if (shouldAppendSpace)
                        sb.Append("\n");

                    AppendResetVariableMethod(sb, fieldKey, variableType);
                    shouldAppendSpace = true;
                    isFirstSection = false;
                }
            }

            // Append all list variables
            for(int dimension = 1;  dimension <= 2;  dimension++)
            {
                foreach(BasicFieldType fieldType in GDEItemManager.BasicFieldTypes)
                {
                    variableType = fieldType.ToString();
                    List<string> fieldKeys = GDEItemManager.SchemaFieldKeysOfType(schemaKey, variableType, dimension);
                    foreach(string fieldKey in fieldKeys)
                    {
                        if (shouldAppendSpace && !didAppendSpaceForSection && !isFirstSection)
                        {
                            sb.Append("\n");
                        }

                        AppendResetListVariableMethod(sb, fieldKey, variableType, dimension);
                        shouldAppendSpace = true;
                        didAppendSpaceForSection = true;
                        isFirstSection = false;
                    }
                }
                didAppendSpaceForSection = false;
            }

            // Append all custom variables
            for(int dimension = 0;  dimension <= 2;  dimension++)
            {
                List<string> fieldKeys = GDEItemManager.SchemaCustomFieldKeys(schemaKey, dimension);
                foreach(string fieldKey in fieldKeys)
                {
                    if (shouldAppendSpace && !didAppendSpaceForSection && !isFirstSection)
                    {
                        sb.Append("\n");
                    }

                    schemaData.TryGetString(string.Format(GDMConstants.MetaDataFormat, GDMConstants.TypePrefix, fieldKey), out variableType);
                    variableType = string.Format(GDECodeGenConstants.DataClassNameFormat, variableType);

                    AppendResetCustomVariableMethod(sb, fieldKey, variableType, dimension);
                    shouldAppendSpace = true;
                    didAppendSpaceForSection = true;
                    isFirstSection = false;
                }

                didAppendSpaceForSection = false;
            }
        }
    void DrawSingleField(string schemaKey, string fieldKey, Dictionary<string, object> schemaData)
    {
        string fieldType;
        schemaData.TryGetString(string.Format(GDEConstants.MetaDataFormat, GDEConstants.TypePrefix, fieldKey), out fieldType);

        BasicFieldType fieldTypeEnum = BasicFieldType.Undefined;
        if (Enum.IsDefined(typeof(BasicFieldType), fieldType))
        {
            fieldTypeEnum = (BasicFieldType)Enum.Parse(typeof(BasicFieldType), fieldType);
            if (!fieldTypeEnum.Equals(BasicFieldType.Vector2) &&
                !fieldTypeEnum.Equals(BasicFieldType.Vector3) &&
                !fieldTypeEnum.Equals(BasicFieldType.Vector4) &&
                !fieldTypeEnum.Equals(BasicFieldType.Color))
                fieldType = fieldType.ToLower();
        }

        float width = 120;
        EditorGUI.LabelField(new Rect(currentLinePosition, TopOfLine(), width, StandardHeight()), fieldType);
        currentLinePosition += (width + 2);

        string editFieldKey = string.Format(GDEConstants.MetaDataFormat, schemaKey, fieldKey);
        DrawEditableLabel(fieldKey, editFieldKey, RenameSchemaField, schemaData);

        switch(fieldTypeEnum)
        {
            case BasicFieldType.Bool:
                DrawBool(fieldKey, schemaData, GDEStrings.DefaultValueLbl);
                break;
            case BasicFieldType.Int:
                DrawInt(fieldKey, schemaData, GDEStrings.DefaultValueLbl);
                break;
            case BasicFieldType.Float:
                DrawFloat(fieldKey, schemaData, GDEStrings.DefaultValueLbl);
                break;
            case BasicFieldType.String:
                DrawString(fieldKey, schemaData, GDEStrings.DefaultValueLbl);
                break;

            case BasicFieldType.Vector2:
                DrawVector2(fieldKey, schemaData, GDEStrings.DefaultValuesLbl);
                break;
            case BasicFieldType.Vector3:
                DrawVector3(fieldKey, schemaData, GDEStrings.DefaultValuesLbl);
                break;
            case BasicFieldType.Vector4:
                DrawVector4(fieldKey, schemaData, GDEStrings.DefaultValuesLbl);
                break;

            case BasicFieldType.Color:
                DrawColor(fieldKey, schemaData, GDEStrings.DefaultValuesLbl);
                break;

            default:
                DrawCustom(fieldKey, schemaData, false);
                break;
        }

        GUIContent content = new GUIContent(GDEStrings.DeleteBtn);
        width = GUI.skin.button.CalcSize(content).x;
        if (fieldTypeEnum.Equals(BasicFieldType.Vector2) ||
            fieldTypeEnum.Equals(BasicFieldType.Vector3) ||
            fieldTypeEnum.Equals(BasicFieldType.Vector4))
        {
            if (GUI.Button(new Rect(currentLinePosition, VerticalMiddleOfLine(), width, StandardHeight()), content))
                deletedFields.Add(fieldKey);

            NewLine(GDEConstants.VectorFieldBuffer+1);
        }
        else
        {
            if (GUI.Button(new Rect(currentLinePosition, TopOfLine(), width, StandardHeight()), content))
                deletedFields.Add(fieldKey);

            NewLine();
        }
    }
Beispiel #46
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);
            }
        }
    void DrawSingleField(string schemaKey, string fieldKey, Dictionary<string, object> itemData)
    {
        string fieldType;
        itemData.TryGetString(string.Format(GDEConstants.MetaDataFormat, GDEConstants.TypePrefix, fieldKey), out fieldType);

        BasicFieldType fieldTypeEnum = BasicFieldType.Undefined;
        if (Enum.IsDefined(typeof(BasicFieldType), fieldType))
        {
            fieldTypeEnum = (BasicFieldType)Enum.Parse(typeof(BasicFieldType), fieldType);
            if (!fieldTypeEnum.Equals(BasicFieldType.Vector2) &&
                !fieldTypeEnum.Equals(BasicFieldType.Vector3) &&
                !fieldTypeEnum.Equals(BasicFieldType.Vector4) &&
                !fieldTypeEnum.Equals(BasicFieldType.Color))
                fieldType = fieldType.ToLower();
        }

        float width = 120;
        EditorGUI.LabelField(new Rect(currentLinePosition, TopOfLine(), width, StandardHeight()), fieldType);
        currentLinePosition += (width + 2);

        width = 120;
        EditorGUI.LabelField(new Rect(currentLinePosition, TopOfLine(), width, StandardHeight()), fieldKey.HighlightSubstring(filterText, highlightColor), labelStyle);
        currentLinePosition += (width + 2);

        switch(fieldTypeEnum)
        {
            case BasicFieldType.Bool:
            {
                DrawBool(fieldKey, itemData, GDEStrings.ValueLbl);
                NewLine();
                break;
            }
            case BasicFieldType.Int:
            {
                DrawInt(fieldKey, itemData, GDEStrings.ValueLbl);
                NewLine();
                break;
            }
            case BasicFieldType.Float:
            {
                DrawFloat(fieldKey, itemData, GDEStrings.ValueLbl);
                NewLine();
                break;
            }
            case BasicFieldType.String:
            {
                DrawString(fieldKey, itemData, GDEStrings.ValueLbl);
                NewLine();
                break;
            }
            case BasicFieldType.Vector2:
            {
                DrawVector2(fieldKey, itemData, GDEStrings.ValuesLbl);
                NewLine(GDEConstants.VectorFieldBuffer+1);
                break;
            }
            case BasicFieldType.Vector3:
            {
                DrawVector3(fieldKey, itemData, GDEStrings.ValuesLbl);
                NewLine(GDEConstants.VectorFieldBuffer+1);
                break;
            }
            case BasicFieldType.Vector4:
            {
                DrawVector4(fieldKey, itemData, GDEStrings.ValuesLbl);
                NewLine(GDEConstants.VectorFieldBuffer+1);
                break;
            }
            case BasicFieldType.Color:
            {
                DrawColor(fieldKey, itemData, GDEStrings.ValuesLbl);
                NewLine();
                break;
            }

            default:
            {
                List<string> itemKeys = GetPossibleCustomValues(schemaKey, fieldType);
                DrawCustom(fieldKey, itemData, true, itemKeys);
                NewLine();
                break;
            }
        }
    }
        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);
            }
        }