武器切换与管理

master
SweetMe1ody 5 years ago
parent f39b78c40c
commit 0d19312ef4

@ -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<Weapon>();
sword = transform.Find("sword").GetComponent<Weapon>();
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;
}
}
Loading…
Cancel
Save