/// --------------------------------------------- /// Behavior Designer /// Copyright (c) Opsive. All Rights Reserved. /// https://www.opsive.com /// --------------------------------------------- namespace Opsive.BehaviorDesigner.Samples { using UnityEngine; /// /// Manages the resources when gathered. /// public class ResourceTrigger : MonoBehaviour { [Tooltip("The location that the resource should be moved to when harvested.")] [SerializeField] protected CraftTrigger m_CraftLocation; private GameObject[] m_Resources; private int m_Index; /// /// Finds all of the resources that belong to the trigger. /// private void Start() { m_Resources = new GameObject[transform.childCount]; for (int i = 0; i < m_Resources.Length; ++i) { m_Resources[i] = transform.GetChild(i).gameObject; } } /// /// Pickups the resource. /// public void Pickup() { m_CraftLocation.Pickup(m_Resources[m_Index]); m_Index = (m_Index + 1) % m_Resources.Length; } } }