Basic game completed

This commit is contained in:
2024-12-09 23:16:34 +01:00
parent 10b694496b
commit 3b30d20e62
457 changed files with 34712 additions and 11643 deletions

View File

@@ -0,0 +1,51 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
public class Gun : MonoBehaviour
{
public UnityEvent onGunShoot;
public float fireCoolDown;
public bool automatic;
private float currentCooldown;
void Start()
{
currentCooldown = fireCoolDown;
}
void Update()
{
if(automatic)
{
if(Input.GetMouseButton(0))
{
if(currentCooldown <= 0f)
{
//if not null (?)
onGunShoot?.Invoke();
currentCooldown = fireCoolDown;
}
}
}
else
{
if(Input.GetMouseButtonDown(0))
{
if(currentCooldown <= 0f)
{
//if not null (?)
onGunShoot?.Invoke();
currentCooldown = fireCoolDown;
}
}
}
currentCooldown -= Time.deltaTime;
}
}