From 7f493f682503f5186308de7b8f74b5b49233cfe4 Mon Sep 17 00:00:00 2001 From: chai <215380520@qq.com> Date: Thu, 2 Nov 2023 11:51:31 +0800 Subject: +init --- GameCode/PracticeTargetCoinDrop.cs | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 GameCode/PracticeTargetCoinDrop.cs (limited to 'GameCode/PracticeTargetCoinDrop.cs') diff --git a/GameCode/PracticeTargetCoinDrop.cs b/GameCode/PracticeTargetCoinDrop.cs new file mode 100644 index 0000000..760d9c2 --- /dev/null +++ b/GameCode/PracticeTargetCoinDrop.cs @@ -0,0 +1,33 @@ +using UnityEngine; + +public class PracticeTargetCoinDrop : MonoBehaviour +{ + private Hp hp; + + private TagManager tagManager; + + [SerializeField] + private int totalCoinsToDrop = 3; + + private void Start() + { + hp = GetComponent(); + tagManager = TagManager.instance; + } + + private void Update() + { + if (tagManager.CountAllTaggedObjectsWithTag(TagManager.ETag.PracticeTargets) <= totalCoinsToDrop) + { + hp.coinCount = 1; + } + } + + private void OnDestroy() + { + if ((bool)hp && hp.HpValue <= 0f) + { + AchievementManager.UnlockAchievement(AchievementManager.Achievements.START_TUTORIAL); + } + } +} -- cgit v1.1-26-g67d0