TH1/Unity/Assets/Scripts/TH1_Logic/HeroTask/HeroTaskManager.cs

93 lines
3.4 KiB
C#

/*
* @Author: 白哉
* @Description:
* @Date: 2025年09月05日 星期五 16:09:49
* @Modify:
*/
using System.Collections.Generic;
using Logic.HeroTask;
using Logic.Skill;
using RuntimeData;
namespace TH1_Logic.HeroTask
{
public class HeroTaskManager
{
public static HeroTaskManager Instance = new HeroTaskManager();
private HeroTaskData _data;
public void Init()
{
_data = new HeroTaskData();
foreach (var heroInfo in Table.Instance.HeroDataAssets.HeroInfoList)
{
if (heroInfo == null || heroInfo.TaskList == null) continue;
if (!ContentGate.CanUseHero(heroInfo.GiantType)) continue;
for (int j = 0; j < heroInfo.TaskList.Count; j++)
{
var taskInfo = heroInfo.TaskList[j];
var content = HeroTaskFactory.GetHeroTaskContentBase(taskInfo.taskContentType);
if (content == null) continue;
content.TargetLevel = taskInfo.Param;
content.SkillType = taskInfo.SkillParam;
content.SpType = taskInfo.SpType;
content.UnitFullTypes ??= new List<UnitFullType>();
content.UnitFullTypes.Clear();
if (taskInfo.UnitFullTypes != null)
foreach (var target in taskInfo.UnitFullTypes) content.UnitFullTypes.Add(target);
content.TargetTypes ??= new List<SanaeDivineType>();
content.TargetTypes.Clear();
if (taskInfo.TargetBuff != null)
foreach (var target in taskInfo.TargetBuff) content.TargetTypes.Add(target);
content.SkillTypeList ??= new List<SkillType>();
content.SkillTypeList.Clear();
if (taskInfo.SkillList != null)
foreach (var skillType in taskInfo.SkillList) content.SkillTypeList.Add(skillType);
var item = new HeroTaskItem();
item.UnitType = UnitType.Giant;
item.GiantType = heroInfo.GiantType;
item.Level = (uint)(j + 1);
item.Content = content;
_data.Items.Add(item);
}
}
}
public HeroTaskContentBase GetHeroTaskContent(UnitData unit)
{
if (_data == null) return null;
foreach (var item in _data.Items)
{
if(item.UnitType != unit.UnitType) continue;
if(item.GiantType != unit.GiantType) continue;
if(item.Level != unit.UnitLevel) continue;
return item.GetCopyHeroTaskContentBase();
}
return null;
}
public bool GetHeroTaskContent(UnitFullType type,out HeroTaskContentBase task)
{
task = null;
if (_data == null) return false;
foreach (var item in _data.Items)
{
if(item.UnitType != type.UnitType) continue;
if(item.GiantType != type.GiantType) continue;
if(item.Level != type.UnitLevel) continue;
task = item.GetCopyHeroTaskContentBase();
return true;
}
return false;
}
}
}