/// <summary> /// 删除数据 /// </summary> /// <param name="itemsInfo"></param> public void DeleteData(NpcInfoBean npcInfo) { if (npcInfo == null) { return; } BaseDeleteDataWithLeft("id", "npc_id", npcInfo.id + ""); }
public void GetNpcInfoSuccess(int type, List <NpcInfoBean> listData) { this.listNpcInfo = new Dictionary <long, NpcInfoBean>(); for (int i = 0; i < listData.Count; i++) { NpcInfoBean itemData = listData[i]; listNpcInfo.Add(itemData.id, itemData); } }
/// <summary> /// 插入数据 /// </summary> /// <param name="itemsInfo"></param> public void InsertData(NpcInfoBean itemsInfo) { List <string> listLeftName = new List <string> { "npc_id", "title_name", "name" }; BaseInsertDataWithLeft(itemsInfo, listLeftName); }
/// <summary> /// 获取所有角色数据 /// </summary> public List <CharacterBean> GetAllCharacterData() { List <CharacterBean> listData = new List <CharacterBean>(); foreach (long key in listNpcInfo.Keys) { NpcInfoBean itemData = listNpcInfo[key]; CharacterBean characterData = new CharacterBean(itemData); listData.Add(characterData); } return(listData); }
protected void UIForStoryInfoDetailsNpcPosition(StoryInfoDetailsBean itemData) { if (EditorUI.GUIButton("更新显示", 100, 20)) { RemoveSceneObjByName("character_" + itemData.num); RefreshSceneData(listOrderStoryInfoDetails); } if (EditorUI.GUIButton("获取显示坐标", 120, 20)) { GameObject objItem = GetSceneObjByName("character_" + itemData.num); itemData.position_x = objItem.transform.localPosition.x; itemData.position_y = objItem.transform.localPosition.y; } if (EditorUI.GUIButton("删除")) { RemoveStoryInfoDetailsItem(itemData); return; } NpcInfoBean npcInfo; if (itemData.npc_id == 0) { npcInfo = new NpcInfoBean(); npcInfo.name = "玩家"; } else if (itemData.npc_id == -1) { npcInfo = new NpcInfoBean(); npcInfo.name = "妻子"; } else { npcInfo = mapNpcInfo[itemData.npc_id]; } EditorUI.GUIText("NPCId(0:自己,-1:妻子):", 200, 20); itemData.npc_id = EditorUI.GUIEditorText(itemData.npc_id, 100, 20); EditorUI.GUIText("姓名:" + npcInfo.title_name + "-" + npcInfo.name, 200, 20); EditorUI.GUIText("NPC序号:", 100, 20); itemData.num = int.Parse(EditorUI.GUIEditorText(itemData.num + "", 50, 20)); EditorUI.GUIText("NPC站位 ", 100, 20); EditorUI.GUIText("NPC位置X:", 120, 20); itemData.position_x = float.Parse(EditorUI.GUIEditorText(itemData.position_x + "", 100, 20)); EditorUI.GUIText("NPC位置Y:", 120, 20); itemData.position_y = float.Parse(EditorUI.GUIEditorText(itemData.position_y + "", 100, 20)); EditorUI.GUIText("NPC朝向1左2右:", 120, 20); itemData.face = int.Parse(EditorUI.GUIEditorText(itemData.face + "", 50, 20)); }
/// <summary> /// 设置数据-聊天 /// </summary> /// <param name="userId"></param> /// <param name="npcType"></param> public void SetDataForTalk(NpcInfoBean npcInfo) { this.mTalkNpcInfo = npcInfo; mTextEnum = TextEnum.Talk; textOrder = 1; GameDataBean gameData = GameDataHandler.Instance.manager.GetGameData(); CharacterFavorabilityBean characterFavorability = gameData.GetCharacterFavorability(mTalkNpcInfo.id); //如果是小镇居民的第一次对话 if (mTalkNpcInfo.GetNpcType() == NpcTypeEnum.Town && characterFavorability.firstMeet) { characterFavorability.firstMeet = false; TextInfoHandler.Instance.manager.GetTextForTownFirstMeet(mTalkNpcInfo.id, SetTextInfoData); return; } //获取对话选项 TextInfoHandler.Instance.manager.GetTextForTalkOptions(gameData, mTalkNpcInfo, SetTextInfoData); }
/// <summary> /// NPC创建 /// </summary> public static void GUINpcInfoCreate( NpcInfoService npcInfoService, GameObject objNpcContainer, GameObject objNpcModel, NpcInfoBean npcInfo) { GUILayout.BeginHorizontal(); if (GUILayout.Button("显示", GUILayout.Width(100), GUILayout.Height(20))) { CharacterBean characterData = new CharacterBean(npcInfo); ShowNpc(objNpcContainer, objNpcModel, characterData); } if (GUILayout.Button("创建", GUILayout.Width(100), GUILayout.Height(20))) { npcInfo.valid = 1; npcInfo.face = 1; npcInfoService.InsertData(npcInfo); } GUILayout.EndHorizontal(); GUINpcInfoItem(objNpcContainer, npcInfo); }
/// <summary> /// 根据类型获取NPC信息 /// </summary> /// <param name="types"></param> /// <returns></returns> public List <NpcInfoBean> GetNpcInfoByType(int[] types) { List <NpcInfoBean> listData = new List <NpcInfoBean>(); if (listNpcInfo == null) { return(listData); } foreach (int type in types) { foreach (long key in listNpcInfo.Keys) { NpcInfoBean itemData = listNpcInfo[key]; if (itemData.npc_type == type) { listData.Add(itemData); } } } return(listData); }
/// <summary> /// 对话事件触发 /// </summary> /// <param name="markId"></param> public bool EventTriggerForTalk(NpcInfoBean npcInfo, bool isStopTime) { if (!CheckEventTrigger()) { return(false); } SetEventStatus(EventStatusEnum.EventIng); SetEventType(EventTypeEnum.Talk); //暂停时间 if (isStopTime) { GameTimeHandler.Instance.SetTimeStop(); } //控制模式修改 GameControlHandler.Instance.StopControl(); UIGameText uiGameText = UIHandler.Instance.manager.OpenUIAndCloseOther <UIGameText>(UIEnum.GameText); uiGameText.SetDataForTalk(npcInfo); uiGameText.SetCallBack(this); return(true); }
public override void InteractiveDetection(CharacterInteractiveCpt characterInt) { if (Input.GetButtonDown(InputInfo.Interactive_E)) { if (GameEventHandler.Instance.GetEventStatus() == EventStatusEnum.EventEnd) { //先改变人物面向 if (characterInt.transform.position.x > transform.position.x) { mNpcAI.SetCharacterFace(2); } else { mNpcAI.SetCharacterFace(1); } //获取人物信息 NpcInfoBean npcInfo = mNpcAI.characterData.npcInfoData; GameEventHandler.Instance.EventTriggerForTalk(npcInfo, true); //如果角色有问题提示。则取消问号 mNpcAI.CancelExpression(); } } }
/// <summary> /// 更新数据 /// </summary> /// <param name="npcInfoData"></param> public void Update(NpcInfoBean npcInfoData) { DeleteData(npcInfoData); InsertData(npcInfoData); }
public CharacterForFamilyBean(NpcInfoBean npcInfo, TimeBean birthTime) : base(npcInfo) { this.birthTime = birthTime; }
/// <summary> /// 获取交流对话选项 /// </summary> public void GetTextForTalkOptions(GameDataBean gameData, NpcInfoBean npcInfo, Action <List <TextInfoBean> > action) { //如果不是第一次对话则有以下选项 listTextData = new List <TextInfoBean>(); List <NpcTalkTypeEnum> npcTalkTypes = npcInfo.GetTalkTypes(); listTextData.Add(new TextInfoBean(TextInfoTypeEnum.Talk, 0, TextHandler.Instance.manager.GetTextById(99101))); foreach (NpcTalkTypeEnum itemType in npcTalkTypes) { switch (itemType) { case NpcTalkTypeEnum.Talk: listTextData.Add(new TextInfoBean(TextInfoTypeEnum.Talk, 1, TextHandler.Instance.manager.GetTextById(99102))); break; case NpcTalkTypeEnum.OneTalk: if (!GameCommonInfo.DailyLimitData.CheckIsTalkNpc(npcInfo.id)) { listTextData.Add(new TextInfoBean(TextInfoTypeEnum.Talk, 1, TextHandler.Instance.manager.GetTextById(99102))); } break; case NpcTalkTypeEnum.Recruit: if (!gameData.CheckHasWorker(npcInfo.id + "")) { listTextData.Add(new TextInfoBean(TextInfoTypeEnum.Talk, 1, TextHandler.Instance.manager.GetTextById(99104))); } break; case NpcTalkTypeEnum.Gift: if (!GameCommonInfo.DailyLimitData.CheckIsGiftNpc(npcInfo.id)) { listTextData.Add(new TextInfoBean(TextInfoTypeEnum.Talk, 1, TextHandler.Instance.manager.GetTextById(99105))); } break; case NpcTalkTypeEnum.GuildCoinExchange: listTextData.Add(new TextInfoBean(TextInfoTypeEnum.Talk, 1, TextHandler.Instance.manager.GetTextById(99201))); break; case NpcTalkTypeEnum.TrophyExchange: listTextData.Add(new TextInfoBean(TextInfoTypeEnum.Talk, 1, TextHandler.Instance.manager.GetTextById(99202))); break; case NpcTalkTypeEnum.EquipExchange: listTextData.Add(new TextInfoBean(TextInfoTypeEnum.Talk, 1, TextHandler.Instance.manager.GetTextById(99203))); break; case NpcTalkTypeEnum.ItemsExchange: listTextData.Add(new TextInfoBean(TextInfoTypeEnum.Talk, 1, TextHandler.Instance.manager.GetTextById(99204))); break; } } CharacterFavorabilityBean characterFavorability = gameData.GetCharacterFavorability(npcInfo.id); FamilyDataBean familyData = gameData.GetFamilyData(); //如果满足了结婚条件。添加结婚对话 if ( //该角色是否可以结婚 npcInfo.CheckCanMarry() //好感是否达到要求 && characterFavorability.CheckCanMarry() //是否已经向其他人求婚或者已经结婚 && (familyData.timeForMarry == null || familyData.timeForMarry.year == 0)) { listTextData.Add(new TextInfoBean(TextInfoTypeEnum.Talk, 1, TextHandler.Instance.manager.GetTextById(99205))); } //离开选项 listTextData.Add(new TextInfoBean(TextInfoTypeEnum.Talk, 1, TextHandler.Instance.manager.GetTextById(99103))); //继续查询该人物的所有对话 GetTextForTalkByMinFavorability(npcInfo.id, characterFavorability.favorabilityLevel, action); action?.Invoke(listTextData); }
/// <summary> /// Npc Item /// </summary> public static void GUINpcInfoItem(GameObject objNpcContainer, NpcInfoBean npcInfo) { if (GUILayout.Button("获取场景位置数据", GUILayout.Width(120), GUILayout.Height(20))) { BaseNpcAI npcAI = objNpcContainer.GetComponentInChildren <BaseNpcAI>(); npcInfo.position_x = npcAI.transform.position.x; npcInfo.position_y = npcAI.transform.position.y; } GUILayout.Label("NPCID:", GUILayout.Width(100), GUILayout.Height(20)); npcInfo.id = long.Parse(EditorGUILayout.TextArea(npcInfo.id + "", GUILayout.Width(100), GUILayout.Height(20))); npcInfo.npc_id = npcInfo.id; GUILayout.BeginHorizontal(); npcInfo.npc_type = (int)EditorUI.GUIEnum <NpcTypeEnum>("Npc类型:", npcInfo.npc_type); NpcTypeEnum npcType = (NpcTypeEnum)npcInfo.npc_type; GUILayout.Label("对话选项:", GUILayout.Width(100), GUILayout.Height(20)); npcInfo.talk_types = EditorUI.GUIEditorText(npcInfo.talk_types, 50); GUILayout.EndHorizontal(); if (npcType != NpcTypeEnum.Passerby) { GUILayout.BeginHorizontal(); GUILayout.Label("姓名:", GUILayout.Width(100), GUILayout.Height(20)); npcInfo.name = EditorGUILayout.TextArea(npcInfo.name + "", GUILayout.Width(100), GUILayout.Height(20)); GUILayout.Label("性别:1男 2女", GUILayout.Width(100), GUILayout.Height(20)); npcInfo.sex = int.Parse(EditorGUILayout.TextArea(npcInfo.sex + "", GUILayout.Width(30), GUILayout.Height(20))); GUILayout.Label("称号:", GUILayout.Width(100), GUILayout.Height(20)); npcInfo.title_name = EditorGUILayout.TextArea(npcInfo.title_name + "", GUILayout.Width(100), GUILayout.Height(20)); GUILayout.Label("朝向 1左 2右", GUILayout.Width(100), GUILayout.Height(20)); npcInfo.face = int.Parse(EditorGUILayout.TextArea(npcInfo.face + "", GUILayout.Width(30), GUILayout.Height(20))); GUILayout.Label("位置XY:", GUILayout.Width(100), GUILayout.Height(20)); npcInfo.position_x = float.Parse(EditorGUILayout.TextArea(npcInfo.position_x + "", GUILayout.Width(100), GUILayout.Height(20))); npcInfo.position_y = float.Parse(EditorGUILayout.TextArea(npcInfo.position_y + "", GUILayout.Width(100), GUILayout.Height(20))); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("眼睛:", GUILayout.Width(100), GUILayout.Height(20)); npcInfo.eye_id = EditorGUILayout.TextArea(npcInfo.eye_id + "", GUILayout.Width(200), GUILayout.Height(20)); string eyePath = "Assets/Texture/Character/Eye/"; EditorUI.GUIPic(eyePath, npcInfo.eye_id); GUILayout.Label("眼睛颜色:", GUILayout.Width(100), GUILayout.Height(20)); ColorBean eyeColorData = new ColorBean(npcInfo.eye_color); Color eyeColor = eyeColorData.GetColor();; eyeColor = EditorGUILayout.ColorField(eyeColor, GUILayout.Width(50), GUILayout.Height(20)); npcInfo.eye_color = eyeColor.r + "," + eyeColor.g + "," + eyeColor.b + "," + eyeColor.a; GUILayout.Label("嘴巴:", GUILayout.Width(100), GUILayout.Height(20)); npcInfo.mouth_id = EditorGUILayout.TextArea(npcInfo.mouth_id + "", GUILayout.Width(200), GUILayout.Height(20)); string mouthPath = "Assets/Texture/Character/Mouth/"; EditorUI.GUIPic(mouthPath, npcInfo.mouth_id); GUILayout.Label("嘴巴颜色:", GUILayout.Width(100), GUILayout.Height(20)); ColorBean mouthColorData = new ColorBean(npcInfo.mouth_color); Color mouthColor = mouthColorData.GetColor();; mouthColor = EditorGUILayout.ColorField(mouthColor, GUILayout.Width(50), GUILayout.Height(20)); npcInfo.mouth_color = mouthColor.r + "," + mouthColor.g + "," + mouthColor.b + "," + mouthColor.a; GUILayout.Label("头发:", GUILayout.Width(100), GUILayout.Height(20)); npcInfo.hair_id = EditorGUILayout.TextArea(npcInfo.hair_id + "", GUILayout.Width(200), GUILayout.Height(20)); string hairPath = "Assets/Texture/Character/Hair/"; EditorUI.GUIPic(hairPath, npcInfo.hair_id); GUILayout.Label("头发颜色:", GUILayout.Width(100), GUILayout.Height(20)); ColorBean hairColorData = new ColorBean(npcInfo.hair_color); Color hairColor = hairColorData.GetColor();; hairColor = EditorGUILayout.ColorField(hairColor, GUILayout.Width(50), GUILayout.Height(20)); npcInfo.hair_color = hairColor.r + "," + hairColor.g + "," + hairColor.b + "," + hairColor.a; GUILayout.Label("皮肤颜色:", GUILayout.Width(100), GUILayout.Height(20)); ColorBean skinColorData = new ColorBean(npcInfo.skin_color); Color skinColor = skinColorData.GetColor();; skinColor = EditorGUILayout.ColorField(skinColor, GUILayout.Width(50), GUILayout.Height(20)); npcInfo.skin_color = skinColor.r + "," + skinColor.g + "," + skinColor.b + "," + skinColor.a; GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("命:", GUILayout.Width(30), GUILayout.Height(20)); npcInfo.attributes_life = int.Parse(EditorGUILayout.TextArea(npcInfo.attributes_life + "", GUILayout.Width(50), GUILayout.Height(20))); GUILayout.Label("厨:", GUILayout.Width(30), GUILayout.Height(20)); npcInfo.attributes_cook = int.Parse(EditorGUILayout.TextArea(npcInfo.attributes_cook + "", GUILayout.Width(50), GUILayout.Height(20))); GUILayout.Label("速:", GUILayout.Width(30), GUILayout.Height(20)); npcInfo.attributes_speed = int.Parse(EditorGUILayout.TextArea(npcInfo.attributes_speed + "", GUILayout.Width(50), GUILayout.Height(20))); GUILayout.Label("算:", GUILayout.Width(30), GUILayout.Height(20)); npcInfo.attributes_account = int.Parse(EditorGUILayout.TextArea(npcInfo.attributes_account + "", GUILayout.Width(50), GUILayout.Height(20))); GUILayout.Label("魅:", GUILayout.Width(30), GUILayout.Height(20)); npcInfo.attributes_charm = int.Parse(EditorGUILayout.TextArea(npcInfo.attributes_charm + "", GUILayout.Width(50), GUILayout.Height(20))); GUILayout.Label("武:", GUILayout.Width(30), GUILayout.Height(20)); npcInfo.attributes_force = int.Parse(EditorGUILayout.TextArea(npcInfo.attributes_force + "", GUILayout.Width(50), GUILayout.Height(20))); GUILayout.Label("运:", GUILayout.Width(30), GUILayout.Height(20)); npcInfo.attributes_lucky = int.Parse(EditorGUILayout.TextArea(npcInfo.attributes_lucky + "", GUILayout.Width(50), GUILayout.Height(20))); if (npcType == NpcTypeEnum.RecruitTown) { GUILayout.Label("忠诚:", GUILayout.Width(30), GUILayout.Height(20)); npcInfo.attributes_loyal = int.Parse(EditorGUILayout.TextArea(npcInfo.attributes_loyal + "", GUILayout.Width(50), GUILayout.Height(20))); GUILayout.Label("工资 S:", GUILayout.Width(30), GUILayout.Height(20)); npcInfo.wage_s = int.Parse(EditorGUILayout.TextArea(npcInfo.wage_s + "", GUILayout.Width(50), GUILayout.Height(20))); } GUILayout.Label("喜欢的东西ID(用,分隔):", GUILayout.Width(150), GUILayout.Height(20)); npcInfo.love_items = EditorGUILayout.TextArea(npcInfo.love_items + "", GUILayout.Width(100), GUILayout.Height(20)); GUILayout.Label("喜欢的菜品:", GUILayout.Width(100), GUILayout.Height(20)); npcInfo.love_menus = EditorGUILayout.TextArea(npcInfo.love_menus + "", GUILayout.Width(50), GUILayout.Height(20)); GUILayout.Label("技能:", GUILayout.Width(100), GUILayout.Height(20)); npcInfo.skill_ids = EditorUI.GUIEditorText(npcInfo.skill_ids, 100); GUILayout.EndHorizontal(); } GUILayout.BeginHorizontal(); EditorUI.GUIText("|", 10); EditorUI.GUIText("面具:", 50); npcInfo.mask_id = long.Parse(EditorGUILayout.TextArea(npcInfo.mask_id + "", GUILayout.Width(100), GUILayout.Height(20))); string maskPath = "Assets/Texture/Character/Dress/Mask/"; ItemsInfoBean maskInfo = GameItemsHandler.Instance.manager.GetItemsById(npcInfo.mask_id); if (maskInfo != null) { EditorUI.GUIPic(maskPath, maskInfo.icon_key); } EditorUI.GUIText("|", 10); EditorUI.GUIText("帽子:", 50); npcInfo.hat_id = long.Parse(EditorGUILayout.TextArea(npcInfo.hat_id + "", GUILayout.Width(100), GUILayout.Height(20))); string hatPath = "Assets/Texture/Character/Dress/Hat/"; ItemsInfoBean hatInfo = GameItemsHandler.Instance.manager.GetItemsById(npcInfo.hat_id); if (hatInfo != null) { EditorUI.GUIPic(hatPath, hatInfo.icon_key); } EditorUI.GUIText("|", 10); EditorUI.GUIText("衣服:", 50); npcInfo.clothes_id = long.Parse(EditorGUILayout.TextArea(npcInfo.clothes_id + "", GUILayout.Width(100), GUILayout.Height(20))); string clothesPath = "Assets/Texture/Character/Dress/Clothes/"; ItemsInfoBean clothesInfo = GameItemsHandler.Instance.manager.GetItemsById(npcInfo.clothes_id); if (clothesInfo != null) { EditorUI.GUIPic(clothesPath, clothesInfo.icon_key); } EditorUI.GUIText("|", 10); EditorUI.GUIText("鞋子:", 50); npcInfo.shoes_id = long.Parse(EditorGUILayout.TextArea(npcInfo.shoes_id + "", GUILayout.Width(100), GUILayout.Height(20))); string shoesPath = "Assets/Texture/Character/Dress/Shoes/"; ItemsInfoBean shoesInfo = GameItemsHandler.Instance.manager.GetItemsById(npcInfo.shoes_id); if (shoesInfo != null) { EditorUI.GUIPic(shoesPath, shoesInfo.icon_key); } EditorUI.GUIText("|", 10); EditorUI.GUIText("武器:", 50); npcInfo.hand_id = long.Parse(EditorGUILayout.TextArea(npcInfo.hand_id + "", GUILayout.Width(100), GUILayout.Height(20))); ItemsInfoBean handInfo = GameItemsHandler.Instance.manager.GetItemsById(npcInfo.hand_id); if (handInfo != null) { EditorUI.GUIText(handInfo.name, 50); } EditorUI.GUIText("|", 10); GUILayout.EndHorizontal(); npcInfo.condition = EditorUI.GUIListData <ShowConditionEnum>("Npc出现条件", npcInfo.condition); }
public CharacterBean(NpcInfoBean npcInfo) { baseInfo.characterType = npcInfo.npc_type; baseInfo.characterId = npcInfo.id + ""; baseInfo.titleName = npcInfo.title_name; baseInfo.name = npcInfo.name; baseInfo.priceL = npcInfo.wage_l; baseInfo.priceM = npcInfo.wage_m; baseInfo.priceS = npcInfo.wage_s; //设置最喜欢的东西 if (!CheckUtil.StringIsNull(npcInfo.love_items)) { baseInfo.listLoveItems = StringUtil.SplitBySubstringForArrayLong(npcInfo.love_items, ',').ToList(); } body = new CharacterBodyBean(); body.hair = npcInfo.hair_id; //设置头发颜色 ColorBean hairColor = new ColorBean(npcInfo.hair_color); if (hairColor != null) { body.hairColor = hairColor; } body.eye = npcInfo.eye_id; //设置眼睛颜色 ColorBean eyeColor = new ColorBean(npcInfo.eye_color); if (eyeColor != null) { body.eyeColor = eyeColor; } body.mouth = npcInfo.mouth_id; //设置嘴巴颜色 ColorBean mouthColor = new ColorBean(npcInfo.mouth_color); if (mouthColor != null) { body.mouthColor = mouthColor; } body.sex = npcInfo.sex; body.face = npcInfo.face; //设置皮肤颜色 ColorBean skinColor = new ColorBean(npcInfo.skin_color); if (skinColor != null) { body.skinColor = skinColor; } //设置装备 equips = new CharacterEquipBean(); equips.maskId = npcInfo.mask_id; equips.handId = npcInfo.hand_id; equips.hatId = npcInfo.hat_id; equips.clothesId = npcInfo.clothes_id; equips.shoesId = npcInfo.shoes_id; equips.maskId = npcInfo.mask_id; //设置属性 attributes = new CharacterAttributesBean(); attributes.loyal = npcInfo.attributes_loyal; attributes.life = npcInfo.attributes_life; attributes.cook = npcInfo.attributes_cook; attributes.speed = npcInfo.attributes_speed; attributes.account = npcInfo.attributes_account; attributes.charm = npcInfo.attributes_charm; attributes.force = npcInfo.attributes_force; attributes.lucky = npcInfo.attributes_lucky; //设置技能 attributes.listSkills = npcInfo.GetSkillIds(); npcInfoData = npcInfo; }
/// <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; } } }
protected void UIForStoryInfoDetailsTalk(StoryInfoDetailsBean itemData) { if (EditorUI.GUIButton("删除", 200, 20)) { storyInfoService.DeleteDetailsDataByIdOrderType(itemData.story_id, itemData.story_order, itemData.type); listOrderStoryInfoDetails.Remove(itemData); } GUILayout.BeginVertical(); GUILayout.Space(20); GUILayout.BeginHorizontal(); EditorUI.GUIText("对话 ", 120, 20); if (EditorUI.GUIButton("添加子对话", 120, 20)) { if (listStoryTextInfo == null) { listStoryTextInfo = new List <TextInfoBean>(); } TextInfoBean textInfo = new TextInfoBean(); textInfo.id = itemData.text_mark_id * 1000 + listStoryTextInfo.Count + 1; textInfo.text_id = textInfo.id; textInfo.type = 0; textInfo.mark_id = itemData.text_mark_id; textInfo.user_id = 0; textInfo.text_order = listStoryTextInfo.Count + 1; listStoryTextInfo.Add(textInfo); } if (EditorUI.GUIButton("删除所有对话", 120, 20)) { RemoveStoryInfoDetailsItem(itemData); return; } GUILayout.EndHorizontal(); if (listStoryTextInfo != null) { TextInfoBean removeTempText = null; foreach (TextInfoBean textInfo in listStoryTextInfo) { GUILayout.BeginHorizontal(); if (EditorUI.GUIButton("删除子对话", 120, 20)) { removeTempText = textInfo; textInfoService.DeleteDataById(TextEnum.Story, textInfo.id); } if (EditorUI.GUIButton("更新", 120, 20)) { textInfoService.UpdateDataById(TextEnum.Story, textInfo.id, textInfo); } EditorUI.GUIText("ID", 50, 20); textInfo.id = EditorUI.GUIEditorText(textInfo.id, 120, 20); textInfo.type = (int)EditorUI.GUIEnum <TextInfoTypeEnum>("对话类型", textInfo.type, 300, 20); EditorUI.GUIText("对话顺序", 100, 20); textInfo.text_order = int.Parse(EditorUI.GUIEditorText(textInfo.text_order + "", 100, 20)); EditorUI.GUIText("下一对话", 100, 20); textInfo.next_order = int.Parse(EditorUI.GUIEditorText(textInfo.next_order + "", 100, 20)); if (textInfo.type == 0) { EditorUI.GUIText("userID", 100, 20); textInfo.user_id = EditorUI.GUIEditorText(textInfo.user_id, 100, 20); EditorUI.GUIText("姓名", 100, 20); NpcInfoBean npcInfo; if (textInfo.user_id == 0) { npcInfo = new NpcInfoBean(); npcInfo.name = "玩家"; } else { npcInfo = mapNpcInfo[textInfo.user_id]; } EditorUI.GUIText(npcInfo.title_name + "-" + npcInfo.name, 120, 20); EditorUI.GUIText("指定的姓名", 120, 20); textInfo.name = EditorUI.GUIEditorText(textInfo.name, 100, 20); } else if (textInfo.type == 1) { EditorUI.GUIText("select type", 120, 20); textInfo.select_type = int.Parse(EditorUI.GUIEditorText(textInfo.select_type + "", 100, 20)); EditorUI.GUIText("分支选择", 120, 20); if (textInfo.select_type == 0) { EditorUI.GUIText("默认对话", 120, 20); } else { EditorUI.GUIText("分支选项 下一句对话ID", 200, 20); textInfo.next_order = int.Parse(EditorUI.GUIEditorText(textInfo.next_order + "", 100, 20)); } } else if (textInfo.type == 5) { EditorUI.GUIText("黑幕时间", 120, 20); textInfo.wait_time = float.Parse(EditorUI.GUIEditorText(textInfo.wait_time + "", 100, 20)); } EditorUI.GUIText("对话内容", 120, 20); textInfo.content = EditorUI.GUIEditorText(textInfo.content, 400, 20); EditorUI.GUIText("增加的好感:", 120, 20); textInfo.add_favorability = int.Parse(EditorUI.GUIEditorText(textInfo.add_favorability + "", 50, 20)); if (EditorUI.GUIButton("更新", 120, 20)) { textInfoService.UpdateDataById(TextEnum.Story, textInfo.id, textInfo); } textInfo.reward_data = EditorUI.GUIListData <RewardTypeEnum>("奖励", textInfo.reward_data); textInfo.pre_data = EditorUI.GUIListData <PreTypeEnum>("付出", textInfo.pre_data); GUILayout.EndHorizontal(); } if (removeTempText != null) { listStoryTextInfo.Remove(removeTempText); } } GUILayout.EndVertical(); }