Scriptum/Assets/Scripts/REFACTORING/Application/Mission/Condition/Subject/CollectRequiredSubject.cs
2022-12-27 15:24:26 +01:00

35 lines
1.2 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
/// <summary>
/// Note: we dont add here local counter like in (Kill condition) because amount of items may be decreasing after np selling not only increased
/// </summary>
[Serializable]
public class CollectRequiredSubject : RequiredSubject
{
protected override string MODEL_LOCALIZATION => "Items/";
public CollectRequiredSubject(RequiredSubject requiredSubject) : base(requiredSubject.RequiredAmount, requiredSubject.RequiredObject) { }
public CollectRequiredSubject(int requiredAmount, GameObject enemy) : base(requiredAmount, enemy) { }
public CollectRequiredSubject(int requiredAmount, string enemyName) : base(requiredAmount, enemyName) { }
public override bool CheckCondition()
{
var isConditionMet =
InventoryUIManager.Instance.FindItemInWarehouseByName(RequiredObject.gameObject.name).Count >= RequiredAmount;
if (isConditionMet)
for(int i = 0; i < RequiredAmount; i++)
InventoryUIManager.Instance.RemoveOneByItemName(RequiredObject.gameObject.name);
return isConditionMet;
}
}