Scriptum/Assets/Scripts/REFACTORING/Application/Mission/Condition/MissionCondition.cs

45 lines
1.0 KiB
C#
Raw Permalink Normal View History

2022-12-27 15:16:59 +01:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
[Serializable]
public class MissionCondition
{
[SerializeField]
public MissionTypeEnum Type;
[SerializeField]
public List<RequiredSubject> RequiredElements = new List<RequiredSubject>();
2023-01-03 22:44:24 +01:00
public MissionCondition(MissionTypeEnum type) { Type = type; }
2022-12-27 15:16:59 +01:00
public bool IsConditionMeeted()
{
return RequiredElements.Where(element => element.CheckCondition()).Count() == RequiredElements.Count();
}
public MissionCondition Build()
{
switch(Type)
{
case MissionTypeEnum.Kill:
{
2023-01-03 22:44:24 +01:00
return new KillMissionCondition(this);
2022-12-27 15:16:59 +01:00
}
case MissionTypeEnum.Collect:
{
return new CollectMissionCondition(this);
}
default:
{
throw new Exception($"MissionCondition - Build - unrecognized type: {Type}");
}
}
}
}