123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- using System.Collections.Generic;
- namespace GFGGame
- {
- public class FieldDataManager : SingletonBase<FieldDataManager>
- {
- /// <summary>
- /// 本期主题
- /// </summary>
- public int scoreType = 1;
- public Dictionary<int, int> _levelIdDic = new Dictionary<int, int>();
- private Dictionary<int, int> _taskDic = new Dictionary<int, int>();
- public void UpdateTask(int taskId, int state)
- {
- if (!_taskDic.ContainsKey(taskId))
- {
- _taskDic.Add(taskId, state);
- }
- else
- {
- _taskDic[taskId] = state;
- }
- }
- /// <summary>
- /// 根据挑战难度获取副本配置
- /// </summary>
- /// <param name="difficulty"></param>
- /// <returns></returns>
- public FieldCfg GetFieldCfgByDifficulty(int difficulty)
- {
- return FieldCfgArray.Instance.GetCfgs(difficulty)[0];
- }
- /// <summary>
- /// 根据挑战难度获取当前战斗Id
- /// </summary>
- /// <returns></returns>
- public int GetLevelIdByDifficulty(int difficulty)
- {
- if (_levelIdDic.ContainsKey(difficulty))
- {
- return _levelIdDic[difficulty];
- }
- else
- {
- FieldCfg cfg = GetFieldCfgByDifficulty(difficulty);
- return StoryLevelCfgArray.Instance.GetCfgs(cfg.type, cfg.subType, cfg.id)[0].id;
- }
- }
- /// <summary>
- /// 获取任务列表
- /// </summary>
- /// <returns></returns>
- public List<FieldTaskCfg> GetTaskCfgs()
- {
- List<FieldTaskCfg> cfgs = new List<FieldTaskCfg>(FieldTaskCfgArray.Instance.dataArray);
- cfgs.Sort((FieldTaskCfg a, FieldTaskCfg b) =>
- {
- int stateA = GetTaskState(a.id);
- int stateB = GetTaskState(b.id);
- return stateA.CompareTo(stateB);
- });
- return cfgs;
- }
- /// <summary>
- /// 根据任务ID获取任务状态0可领取1未完成2已领取
- /// </summary>
- /// <param name="taskId"></param>
- /// <returns></returns>
- public int GetTaskState(int taskId)
- {
- return _taskDic.ContainsKey(taskId) ? _taskDic[taskId] : 0;
- }
- }
- }
|