コード例 #1
0
        public static CinemaJsonData LoadData(CinemaType type, string dataPath)
        {
            CinemaJsonData result = null;

            switch (type)
            {
            case CinemaType.Live:
                result = Persistence.json.LoadFile <CinemaJsonData>(dataPath);
                break;

            case CinemaType.Anchor:
                result = Persistence.json.LoadFile <AnchorCinemaJsonData>(dataPath);
                break;

            case CinemaType.Camera:
                result = Persistence.json.LoadFile <CameraCinemaJsonData>(dataPath);
                break;
            }
            return(result);
        }
コード例 #2
0
        //读取本地的动画相关json数据并缓存
        private void _LoadAndCacheCinemaJsonData()
        {
            cinemaIdMapCinemaJsonData.Clear();
            cinemaNameMapCinemaJsonData.Clear();
            cinemaIdMapCinemaName.Clear();
            cinemaTypeMapCinemaIds.Clear();
            npcIdMapCinemaIds.Clear();
            cinemaListData = null;
            //加载cinema_list数据
            cinemaListData = Persistence.json.LoadFile <CinemaListJsonData>(CinemaDataCommon.GetCinemaListFullPath());
            int count = 0;

            if (null != cinemaListData)
            {
                count = cinemaListData.cinema_list.Length;
            }

            string cinemaJsonFullPath = "";

            for (int i = 0; i < count; i++)
            {
                var lData = cinemaListData.cinema_list[i];
                cinemaJsonFullPath = CinemaDataCommon.GetCinemaJsonFileFullPath(lData.path);
                CinemaJsonData cinemaJsonData = CinemaJsonData.LoadData(lData.type, cinemaJsonFullPath);

                //缓存数据1
                CinemaJsonData tmpCinemaJsonData = null;
                if (!cinemaIdMapCinemaJsonData.TryGetValue(lData.id, out tmpCinemaJsonData))
                {
                    cinemaIdMapCinemaJsonData.Add(lData.id, cinemaJsonData);
                }
                else
                {
                    cinemaIdMapCinemaJsonData[lData.id] = cinemaJsonData;
                }

                //缓存数据2
                CinemaJsonData tmpCinemaJsonData2 = null;
                if (!cinemaNameMapCinemaJsonData.TryGetValue(lData.path, out tmpCinemaJsonData2))
                {
                    cinemaNameMapCinemaJsonData.Add(lData.path, cinemaJsonData);
                }
                else
                {
                    cinemaNameMapCinemaJsonData[lData.path] = cinemaJsonData;
                }

                //缓存数据3
                string tempName = "";
                if (!cinemaIdMapCinemaName.TryGetValue(lData.id, out tempName))
                {
                    cinemaIdMapCinemaName.Add(lData.id, lData.path);
                }
                else
                {
                    cinemaIdMapCinemaName[lData.id] = lData.path;
                }
                //缓存数据4
                List <int> tempList;
                if (!cinemaTypeMapCinemaIds.TryGetValue(lData.type, out tempList))
                {
                    cinemaTypeMapCinemaIds[lData.type] = new List <int>();
                }
                if (!cinemaTypeMapCinemaIds[lData.type].Contains(lData.id))
                {
                    cinemaTypeMapCinemaIds[lData.type].Add(lData.id);
                }

                //缓存数据5
                List <int> tempList2;
                if (cinemaJsonData is CameraCinemaJsonData)
                {
                    int[] npcIds = (cinemaJsonData as CameraCinemaJsonData).hideNpcIds;
                    if (null != npcIds && npcIds.Length > 0)
                    {
                        for (int j = 0; j < npcIds.Length; j++)
                        {
                            int npcId = npcIds[j];
                            if (!npcIdMapCinemaIds.TryGetValue(npcId, out tempList2))
                            {
                                npcIdMapCinemaIds[npcId] = new List <int>();
                            }
                            npcIdMapCinemaIds[npcId].Add(lData.id);
                        }
                    }
                }
            }
        }