protected virtual void LoadSceneObjects()
        {
            m_is_entity_collection_created = false;

            var exhibitions = GameEvents.UIEvents.UI_Bag_Event.Listen_GetAllExhibitions.SafeInvoke();

            foreach (PropData ex in exhibitions)
            {
                EntityBase sceneItemEntity = EntityManager.Instance.AllocEntity(EntityType.Scene_Exhibit);

                sceneItemEntity.SetAssetName(ex.prop.exhibit);
                sceneItemEntity.SetEntityData(ex.prop.id);
                //sceneItemEntity.SetLightTexture(m_sceneExtraLightTex);
                sceneItemEntity.PreloadAsset();

                AddSceneEntity(sceneItemEntity);
            }

            m_is_entity_collection_created = true;
        }
Exemple #2
0
        /// <summary>
        /// 载入场景物件
        /// </summary>
        /// <param name="decoratorList"></param>
        /// <param name="taskObjectList"></param>
        protected virtual void LoadSceneObjects(IList <long> decoratorList, IList <long> taskObjectList)
        {
            EngineCoreEvents.ResourceEvent.GetAssetEvent.SafeInvoke(this.m_sceneData.exhibitGroupId, (assetName, assetObject) =>
            {
                m_sceneInfo = JSON.ToObject <SceneItemJson>(assetObject.ToString());

                EngineCoreEvents.ResourceEvent.ReleaseAssetEvent.SafeInvoke(m_sceneData.exhibitGroupId, assetObject);

                Dictionary <long, ItemInfoJson> sceneItemConfigDict = new Dictionary <long, ItemInfoJson>();

                //临时修改加载lightmap
                GOGUI.GOGUITools.GetAssetAction.SafeInvoke(m_sceneInfo.lightMapName, (prefabName, obj) =>
                {
                    this.m_isLightMapReady = true;
                    //Texture lightTex = null;

                    if (StringUtils.IsNullEmptyOrWhiteSpace(m_sceneInfo.lightMapName) || obj == null)
                    {
                        Debug.LogWarning($"can't find lightmap in  {assetName}");
                    }

                    if (obj != null)
                    {
                        this.m_sceneExtraLightTex = obj as Texture;
                    }

                    for (int i = 0; i < m_sceneInfo.items.Count; ++i)
                    {
                        ItemInfoJson itemInfo = m_sceneInfo.items[i];

                        if (!sceneItemConfigDict.ContainsKey(itemInfo.itemID))
                        {
                            sceneItemConfigDict.Add(itemInfo.itemID, itemInfo);
                        }
                        else
                        {
                            Debug.LogError("item id duplicate ,item id:" + itemInfo.itemID + ", config info :" + assetName);
                        }
                    }


                    //todo:之后重构 2018-7-26 20:25:39
                    for (int i = 0; i < decoratorList.Count; ++i)
                    {
                        long itemID = decoratorList[i];
                        if (!sceneItemConfigDict.ContainsKey(itemID))
                        {
                            Debug.LogError("no item :" + itemID + " in " + assetName);
                        }

                        ItemInfoJson itemInfo = sceneItemConfigDict[itemID];

                        EntityBase sceneItemEntity = EntityManager.Instance.AllocEntity(EntityType.Scene_Decoration);
                        Confexhibit confItem       = Confexhibit.Get(itemInfo.itemID);
                        if (confItem == null || string.IsNullOrEmpty(confItem.assetName))
                        {
                            Debug.Log("can't find item:" + itemInfo.itemID);
                            continue;
                        }
                        sceneItemEntity.SetAssetName(confItem.assetName);
                        sceneItemEntity.SetEntityData(itemInfo);
                        sceneItemEntity.SetLightTexture(m_sceneExtraLightTex);
                        sceneItemEntity.PreloadAsset();

                        AddSceneEntity(sceneItemEntity);
                    }

                    for (int i = 0; i < taskObjectList.Count; ++i)
                    {
                        long itemID = taskObjectList[i];
                        if (!sceneItemConfigDict.ContainsKey(itemID))
                        {
                            Debug.LogError("no item :" + itemID + " in " + assetName);
                        }

                        ItemInfoJson itemInfo = sceneItemConfigDict[itemID];

                        EntityBase sceneItemEntity = EntityManager.Instance.AllocEntity(EntityType.Scene_Object);
                        Confexhibit confItem       = Confexhibit.Get(itemInfo.itemID);
                        if (confItem == null || string.IsNullOrEmpty(confItem.assetName))
                        {
                            Debug.Log("can't find item:" + itemInfo.itemID);
                            continue;
                        }
                        sceneItemEntity.SetAssetName(confItem.assetName);
                        sceneItemEntity.SetEntityData(itemInfo);
                        sceneItemEntity.SetLightTexture(m_sceneExtraLightTex);
                        sceneItemEntity.PreloadAsset();

                        AddSceneEntity(sceneItemEntity);
                    }

                    InitFindingEntityItems();
                }, LoadPriority.Default);
                ///////
            }, LoadPriority.Prior);
        }