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