private List <RewardWrapper> GetCompleteTaskDropItem() { rewardCash = 0; rewardCoin = 0; rewardExp = 0; rewardVit = 0; m_title_txt.Visible = false; List <RewardWrapper> task_rewards = new List <RewardWrapper>(); for (int i = 0; i < m_taskInfo.RewardList.Count; ++i) { TaskRewardBase taskReward = m_taskInfo.RewardList[i]; TaskRewardMode taskRewardType = (taskReward.GetType().GetCustomAttributes(typeof(TaskRewardAttribute), true)[0] as TaskRewardAttribute).RewardMode; switch (taskRewardType) { case TaskRewardMode.ITEM: TaskRewardItem rewardItem = taskReward as TaskRewardItem; if (rewardItem.RewardData != null) { task_rewards.Add(GetRewardWrapperByTaskRewardData(rewardItem.RewardData)); } break; case TaskRewardMode.TITLE: TaskRewardTitle rewardTitle = taskReward as TaskRewardTitle; m_titleGet.Visible = rewardTitle.RewardData > 0; ShowTaskTitle(rewardTitle.RewardData); break; } } return(task_rewards); }
/// <summary> /// 添加任务奖励信息 /// </summary> /// <param name="taskRewardInfo"></param> public void AddTaskRewardInfo(TaskRewardBase taskRewardInfo) { this.m_taskRewardList.Add(taskRewardInfo); }
/// <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); }
/// <summary> /// 交任务相应 /// </summary> /// <param name="message"></param> private void OnCommitTask(object message) { SCTaskCommitResponse msg = message as SCTaskCommitResponse; if (!MsgStatusCodeUtil.OnError(msg.Result)) { TaskBase commitTaskInfo = this.m_playerTaskSet.GetTaskById(msg.TaskId); if (commitTaskInfo == null) { Debug.LogError($"commit task :{msg.TaskId} not found"); } GameEvents.TaskEvents.OnReceiveTask.SafeInvoke(commitTaskInfo); GameEvents.PlayerEvents.OnExpChanged.SafeInvoke(null, msg.Exp); commitTaskInfo.TaskCurrentStatus = TaskStatus.REWARDED; commitTaskInfo.TaskSyncStatus = TaskSyncStatus.SYNCED; if (this.m_currentTaskList.Contains(commitTaskInfo)) { this.m_currentTaskList.Remove(commitTaskInfo); } //同步玩家最新信息 GameEvents.PlayerEvents.RequestLatestPlayerInfo.SafeInvoke(); //同步背包 //GlobalInfo.MY_PLAYER_INFO.SyncPlayerBag(); NormalTask taskInfo = commitTaskInfo as NormalTask; for (int i = 0; i < taskInfo.RewardList.Count; ++i) { TaskRewardBase taskReward = taskInfo.RewardList[i]; TaskRewardMode taskRewardType = (taskReward.GetType().GetCustomAttributes(typeof(TaskRewardAttribute), true)[0] as TaskRewardAttribute).RewardMode; if (TaskRewardMode.ITEM == taskRewardType) { TaskRewardItem rewardItem = taskReward as TaskRewardItem; RewardItemDataWrap rewardItemData = rewardItem.RewardData; if (RewardItemType.ITEM == rewardItemData.ItemType) { GlobalInfo.MY_PLAYER_INFO.AddSingleBagInfo(rewardItemData.ItemID, rewardItemData.ItemNum); } } } GameEvents.UIEvents.UI_GameEntry_Event.Listen_OnCombinePropCollected.SafeInvoke(); //> BigWorldManager.Instance.EnterBigWorld(); GameEvents.TaskEvents.OnCompletedTask.SafeInvoke(msg.Result, commitTaskInfo); HttpPingModule.Instance.SendPing(); //TODO : 放在主界面onshow //if (C_FIRST_TASK_ID == commitTaskInfo.TaskConfID) //{ // SignInManager sm = new SignInManager(); //} } else { GameEvents.TaskEvents.OnSyncedTaskList.SafeInvoke(1); } }