Started work on making the system for the guns ammo bullets and health

main
RedStealthDev 2 years ago
parent cf74ae56f9
commit 551f70efc1

@ -0,0 +1,149 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &8107388911180569254
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 8107388911180569251}
- component: {fileID: 8107388911180569250}
- component: {fileID: 8107388911180569253}
- component: {fileID: 8107388911180569252}
- component: {fileID: 8107388911180569255}
m_Layer: 0
m_Name: Bullet
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &8107388911180569251
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8107388911180569254}
m_LocalRotation: {x: 0, y: 0, z: -0.7071068, w: 0.7071068}
m_LocalPosition: {x: -63.06925, y: -3.2288797, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: -90}
--- !u!212 &8107388911180569250
SpriteRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8107388911180569254}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 0
m_RayTraceProcedural: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 0
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_Sprite: {fileID: 7482667652216324306, guid: 75f5f34dc1b5347e0b8351032682f224, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0
m_FlipY: 0
m_DrawMode: 0
m_Size: {x: 1, y: 1}
m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!114 &8107388911180569253
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8107388911180569254}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: cfba024dcfb32ae49b5d7587a88bb214, type: 3}
m_Name:
m_EditorClassIdentifier:
rb: {fileID: 8107388911180569252}
--- !u!50 &8107388911180569252
Rigidbody2D:
serializedVersion: 4
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8107388911180569254}
m_BodyType: 0
m_Simulated: 1
m_UseFullKinematicContacts: 0
m_UseAutoMass: 0
m_Mass: 1
m_LinearDrag: 0
m_AngularDrag: 0
m_GravityScale: 0
m_Material: {fileID: 0}
m_Interpolate: 0
m_SleepingMode: 1
m_CollisionDetection: 0
m_Constraints: 0
--- !u!61 &8107388911180569255
BoxCollider2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8107388911180569254}
m_Enabled: 1
m_Density: 1
m_Material: {fileID: 0}
m_IsTrigger: 1
m_UsedByEffector: 0
m_UsedByComposite: 0
m_Offset: {x: 0, y: 0.21133333}
m_SpriteTilingProperty:
border: {x: 0, y: 0, z: 0, w: 0}
pivot: {x: 0.5, y: 0.28866667}
oldSize: {x: 1, y: 1}
newSize: {x: 1, y: 1}
adaptiveTilingThreshold: 0.5
drawMode: 0
adaptiveTiling: 0
m_AutoTiling: 0
serializedVersion: 2
m_Size: {x: 1, y: 1}
m_EdgeRadius: 0

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: a0bbab42aeac389439de3d9037aa88f4
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,104 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &8635401260561399886
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 8635401260561399923}
- component: {fileID: 8635401260561399884}
- component: {fileID: 8635401260561399885}
m_Layer: 0
m_Name: Pistol
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &8635401260561399923
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8635401260561399886}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -59.94009, y: -0.20920512, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!212 &8635401260561399884
SpriteRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8635401260561399886}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 0
m_RayTraceProcedural: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 0
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_Sprite: {fileID: -2064222288, guid: 28104bf5f59125b44af998dd9595d71d, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0
m_FlipY: 0
m_DrawMode: 0
m_Size: {x: 1, y: 1}
m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!114 &8635401260561399885
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8635401260561399886}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: a2857247eb0cbbd43be5c68412690d4b, type: 3}
m_Name:
m_EditorClassIdentifier:
maxAmmo: -1
shootSpeed: 1
damage: 10
fullAuto: 0
Bullet: {fileID: 8107388911180569254, guid: a0bbab42aeac389439de3d9037aa88f4, type: 3}

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: f07ede375ba2efb408bce98a7e165ce2
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

@ -2694,6 +2694,67 @@ Transform:
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 0 m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1001 &1166307037
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 1647816734}
m_Modifications:
- target: {fileID: 8635401260561399885, guid: f07ede375ba2efb408bce98a7e165ce2, type: 3}
propertyPath: fullAuto
value: 1
objectReference: {fileID: 0}
- target: {fileID: 8635401260561399886, guid: f07ede375ba2efb408bce98a7e165ce2, type: 3}
propertyPath: m_Name
value: Pistol
objectReference: {fileID: 0}
- target: {fileID: 8635401260561399923, guid: f07ede375ba2efb408bce98a7e165ce2, type: 3}
propertyPath: m_RootOrder
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8635401260561399923, guid: f07ede375ba2efb408bce98a7e165ce2, type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8635401260561399923, guid: f07ede375ba2efb408bce98a7e165ce2, type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8635401260561399923, guid: f07ede375ba2efb408bce98a7e165ce2, type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8635401260561399923, guid: f07ede375ba2efb408bce98a7e165ce2, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 8635401260561399923, guid: f07ede375ba2efb408bce98a7e165ce2, type: 3}
propertyPath: m_LocalRotation.x
value: -0
objectReference: {fileID: 0}
- target: {fileID: 8635401260561399923, guid: f07ede375ba2efb408bce98a7e165ce2, type: 3}
propertyPath: m_LocalRotation.y
value: -0
objectReference: {fileID: 0}
- target: {fileID: 8635401260561399923, guid: f07ede375ba2efb408bce98a7e165ce2, type: 3}
propertyPath: m_LocalRotation.z
value: -0
objectReference: {fileID: 0}
- target: {fileID: 8635401260561399923, guid: f07ede375ba2efb408bce98a7e165ce2, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8635401260561399923, guid: f07ede375ba2efb408bce98a7e165ce2, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8635401260561399923, guid: f07ede375ba2efb408bce98a7e165ce2, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: f07ede375ba2efb408bce98a7e165ce2, type: 3}
--- !u!1 &1241877575 --- !u!1 &1241877575
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -2828,6 +2889,7 @@ GameObject:
serializedVersion: 6 serializedVersion: 6
m_Component: m_Component:
- component: {fileID: 1647816734} - component: {fileID: 1647816734}
- component: {fileID: 1647816735}
m_Layer: 0 m_Layer: 0
m_Name: Hand m_Name: Hand
m_TagString: Untagged m_TagString: Untagged
@ -2846,10 +2908,23 @@ Transform:
m_LocalPosition: {x: 2.25, y: -0.25, z: 0} m_LocalPosition: {x: 2.25, y: -0.25, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: [] m_Children:
- {fileID: 2011179002}
m_Father: {fileID: 252431638} m_Father: {fileID: 252431638}
m_RootOrder: 0 m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1647816735
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1647816733}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 87300c79431bf0440bcfa28bae89965c, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &1698802171 --- !u!1 &1698802171
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -2935,6 +3010,11 @@ Transform:
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 4 m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!4 &2011179002 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 8635401260561399923, guid: f07ede375ba2efb408bce98a7e165ce2, type: 3}
m_PrefabInstance: {fileID: 1166307037}
m_PrefabAsset: {fileID: 0}
--- !u!1 &2136821952 --- !u!1 &2136821952
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

@ -0,0 +1,27 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Bullet : MonoBehaviour
{
public Rigidbody2D rb;
[System.NonSerialized]public int setDmg;
private int Damage;
private void Start()
{
Damage = setDmg;
rb.AddForce(Vector2.right * 20);
}
private void OnCollisionEnter2D(Collision2D other)
{
if(other.collider.CompareTag("Player"))
{
return;
}
if(other.collider.TryGetComponent<Health>(out Health health))
{
health.RemoveHP(Damage);
}
GameObject.Destroy(gameObject);
}
}

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: cfba024dcfb32ae49b5d7587a88bb214
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,22 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Health : MonoBehaviour
{
public void RemoveHP(int Damage)
{
}
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7e128d9abd8ec5d429909167b9586bc7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,38 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Weapon : MonoBehaviour
{
[SerializeField] private int maxAmmo;
[SerializeField] private float shootSpeed;
[SerializeField] private int damage;
[SerializeField] private bool fullAuto;
[SerializeField] private GameObject Bullet;
private int Ammo;
private bool shootDone;
private float Wait;
private void Start()
{
Ammo = maxAmmo;
}
public void shoot()
{
if(Ammo == 0 || Wait > 0 || shootDone && !fullAuto)
{
return;
}
if(!fullAuto)
{
shootDone = true;
}
Wait += shootSpeed;
GameObject bullet = GameObject.Instantiate(Bullet, transform.position, transform.rotation);
bullet.GetComponent<Bullet>().setDmg = damage;
}
private void Update()
{
Wait -= Time.deltaTime;
Wait = Mathf.Clamp(Wait, 0, shootSpeed);
}
}

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a2857247eb0cbbd43be5c68412690d4b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,38 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
public class Weapons : MonoBehaviour
{
private Inputs Input;
private InputAction Shoot;
private void Awake()
{
Input = new Inputs();
}
private void OnEnable()
{
Shoot = Input.Movement.attack;
Shoot.Enable();
}
private void OnDisable()
{
Shoot.Disable();
}
private void Update()
{
if(Shoot.IsPressed())
{
shoot();
}
}
private void shoot()
{
if(transform.childCount > 0)
{
Transform gun = transform.GetChild(0);
gun.GetComponent<Weapon>().shoot();
}
}
}

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 87300c79431bf0440bcfa28bae89965c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Loading…
Cancel
Save