Ejemplo n.º 1
0
        /// <summary>
        /// 同步任务的详细信息
        /// </summary>
        public void SyncTaskInfo(TaskInfo syncTaskInfo)
        {
            bool status_seted = false;

            for (int i = 0; i < this.m_taskCompleteConditionList.Count; ++i)
            {
                TaskCompleteCondition completeCondition = this.m_taskCompleteConditionList[i];
                switch ((TaskStatus)syncTaskInfo.Status)
                {
                case TaskStatus.COMPLETED:
                case TaskStatus.REWARDED:
                    completeCondition.TaskCompleteConditionProgress = 1f;
                    break;

                case TaskStatus.PROGRESSING:
                {
                    if (completeCondition is TaskCompleteByLevel)
                    {
                        completeCondition.SetCompleteProgressData(syncTaskInfo.Level);
                    }
                    else if (completeCondition is TaskCompleteByScene)
                    {
                        completeCondition.SetCompleteProgressData(syncTaskInfo.SceneProgress);
                    }
                    //else if (completeCondition is TaskCompleteByEventID)
                    //{
                    //    completeCondition.SetCompleteProgressData(syncTaskInfo.EventProgress);
                    //}
                    else if (completeCondition is TaskCompleteByDialogID)
                    {
                        //对话任务
                        //TODO:防止任务状态同步消息,未按指定顺序到达。完成的任务,不能在重置为进行中。
                        this.m_taskStatus = syncTaskInfo.Status > (int)(this.m_taskStatus) ? (TaskStatus)syncTaskInfo.Status : this.m_taskStatus;
                        status_seted      = true;
                        completeCondition.SetCompleteProgressData(syncTaskInfo.DialogueProgress);
                    }
                    else if (completeCondition is TaskCompleteItems)
                    {
                        completeCondition.SetCompleteProgressData(syncTaskInfo.PropProgresss);
                        completeCondition.SetCompleteProgressData(syncTaskInfo.ExhibitProgress);
                    }
                }
                break;

                default:
                    break;
                }
            }

            //TODO:防止任务状态同步消息,未按指定顺序到达。完成的任务,不能在重置为进行中。
            if (!status_seted)
            {
                this.m_taskStatus = (TaskStatus)syncTaskInfo.Status;
            }

            this.m_taskSyncStatus = TaskSyncStatus.SYNCED;
        }
Ejemplo n.º 2
0
        //private static void OnExcuteTask(NormalTask taskInfo)
        //{

        //    if (taskInfo.CompleteConditionList.Count <= 1)
        //    { //目录没有组合条件
        //        TaskCompleteCondition taskCompleteCondition = taskInfo.CompleteConditionList[0];
        //        TaskCompleteAttribute taskCompleteAttribute = taskCompleteCondition.GetType().GetCustomAttributes(typeof(TaskCompleteAttribute), true)[0] as TaskCompleteAttribute;
        //        switch (taskCompleteAttribute.CompleteMode)
        //        {
        //            case TaskCompleteMode.CompletedByDialog:
        //                TalkUIHelper.OnStartTalk((long)taskCompleteCondition.TaskCompleteData);

        //                break;
        //            case TaskCompleteMode.CompletedBySceneID:
        //                long sceneID = (long)taskCompleteCondition.TaskCompleteData;
        //                ChapterInfo taskBelongChapterInfo = GetTaskBelongChapter(taskInfo.TaskConfID);
        //                CommonHelper.OpenEnterGameSceneUI(sceneID, taskBelongChapterInfo, taskInfo.TaskConfID);
        //                break;

        //            //case TaskCompleteMode.CompletedByEvents:
        //            //    EventGameUIAssist.BeginEventGame((long)taskCompleteCondition.TaskCompleteData);
        //            //    break;

        //            case TaskCompleteMode.CompletedByItem:
        //                GameEvents.TaskEvents.OnShowCollectionTaskDetail.SafeInvoke(taskInfo, ShowSceneInBigWorld);
        //                break;
        //            case TaskCompleteMode.CompleteByReasonID:
        //                ReasoningUILogic.ShowReasonUIById((long)taskCompleteCondition.TaskCompleteData);
        //                break;
        //            case TaskCompleteMode.CompleteByScanID:
        //                long scanID = (long)taskCompleteCondition.TaskCompleteData;
        //                ChapterInfo scanTaskBelongChapterInfo = GetTaskBelongChapter(taskInfo.TaskConfID);
        //                CommonHelper.OpenEnterGameSceneUI(scanID, scanTaskBelongChapterInfo, taskInfo.TaskConfID);
        //                break;
        //            default:
        //                break;
        //        }
        //    }
        //    else
        //    {
        //        TaskCompleteCondition c_items = taskInfo.CompleteConditionList.Find((item) => item.GetType() == typeof(TaskCompleteItems));

        //        if (null != c_items)
        //        {
        //            TaskCompleteCondition c_scene = taskInfo.CompleteConditionList.Find((item) => item.GetType() == typeof(TaskCompleteByScene));

        //            Action<long> close_act = null;

        //            if (null != c_scene)
        //            {
        //                close_act = (task_conf_id) =>
        //                {
        //                    long task_config_id = task_conf_id;
        //                    long sceneID = (long)c_scene.TaskCompleteData;
        //                    ChapterInfo taskBelongChapterInfo = GetTaskBelongChapter(taskInfo.TaskConfID);
        //                    CommonHelper.OpenEnterGameSceneUI(sceneID, taskBelongChapterInfo, taskInfo.TaskConfID);
        //                };
        //            }

        //            GameEvents.TaskEvents.OnShowCollectionTaskDetail.SafeInvoke(taskInfo, close_act);
        //        }
        //    }


        //}


        private static void OnExcuteTask(NormalTask taskInfo)
        {
            if (taskInfo.CompleteConditionList.Count <= 1)
            { //目录没有组合条件
                TaskCompleteCondition taskCompleteCondition = taskInfo.CompleteConditionList[0];
                TaskCompleteAttribute taskCompleteAttribute = taskCompleteCondition.GetType().GetCustomAttributes(typeof(TaskCompleteAttribute), true)[0] as TaskCompleteAttribute;
                switch (taskCompleteAttribute.CompleteMode)
                {
                case TaskCompleteMode.CompletedByDialog:
                {
                    TalkUIHelper.OnStartTalk((long)taskCompleteCondition.TaskCompleteData);
                }

                break;

                case TaskCompleteMode.CompletedBySceneID:
                {
                    Action <long> close_act = null;

                    close_act = (task_conf_id) =>
                    {
                        long        sceneID = (long)taskCompleteCondition.TaskCompleteData;
                        ChapterInfo taskBelongChapterInfo = GetTaskBelongChapter(taskInfo.TaskConfID);
                        CommonHelper.OpenEnterGameSceneUI(sceneID, taskBelongChapterInfo, taskInfo.TaskConfID);
                    };


                    GameEvents.TaskEvents.OnTryShowCollectionTaskDetail.SafeInvoke(taskInfo, close_act);
                }
                break;

                //case TaskCompleteMode.CompletedByEvents:
                //    EventGameUIAssist.BeginEventGame((long)taskCompleteCondition.TaskCompleteData);
                //    break;

                case TaskCompleteMode.CompletedByItem:
                {
                    GameEvents.TaskEvents.OnTryShowCollectionTaskDetail.SafeInvoke(taskInfo, ShowSceneInBigWorld);
                }
                break;

                case TaskCompleteMode.CompleteByReasonID:
                {
                    Action <long> close_act = null;

                    close_act = (task_conf_id) =>
                    {
                        ReasoningUILogic.ShowReasonUIById((long)taskCompleteCondition.TaskCompleteData);
                    };

                    GameEvents.TaskEvents.OnTryShowCollectionTaskDetail.SafeInvoke(taskInfo, close_act);
                }
                break;

                case TaskCompleteMode.CompleteByCombinePropID:
                {
                    Action <long> close_act = null;

                    close_act = (task_conf_id) =>
                    {
                        long[] ids = ConfTask.Get(task_conf_id).conditionPropExIds;

                        if (ids.Length > 0)
                        {
                            FrameMgr.OpenUIParams uiParams = new FrameMgr.OpenUIParams(UIDefine.UI_COMBINE);
                            uiParams.Param = ids[0];

                            EngineCoreEvents.UIEvent.ShowUIEventWithParam.SafeInvoke(uiParams);
                        }
                        else
                        {
                            EngineCoreEvents.UIEvent.ShowUIEvent.SafeInvoke(UIDefine.UI_COMBINE);
                        }
                    };

                    GameEvents.TaskEvents.OnTryShowCollectionTaskDetail.SafeInvoke(taskInfo, close_act);
                }
                break;

                case TaskCompleteMode.CompleteByScanID:

                {
                    Action <long> close_act = null;

                    close_act = (task_conf_id) =>
                    {
                        long        scanID = (long)taskCompleteCondition.TaskCompleteData;
                        ChapterInfo scanTaskBelongChapterInfo = GetTaskBelongChapter(taskInfo.TaskConfID);
                        CommonHelper.OpenEnterGameScanUI(scanID, scanTaskBelongChapterInfo, taskInfo.TaskConfID);
                    };

                    GameEvents.TaskEvents.OnTryShowCollectionTaskDetail.SafeInvoke(taskInfo, close_act);
                }
                break;

                default:
                    break;
                }
            }
            else
            {
                TaskCompleteCondition c_items = taskInfo.CompleteConditionList.Find((item) => item.GetType() == typeof(TaskCompleteItems));

                if (null != c_items)
                {
                    TaskCompleteCondition c_scene = taskInfo.CompleteConditionList.Find((item) => item.GetType() == typeof(TaskCompleteByScene));

                    Action <long> close_act = null;

                    if (null != c_scene)
                    {
                        close_act = (task_conf_id) =>
                        {
                            long        task_config_id        = task_conf_id;
                            long        sceneID               = (long)c_scene.TaskCompleteData;
                            ChapterInfo taskBelongChapterInfo = GetTaskBelongChapter(taskInfo.TaskConfID);
                            CommonHelper.OpenEnterGameSceneUI(sceneID, taskBelongChapterInfo, taskInfo.TaskConfID);
                        };
                    }

                    GameEvents.TaskEvents.OnTryShowCollectionTaskDetail.SafeInvoke(taskInfo, close_act);
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 创建任务
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="taskId">任务配置ID</param>
        /// <param name="triggerModeList">任务触发条件参数</param>
        /// <param name="completedModeList">任务完成条件参数</param>
        /// <param name="rewardModeList">任务奖励条件参数</param>
        /// <param name="taskType"></param>
        /// <returns></returns>
        public T CreateTask <T>(long taskId, List <TaskCreaterParams> triggerModeList, List <TaskCreaterParams> completedModeList, List <TaskCreaterParams> rewardModeList, int taskType = 1) where T : TaskBase
        {
            Type taskImplType;

            if (this.m_taskImplDict.TryGetValue(taskType, out taskImplType))
            {
                T taskImpl = Activator.CreateInstance(taskImplType, taskId) as T;

                for (int i = 0; i < triggerModeList.Count; ++i)
                {
                    TaskTriggerMode triggerMode = (TaskTriggerMode)triggerModeList[i].Condition;

                    Type triggerImplType;
                    if (this.m_taskTriggerConditionDict.TryGetValue(triggerMode, out triggerImplType))
                    {
                        TaskTriggerCondition triggerImpl = Activator.CreateInstance(triggerImplType, triggerModeList[i].Data) as TaskTriggerCondition;

                        taskImpl.AddTaskTriggerCondition(triggerImpl);
                    }
                    else
                    {
                        throw new Exception("trigger mode :" + triggerMode + " not implement");
                    }
                }

                for (int i = 0; i < completedModeList.Count; ++i)
                {
                    TaskCompleteMode completeMode = (TaskCompleteMode)completedModeList[i].Condition;

                    Type triggerCompleteImplType;
                    if (this.m_taskCompleteDict.TryGetValue(completeMode, out triggerCompleteImplType))
                    {
                        TaskCompleteCondition completeTaskConditionImpl = Activator.CreateInstance(triggerCompleteImplType, completedModeList[i].Data) as TaskCompleteCondition;

                        taskImpl.AddTaskCompleteCondition(completeTaskConditionImpl);
                    }
                    else
                    {
                        throw new Exception("completed mode :" + completeMode + " not implement");
                    }
                }

                for (int i = 0; i < rewardModeList.Count; ++i)
                {
                    TaskRewardMode rewardMode = (TaskRewardMode)rewardModeList[i].Condition;

                    Type rewardImpl;
                    if (this.m_taskRewardDict.TryGetValue(rewardMode, out rewardImpl))
                    {
                        TaskRewardBase taskRewardImpl = Activator.CreateInstance(rewardImpl, rewardModeList[i].Data) as TaskRewardBase;

                        taskImpl.AddTaskRewardInfo(taskRewardImpl);
                    }
                    else
                    {
                        throw new Exception("reward mode :" + rewardMode + " not implement");
                    }
                }

                return(taskImpl);
            }

            return(null);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// 添加 任务完成条件
 /// </summary>
 /// <param name="taskCompleteCondition"></param>
 public void AddTaskCompleteCondition(TaskCompleteCondition taskCompleteCondition)
 {
     this.m_taskCompleteConditionList.Add(taskCompleteCondition);
 }
Ejemplo n.º 5
0
        private void OnRes(object obj)
        {
            if (obj is SCChatFinishResponse)
            {
                SCChatFinishResponse res = (SCChatFinishResponse)obj;
                if (res.Status == null)
                {
                    var req = EngineCoreEvents.SystemEvents.GetRspPairReq.SafeInvoke();
                    CSChatFinishRequest req_msg = req as CSChatFinishRequest;
                    long chat_id = req_msg.ChatId;

                    foreach (var task in m_currentTaskList)
                    {
                        NormalTask taskInfo = task as NormalTask;

                        if (taskInfo.CompleteConditionList.Count > 1 || 0 == taskInfo.CompleteConditionList.Count)
                        {
                            continue;
                        }

                        TaskCompleteCondition taskCompleteCondition = taskInfo.CompleteConditionList[0];
                        TaskCompleteAttribute taskCompleteAttribute = taskCompleteCondition.GetType().GetCustomAttributes(typeof(TaskCompleteAttribute), true)[0] as TaskCompleteAttribute;

                        if (TaskCompleteMode.CompletedByDialog != taskCompleteAttribute.CompleteMode)
                        {
                            continue;
                        }

                        long task_dialog_id = (long)taskCompleteCondition.TaskCompleteData;

                        if (chat_id != task_dialog_id)
                        {
                            continue;
                        }

                        taskInfo.TaskCurrentStatus = TaskStatus.COMPLETED;
                    }

                    GameEvents.TaskEvents.OnSyncedTaskList.SafeInvoke(this.m_currentTaskList.Count);
                }
            }
            else if (obj is SCCombineResponse)
            {
                SCCombineResponse res = (SCCombineResponse)obj;
                if (res.Success)
                {
                    var req = EngineCoreEvents.SystemEvents.GetRspPairReq.SafeInvoke();
                    CSCombineRequest req_msg      = req as CSCombineRequest;
                    long             combine_id   = req_msg.CombineId;
                    long             prop_id      = ConfCombineFormula.Get(combine_id).outputId;
                    bool             tsk_finished = false;
                    foreach (var task in m_currentTaskList)
                    {
                        NormalTask taskInfo = task as NormalTask;

                        if (taskInfo.CompleteConditionList.Count > 1 || 0 == taskInfo.CompleteConditionList.Count)
                        {
                            continue;
                        }

                        TaskCompleteCondition taskCompleteCondition = taskInfo.CompleteConditionList[0];
                        TaskCompleteAttribute taskCompleteAttribute = taskCompleteCondition.GetType().GetCustomAttributes(typeof(TaskCompleteAttribute), true)[0] as TaskCompleteAttribute;

                        if (TaskCompleteMode.CompleteByCombinePropID != taskCompleteAttribute.CompleteMode)
                        {
                            continue;
                        }
                        long[] all_tsk_combine_prop_id = (long[])taskCompleteCondition.TaskCompleteData;

                        if (0 == all_tsk_combine_prop_id.Length)
                        {
                            Debug.LogError($"合成任务{taskInfo.TaskConfID}没有配置完成物件");
                            continue;
                        }

                        long task_combine_prop_id = all_tsk_combine_prop_id[0];

                        if (prop_id != task_combine_prop_id)
                        {
                            continue;
                        }

                        tsk_finished = true;
                        taskInfo.TaskCurrentStatus = TaskStatus.COMPLETED;
                    }
                    if (tsk_finished)
                    {
                        GameEvents.TaskEvents.OnSyncedTaskList.SafeInvoke(this.m_currentTaskList.Count);
                        EngineCoreEvents.UIEvent.HideUIEvent.SafeInvoke(UIDefine.UI_COMBINE);
                    }
                }
            }
            else if (obj is SCCartoonEnterResponse)
            {
                SCCartoonEnterResponse res = obj as SCCartoonEnterResponse;
                if (!MsgStatusCodeUtil.OnError(res.Result))
                {
                    var req = EngineCoreEvents.SystemEvents.GetRspPairReq.SafeInvoke();
                    CSCartoonEnterRequest req_msg = req as CSCartoonEnterRequest;
                    long cur_scene_id             = req_msg.SceneId;

                    foreach (var task in m_currentTaskList)
                    {
                        NormalTask taskInfo = task as NormalTask;

                        if (taskInfo.CompleteConditionList.Count > 1 || 0 == taskInfo.CompleteConditionList.Count)
                        {
                            continue;
                        }

                        TaskCompleteCondition taskCompleteCondition = taskInfo.CompleteConditionList[0];
                        TaskCompleteAttribute taskCompleteAttribute = taskCompleteCondition.GetType().GetCustomAttributes(typeof(TaskCompleteAttribute), true)[0] as TaskCompleteAttribute;

                        if (TaskCompleteMode.CompletedBySceneID != taskCompleteAttribute.CompleteMode)
                        {
                            continue;
                        }

                        long scene_id = (long)taskCompleteCondition.TaskCompleteData;

                        if (CommonData.C_CARTOON_SCENE_START_ID != scene_id / CommonData.C_SCENE_TYPE_ID)
                        {
                            continue;
                        }

                        if (cur_scene_id != scene_id)
                        {
                            continue;
                        }

                        taskInfo.TaskCurrentStatus = TaskStatus.COMPLETED;
                    }
                }
            }
            else if (obj is SCCartoonRewardReqsponse)
            {
                GameEvents.TaskEvents.OnSyncedTaskList.SafeInvoke(this.m_currentTaskList.Count);
            }
        }