private void CreateNpcModel(int npcId)
    {
        string uiname = ((NpcTypeID)npcId).ToString();
        var    tfNpc  = Module_Home.instance.FindChild(uiname);

        if (tfNpc != null)
        {
            moduleHome.HideOthers(uiname);
            return;
        }

        moduleHome.HideOthers();
        Level.PrepareAssets(Module_Battle.BuildNpcSimplePreloadAssets(npcId), r =>
        {
            moduleGlobal.UnLockUI();
            if (!r)
            {
                return;
            }

            var npc = moduleHome.CreateNpc(npcId, Vector3.zero, new Vector3(0, 180, 0), uiname);
            if (npc)
            {
                npc.animator.enabled = false;
                npc.gameObject.SafeSetActive(true);
            }
            moduleHome.HideOthers(uiname);
        });
    }
Esempio n. 2
0
    public void Create_Npc()
    {
        Module_Home.instance.HideOthers(uiName);

        CreateClickBox();
        if (npc_creatrue || isCreating)
        {
            return;
        }

        //在创建一个NPC之前,先找有没有已经创建了这个NPC,避免重复创建
        var npc = Module_Home.instance.FindChild(uiName);

        if (npc)
        {
            var behaviour = npc.GetComponent <SceneObjectBehaviour>();
            npc_creatrue = behaviour?.sceneObject as Creature;
            if (npc_creatrue)
            {
                npc_creatrue.gameObject.SafeSetActive(false);

                SetCurNpc();
                OnComplate(npc_creatrue);
                return;
            }

            Destroy(npc);
        }

        isCreating = true;
        Module_Global.instance.LockUI("", 0.2f);

        Level.PrepareAssets(Module_Battle.BuildNpcSimplePreloadAssets((int)npc_Type), r =>
        {
            Module_Global.instance.UnLockUI();
            if (!r)
            {
                return;
            }

            npc_creatrue = Module_Home.instance.CreateNpc((int)npc_Type, Vector3.zero, new Vector3(0, 180, 0), uiName);
            if (npc_creatrue)
            {
                SetCurNpc();

                npc_creatrue.animator.enabled = false;
                npc_creatrue.gameObject.SafeSetActive(false);

                OnComplate(npc_creatrue);
            }
            isCreating = false;
        });
    }
Esempio n. 3
0
    public static List <string> GetPerStoryPreAssets(int plotId, EnumStoryType type, int index)
    {
        List <string> list  = new List <string>();
        StoryInfo     story = ConfigManager.Get <StoryInfo>(plotId);

        index += GeneralConfigInfo.sstoryPreLoadNum;
        if (story)
        {
            if (story.storyItems.Length - 1 < index || index < 0)
            {
                return(null);
            }
            StoryInfo.StoryItem item = story.storyItems[index];

            #region theatre story
            if (type == EnumStoryType.TheatreStory || type == EnumStoryType.NpcTheatreStory)
            {
                //npc assets
                for (int j = 0; j < item.talkingRoles.Length; j++)
                {
                    NpcInfo npc = ConfigManager.Get <NpcInfo>(item.talkingRoles[j].roleId);
                    if (npc == null)
                    {
                        continue;
                    }

                    var npcAssets = Module_Battle.BuildNpcSimplePreloadAssets(npc.ID);
                    for (int m = 0; m < npcAssets.Count; m++)
                    {
                        list.Add(npcAssets[m]);
                    }
                }

                //texture assets
                list.Add(item.background);
                list.Add(item.contentBg);
                if (!item.playerIconDetail.Equals("PlayerIcon"))
                {
                    list.Add(item.playerIconDetail);
                }

                //model assets
                if (item.models != null && item.models.Length > 0)
                {
                    for (int ii = 0; ii < item.models.Length; ii++)
                    {
                        list.Add(item.models[ii].model);
                    }
                }
            }
            #endregion

            #region common data
            //full screen effect
            list.Add(item.effect);
            if (item.effect.Equals(StoryConst.EYE_CLIP_EFFECT))
            {
                list.Add(StoryConst.EYE_GAUSS_MATERIAL_ASSET);
            }
            //music assets
            if (item.musicData.validMusic && !item.musicData.musicName.Equals(StoryConst.STOP_CURRENT_MUSIC_FLAG) &&
                !item.musicData.musicName.Equals(StoryConst.RESET_CURRENT_MUSIC_FLAG) && !item.musicData.musicName.Equals(StoryConst.RESET_LAST_MUSIC_FLAG)
                )
            {
                list.Add(item.musicData.musicName);
            }
            //voice assets
            list.Add(item.voiceName);
            //sound effect assets
            for (int j = 0; j < item.soundEffect.Length; j++)
            {
                list.Add(item.soundEffect[j].soundName);
            }
            #endregion
        }
        return(list);
    }
Esempio n. 4
0
    /// <summary>
    /// 针对不同的模式可能会加载不同的资源
    /// </summary>
    /// <param name="plotId"></param>
    /// <param name="type">1代表剧场对话,2代表战斗对话</param>
    /// <returns></returns>
    public static List <string> GetPerStoryPreAssets(int plotId, EnumStoryType type)
    {
        List <string> list = new List <string>();

        switch (type)
        {
        case EnumStoryType.TheatreStory:
        case EnumStoryType.NpcTheatreStory:
            list.Add(StoryConst.THEATRE_STORY_ASSET_NAME);
            list.Add(StoryConst.THEATRE_MASK_ASSET_NAME);
            list.Add(StoryConst.THEATRE_GM_ASSET_NAME);
            //list.Add(StoryConst.DEFALUT_CONTENT_BG);
            break;

        case EnumStoryType.FreeBattleStory:
        case EnumStoryType.PauseBattleStory:
            list.Add(StoryConst.BATTLE_STORY_ASSET_NAME);
            break;
        }

        StoryInfo story = ConfigManager.Get <StoryInfo>(plotId);

        if (story)
        {
            //if (type == EnumStoryType.TheatreStory) list.Add("character_render_camera");
            //load
            StoryInfo.StoryItem item = null;
            for (int i = 0; i < story.storyItems.Length; i++)
            {
                if (i > GeneralConfigInfo.sstoryPreLoadNum && GeneralConfigInfo.sstoryPreLoadNum > 0)
                {
                    break;
                }

                item = story.storyItems[i];

                #region theatre story
                if (type == EnumStoryType.TheatreStory || type == EnumStoryType.NpcTheatreStory)
                {
                    //npc assets
                    for (int j = 0; j < item.talkingRoles.Length; j++)
                    {
                        NpcInfo npc = ConfigManager.Get <NpcInfo>(item.talkingRoles[j].roleId);
                        if (npc == null)
                        {
                            continue;
                        }

                        var npcAssets = Module_Battle.BuildNpcSimplePreloadAssets(npc.ID);
                        for (int m = 0; m < npcAssets.Count; m++)
                        {
                            list.Add(npcAssets[m]);
                        }
                    }
                    //texture assets
                    list.Add(item.background);
                    list.Add(item.contentBg);
                    if (!item.playerIconDetail.Equals("PlayerIcon"))
                    {
                        list.Add(item.playerIconDetail);
                    }
                    //model assets
                    if (item.models != null && item.models.Length > 0)
                    {
                        for (int ii = 0; ii < item.models.Length; ii++)
                        {
                            list.Add(item.models[ii].model);
                        }
                    }
                }
                #endregion

                #region common data
                list.Add(item.effect);
                if (item.effect.Equals(StoryConst.EYE_CLIP_EFFECT))
                {
                    list.Add(StoryConst.EYE_GAUSS_MATERIAL_ASSET);
                }

                //music assets
                if (item.musicData.validMusic && !item.musicData.musicName.Equals(StoryConst.STOP_CURRENT_MUSIC_FLAG) &&
                    !item.musicData.musicName.Equals(StoryConst.RESET_CURRENT_MUSIC_FLAG) && !item.musicData.musicName.Equals(StoryConst.RESET_LAST_MUSIC_FLAG))
                {
                    list.Add(item.musicData.musicName);
                }
                //voice assets
                list.Add(item.voiceName);
                //sound effect assets
                for (int j = 0; j < item.soundEffect.Length; j++)
                {
                    list.Add(item.soundEffect[j].soundName);
                }
                #endregion
            }
        }

        return(list);
    }