Scriptum/Assets/Scripts/REFACTORING/Application/Mission/Condition/MissionCondition.cs
2023-01-03 22:44:24 +01:00

45 lines
1.0 KiB
C#

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>();
public MissionCondition(MissionTypeEnum type) { Type = type; }
public bool IsConditionMeeted()
{
return RequiredElements.Where(element => element.CheckCondition()).Count() == RequiredElements.Count();
}
public MissionCondition Build()
{
switch(Type)
{
case MissionTypeEnum.Kill:
{
return new KillMissionCondition(this);
}
case MissionTypeEnum.Collect:
{
return new CollectMissionCondition(this);
}
default:
{
throw new Exception($"MissionCondition - Build - unrecognized type: {Type}");
}
}
}
}