103 lines
3.5 KiB
C#
103 lines
3.5 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
namespace Beyond
|
|
{
|
|
public class InteractionStep : MonoBehaviour
|
|
{
|
|
public BaseStepController baseStepController;
|
|
public List<GameObject> objectsToInteractwith = new();
|
|
[SerializeField]
|
|
private bool interactedWithFruit = false, interactedWithFlower = false;
|
|
private bool disableInteractableOnEnd = false;
|
|
public List<bEquipSlot> hpSlots, faithSlots, gemstoneSlots;
|
|
public bEquipArea consumablesArea;
|
|
|
|
private void Start()
|
|
{
|
|
// consumablesSlots = consumablesEquipArea.equipSlots;
|
|
// objectsToInteractwith.ForEach(obj => interacted.Add(false));
|
|
if (objectsToInteractwith != null && objectsToInteractwith.Count > 0)
|
|
{
|
|
baseStepController.OnEvaluationStart += () => objectsToInteractwith.ForEach(obj => obj.SetActive(true));
|
|
if (disableInteractableOnEnd)
|
|
{
|
|
baseStepController.OnCompleted += () =>
|
|
{
|
|
objectsToInteractwith.ForEach(obj =>
|
|
{
|
|
if (obj != null)
|
|
{
|
|
obj.SetActive(false);
|
|
}
|
|
});
|
|
};
|
|
}
|
|
// baseStepController.EvaluateInputs += () => !interacted.Exists(inter => inter == false);
|
|
baseStepController.ConditionsAreMet = () => interactedWithFlower && interactedWithFruit;
|
|
}
|
|
baseStepController.OnCompleted += () => EquipItemsIfNoneEquipped();
|
|
}
|
|
|
|
private void EquipItemsIfNoneEquipped()
|
|
{
|
|
TryToEquipHPConsumable();
|
|
TryToEquipFaithConsumable();
|
|
TryToEquipGemstone();
|
|
}
|
|
|
|
private void TryToEquipHPConsumable()
|
|
{
|
|
if (!hpSlots.Find(slot => slot.item))
|
|
{
|
|
bItem consumableToEquip = Player.Instance.ItemManager.items.Find(item => item.type == bItemType.Consumable);
|
|
|
|
if (consumableToEquip)
|
|
{
|
|
consumablesArea.AddItemToEquipSlot(hpSlots[0], consumableToEquip);
|
|
interactedWithFruit = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
private void TryToEquipFaithConsumable()
|
|
{
|
|
if (!faithSlots.Find(slot => slot.item))
|
|
{
|
|
bItem consumableToEquip = Player.Instance.ItemManager.items.Find(item => item.type == bItemType.ConsumablesFaith);
|
|
|
|
if (consumableToEquip)
|
|
{
|
|
consumablesArea.AddItemToEquipSlot(faithSlots[0], consumableToEquip);
|
|
interactedWithFlower = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
private void TryToEquipGemstone()
|
|
{
|
|
//if (!hpSlots.Find(slot => slot.item))
|
|
{
|
|
bItem consumableToEquip = Player.Instance.ItemManager.items.Find(item => item.type == bItemType.Gemstones);
|
|
|
|
if (consumableToEquip)
|
|
{
|
|
consumablesArea.AddItemToEquipSlot(gemstoneSlots[0], consumableToEquip);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
public void MarkAsInteractedWithFruit()
|
|
{
|
|
interactedWithFruit = true;
|
|
}
|
|
|
|
public void MarkAsInteractedWithFlower()
|
|
{
|
|
interactedWithFlower = true;
|
|
}
|
|
}
|
|
} |