Files
No-Time-To-Rest/Assets/Scripts/WeaponController.cs
T
2025-03-08 22:41:34 +03:00

20 lines
580 B
C#

using System.Collections.Generic;
using UnityEngine;
public class WeaponController : MonoBehaviour
{
[SerializeField] Weapon[] weapons;
[SerializeField] int currentWeapon = 0;
void Start() {
weapons = GetComponentsInChildren<Weapon>();
for (int i = 0; i < weapons.Length; ++i) {
if (i != currentWeapon) weapons[i].SetWeaponState(false);
}
}
void Update() {
if (Input.GetMouseButton(0) && weapons[currentWeapon].isActive) weapons[currentWeapon].Shoot(Input.GetMouseButtonDown(0), Input.GetMouseButton(0));
}
}