コード例 #1
0
 /// <summary>
 /// 当前任务状态发生变化
 /// </summary>
 /// <param name="iNowTaskState"></param>
 /// <param name="fieldName"></param>
 private void INowTaskStateChanged(INowTaskState iNowTaskState, string fieldName)
 {
     //开始任务
     if (string.Equals(fieldName, GameState.GetFieldNameStatic <INowTaskState, int>(temp => temp.StartTask)))
     {
         Init();
         // 如果存在该任务且该任务是主线
         TaskMap.RunTimeTaskInfo runTimeTaskInfo = runtimeTasksData.GetTasksWithID(iNowTaskState.StartTask, true);
         if (runTimeTaskInfo != null && runTimeTaskInfo.TaskInfoStruct.TaskType == TaskMap.Enums.EnumTaskType.Main && !runTimeTaskInfo.TaskInfoStruct.NeedShowTalk && runTimeTaskInfo.TaskInfoStruct.NeedShowImageTip)
         {
             Debug.Log("显示图片提示:" + runTimeTaskInfo.ID);
             string directoryPath = runTimeTaskInfo.TaskInfoStruct.ShowImageTipDirectoryName;
             if (!string.IsNullOrEmpty(directoryPath))//该文件夹不为空
             {
                 directoryPath = ResourceDirectoryPath + "/" + directoryPath;
                 needShowArray = Resources.LoadAll <Sprite>(directoryPath);
                 if (needShowArray.Length > 0)
                 {
                     gameObject.SetActive(true); //显示面板
                     nowPage = 0;
                     ShowImageTip();             //显示
                 }
             }
         }
     }
 }
コード例 #2
0
 /// <summary>
 /// 当前任务状态发生变化
 /// </summary>
 /// <param name="iNowTaskState"></param>
 /// <param name="fieldName"></param>
 private void INowTaskStateChanged(INowTaskState iNowTaskState, string fieldName)
 {
     //开始任务
     if (string.Equals(fieldName, GameState.GetFieldNameStatic <INowTaskState, int>(temp => temp.StartTask)))
     {
         Init();
         // 如果存在该任务且该任务是主线
         TaskMap.RunTimeTaskInfo runTimeTaskInfo = runtimeTasksData.GetTasksWithID(iNowTaskState.StartTask, true);
         if (runTimeTaskInfo != null && runTimeTaskInfo.TaskInfoStruct.TaskType == TaskMap.Enums.EnumTaskType.Main && runTimeTaskInfo.TaskInfoStruct.NeedShowTalk && !runTimeTaskInfo.TaskInfoStruct.NeedShowImageTip)
         {
             DialogueCondition dialogueCodition = dialogueStructData.SearchDialogueConditionsByNPCID(-1,
                                                                                                     temp => temp.enumDialogueType == EnumDialogueType.Task && temp.thisTask == iNowTaskState.StartTask).FirstOrDefault();
             if (dialogueCodition != null)
             {
                 gameObject.SetActive(true); //显示面板
                 InitTalk(dialogueCodition); //初始化对话
             }
         }
     }
     else if (string.Equals(fieldName, GameState.GetFieldNameStatic <INowTaskState, int>(temp => temp.OverTaskID)))
     {
         Init();
         // 如果存在该任务且该任务是主线
         TaskMap.RunTimeTaskInfo runTimeTaskInfo = runtimeTasksData.GetTasksWithID(iNowTaskState.OverTaskID, false);
         if (runTimeTaskInfo != null && runTimeTaskInfo.TaskInfoStruct.TaskType == TaskMap.Enums.EnumTaskType.Main && runTimeTaskInfo.TaskInfoStruct.NeedShowTalk)
         {
             Debug.Log("显示结束任务对话:" + runTimeTaskInfo.ID);
             DialogueCondition dialogueCodition = dialogueStructData.SearchDialogueConditionsByNPCID(-1,
                                                                                                     temp => temp.enumDialogueType == EnumDialogueType.Task && temp.overTask == iNowTaskState.OverTaskID).FirstOrDefault();
             if (dialogueCodition != null)
             {
                 gameObject.SetActive(true); //显示面板
                 InitTalk(dialogueCodition); //初始化对话
             }
         }
     }
 }
コード例 #3
0
 /// <summary>
 /// 判断任务情况
 /// </summary>
 /// <param name="iNowTaskState"></param>
 /// <param name="fieldName"></param>
 private void CheckTask(INowTaskState iNowTaskState)
 {
     if (iNowTaskState != null && NPCDataInfo != null && NPCDataInfo.NPCShowCondition != null && runTimeTaskData != null)
     {
         NPCDataInfo.NPCShowCondition.TaskCoditionHidePath = false;
         if (NPCDataInfo.NPCShowCondition.TaskConditionsHide != null && NPCDataInfo.NPCShowCondition.TaskConditionsHide.Length > 0)
         {
             foreach (var item in NPCDataInfo.NPCShowCondition.TaskConditionsHide)
             {
                 TaskMap.RunTimeTaskInfo runtimeTaskInfo = runTimeTaskData.GetTasksWithID(item.TaskID, false);
                 if (runtimeTaskInfo != null && runtimeTaskInfo.TaskProgress == item.TaskState)
                 {
                     NPCDataInfo.NPCShowCondition.TaskCoditionHidePath = true;
                     break;
                 }
             }
         }
         NPCDataInfo.NPCShowCondition.TaskCoditionShowPath = false;
         if (NPCDataInfo.NPCShowCondition.TaskConditionShow != null && NPCDataInfo.NPCShowCondition.TaskConditionShow.Length > 0)
         {
             foreach (var item in NPCDataInfo.NPCShowCondition.TaskConditionShow)
             {
                 TaskMap.RunTimeTaskInfo runtimeTaskInfo = runTimeTaskData.GetTasksWithID(item.TaskID, false);
                 if (runtimeTaskInfo != null && runtimeTaskInfo.TaskProgress == item.TaskState)
                 {
                     NPCDataInfo.NPCShowCondition.TaskCoditionShowPath = true;
                     break;
                 }
             }
         }
         else
         {
             NPCDataInfo.NPCShowCondition.TaskCoditionShowPath = true;
         }
     }
     UpdateShow();
 }
コード例 #4
0
    /// <summary>
    /// 展示对话
    /// </summary>
    private void ShowTalk()
    {
        DialogueValue dialogueValue = dialogueStructData.SearchDialogueValueByID(nowDialoguePoint.dialogueID);

        titleText.text = dialogueValue.showValue;
        int childCount = selectItemBackTrans.childCount;

        Transform[] childTransfroms = new Transform[childCount];
        for (int i = 0; i < childCount; i++)
        {
            childTransfroms[i] = selectItemBackTrans.GetChild(i);
        }
        for (int i = 0; i < childCount; i++)
        {
            if (!Transform.Equals(childTransfroms[i], exampleItemObj.transform))//如果不是例子对象则销毁
            {
                GameObject.DestroyImmediate(childTransfroms[i].gameObject);
            }
        }
        showItemList.Clear();
        //添加
        Action <string, Action <Transform> > AddItemAction = (showValue, ClickCallback) =>
        {
            GameObject createItemObj = GameObject.Instantiate <GameObject>(exampleItemObj);
            createItemObj.transform.SetParent(selectItemBackTrans);
            createItemObj.SetActive(true);
            Transform itemTextTrans = createItemObj.transform.GetChild(0);
            Text      itemText      = itemTextTrans.GetComponent <Text>();
            itemText.text = showValue;
            showItemList.Add(createItemObj.transform);
            //添加事件
            EventTrigger eventTrigger = createItemObj.AddComponent <EventTrigger>();
            eventTrigger.triggers = new List <EventTrigger.Entry>();
            //点击事件
            EventTrigger.Entry entry_Click = new EventTrigger.Entry();
            entry_Click.eventID  = EventTriggerType.PointerClick;
            entry_Click.callback = new EventTrigger.TriggerEvent();
            entry_Click.callback.AddListener(temp => ClickCallback(createItemObj.transform));
            eventTrigger.triggers.Add(entry_Click);
            //鼠标进入事件
            EventTrigger.Entry entry_Enter = new EventTrigger.Entry();
            entry_Enter.eventID  = EventTriggerType.PointerEnter;
            entry_Enter.callback = new EventTrigger.TriggerEvent();
            entry_Enter.callback.AddListener(temp =>
            {
                createItemObj.GetComponent <Image>().color = new Color(1, 1, 1, 0.4f);
                selectItemIndex = showItemList.IndexOf(createItemObj.transform);
            });
            eventTrigger.triggers.Add(entry_Enter);
            //鼠标离开事件
            EventTrigger.Entry entry_Leave = new EventTrigger.Entry();
            entry_Leave.eventID  = EventTriggerType.PointerExit;
            entry_Leave.callback = new EventTrigger.TriggerEvent();
            entry_Leave.callback.AddListener(temp => createItemObj.GetComponent <Image>().color = new Color(1, 1, 1, 0));
            eventTrigger.triggers.Add(entry_Leave);
        };

        DialoguePoint[] childPoints = nowDialoguePoint.childDialoguePoints;
        foreach (DialoguePoint dialoguePoint in childPoints)       //便利添加子选项
        {
            if (dontShowDialoguePointList.Contains(dialoguePoint)) //不显示的不添加
            {
                continue;
            }
            DialogueValue childDialogueValue = dialogueStructData.SearchDialogueValueByID(dialoguePoint.dialogueID);
            AddItemAction(childDialogueValue.titleValue, temp =>
            {
                int index = showItemList.IndexOf(temp);
                DialoguePoint[] nowShowChildsPoints = nowDialoguePoint.childDialoguePoints.Where(point => !dontShowDialoguePointList.Contains(point)).ToArray();
                if (index < 0 || index >= nowShowChildsPoints.Length)
                {
                    return;
                }

                DialoguePoint clickPoint = nowShowChildsPoints[index];
                if (clickPoint.childDialoguePoints == null || clickPoint.childDialoguePoints.Length == 0) //如果有任务则接取,如果没有则不做处理
                {
                    DialogueValue clickValue = dialogueStructData.SearchDialogueValueByID(clickPoint.dialogueID);
                    if (!string.IsNullOrEmpty(clickValue.otherValue))
                    {
                        int taskID = -1;
                        if (int.TryParse(clickValue.otherValue, out taskID))
                        {
                            TaskMap.RunTimeTaskInfo runTimeTaskInfo = runtimeTasksData.GetTasksWithID(taskID);
                            if (runTimeTaskInfo != null && runTimeTaskInfo.IsOver == false && runTimeTaskInfo.IsStart == false)
                            {
                                iNowTaskState.StartTask = runTimeTaskInfo.ID;
                                gameObject.SetActive(false);
                            }
                        }
                    }
                }
                else //继续进入下面节点
                {
                    nowDialoguePoint = clickPoint;
                    ShowTalk();
                }
            });
        }
        //最后添加一个返回选项
        AddItemAction("返回", temp =>
        {
            if (nowDialoguePoint.parentDialoguePoint != null)
            {
                nowDialoguePoint = nowDialoguePoint.parentDialoguePoint;
                ShowTalk();
            }
            else
            {
                gameObject.SetActive(false);
            }
        });
        StartCoroutine(UpdateContentSizeFitter(panelContentSizeFitter));
        //选择第一个下标
        selectItemIndex = 0;
        SetSelectItemIndex();
    }