/// <summary> /// 刷新场景数据 /// </summary> /// <param name="listData"></param> public void RefreshSceneData(List <StoryInfoDetailsBean> listData) { if (listData == null) { return; } if (listStoryTextInfo != null) { listStoryTextInfo.Clear(); } listStoryTextInfo = null; foreach (StoryInfoDetailsBean itemData in listData) { StoryInfoDetailsBean.StoryInfoDetailsTypeEnum storyInfoDetailsType = itemData.GetStoryInfoDetailsType(); if (storyInfoDetailsType == StoryInfoDetailsBean.StoryInfoDetailsTypeEnum.NpcPosition) { GameObject objNpc = GetSceneObjByName("character_" + itemData.num); BaseNpcAI npcAI = null; if (objNpc != null) { npcAI = objNpc.GetComponent <BaseNpcAI>(); } if (npcAI == null) { NpcInfoBean npcInfoBean; if (itemData.npc_id == 0) { npcInfoBean = new NpcInfoBean(); } else if (itemData.npc_id == -1) { npcInfoBean = new NpcInfoBean(); } else { if (mapNpcInfo.TryGetValue(itemData.npc_id, out NpcInfoBean npcInfo)) { npcInfoBean = npcInfo; } else { npcInfoBean = new NpcInfoBean(); LogUtil.LogError("创建NPC失败 找不到ID为" + itemData.npc_id + "的NPC信息"); } } objNpc = CreateNpc(npcInfoBean.npc_id, new Vector3(itemData.position_x, itemData.position_y), itemData.num); npcAI = objNpc.GetComponent <BaseNpcAI>(); } npcAI.transform.localPosition = new Vector3(itemData.position_x, itemData.position_y); //设置朝向 npcAI.SetCharacterFace(itemData.face); } else if (storyInfoDetailsType == StoryInfoDetailsBean.StoryInfoDetailsTypeEnum.NpcEquip) { GameObject objNpc = GetSceneObjByName("character_" + itemData.num); if (objNpc == null) { continue; } BaseNpcAI npcAI = objNpc.GetComponent <BaseNpcAI>(); if (npcAI == null) { continue; } SexEnum sex = npcAI.characterData.body.GetSex(); itemData.GetNpcEquip(sex, out long hatId, out long clothesId, out long shoesId); if (hatId != -1) { npcAI.characterData.equips.hatTFId = hatId; } if (clothesId != -1) { npcAI.characterData.equips.clothesTFId = clothesId; } if (shoesId != -1) { npcAI.characterData.equips.shoesTFId = shoesId; } npcAI.SetCharacterData(npcAI.characterData); } else if (storyInfoDetailsType == StoryInfoDetailsBean.StoryInfoDetailsTypeEnum.PropPosition) { GameObject objProp = GetSceneObjByName("prop_" + itemData.num); if (objProp == null) { GameObject objModel = StoryInfoHandler.Instance.manager.GetStoryPropModelByName(itemData.key_name); objProp = Instantiate(objModel, StoryInfoHandler.Instance.builderForStory.transform); objProp.name = "prop_" + itemData.num; } //设置位置和朝向 objProp.transform.localPosition = new Vector3(itemData.position_x, itemData.position_y); Vector3 bodyScale = objProp.transform.localScale; switch (itemData.face) { case 1: bodyScale.x = -1; break; case 2: bodyScale.x = 1; break; } objProp.transform.localScale = bodyScale; } //如果是对话 查询对话数据 else if (storyInfoDetailsType == StoryInfoDetailsBean.StoryInfoDetailsTypeEnum.Talk) { listStoryTextInfo = textInfoService.QueryDataByMarkId(TextEnum.Story, itemData.text_mark_id); } else if (storyInfoDetailsType == StoryInfoDetailsBean.StoryInfoDetailsTypeEnum.NpcDestory) { int[] numList = StringUtil.SplitBySubstringForArrayInt(itemData.npc_destroy, ','); foreach (int num in numList) { BaseNpcAI npcAI = CptUtil.GetCptInChildrenByName <BaseNpcAI>(StoryInfoHandler.Instance.builderForStory.gameObject, num + ""); DestroyImmediate(npcAI.gameObject); } } else if (storyInfoDetailsType == StoryInfoDetailsBean.StoryInfoDetailsTypeEnum.CameraPosition) { Vector3 cameraWorldPosition = StoryInfoHandler.Instance.builderForStory.transform.TransformPoint(new Vector3(itemData.position_x, itemData.position_y, -10)); GameCameraHandler.Instance.manager.camera2D.Follow = null; GameCameraHandler.Instance.manager.camera2D.transform.position = cameraWorldPosition; } else if (itemData.type == (int)StoryInfoDetailsBean.StoryInfoDetailsTypeEnum.CameraFollowCharacter) { BaseNpcAI npcAI = CptUtil.GetCptInChildrenByName <BaseNpcAI>(StoryInfoHandler.Instance.builderForStory.gameObject, "character_" + itemData.num); GameCameraHandler.Instance.manager.camera2D.Follow = npcAI.transform; } } }
/// <summary> /// 团队查询 UI /// </summary> public static void GUINpcTeamFind( TextInfoService textInfoService, NpcTeamService npcTeamService, string findIdsStr, List <NpcTeamBean> listFindData, Dictionary <long, List <TextInfoBean> > mapTeamTalkInfo, out string outFindIdsStr, out List <NpcTeamBean> outlistFindData, out Dictionary <long, List <TextInfoBean> > outMapTeamTalkInfo) { GUILayout.Label("Npc团队查询", GUILayout.Width(100), GUILayout.Height(20)); GUILayout.BeginHorizontal(); outFindIdsStr = EditorGUILayout.TextArea(findIdsStr + "", GUILayout.Width(200), GUILayout.Height(20)); if (GUILayout.Button("查询团队", GUILayout.Width(100), GUILayout.Height(20))) { long[] findIds = StringUtil.SplitBySubstringForArrayLong(findIdsStr, ','); listFindData = npcTeamService.QueryDataById(findIds); } if (GUILayout.Button("查询顾客团队", GUILayout.Width(100), GUILayout.Height(20))) { listFindData = npcTeamService.QueryDataByType((int)NpcTeamTypeEnum.Customer); } if (GUILayout.Button("查询好友团队", GUILayout.Width(100), GUILayout.Height(20))) { listFindData = npcTeamService.QueryDataByType((int)NpcTeamTypeEnum.Friend); } if (GUILayout.Button("查询捣乱团队", GUILayout.Width(100), GUILayout.Height(20))) { listFindData = npcTeamService.QueryDataByType((int)NpcTeamTypeEnum.Rascal); } if (GUILayout.Button("查询杂项团队", GUILayout.Width(100), GUILayout.Height(20))) { listFindData = npcTeamService.QueryDataByType((int)NpcTeamTypeEnum.Sundry); } if (GUILayout.Button("查询助兴团队", GUILayout.Width(100), GUILayout.Height(20))) { listFindData = npcTeamService.QueryDataByType((int)NpcTeamTypeEnum.Entertain); } if (GUILayout.Button("查询扫兴团队", GUILayout.Width(100), GUILayout.Height(20))) { listFindData = npcTeamService.QueryDataByType((int)NpcTeamTypeEnum.Disappointed); } GUILayout.EndHorizontal(); if (listFindData != null) { NpcTeamBean itemRemoveData = null; foreach (NpcTeamBean itemData in listFindData) { GUILayout.BeginHorizontal(); if (GUILayout.Button("更新", GUILayout.Width(100), GUILayout.Height(20))) { npcTeamService.Update(itemData); } if (GUILayout.Button("删除", GUILayout.Width(100), GUILayout.Height(20))) { npcTeamService.DeleteDataById(itemData.id); itemRemoveData = itemData; } if (GUILayout.Button("查询团队对话", GUILayout.Width(100), GUILayout.Height(20))) { List <TextInfoBean> listNpcTeamTalkInfo = textInfoService.QueryDataByMarkId(TextEnum.Talk, itemData.GetTalkIds()); HandleTalkInfoDataByMarkId(listNpcTeamTalkInfo, mapTeamTalkInfo); } GUILayout.EndHorizontal(); GUINpcTeamItem(itemData); GUILayout.Space(20); } if (itemRemoveData != null) { listFindData.Remove(itemRemoveData); itemRemoveData = null; } } outlistFindData = listFindData; outMapTeamTalkInfo = mapTeamTalkInfo; }
public List <TextInfoBean> GetTextForLook(long markId) { return(mTextInfoService.QueryDataByMarkId(TextEnum.Look, markId)); }