using System.Collections.Generic;
namespace GFGGame
{
public struct FieldInfos
{
///
/// 当前主题 由ConstItemAttributeType定义
///
public int theme;
///
/// 最高关卡记录列表,由简单到难
///
public List highestLvls;
///
/// 每周已领奖励
///
public int bonusWeekly;
///
/// 奖励上限
///
public int bonusMaxLimit;
///
/// 任务奖励状态 由ConstBonusStatus定义
///
public Dictionary taskDic;
///
/// 仅在上线时判断是否有奖励未结算
///
public bool hasBonus;
};
public struct FieldResult
{
///
/// 完成关数
///
public int passLvl;
///
/// 奖励列表
///
public List bonusList;
///
/// 体力消耗
///
public int costNum;
///
/// 难度,由ConstInstanceZonesSubType定义
///
public int hardLvl;
}
public class FieldDataManager : SingletonBase
{
// private int _theme = 1; //当前主题 由ConstItemAttributeType定义
// ///
// /// 本期主题
// ///
// public int Theme
// {
// get { return _theme; }
// set { _theme = value; }
// }
// private int _bonusWeekly = 0;//每周已领奖励
// ///
// /// 每周已领奖励
// ///
// ///
// public int BonusWeekly
// {
// get { return _bonusWeekly; }
// set { _bonusWeekly = value; }
// }
// private int _bonusMaxLimit = 0;//奖励上限
// ///
// /// 奖励上限
// ///
// ///
// public int BonusMaxLimit
// {
// get { return _bonusMaxLimit; }
// set { _bonusMaxLimit = value; }
// }
// private List _highestLvls = new List();//最高关卡记录列表,由简单到难
// private Dictionary _taskDic = new Dictionary();//任务奖励状态 由ConstBonusStatus定义
// private bool hasBonus = false;//仅在上线时判断是否有奖励未结算
public FieldInfos fieldInfos = new FieldInfos();
public FieldResult fieldResult = new FieldResult();
///
/// 当前难度
///
public int difficulty = 0;
//当前关卡进度
public int currFightIndex = 0;
public void UpdateTask(int taskId, int state)
{
if (!fieldInfos.taskDic.ContainsKey(taskId))
{
fieldInfos.taskDic.Add(taskId, state);
}
else
{
fieldInfos.taskDic[taskId] = state;
}
}
///
/// 根据挑战难度获取最高记录
///
///
///
public int GetHighestLvByDifficulty(int difficulty)
{
if (fieldInfos.highestLvls.IndexOf(difficulty) < 0)
{
return 0;
}
else
{
return fieldInfos.highestLvls[difficulty];
}
}
///
/// 根据挑战难度获取副本配置
///
///
///
public FieldCfg GetFieldCfgByDifficulty(int difficulty)
{
return FieldCfgArray.Instance.GetCfgs(difficulty)[0];
}
///
/// 根据挑战难度获取当前战斗Id
///
///
public int GetLevelIdByDifficulty(int difficulty, int index)
{
FieldCfg cfg = GetFieldCfgByDifficulty(difficulty);
return StoryLevelCfgArray.Instance.GetCfgs(cfg.type, cfg.subType, cfg.id)[index].id;
}
///
/// 获取任务列表
///
///
public List GetTaskCfgs()
{
List cfgs = new List(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;
}
///
/// 根据任务ID获取任务状态0可领取1未完成2已领取
///
///
///
public int GetTaskState(int taskId)
{
return fieldInfos.taskDic.ContainsKey(taskId) ? fieldInfos.taskDic[taskId] : 1;
}
}
}