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

32 lines
1.2 KiB
C#

using System;
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(int requiredAmount) : base(requiredAmount) { }
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;
}
}