public void SetUpDialogView(HLHNPC npc, HLHDialogGroup dialogGroup, CallBack quitCallBack) { this.npc = npc; this.dialogGroup = dialogGroup; this.quitCallBack = quitCallBack; bool hasNpcIcon = false; if (npc.npcName.Equals("智者·艾尔文")) { hasNpcIcon = true; npcIcon.sprite = wiseManSprite; } //if(npc.npcName.Equals("游侠·安科尔")){ // hasNpcIcon = true; // npcIcon.sprite = youXiaSprite; //} npcIcon.enabled = hasNpcIcon; npcName.text = npc.npcName; dialogText.text = dialogGroup.dialogs[0].dialogContent; currentDialogId = 0; dialogHasFinished = false; this.gameObject.SetActive(true); }
/// <summary> /// 获取合适的对话组【本层指定必须出现的优先级高】 /// </summary> /// <returns>The qulified dialog group.</returns> /// <param name="player">Player.</param> public HLHDialogGroup FindQulifiedDialogGroup(Player player) { HLHDialogGroup targetDg = null; // 查询所有指定层级必须出现的对话组中,有没有指定本层必须出现的 for (int i = 0; i < levelDefiniteDialogGroups.Count; i++) { HLHDialogGroup dg = levelDefiniteDialogGroups [i]; if (dg.triggerLevel == player.currentLevelIndex) { // 如果指定本层必须出现,则检查本层是否已经完成了该对话组 if (CheckDialogGroupFinished(dg)) { break; } targetDg = dg; dialogGroupRecord = dg; return(targetDg); } } // 如果没有必须出现的对话组,则随机一个对话组 int randomSeed = Random.Range(0, levelUndefiniteDialogGroups.Count); targetDg = levelUndefiniteDialogGroups[randomSeed]; dialogGroupRecord = targetDg; return(targetDg); }
/// <summary> /// 初始化对话界面 /// </summary> public void SetUpDialogPlane() { HLHDialogGroup dialogGroup = npc.FindQulifiedDialogGroup(Player.mainPlayer); dialogView.SetUpDialogView(npc, dialogGroup, ShowMainNpcView); mainNPCView.gameObject.SetActive(false); }
public void QuitDialogPlane() { npcIcon.sprite = null; npcIcon.enabled = false; dialogText.text = string.Empty; currentDialogId = 0; dialogGroup = null; if (quitCallBack != null) { quitCallBack(); } this.gameObject.SetActive(false); }
/// <summary> /// 检查传入的对话组是否已经完成全部交谈的话 /// </summary> /// <returns><c>true</c>, if dialog group finished was checked, <c>false</c> otherwise.</returns> /// <param name="dialogGroup">Dialog group.</param> public bool CheckDialogGroupFinished(HLHDialogGroup dialogGroup) { bool dialogGroupFinished = false; List <HLHNPCChatRecord> dialogRecords = GameManager.Instance.gameDataCenter.chatRecords; for (int i = 0; i < dialogRecords.Count; i++) { HLHNPCChatRecord dialogRecord = dialogRecords[i]; if (dialogRecord.npcId == npcId && dialogRecord.npcDialogGroupID == dialogGroup.dialogGroupId) { dialogGroupFinished = true; break; } } return(dialogGroupFinished); }
private void DrawDialogs(HLHDialogGroup dg, bool[,] dgFoldoutInfoArray) { if (dg.dialogs == null) { dg.dialogs = new List <HLHDialog> (); } EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("***编辑对话数组", new GUILayoutOption[] { GUILayout.Height(20), GUILayout.Width(120) }); EditorGUILayout.BeginVertical(); //dg.isMultiOff = EditorGUILayout.Toggle ("是否可以反复触发", dg.isMultiOff, middleLayouts); EditorGUILayout.BeginHorizontal(); bool createNewDialog = GUILayout.Button("添加新的对话", buttonLayouts); bool removeLastDialog = GUILayout.Button("删除尾部对话", buttonLayouts); bool unfoldAll = GUILayout.Button("全部展开", buttonLayouts); bool foldAll = GUILayout.Button("全部合上", buttonLayouts); EditorGUILayout.EndHorizontal(); if (unfoldAll) { for (int i = 0; i < dgFoldoutInfoArray.GetLength(1); i++) { dgFoldoutInfoArray[dg.dialogGroupId, i] = true; } } if (foldAll) { for (int i = 0; i < dgFoldoutInfoArray.GetLength(1); i++) { dgFoldoutInfoArray[dg.dialogGroupId, i] = false; } } if (createNewDialog) { HLHDialog d = new HLHDialog(); dg.dialogs.Add(d); } if (removeLastDialog && dg.dialogs.Count > 0) { dg.dialogs.RemoveAt(dg.dialogs.Count - 1); } for (int j = 0; j < dg.dialogs.Count; j++) { HLHDialog d = dg.dialogs [j]; d.dialogId = j; string foldContent = string.Format("编辑对话 \t\t***对话ID: {0}\t\t\t***对话内容: {1}", d.dialogId, d.dialogContent); dgFoldoutInfoArray [dg.dialogGroupId, j] = EditorGUILayout.Foldout(dgFoldoutInfoArray [dg.dialogGroupId, j], foldContent); if (dgFoldoutInfoArray [dg.dialogGroupId, j]) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("\t\t\t\t\t", new GUILayoutOption[] { GUILayout.Height(20), GUILayout.Width(20) }); EditorGUILayout.BeginVertical(); EditorGUILayout.LabelField("对话ID", d.dialogId.ToString(), shortLayouts); d.dialogContent = EditorGUILayout.TextField("对话内容", d.dialogContent, longLayouts); if (d.choiceIds == null) { d.choiceIds = new List <int> (); } EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); } } EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); EditorGUILayout.Separator(); EditorGUILayout.LabelField("================================================================", seperatorLayouts); }
private void DrawRegularDialogGroups(List <HLHDialogGroup> dialogGroups, bool[] dialogGroupFoldOutArray, bool[,] dialogsFoldOutArray) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("***编辑对话组", new GUILayoutOption[] { GUILayout.Height(20), GUILayout.Width(120) }); EditorGUILayout.BeginVertical(); EditorGUILayout.BeginHorizontal(); bool createNewDialogGroup = GUILayout.Button("添加新的对话组", buttonLayouts); bool removeLastDialogGroup = GUILayout.Button("删除尾部对话组", buttonLayouts); EditorGUILayout.EndHorizontal(); if (createNewDialogGroup) { HLHDialogGroup dg = new HLHDialogGroup(); dg.dialogs = new List <HLHDialog> (); //dg.choices = new List<HLHChoice> (); dialogGroups.Add(dg); } if (removeLastDialogGroup && dialogGroups.Count > 0) { dialogGroups.RemoveAt(dialogGroups.Count - 1); } for (int i = 0; i < dialogGroups.Count; i++) { dialogGroupFoldOutArray [i] = EditorGUILayout.Foldout(dialogGroupFoldOutArray [i], "npc对话组 情况" + (i + 1).ToString() + " 对话组ID:" + i.ToString()); if (dialogGroupFoldOutArray [i]) { HLHDialogGroup dg = dialogGroups [i]; dg.dialogGroupId = i; dg.triggerLevel = EditorGUILayout.IntField("触发关卡", dg.triggerLevel, middleLayouts); dg.isMultiTimes = EditorGUILayout.ToggleLeft("是否可反复对话", dg.isMultiTimes, shorterLayouts); dg.isRewardTriggered = EditorGUILayout.ToggleLeft("触发奖励", dg.isRewardTriggered, shorterLayouts); if (dg.isRewardTriggered) { EditorGUILayout.BeginHorizontal(); HLHRewardType rewardType = (HLHRewardType)EditorGUILayout.IntField("奖励类型", (int)dg.reward.rewardType, shortLayouts); EditorGUILayout.LabelField("0:奖励金币 1:奖励物品", middleLayouts); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); int rewardValue = EditorGUILayout.IntField("奖励数据", dg.reward.rewardValue, shortLayouts); EditorGUILayout.LabelField("奖励金币时为金币数量,奖励物品时为物品id", middleLayouts); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); int attachValue = EditorGUILayout.IntField("附加信息", dg.reward.attachValue, shortLayouts); EditorGUILayout.LabelField("奖励物品时为物品数量", middleLayouts); EditorGUILayout.EndHorizontal(); dg.reward = new HLHNPCReward(rewardType, rewardValue, attachValue); } DrawDialogs(dg, dialogsFoldOutArray); } } EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); EditorGUILayout.Separator(); EditorGUILayout.Separator(); EditorGUILayout.LabelField("================================================================", seperatorLayouts); }