From 0d19312ef4fc0fdf1ea16bfe48b72dca75bf59be Mon Sep 17 00:00:00 2001 From: SweetMe1ody <770757532@qq.com> Date: Mon, 21 Jun 2021 20:14:39 +0800 Subject: [PATCH] =?UTF-8?q?=E6=AD=A6=E5=99=A8=E5=88=87=E6=8D=A2=E4=B8=8E?= =?UTF-8?q?=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Script/WeaponManager.cs | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 Script/WeaponManager.cs diff --git a/Script/WeaponManager.cs b/Script/WeaponManager.cs new file mode 100644 index 0000000..7e7379b --- /dev/null +++ b/Script/WeaponManager.cs @@ -0,0 +1,32 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class WeaponManager : MonoBehaviour +{ + public int currentIndex = 0; + public Weapon[] weapons = new Weapon[9]; + int maximum = 2; + Weapon knife; + Weapon sword; + void Start() + { + knife = transform.Find("knife").GetComponent(); + sword = transform.Find("sword").GetComponent(); + weapons[0] = knife; + weapons[1] = sword; + } + public void GetWeapon(int index) + { + weapons[index].gameObject.SetActive(true); + currentIndex = index; + } + public void SetCurrnetWeaponActive(bool value) + { + weapons[currentIndex].gameObject.SetActive(value); + } + public void GetNewWeapon(Weapon newWeapon) + { + weapons[maximum++] = newWeapon; + } +}