示例#1
0
 public void UpdateData(TaskData data)
 {
     taskData      = data;
     currentDialog = taskData.GetCurrentDialog();
     scene         = JsonManager.GetInstance().GetMapping <SceneData>("Scenes", taskData.BelongToSceneId);
     npc           = JsonManager.GetInstance().GetMapping <NpcData>("Npcs", taskData.BelongToNpcId);
     areaNames     = JsonManager.GetInstance().GetJson("AreaNames");
     areaName      = areaNames[scene.BelongToAreaName] != null ? areaNames[scene.BelongToAreaName]["Name"].ToString() : "";
     EventTriggerListener.Get(ScoutBtn.gameObject).onClick = onClick;
 }
示例#2
0
        /// <summary>
        /// 检测任务对话状态(任务对话的进度在这里来更新, 每次验证任务对话类型,然后判断是否可以完成,如果可以完成则CurrentDialogIndex+1)
        /// </summary>
        /// <param name="taskId">Task identifier.</param>
        /// <param name="auto">If set to <c>true</c> auto.</param>
        /// <param name="selectedNo">If set to <c>true</c> selected no.</param>
        public void CheckTaskDialog(string taskId, bool auto = false, bool selectedNo = false)
        {
            TaskData data = getTask(taskId);

            if (data != null)
            {
                if (data.State == TaskStateType.Completed)
                {
//					db.CloseSqlConnection();
                    return;
                }
                string         triggerNewBackTaskDataId = "";
                TaskDialogType dialogType = data.GetCurrentDialog().Type;
                bool           canModify  = false;
                JArray         pushData   = new JArray();
                TaskDialogData dialog     = data.GetCurrentDialog();
                data.State = TaskStateType.Accepted;
                if (data.GetCurrentDialogStatus() == TaskDialogStatusType.Initial)
                {
                    if (dialogType == TaskDialogType.JustTalk || dialogType == TaskDialogType.Notice)
                    {
                        //交谈步骤和信息显示步骤直接变为已读状态
                        data.SetCurrentDialogStatus(TaskDialogStatusType.ReadYes);
                    }
                    else
                    {
                        //其他状态的话需要等待下一个步骤提交时检测是否可以完成,所以先HoldOn
                        data.SetCurrentDialogStatus(TaskDialogStatusType.HoldOn);
                        bool loadEvents = false;
                        //如果是动态战斗事件步骤需要在这里创建动态战斗事件
                        if (dialogType == TaskDialogType.EventFightWined)
                        {
//							Debug.LogWarning("如果是动态战斗事件步骤需要在这里创建动态战斗事件");
                            //创建一个区域大地图的战斗事件
                            CreateNewEvent(SceneEventType.Battle, dialog.StringValue, UserModel.CurrentUserData.CurrentAreaSceneName);
                            loadEvents = true;
                        }
                        //如果是区域大地图野外任务事件步骤需要在这里创建动态任务事件
                        if (dialogType == TaskDialogType.CreateTaskIsBindedWithEvent)
                        {
//							Debug.LogWarning("如果是区域大地图野外任务事件步骤需要在这里创建动态任务事件");
                            //创建一个区域大地图的战斗事件
                            AddNewTask(dialog.StringValue);
                            CreateNewEvent(SceneEventType.Task, dialog.StringValue, UserModel.CurrentUserData.CurrentAreaSceneName);
                            loadEvents = true;
                        }
                        if (loadEvents)
                        {
                            //加载动态事件列表
                            Messenger.Broadcast <string>(NotifyTypes.GetActiveEventsInArea, UserModel.CurrentUserData.CurrentAreaSceneName);
                        }
                    }
                    dialog = data.GetCurrentDialog();
                    pushData.Add(new JArray(dialog.Index.ToString(), dialog.Type, dialog.TalkMsg, (short)data.GetCurrentDialogStatus(), dialog.IconId, dialog.StringValue));
                    canModify = true;
                }
                else
                {
                    RoleData hostRole;
                    switch (dialogType)
                    {
                    case TaskDialogType.Choice:
                        if (!auto)
                        {
                            triggerNewBackTaskDataId = selectedNo ? data.GetCurrentDialog().BackNoTaskDataId : data.GetCurrentDialog().BackYesTaskDataId;
                            data.SetCurrentDialogStatus(selectedNo ? TaskDialogStatusType.ReadNo : TaskDialogStatusType.ReadYes);
                            //输出步骤执行结果信息
                            pushData.Add(new JArray(dialog.Index.ToString() + "_0", TaskDialogType.Notice, data.GetCurrentDialogStatus() == TaskDialogStatusType.ReadYes ? dialog.YesMsg : dialog.NoMsg, (short)data.GetCurrentDialogStatus(), dialog.IconId, dialog.StringValue));
                            canModify = true;
                        }
                        break;

                    case TaskDialogType.ConvoyNpc:     //暂时没考虑好怎么做护送npc任务
                        data.SetCurrentDialogStatus(TaskDialogStatusType.ReadYes);
                        pushData.Add(new JArray(dialog.Index.ToString() + "_0", TaskDialogType.Notice, dialog.YesMsg, (short)data.GetCurrentDialogStatus(), dialog.IconId, dialog.StringValue));
                        canModify = true;
                        break;

                    case TaskDialogType.FightWined:
                    case TaskDialogType.EventFightWined:
                        if (IsFightWined(dialog.StringValue))
                        {
                            data.SetCurrentDialogStatus(TaskDialogStatusType.ReadYes);
                            pushData.Add(new JArray(dialog.Index.ToString() + "_0", TaskDialogType.Notice, dialog.YesMsg, (short)data.GetCurrentDialogStatus(), dialog.IconId, dialog.StringValue));
                            canModify = true;
                        }
                        break;

                    case TaskDialogType.JustTalk:
                    case TaskDialogType.Notice:
                        canModify = true;
                        break;

                    case TaskDialogType.RecruitedThePartner:
                        if (GetRoleDataByRoleId(dialog.StringValue) != null)
                        {
                            data.SetCurrentDialogStatus(TaskDialogStatusType.ReadYes);
                            pushData.Add(new JArray(dialog.Index.ToString() + "_0", TaskDialogType.Notice, dialog.YesMsg, (short)data.GetCurrentDialogStatus(), dialog.IconId, dialog.StringValue));
                            canModify = true;
                        }
                        break;

                    case TaskDialogType.SendItem:
                        if (CostItemFromBag(dialog.StringValue, dialog.IntValue))
                        {
                            DbManager.Instance.UpdateUsedItemRecords(dialog.StringValue, dialog.IntValue);
                            data.SetCurrentDialogStatus(TaskDialogStatusType.ReadYes);
                            pushData.Add(new JArray(dialog.Index.ToString() + "_0", TaskDialogType.Notice, dialog.YesMsg, (short)data.GetCurrentDialogStatus(), dialog.IconId, dialog.StringValue));
                            canModify = true;
                        }
                        break;

                    case TaskDialogType.UsedTheBook:
                        hostRole = GetHostRoleData();
                        if (hostRole != null)
                        {
                            for (int i = 0; i < hostRole.ResourceBookDataIds.Count; i++)
                            {
                                if (hostRole.ResourceBookDataIds[i] == dialog.StringValue)
                                {
                                    data.SetCurrentDialogStatus(TaskDialogStatusType.ReadYes);
                                    pushData.Add(new JArray(dialog.Index.ToString() + "_0", TaskDialogType.Notice, dialog.YesMsg, (short)data.GetCurrentDialogStatus(), dialog.IconId, dialog.StringValue));
                                    canModify = true;
                                    break;
                                }
                            }
                        }
                        break;

                    case TaskDialogType.UsedTheSkillOneTime:
                        if (GetUsedTheSkillTimes(dialog.StringValue) > 0)
                        {
                            data.SetCurrentDialogStatus(TaskDialogStatusType.ReadYes);
                            pushData.Add(new JArray(dialog.Index.ToString() + "_0", TaskDialogType.Notice, dialog.YesMsg, (short)data.GetCurrentDialogStatus(), dialog.IconId, dialog.StringValue));
                            canModify = true;
                        }
                        break;

                    case TaskDialogType.UsedTheWeapon:
                        hostRole = GetHostRoleData();
                        if (hostRole.ResourceWeaponDataId == dialog.StringValue)
                        {
                            data.SetCurrentDialogStatus(TaskDialogStatusType.ReadYes);
                            pushData.Add(new JArray(dialog.Index.ToString() + "_0", TaskDialogType.Notice, dialog.YesMsg, (short)data.GetCurrentDialogStatus(), dialog.IconId, dialog.StringValue));
                            canModify = true;
                        }
                        break;

                    case TaskDialogType.WeaponPowerPlusSuccessed:
                        if (GetWeaponPowerPlusSuccessedTimes(dialog.IntValue) > 0)
                        {
                            data.SetCurrentDialogStatus(TaskDialogStatusType.ReadYes);
                            pushData.Add(new JArray(dialog.Index.ToString() + "_0", TaskDialogType.Notice, dialog.YesMsg, (short)data.GetCurrentDialogStatus(), dialog.IconId, dialog.StringValue));
                            canModify = true;
                        }
                        break;

                    case TaskDialogType.SendResource:
//						if (CostResource((ResourceType)Enum.Parse(typeof(ResourceType), dialog.StringValue), dialog.IntValue)) {
                        if (GetResourceNum((ResourceType)Enum.Parse(typeof(ResourceType), dialog.StringValue)) >= dialog.IntValue)
                        {
                            data.SetCurrentDialogStatus(TaskDialogStatusType.ReadYes);
                            pushData.Add(new JArray(dialog.Index.ToString() + "_0", TaskDialogType.Notice, dialog.YesMsg, (short)data.GetCurrentDialogStatus(), dialog.IconId, dialog.StringValue));
                            canModify = true;
                        }
                        break;

                    case TaskDialogType.TheHour:
                        if (FramePanelCtrl.CurrentTimeIndex == dialog.IntValue)
                        {
                            data.SetCurrentDialogStatus(TaskDialogStatusType.ReadYes);
                            pushData.Add(new JArray(dialog.Index.ToString() + "_0", TaskDialogType.Notice, dialog.YesMsg, (short)data.GetCurrentDialogStatus(), dialog.IconId, dialog.StringValue));
                            canModify = true;
                        }
                        break;

                    case TaskDialogType.PushRoleToWinshop:
                        PushNewRoleToWinShop(dialog.StringValue);
                        data.SetCurrentDialogStatus(TaskDialogStatusType.ReadYes);
                        pushData.Add(new JArray(dialog.Index.ToString() + "_0", TaskDialogType.Notice, dialog.YesMsg, (short)data.GetCurrentDialogStatus(), dialog.IconId, dialog.StringValue));
                        canModify = true;
                        break;

                    case TaskDialogType.CreateTaskIsBindedWithEvent:
                        if (IsTaskCompleted(dialog.StringValue))
                        {
                            data.SetCurrentDialogStatus(TaskDialogStatusType.ReadYes);
                            pushData.Add(new JArray(dialog.Index.ToString() + "_0", TaskDialogType.Notice, dialog.YesMsg, (short)data.GetCurrentDialogStatus(), dialog.IconId, dialog.StringValue));
                            canModify = true;
                        }
                        break;

                    default:
                        break;
                    }
                    if (canModify && data.CheckCompleted())
                    {
                        data.State = TaskStateType.Completed;
                    }
                }
                TaskStateType currentState = data.State;
                if (canModify)
                {
                    db = OpenDb();
                    //如果是可循环的任务这里需要置为可接受,否则置为已完成
                    if (data.State == TaskStateType.Completed && data.CanRepeat)
                    {
                        data.State = TaskStateType.CanAccept;
                        for (int a = 0; a < data.ProgressData.Count; a++)
                        {
                            data.ProgressData[a] = (short)TaskDialogStatusType.Initial;
                        }
                        data.SetCurrentDialogIndex(0);
                    }
                    //update data
                    db.ExecuteQuery("update TasksTable set ProgressData = '" + data.ProgressData.ToString() +
                                    "', CurrentDialogIndex = " + data.CurrentDialogIndex +
                                    ", State = " + ((int)data.State) +
                                    " where TaskId ='" + taskId + "' and BelongToRoleId = '" + currentRoleId + "'");
                    db.CloseSqlConnection();
                    int index = taskListData.FindIndex(item => item.Id == taskId);
                    //update cache
                    if (taskListData.Count > index)
                    {
                        taskListData[index] = data;
                    }
                }
                //触发新任务
                if (triggerNewBackTaskDataId != "" && triggerNewBackTaskDataId != "0")
                {
                    AddNewTaskExceptType(triggerNewBackTaskDataId, TaskType.IsBindedWithEvent);
                    //检测任务状态
                    checkAddedTasksStatus();
                }
                if (currentState == TaskStateType.Completed)
                {
                    //添加任务奖励物品
                    //查询背包是否已满
                    bool enoughBagSeat = false;
//					int hasNum = GetItemNumLeftInBag(); //还剩余的背包位子
//					if (hasNum > 0) {
//						enoughBagSeat = true;
//					}
                    //任务掉落的物品没有背包限制
                    List <DropData> drops = PushItemToBag(data.Rewards, true);
                    if (drops.Count > 0)
                    {
                        Messenger.Broadcast <List <DropData> >(NotifyTypes.ShowDropsListPanel, drops);
                    }
                    //如果是就职任务则提示就职成功
                    if (data.IsInaugurationTask)
                    {
                        HostData = GetHostRoleData();
                        if (HostData.Occupation == OccupationType.None)
                        {
                            //加入门派
                            HostData.Occupation = data.InaugurationOccupation;
                            HostData.Disposed();
                            db = OpenDb();
                            db.ExecuteQuery("update RolesTable set RoleData = '" + DESStatics.StringEncoder(JsonManager.GetInstance().SerializeObject(HostData)) + "' where Id = " + HostData.PrimaryKeyId);
                            //判断兵器是否属于本门派
                            WeaponData currentWeapon = JsonManager.GetInstance().GetMapping <WeaponData>("Weapons", HostData.ResourceWeaponDataId);
                            if (currentWeapon.Occupation != OccupationType.None && currentWeapon.Occupation != HostData.Occupation)
                            {
                                SqliteDataReader sqReader = db.ExecuteQuery("select * from WeaponsTable where BeUsingByRoleId = '" + currentRoleId + "' and BelongToRoleId ='" + currentRoleId + "'");
                                while (sqReader.Read())
                                {
                                    //将兵器先卸下
                                    int dataId = sqReader.GetInt32(sqReader.GetOrdinal("Id"));
                                    db.ExecuteQuery("update WeaponsTable set BeUsingByRoleId = '' where Id = " + dataId);
                                }
                            }
                            db.CloseSqlConnection();
                            //检查下是否有新兵器需要
                            CheckNewWeaponIdsOfWorkshop(UserModel.CurrentUserData.CurrentCitySceneId);
                            Messenger.Broadcast(NotifyTypes.MakeCheckNewFlags); //判断城镇界面的新增提示
                            AlertCtrl.Show(string.Format("你已成功加入{0}!", Statics.GetOccupationName(HostData.Occupation)));
                        }
                        else
                        {
                            AlertCtrl.Show("你已是有门有派之人, 不可在此另行拜师!");
                        }
                    }
                    //任务完成后出发后续任务
                    addChildrenTasks(data.Id);
                    //任务完成后移除区域大地图上的任务事件
                    RemoveTaskEvent(data.Id);
                }
                Messenger.Broadcast <JArray>(NotifyTypes.CheckTaskDialogEcho, pushData);
                if (data.GetCurrentDialogStatus() == TaskDialogStatusType.ReadNo || data.GetCurrentDialogStatus() == TaskDialogStatusType.ReadYes)
                {
                    data.NextDialogIndex();
                }
            }
        }
示例#3
0
        public void RefreshView()
        {
            string   color   = "";
            string   content = "";
            string   rewards = "";
            DropData drop;

            for (int i = 0; i < taskData.Rewards.Count; i++)
            {
                drop     = taskData.Rewards[i];
                rewards += drop.Item.Name + (drop.Num > 1 ? "*" + drop.Num : "");
                if (i < taskData.Rewards.Count - 1)
                {
                    rewards += ", ";
                }
            }
            switch (taskData.State)
            {
            case TaskStateType.Accepted:
                color   = "#FF0000";
                content = string.Format("{0}\n{1}", taskData.Desc, getDialogDesc(taskData.GetCurrentDialog()));
                break;

            case TaskStateType.CanAccept:
                color   = "#00FFFF";
                content = string.Format("{0}\n{1}", taskData.Desc, getDialogDesc(taskData.GetCurrentDialog()));
                break;

            case TaskStateType.CanNotAccept:
                color = "#CCCCCC";
                string condition = "";
                switch (taskData.Type)
                {
                case TaskType.Gender:
                    condition = (GenderType)taskData.IntValue == GenderType.Female ? "需要主角为 女性" : "需要主角为 男性";
                    break;

                case TaskType.ItemInHand:
                    condition = "需要拥有 " + JsonManager.GetInstance().GetMapping <ItemData>("ItemDatas", taskData.StringValue).Name;
                    break;

                case TaskType.MoralRange:
                    condition = "需要道德点区间为 " + taskData.MinIntValue + "-" + taskData.MaxIntValue;
                    break;

                case TaskType.None:
                    condition = "无限制";
                    break;

                case TaskType.Occupation:
                    condition = "主角所属门派必须为 " + Statics.GetOccupationName((OccupationType)taskData.IntValue);
                    break;

                case TaskType.TheHour:
                    condition = "需要到 " + Statics.GetTimeName(taskData.IntValue) + " 才能接取";
                    break;

                default:
                    break;
                }
                content = string.Format("{0}\n接取条件:<color=\"#FF0000\">{1}</color>\n目标:前往<color=\"#F57729\">{2}</color>的<color=\"#F57729\">{3}</color>找<color=\"#F57729\">{4}</color>交谈", taskData.Desc, condition, areaName, scene.Name, npc.Name);
                break;

            case TaskStateType.Completed:
                color   = "#999999";
                content = "已完成";
                break;

            case TaskStateType.Ready:
                color   = "#00FF00";
                content = string.Format("{0}\n{1}", taskData.Desc, getDialogDesc(taskData.GetCurrentDialog()));
                break;

            default:
                color = "#FFFFFF";
                break;
            }
            title.text = string.Format("<color=\"{0}\">{1}</color>", color, taskData.Name);
            desc.text  = string.Format("{0}\n奖励:{1}", content, rewards != "" ? rewards : "无");
        }