/// <summary> /// 获得对话影响所有的演员Uid /// </summary> /// <param name="addDialogInfo"></param> /// <param name="dialogModel"></param> /// <returns></returns> private List <int> GetDialogActorUids(AddDialogInfo addDialogInfo, DialogModel dialogModel) { List <int> actorUids = new List <int>(); if (addDialogInfo.Sponsor != null) { actorUids.Add(addDialogInfo.Sponsor.Uid); } if (addDialogInfo.Targets != null && addDialogInfo.Targets.Count > 0) { for (int i = 0; i < addDialogInfo.Targets.Count; i++) { if (!actorUids.Contains(addDialogInfo.Targets[i].Uid)) { actorUids.Add(addDialogInfo.Targets[i].Uid); } } } List <int> actorIds = CollectDialogActorIds(dialogModel); for (int i = 0; i < actorIds.Count; i++) { List <ActorObj> actors = MapLocate.Map.GetActors(actorIds[i]); for (int j = 0; j < actors.Count; j++) { if (!actorUids.Contains(actors[j].Uid)) { actorUids.Add(actors[j].Uid); } } } return(actorUids); }
public string CreateDialog(AddDialogInfo addDialogInfo) { string uid = CalcDialogUid(addDialogInfo); if (dialogObjs.ContainsKey(uid)) { DialogLocate.Log.LogError("创建对话失败>>>>Uid重复", uid); return(""); } if (DialogLocate.Config.GetDialogModel(addDialogInfo.DialogType, addDialogInfo.DialogId, out var model)) { List <int> actorUids = GetDialogActorUids(addDialogInfo, model); for (int i = 0; i < actorUids.Count; i++) { if (speakIngActors.Contains(actorUids[i])) { DialogLocate.Log.Log("创建对话失败>>>>对话需要的演员正在对话", uid, actorUids[i]); return(""); } } DialogObj dialogObj = new DialogObj(uid, addDialogInfo.DialogType, addDialogInfo.DialogId, addDialogInfo.DialogStep, model); dialogObj.SetSponsor(addDialogInfo.Sponsor); dialogObj.SetTargets(addDialogInfo.Targets); dialogObjs.Add(uid, dialogObj); DialogLocate.Display.OnCreateDialog(dialogObj, actorUids); return(uid); } else { DialogLocate.Log.LogError("创建对话失败>>>>没有配置", uid); return(""); } }
/// <summary> /// 计算对话Uid /// </summary> /// <param name="addDialogInfo"></param> private string CalcDialogUid(AddDialogInfo addDialogInfo) { return(addDialogInfo.ToString()); }