GlobalGameJame/Assets/Scripts/WeaponManager.cs

47 lines
1.2 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class WeaponManager : MonoBehaviour
{
public enum WeaponType { None, Shoot, Meele };
public WeaponType weaponType = WeaponType.None;
public float weaponRange = 1;
public GameObject spawnShoot;
public GameObject particleShoot;
public float damage = 0;
public float fireRate = 0.5f;
private float fireTime;
// Start is called before the first frame update
void Start()
{
fireTime = fireRate;
}
// Update is called once per frame
void Update()
{
WeaponAttack();
}
public void WeaponAttack()
{
if (Input.GetMouseButtonDown(0) && fireTime <= Time.time) {
if (weaponType == WeaponType.Shoot)
{
if (particleShoot != null)
{
GameObject shoot = Instantiate(particleShoot, spawnShoot.transform.position, spawnShoot.transform.rotation);
Destroy(shoot, 0.3f);
}
}
else if (weaponType == WeaponType.Meele)
{
}
fireTime = fireRate + Time.time;
}
}
}