using System.Collections; using System.Collections.Generic; using UnityEngine; using Sirenix.OdinInspector; /// /// 塞钱箱类 /// [RequireComponent(typeof(BoxCollider2D))] public class MoneyBox : Interactive { /// /// 桌上硬币,用来显示钱箱上是否有钱 /// private GameObject coinOnTheTable; /// /// 箱子里有钱吗? /// public bool hasMoney; void Start(){ Init(); } private void Init(){ itemName = ItemName.塞钱箱; coinOnTheTable = transform.Find("桌上硬币").gameObject; } public override void OnCall(){ OnBeGaveMoney(); } /// /// 当被塞钱的时候触发 /// public override void OnBeGaveMoney(){ //标记自身有钱 hasMoney = true; //显示桌上硬币 coinOnTheTable.SetActive(true); } /// /// 当被拿钱的时候触发 /// public void OnBeTakeMoney(){ //标记自身不再有钱 hasMoney = false; //隐藏桌上硬币 coinOnTheTable.SetActive(false); } }