示例#1
0
    public void ParseJsonEvents(JsonData data)
    {
        if (!data.Keys.Contains(sevent))
        {
            return;
        }
        JsonData jItem = data[sevent];

        if (!jItem.IsArray)
        {
            return;
        }
        EventList.Clear();
        for (int i = 0; i < jItem.Count; i++)
        {
            if (!jItem[i].Keys.Contains(seventList))
            {
                continue;
            }
            JsonData jEventList = jItem[i][seventList];
            if (!jEventList.IsArray)
            {
                Debug.Log("!jEventList.IsArray");
                return;
            }
            int levelId = int.Parse(jItem[i][slevelId].ToString());
            int roomId  = int.Parse(jItem[i][sroomId].ToString());
            for (int n = 0; n < jEventList.Count; n++)
            {
                int         eventId       = int.Parse(jEventList[n][seventId].ToString());
                ENTriggerID triggerId     = (ENTriggerID)int.Parse(jEventList[n][striggerTypeId].ToString());
                EventBase   eventBase     = CreateEvent(triggerId);
                JsonData    jActionIdList = jEventList[n][sactionList];
                if (jActionIdList.IsArray)
                {
                    for (int j = 0; j < jActionIdList.Count; j++)
                    {
                        int resultID = (roomId * 1000) + int.Parse(jActionIdList[j].ToString());
                        eventBase.ResultList.Add(resultID);
                    }
                }
                eventBase.Guid    = (roomId * 1000) + eventId;
                eventBase.LevelId = levelId;
                eventBase.RoomId  = roomId;
                eventBase.ParseJsonData(jEventList[n][sparams]);
                EventList.Add(eventBase);
            }
        }
    }