using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GunsScript : MonoBehaviour {
GunController[]gunControllers;
int index=0;
void Awake(){
gunControllers = transform.GetComponentsInChildren<GunController> ();
for (int i = 1; i < gunControllers.Length; i++) {
gunControllers [i].gameObject.SetActive (false);
}
}
void Update () {
//换枪
if (Input.GetKeyDown (KeyCode.Q)) {
gunControllers [index].gameObject.SetActive (false);
index++;
index %= gunControllers.Length;
gunControllers [index].gameObject.SetActive (true);
}
//开火
if (Input.GetMouseButton (0)) {
gunControllers [index].Fire ();
}
//重新装弹
if (Input.GetKeyDown (KeyCode.R)) {
gunControllers [index].Reload ();
}
}
}
using System.Collections.Generic;
using UnityEngine;
public class GunsScript : MonoBehaviour {
GunController[]gunControllers;
int index=0;
void Awake(){
gunControllers = transform.GetComponentsInChildren<GunController> ();
for (int i = 1; i < gunControllers.Length; i++) {
gunControllers [i].gameObject.SetActive (false);
}
}
void Update () {
//换枪
if (Input.GetKeyDown (KeyCode.Q)) {
gunControllers [index].gameObject.SetActive (false);
index++;
index %= gunControllers.Length;
gunControllers [index].gameObject.SetActive (true);
}
//开火
if (Input.GetMouseButton (0)) {
gunControllers [index].Fire ();
}
//重新装弹
if (Input.GetKeyDown (KeyCode.R)) {
gunControllers [index].Reload ();
}
}
}