Gun Reloads now if empty
This commit is contained in:
parent
6bb0bc1c39
commit
df37d14120
@ -238,3 +238,5 @@ MonoBehaviour:
|
|||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
spawnpoint: {fileID: 3929927056536112425}
|
spawnpoint: {fileID: 3929927056536112425}
|
||||||
bullet: {fileID: 939049122039926632, guid: 5bd04146a95212e41bc2c52b7079e131, type: 3}
|
bullet: {fileID: 939049122039926632, guid: 5bd04146a95212e41bc2c52b7079e131, type: 3}
|
||||||
|
dataBullet: {fileID: 11400000, guid: cafd241bae342f446ae8141cc5d72daf, type: 2}
|
||||||
|
reloadTime: 3
|
||||||
|
@ -789,63 +789,6 @@ MeshFilter:
|
|||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 940378051}
|
m_GameObject: {fileID: 940378051}
|
||||||
m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0}
|
m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0}
|
||||||
--- !u!1001 &1030353343
|
|
||||||
PrefabInstance:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
serializedVersion: 2
|
|
||||||
m_Modification:
|
|
||||||
serializedVersion: 3
|
|
||||||
m_TransformParent: {fileID: 0}
|
|
||||||
m_Modifications:
|
|
||||||
- target: {fileID: 939049122039926632, guid: 5bd04146a95212e41bc2c52b7079e131, type: 3}
|
|
||||||
propertyPath: m_Name
|
|
||||||
value: Bullet
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 3286218375903244322, guid: 5bd04146a95212e41bc2c52b7079e131, type: 3}
|
|
||||||
propertyPath: m_LocalPosition.x
|
|
||||||
value: 5.431
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 3286218375903244322, guid: 5bd04146a95212e41bc2c52b7079e131, type: 3}
|
|
||||||
propertyPath: m_LocalPosition.y
|
|
||||||
value: 0
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 3286218375903244322, guid: 5bd04146a95212e41bc2c52b7079e131, type: 3}
|
|
||||||
propertyPath: m_LocalPosition.z
|
|
||||||
value: 0
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 3286218375903244322, guid: 5bd04146a95212e41bc2c52b7079e131, type: 3}
|
|
||||||
propertyPath: m_LocalRotation.w
|
|
||||||
value: 1
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 3286218375903244322, guid: 5bd04146a95212e41bc2c52b7079e131, type: 3}
|
|
||||||
propertyPath: m_LocalRotation.x
|
|
||||||
value: 0
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 3286218375903244322, guid: 5bd04146a95212e41bc2c52b7079e131, type: 3}
|
|
||||||
propertyPath: m_LocalRotation.y
|
|
||||||
value: 0
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 3286218375903244322, guid: 5bd04146a95212e41bc2c52b7079e131, type: 3}
|
|
||||||
propertyPath: m_LocalRotation.z
|
|
||||||
value: 0
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 3286218375903244322, guid: 5bd04146a95212e41bc2c52b7079e131, type: 3}
|
|
||||||
propertyPath: m_LocalEulerAnglesHint.x
|
|
||||||
value: 0
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 3286218375903244322, guid: 5bd04146a95212e41bc2c52b7079e131, type: 3}
|
|
||||||
propertyPath: m_LocalEulerAnglesHint.y
|
|
||||||
value: 0
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 3286218375903244322, guid: 5bd04146a95212e41bc2c52b7079e131, type: 3}
|
|
||||||
propertyPath: m_LocalEulerAnglesHint.z
|
|
||||||
value: 0
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
m_RemovedComponents: []
|
|
||||||
m_RemovedGameObjects: []
|
|
||||||
m_AddedGameObjects: []
|
|
||||||
m_AddedComponents: []
|
|
||||||
m_SourcePrefab: {fileID: 100100000, guid: 5bd04146a95212e41bc2c52b7079e131, type: 3}
|
|
||||||
--- !u!1 &1062964497
|
--- !u!1 &1062964497
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -1984,4 +1927,3 @@ SceneRoots:
|
|||||||
- {fileID: 1513164528}
|
- {fileID: 1513164528}
|
||||||
- {fileID: 1124830199}
|
- {fileID: 1124830199}
|
||||||
- {fileID: 829478755}
|
- {fileID: 829478755}
|
||||||
- {fileID: 1030353343}
|
|
||||||
|
@ -7,17 +7,44 @@ public class WeaponScript : MonoBehaviour
|
|||||||
|
|
||||||
public GameObject spawnpoint;
|
public GameObject spawnpoint;
|
||||||
public GameObject bullet;
|
public GameObject bullet;
|
||||||
|
|
||||||
private void shoot(){
|
public DataBullet dataBullet;
|
||||||
|
|
||||||
|
private int ammo;
|
||||||
|
private bool isReloading = false;
|
||||||
|
private float time = 0;
|
||||||
|
|
||||||
|
public float reloadTime;
|
||||||
|
|
||||||
|
public void reload(){
|
||||||
|
if(ammo == 0){
|
||||||
|
isReloading = true;
|
||||||
|
}
|
||||||
|
if(isReloading){
|
||||||
|
time += Time.deltaTime;
|
||||||
|
if(time > reloadTime){
|
||||||
|
ammo = dataBullet.ammo;
|
||||||
|
time = 0;
|
||||||
|
isReloading = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void shoot(){
|
||||||
|
if(ammo != 0){
|
||||||
if(Input.GetKeyDown(KeyCode.Mouse0)){
|
if(Input.GetKeyDown(KeyCode.Mouse0)){
|
||||||
Instantiate(bullet,spawnpoint.transform.position,transform.rotation);
|
Instantiate(bullet,spawnpoint.transform.position,transform.rotation);
|
||||||
|
ammo--;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
|
dataBullet = GetComponentInChildren<DataBullet>();
|
||||||
|
ammo = dataBullet.ammo;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update is called once per frame
|
// Update is called once per frame
|
||||||
|
Loading…
Reference in New Issue
Block a user