You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
1.8 KiB

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class WeaponManager : MonoBehaviour
{
public int currentIndex = 0;
public Weapon[] weapons = new Weapon[9];
public int maximum = 0;
bool weaponsGUIValue = false;
Weapon knife;
Weapon sword;
Weapon greatsword;
Weapon lance;
GameObject weaponsGUI;
Character character;
void Awake()
{
knife = transform.Find("knife").GetComponent<Weapon>();
sword = transform.Find("sword").GetComponent<Weapon>();
greatsword = transform.Find("greatsword").GetComponent<Weapon>();
lance = transform.Find("lance").GetComponent<Weapon>();
weaponsGUI = transform.Find("WeaponsGUI").gameObject;
if(knife.valid)
weapons[maximum++] = knife;
if(sword.valid)
weapons[maximum++] = sword;
if(greatsword.valid)
weapons[maximum++] = greatsword;
if(lance.valid)
weapons[maximum++] = lance;
character = transform.parent.GetComponent<Character>();
}
public void AddWeapon(Weapon newWeapon)
{
weapons[maximum++] = newWeapon;
}
public void GetWeapon(int index)
{
weapons[currentIndex].gameObject.SetActive(false);
weapons[index].SetRotation(character.GetLookDirection());
weapons[index].gameObject.SetActive(true);
currentIndex = index;
}
public void SetCurrnetWeaponActive(bool value)
{
weapons[currentIndex].gameObject.SetActive(value);
}
public void SetWeaponsGUI()
{
weaponsGUIValue = !weaponsGUIValue;
weaponsGUI.SetActive(weaponsGUIValue);
}
public void SetWeaponsGUIActive(bool value)
{
weaponsGUIValue = value;
weaponsGUI.SetActive(value);
}
}