mirror of
https://github.com/DerTyp7/defrain-shooter-unity.git
synced 2025-10-29 12:52:07 +01:00
Grenades
[+] added + grenade.cs script + grenades can be thrown + grenades "explode" and spawn "explosion" (currently only a 50% transparent cube) - NEEDS TO BE TESTED => BUG FIXED
This commit is contained in:
80
Assets/Materials/BoomMat.mat
Normal file
80
Assets/Materials/BoomMat.mat
Normal file
@@ -0,0 +1,80 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: BoomMat
|
||||
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_ShaderKeywords: _ALPHABLEND_ON
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: 3000
|
||||
stringTagMap:
|
||||
RenderType: Transparent
|
||||
disabledShaderPasses: []
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _BumpMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailAlbedoMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailMask:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailNormalMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _EmissionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MetallicGlossMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _OcclusionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _ParallaxMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Ints: []
|
||||
m_Floats:
|
||||
- _BumpScale: 1
|
||||
- _Cutoff: 0.5
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DstBlend: 10
|
||||
- _GlossMapScale: 1
|
||||
- _Glossiness: 0
|
||||
- _GlossyReflections: 1
|
||||
- _Metallic: 0
|
||||
- _Mode: 2
|
||||
- _OcclusionStrength: 1
|
||||
- _Parallax: 0.02
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SpecularHighlights: 1
|
||||
- _SrcBlend: 5
|
||||
- _UVSec: 0
|
||||
- _ZWrite: 0
|
||||
m_Colors:
|
||||
- _Color: {r: 0.41509432, g: 0.41509432, b: 0.41509432, a: 0.7607843}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
m_BuildTextureStacks: []
|
||||
8
Assets/Materials/BoomMat.mat.meta
Normal file
8
Assets/Materials/BoomMat.mat.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5048f4c098f15fc4b911cdc4c5a2a459
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 2100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Objects/Weapons/Grenades.meta
Normal file
8
Assets/Objects/Weapons/Grenades.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2bebed6b943f95543bfc713f2d1f8193
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
99
Assets/Objects/Weapons/Grenades/DebugExplosion.prefab
Normal file
99
Assets/Objects/Weapons/Grenades/DebugExplosion.prefab
Normal file
@@ -0,0 +1,99 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1 &8367325100912176335
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 3147283493333612388}
|
||||
- component: {fileID: 191511536400925748}
|
||||
- component: {fileID: 671494300856292443}
|
||||
- component: {fileID: 486691901897967612}
|
||||
m_Layer: 0
|
||||
m_Name: DebugExplosion
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &3147283493333612388
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 8367325100912176335}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 18.046112, y: 2.24, z: -9.051534}
|
||||
m_LocalScale: {x: 1.926, y: 2.164027, z: 2.2623}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!33 &191511536400925748
|
||||
MeshFilter:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 8367325100912176335}
|
||||
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
|
||||
--- !u!23 &671494300856292443
|
||||
MeshRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 8367325100912176335}
|
||||
m_Enabled: 1
|
||||
m_CastShadows: 1
|
||||
m_ReceiveShadows: 1
|
||||
m_DynamicOccludee: 1
|
||||
m_StaticShadowCaster: 0
|
||||
m_MotionVectors: 1
|
||||
m_LightProbeUsage: 1
|
||||
m_ReflectionProbeUsage: 1
|
||||
m_RayTracingMode: 2
|
||||
m_RayTraceProcedural: 0
|
||||
m_RenderingLayerMask: 1
|
||||
m_RendererPriority: 0
|
||||
m_Materials:
|
||||
- {fileID: 2100000, guid: 5048f4c098f15fc4b911cdc4c5a2a459, type: 2}
|
||||
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: 3
|
||||
m_MinimumChartSize: 4
|
||||
m_AutoUVMaxDistance: 0.5
|
||||
m_AutoUVMaxAngle: 89
|
||||
m_LightmapParameters: {fileID: 0}
|
||||
m_SortingLayerID: 0
|
||||
m_SortingLayer: 0
|
||||
m_SortingOrder: 0
|
||||
m_AdditionalVertexStreams: {fileID: 0}
|
||||
--- !u!65 &486691901897967612
|
||||
BoxCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 8367325100912176335}
|
||||
m_Material: {fileID: 0}
|
||||
m_IsTrigger: 0
|
||||
m_Enabled: 1
|
||||
serializedVersion: 2
|
||||
m_Size: {x: 1, y: 1, z: 1}
|
||||
m_Center: {x: 0, y: 0, z: 0}
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a8150377575143e4ba9ff51ba16504aa
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
211
Assets/Objects/Weapons/Grenades/Grenade.prefab
Normal file
211
Assets/Objects/Weapons/Grenades/Grenade.prefab
Normal file
@@ -0,0 +1,211 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1 &4029497643973095478
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 6343894089976463891}
|
||||
m_Layer: 0
|
||||
m_Name: Left_Hand_REF
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &6343894089976463891
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 4029497643973095478}
|
||||
m_LocalRotation: {x: -0, y: 0.7071068, z: 0.7071068, w: 0}
|
||||
m_LocalPosition: {x: -6.781926, y: -1.6035255, z: 8.611951}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 6930424391121909828}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: -90, y: 90, z: 0}
|
||||
--- !u!1 &6307342751337709463
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 201745328857467870}
|
||||
m_Layer: 0
|
||||
m_Name: Right_Hand_REF
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &201745328857467870
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 6307342751337709463}
|
||||
m_LocalRotation: {x: -0, y: 0.7071068, z: 0.7071068, w: 0}
|
||||
m_LocalPosition: {x: -6.7219267, y: -1.5935258, z: 8.611951}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 6930424391121909828}
|
||||
m_RootOrder: 1
|
||||
m_LocalEulerAnglesHint: {x: -90, y: 90, z: 0}
|
||||
--- !u!1 &6930424391121909826
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 6930424391121909828}
|
||||
- component: {fileID: 6930424391121909829}
|
||||
- component: {fileID: 6930424391121909830}
|
||||
- component: {fileID: 6930424391121909831}
|
||||
- component: {fileID: 6930424391121909824}
|
||||
- component: {fileID: 8559554177058791497}
|
||||
m_Layer: 0
|
||||
m_Name: Grenade
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &6930424391121909828
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 6930424391121909826}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 18.046112, y: 1.8965256, z: -9.051534}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children:
|
||||
- {fileID: 6343894089976463891}
|
||||
- {fileID: 201745328857467870}
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!33 &6930424391121909829
|
||||
MeshFilter:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 6930424391121909826}
|
||||
m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0}
|
||||
--- !u!23 &6930424391121909830
|
||||
MeshRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 6930424391121909826}
|
||||
m_Enabled: 1
|
||||
m_CastShadows: 1
|
||||
m_ReceiveShadows: 1
|
||||
m_DynamicOccludee: 1
|
||||
m_StaticShadowCaster: 0
|
||||
m_MotionVectors: 1
|
||||
m_LightProbeUsage: 1
|
||||
m_ReflectionProbeUsage: 1
|
||||
m_RayTracingMode: 2
|
||||
m_RayTraceProcedural: 0
|
||||
m_RenderingLayerMask: 1
|
||||
m_RendererPriority: 0
|
||||
m_Materials:
|
||||
- {fileID: 10303, 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: 3
|
||||
m_MinimumChartSize: 4
|
||||
m_AutoUVMaxDistance: 0.5
|
||||
m_AutoUVMaxAngle: 89
|
||||
m_LightmapParameters: {fileID: 0}
|
||||
m_SortingLayerID: 0
|
||||
m_SortingLayer: 0
|
||||
m_SortingOrder: 0
|
||||
m_AdditionalVertexStreams: {fileID: 0}
|
||||
--- !u!135 &6930424391121909831
|
||||
SphereCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 6930424391121909826}
|
||||
m_Material: {fileID: 0}
|
||||
m_IsTrigger: 0
|
||||
m_Enabled: 1
|
||||
serializedVersion: 2
|
||||
m_Radius: 0.5
|
||||
m_Center: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &6930424391121909824
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 6930424391121909826}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: c98f5c47a8b7dd64f86fd6f42c4d6e5e, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
weaponKind: 3
|
||||
dropForce: 20
|
||||
damage: 45
|
||||
firerate: 1
|
||||
recoilStrength: 0
|
||||
currentAmmunition: 1
|
||||
magazinSize: 1
|
||||
totalAmmunition: 1
|
||||
bulletExit: {fileID: 0}
|
||||
allowAction: 1
|
||||
weaponAnimator: {fileID: 0}
|
||||
gunRightREF: {fileID: 201745328857467870}
|
||||
gunLeftREF: {fileID: 6343894089976463891}
|
||||
isGrenade: 1
|
||||
timer: 2
|
||||
explosionForce: 2
|
||||
grenadeRadius: 3
|
||||
hasExploded: 0
|
||||
hasBeenThrown: 0
|
||||
--- !u!114 &8559554177058791497
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 6930424391121909826}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: efa52c67441299049b2e2634d9e3e534, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
explodeParticle: {fileID: 6930424391121909826}
|
||||
weapon: {fileID: 6930424391121909824}
|
||||
weaponManager: {fileID: 0}
|
||||
7
Assets/Objects/Weapons/Grenades/Grenade.prefab.meta
Normal file
7
Assets/Objects/Weapons/Grenades/Grenade.prefab.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dbdc6c009fc3f6144933dcf93b67f8cb
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -585,6 +585,7 @@ MonoBehaviour:
|
||||
m_EditorClassIdentifier:
|
||||
syncMode: 0
|
||||
syncInterval: 0.1
|
||||
weaponManager: {fileID: 8357986889675898169}
|
||||
muzzle: {fileID: 4484858124630204699}
|
||||
shootAnim: {fileID: 3387435154213398635}
|
||||
weaponHolder: {fileID: 5071598280516985511, guid: bd217f9f85ce78e46a925776562625e8, type: 3}
|
||||
@@ -952,42 +953,6 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: 48948dfe9d76b07488dacd46a7955fa1, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!95 &1978909962
|
||||
Animator:
|
||||
serializedVersion: 4
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 6576156620079053231}
|
||||
m_Enabled: 1
|
||||
m_Avatar: {fileID: 9000000, guid: 01316cb596562384da845bc519fb90de, type: 3}
|
||||
m_Controller: {fileID: 9100000, guid: bcfd120671431f84097ebc1045370f76, type: 2}
|
||||
m_CullingMode: 0
|
||||
m_UpdateMode: 0
|
||||
m_ApplyRootMotion: 0
|
||||
m_LinearVelocityBlending: 0
|
||||
m_StabilizeFeet: 0
|
||||
m_WarningMessage:
|
||||
m_HasTransformHierarchy: 1
|
||||
m_AllowConstantClipSamplingOptimization: 1
|
||||
m_KeepAnimatorControllerStateOnDisable: 0
|
||||
--- !u!114 &3855419186248803448
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 6576156620079053231}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: fff0960ef4ea6e04eac66b4a7fd2189d, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_RigLayers:
|
||||
- m_Rig: {fileID: 8865635171929772803}
|
||||
m_Active: 1
|
||||
m_Effectors: []
|
||||
--- !u!1 &7061967201775281134
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -1502,6 +1467,11 @@ PrefabInstance:
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_SourcePrefab: {fileID: 100100000, guid: 01316cb596562384da845bc519fb90de, type: 3}
|
||||
--- !u!4 &8703533484509679896 stripped
|
||||
Transform:
|
||||
m_CorrespondingSourceObject: {fileID: -5815427104119794202, guid: 01316cb596562384da845bc519fb90de, type: 3}
|
||||
m_PrefabInstance: {fileID: 6305701708507383038}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!4 &5767109144009335573 stripped
|
||||
Transform:
|
||||
m_CorrespondingSourceObject: {fileID: -8679921383154817045, guid: 01316cb596562384da845bc519fb90de, type: 3}
|
||||
@@ -1512,6 +1482,11 @@ Transform:
|
||||
m_CorrespondingSourceObject: {fileID: -6617984589164989631, guid: 01316cb596562384da845bc519fb90de, type: 3}
|
||||
m_PrefabInstance: {fileID: 6305701708507383038}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!1 &6576156620079053231 stripped
|
||||
GameObject:
|
||||
m_CorrespondingSourceObject: {fileID: 919132149155446097, guid: 01316cb596562384da845bc519fb90de, type: 3}
|
||||
m_PrefabInstance: {fileID: 6305701708507383038}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!4 &5739201115059209923 stripped
|
||||
Transform:
|
||||
m_CorrespondingSourceObject: {fileID: 1740614089614901821, guid: 01316cb596562384da845bc519fb90de, type: 3}
|
||||
@@ -1522,11 +1497,6 @@ Transform:
|
||||
m_CorrespondingSourceObject: {fileID: -4598867093515939143, guid: 01316cb596562384da845bc519fb90de, type: 3}
|
||||
m_PrefabInstance: {fileID: 6305701708507383038}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!1 &6576156620079053231 stripped
|
||||
GameObject:
|
||||
m_CorrespondingSourceObject: {fileID: 919132149155446097, guid: 01316cb596562384da845bc519fb90de, type: 3}
|
||||
m_PrefabInstance: {fileID: 6305701708507383038}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!4 &9127245645273413481 stripped
|
||||
Transform:
|
||||
m_CorrespondingSourceObject: {fileID: 2965664082145358743, guid: 01316cb596562384da845bc519fb90de, type: 3}
|
||||
@@ -1537,11 +1507,42 @@ Transform:
|
||||
m_CorrespondingSourceObject: {fileID: -5945183352512053224, guid: 01316cb596562384da845bc519fb90de, type: 3}
|
||||
m_PrefabInstance: {fileID: 6305701708507383038}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!4 &8703533484509679896 stripped
|
||||
Transform:
|
||||
m_CorrespondingSourceObject: {fileID: -5815427104119794202, guid: 01316cb596562384da845bc519fb90de, type: 3}
|
||||
m_PrefabInstance: {fileID: 6305701708507383038}
|
||||
--- !u!95 &1978909962
|
||||
Animator:
|
||||
serializedVersion: 4
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 6576156620079053231}
|
||||
m_Enabled: 1
|
||||
m_Avatar: {fileID: 9000000, guid: 01316cb596562384da845bc519fb90de, type: 3}
|
||||
m_Controller: {fileID: 9100000, guid: bcfd120671431f84097ebc1045370f76, type: 2}
|
||||
m_CullingMode: 0
|
||||
m_UpdateMode: 0
|
||||
m_ApplyRootMotion: 0
|
||||
m_LinearVelocityBlending: 0
|
||||
m_StabilizeFeet: 0
|
||||
m_WarningMessage:
|
||||
m_HasTransformHierarchy: 1
|
||||
m_AllowConstantClipSamplingOptimization: 1
|
||||
m_KeepAnimatorControllerStateOnDisable: 0
|
||||
--- !u!114 &3855419186248803448
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 6576156620079053231}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: fff0960ef4ea6e04eac66b4a7fd2189d, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_RigLayers:
|
||||
- m_Rig: {fileID: 8865635171929772803}
|
||||
m_Active: 1
|
||||
m_Effectors: []
|
||||
--- !u!1001 &6343958082870406749
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -1643,16 +1644,6 @@ PrefabInstance:
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_SourcePrefab: {fileID: 100100000, guid: f1dd059fe90d9e14da7ad60b3612969c, type: 3}
|
||||
--- !u!1 &4484858124469057131 stripped
|
||||
GameObject:
|
||||
m_CorrespondingSourceObject: {fileID: 7365407325767981110, guid: f1dd059fe90d9e14da7ad60b3612969c, type: 3}
|
||||
m_PrefabInstance: {fileID: 6343958082870406749}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!4 &8787644481610465855 stripped
|
||||
Transform:
|
||||
m_CorrespondingSourceObject: {fileID: 2448190575139433570, guid: f1dd059fe90d9e14da7ad60b3612969c, type: 3}
|
||||
m_PrefabInstance: {fileID: 6343958082870406749}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!4 &365391085992511043 stripped
|
||||
Transform:
|
||||
m_CorrespondingSourceObject: {fileID: 6708222704297240606, guid: f1dd059fe90d9e14da7ad60b3612969c, type: 3}
|
||||
@@ -1668,3 +1659,13 @@ Transform:
|
||||
m_CorrespondingSourceObject: {fileID: 7365407325767981108, guid: f1dd059fe90d9e14da7ad60b3612969c, type: 3}
|
||||
m_PrefabInstance: {fileID: 6343958082870406749}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!1 &4484858124469057131 stripped
|
||||
GameObject:
|
||||
m_CorrespondingSourceObject: {fileID: 7365407325767981110, guid: f1dd059fe90d9e14da7ad60b3612969c, type: 3}
|
||||
m_PrefabInstance: {fileID: 6343958082870406749}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!4 &8787644481610465855 stripped
|
||||
Transform:
|
||||
m_CorrespondingSourceObject: {fileID: 2448190575139433570, guid: f1dd059fe90d9e14da7ad60b3612969c, type: 3}
|
||||
m_PrefabInstance: {fileID: 6343958082870406749}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
|
||||
@@ -38,7 +38,7 @@ RenderSettings:
|
||||
m_ReflectionIntensity: 1
|
||||
m_CustomReflection: {fileID: 0}
|
||||
m_Sun: {fileID: 705507994}
|
||||
m_IndirectSpecularColor: {r: 0.44657826, g: 0.49641263, b: 0.57481676, a: 1}
|
||||
m_IndirectSpecularColor: {r: 0.44657874, g: 0.49641258, b: 0.5748172, a: 1}
|
||||
m_UseRadianceAmbientProbe: 0
|
||||
--- !u!157 &3
|
||||
LightmapSettings:
|
||||
@@ -657,6 +657,27 @@ PrefabInstance:
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_SourcePrefab: {fileID: 100100000, guid: bd217f9f85ce78e46a925776562625e8, type: 3}
|
||||
--- !u!1 &445037169 stripped
|
||||
GameObject:
|
||||
m_CorrespondingSourceObject: {fileID: 6930424391121909826, guid: dbdc6c009fc3f6144933dcf93b67f8cb, type: 3}
|
||||
m_PrefabInstance: {fileID: 6930424391482245683}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!54 &445037176
|
||||
Rigidbody:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 445037169}
|
||||
serializedVersion: 2
|
||||
m_Mass: 1
|
||||
m_Drag: 0
|
||||
m_AngularDrag: 0.05
|
||||
m_UseGravity: 1
|
||||
m_IsKinematic: 0
|
||||
m_Interpolate: 0
|
||||
m_Constraints: 0
|
||||
m_CollisionDetection: 0
|
||||
--- !u!1 &450235891 stripped
|
||||
GameObject:
|
||||
m_CorrespondingSourceObject: {fileID: -466329591000292508, guid: 823e8b39d52b71b4eb5a91dbc8d6d59e, type: 3}
|
||||
@@ -2375,9 +2396,71 @@ PrefabInstance:
|
||||
- target: {fileID: 5784756223373504909, guid: 5cd2e2b44dc49ae44b48fc76a1e09712, type: 3}
|
||||
propertyPath: playerPrefab
|
||||
value:
|
||||
objectReference: {fileID: 6272346181302961293, guid: a14d876ac00bdf6498e30b3e58b68fdf, type: 3}
|
||||
objectReference: {fileID: 6272346181302961293, guid: 2935eead9a075fd489d6a6dc273a5999, type: 3}
|
||||
m_RemovedComponents: []
|
||||
m_SourcePrefab: {fileID: 100100000, guid: 5cd2e2b44dc49ae44b48fc76a1e09712, type: 3}
|
||||
--- !u!1001 &1541885955888442622
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
m_Modification:
|
||||
m_TransformParent: {fileID: 0}
|
||||
m_Modifications:
|
||||
- target: {fileID: 3147283493333612388, guid: a8150377575143e4ba9ff51ba16504aa, type: 3}
|
||||
propertyPath: m_RootOrder
|
||||
value: 12
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3147283493333612388, guid: a8150377575143e4ba9ff51ba16504aa, type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
value: 18.046112
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3147283493333612388, guid: a8150377575143e4ba9ff51ba16504aa, type: 3}
|
||||
propertyPath: m_LocalPosition.y
|
||||
value: 2.24
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3147283493333612388, guid: a8150377575143e4ba9ff51ba16504aa, type: 3}
|
||||
propertyPath: m_LocalPosition.z
|
||||
value: -9.051534
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3147283493333612388, guid: a8150377575143e4ba9ff51ba16504aa, type: 3}
|
||||
propertyPath: m_LocalRotation.w
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3147283493333612388, guid: a8150377575143e4ba9ff51ba16504aa, type: 3}
|
||||
propertyPath: m_LocalRotation.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3147283493333612388, guid: a8150377575143e4ba9ff51ba16504aa, type: 3}
|
||||
propertyPath: m_LocalRotation.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3147283493333612388, guid: a8150377575143e4ba9ff51ba16504aa, type: 3}
|
||||
propertyPath: m_LocalRotation.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3147283493333612388, guid: a8150377575143e4ba9ff51ba16504aa, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3147283493333612388, guid: a8150377575143e4ba9ff51ba16504aa, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3147283493333612388, guid: a8150377575143e4ba9ff51ba16504aa, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8367325100912176335, guid: a8150377575143e4ba9ff51ba16504aa, type: 3}
|
||||
propertyPath: m_Name
|
||||
value: DebugExplosion
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_SourcePrefab: {fileID: 100100000, guid: a8150377575143e4ba9ff51ba16504aa, type: 3}
|
||||
--- !u!1 &1541885955888442623 stripped
|
||||
GameObject:
|
||||
m_CorrespondingSourceObject: {fileID: 8367325100912176335, guid: a8150377575143e4ba9ff51ba16504aa, type: 3}
|
||||
m_PrefabInstance: {fileID: 1541885955888442622}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!1001 &3454029965885532949
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -2455,6 +2538,67 @@ PrefabInstance:
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_SourcePrefab: {fileID: 100100000, guid: f0c1bca3291086d449266d9ed8942180, type: 3}
|
||||
--- !u!1001 &6930424391482245683
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
m_Modification:
|
||||
m_TransformParent: {fileID: 0}
|
||||
m_Modifications:
|
||||
- target: {fileID: 6930424391121909826, guid: dbdc6c009fc3f6144933dcf93b67f8cb, type: 3}
|
||||
propertyPath: m_Name
|
||||
value: Grenade
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 6930424391121909828, guid: dbdc6c009fc3f6144933dcf93b67f8cb, type: 3}
|
||||
propertyPath: m_RootOrder
|
||||
value: 11
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 6930424391121909828, guid: dbdc6c009fc3f6144933dcf93b67f8cb, type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
value: 18.046112
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 6930424391121909828, guid: dbdc6c009fc3f6144933dcf93b67f8cb, type: 3}
|
||||
propertyPath: m_LocalPosition.y
|
||||
value: 1.8965256
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 6930424391121909828, guid: dbdc6c009fc3f6144933dcf93b67f8cb, type: 3}
|
||||
propertyPath: m_LocalPosition.z
|
||||
value: -9.051534
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 6930424391121909828, guid: dbdc6c009fc3f6144933dcf93b67f8cb, type: 3}
|
||||
propertyPath: m_LocalRotation.w
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 6930424391121909828, guid: dbdc6c009fc3f6144933dcf93b67f8cb, type: 3}
|
||||
propertyPath: m_LocalRotation.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 6930424391121909828, guid: dbdc6c009fc3f6144933dcf93b67f8cb, type: 3}
|
||||
propertyPath: m_LocalRotation.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 6930424391121909828, guid: dbdc6c009fc3f6144933dcf93b67f8cb, type: 3}
|
||||
propertyPath: m_LocalRotation.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 6930424391121909828, guid: dbdc6c009fc3f6144933dcf93b67f8cb, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 6930424391121909828, guid: dbdc6c009fc3f6144933dcf93b67f8cb, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 6930424391121909828, guid: dbdc6c009fc3f6144933dcf93b67f8cb, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8559554177058791497, guid: dbdc6c009fc3f6144933dcf93b67f8cb, type: 3}
|
||||
propertyPath: explodeParticle
|
||||
value:
|
||||
objectReference: {fileID: 1541885955888442623}
|
||||
m_RemovedComponents: []
|
||||
m_SourcePrefab: {fileID: 100100000, guid: dbdc6c009fc3f6144933dcf93b67f8cb, type: 3}
|
||||
--- !u!1001 &8307265127065581321
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
51
Assets/Scripts/Weapons/Grenade.cs
Normal file
51
Assets/Scripts/Weapons/Grenade.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Grenade : MonoBehaviour
|
||||
{
|
||||
[SerializeField] GameObject explodeParticle;
|
||||
[SerializeField] Weapon weapon;
|
||||
private float countdown;
|
||||
|
||||
void Start() {
|
||||
countdown = weapon.Timer;
|
||||
}
|
||||
|
||||
void Update() {
|
||||
// If grenade has been thrown and countdown is over 0 and grenade has not exploded yet
|
||||
if (weapon.HasBeenThrown && !weapon.HasExploded) {
|
||||
// Decrease timer by 1 second
|
||||
countdown -= Time.deltaTime;
|
||||
// If countdown get to 0... BOOM!:
|
||||
if(countdown <= 0) {
|
||||
// Lets grenade explode
|
||||
Explode();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* - Spawn explosion particles and add force to nearby objects - */
|
||||
private void Explode() {
|
||||
// Spawns explosion particle
|
||||
GameObject spawnedExplosion = Instantiate(explodeParticle, transform.position, transform.rotation);
|
||||
// Destroys explosion particle after on second
|
||||
Destroy(spawnedExplosion, 1);
|
||||
// Gets all collider that are in a sphere around the grenade
|
||||
Collider[] colliders = Physics.OverlapSphere(transform.position, weapon.GrenadeRadius);
|
||||
// Iterate over all colliders found in radius
|
||||
foreach(Collider nearbyObject in colliders) {
|
||||
// Get Rigidbody from nearby object and...
|
||||
Rigidbody rb = nearbyObject.GetComponent<Rigidbody>();
|
||||
// if rigidbody exists...
|
||||
if(rb != null) {
|
||||
// adds force to nearby objects
|
||||
rb.AddExplosionForce(weapon.ExplosionForce, transform.position, weapon.GrenadeRadius);
|
||||
}
|
||||
}
|
||||
weapon.HasExploded = true;
|
||||
// Destroys grenade
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Weapons/Grenade.cs.meta
Normal file
11
Assets/Scripts/Weapons/Grenade.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: efa52c67441299049b2e2634d9e3e534
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -5,12 +5,14 @@ using Mirror;
|
||||
using TMPro;
|
||||
public class Shoot : NetworkBehaviour
|
||||
{
|
||||
|
||||
[SerializeField] WeaponManager weaponManager; // For throwing grenade
|
||||
[SerializeField] GameObject muzzle;
|
||||
[SerializeField] ProcedualAnimationController shootAnim;
|
||||
[SerializeField] GameObject weaponHolder;
|
||||
[SerializeField] Camera mCamera;
|
||||
[SerializeField] bool limitAmmunition = true;
|
||||
|
||||
|
||||
private Weapon weapon;
|
||||
private RaycastHit crosshairHitPoint;
|
||||
private Vector3 _pointDirection;
|
||||
@@ -48,21 +50,37 @@ public class Shoot : NetworkBehaviour
|
||||
{
|
||||
weapon.GetComponent<BoxCollider>().enabled = false;
|
||||
}
|
||||
if (weapon.AllowAction && weapon.CurrentAmmunition > 0)
|
||||
{
|
||||
shootAnim.Recoil(0.1f);
|
||||
}
|
||||
CmdFireBullet();
|
||||
|
||||
// If current weapon kind is a rifle or pistole
|
||||
string weaponKindString = weapon.WeaponKind.ToString();
|
||||
if(weaponKindString == "Rifle" || weaponKindString == "Pistole") {
|
||||
if (weapon.AllowAction && weapon.CurrentAmmunition > 0) {
|
||||
shootAnim.Recoil(0.1f);
|
||||
}
|
||||
// Shoot Weapon
|
||||
CmdFireBullet();
|
||||
} // If current weapon kind is grenade
|
||||
else if(weaponKindString == "Grenade"){
|
||||
// Throw Grenade
|
||||
throwGrenade();
|
||||
} // If current weapon kind is kinfe
|
||||
else {
|
||||
// Throw hands (punch)
|
||||
}
|
||||
}
|
||||
if (Input.GetButtonDown("Reload")) {
|
||||
updateCanvas = true;
|
||||
CmdReloadWeapon();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void throwGrenade() {
|
||||
Debug.Log("ThrowGrenade!");
|
||||
// Throws grenade with dropForce
|
||||
weapon.HasBeenThrown = true;
|
||||
weaponManager.dropWeapon(weapon.DropForce);
|
||||
}
|
||||
|
||||
[Command]
|
||||
private void CmdReloadWeapon() {
|
||||
if (weapon.AllowAction && limitAmmunition) {
|
||||
|
||||
@@ -9,10 +9,9 @@ public class Weapon : MonoBehaviour
|
||||
Rifle, Pistole, Knife, Grenade
|
||||
}
|
||||
[SerializeField] weaponKinds weaponKind;
|
||||
[SerializeField] bool active = false;
|
||||
[SerializeField] float dropForce = 10f;
|
||||
[SerializeField] int damage = 0;
|
||||
[SerializeField] float firerate = 0;
|
||||
[SerializeField] int roundsPerShot = 1;
|
||||
[SerializeField] float recoilStrength = 0;
|
||||
[SerializeField] int currentAmmunition = 0;
|
||||
[SerializeField] int magazinSize = 0;
|
||||
@@ -22,12 +21,17 @@ public class Weapon : MonoBehaviour
|
||||
[SerializeField] Animator weaponAnimator;
|
||||
[SerializeField] Transform gunRightREF;
|
||||
[SerializeField] Transform gunLeftREF;
|
||||
[Header("Grenade")]
|
||||
[SerializeField] bool isGrenade = false;
|
||||
[SerializeField] float timer = 2f;
|
||||
[SerializeField] float explosionForce = 2f;
|
||||
[SerializeField] float grenadeRadius = 3f;
|
||||
[SerializeField] bool hasExploded = false;
|
||||
[SerializeField] bool hasBeenThrown = false;
|
||||
|
||||
public bool Active { get => active; set => active = value; }
|
||||
public weaponKinds WeaponKind { get => weaponKind; }
|
||||
public int Damage { get => damage; set => damage = value; }
|
||||
public float Firerate { get => firerate; set => firerate = value; }
|
||||
public int RoundsPerShot { get => roundsPerShot; set => roundsPerShot = value; }
|
||||
public float RecoilStrength { get => recoilStrength; set => recoilStrength = value; }
|
||||
public int CurrentAmmunition { get => currentAmmunition; set => currentAmmunition = value; }
|
||||
public int MagazinSize { get => magazinSize; set => magazinSize = value; }
|
||||
@@ -37,10 +41,18 @@ public class Weapon : MonoBehaviour
|
||||
public Animator WeaponAnimator { get => weaponAnimator; }
|
||||
public Transform GunLeftREF { get => gunLeftREF; }
|
||||
public Transform GunRightREF { get => gunRightREF; }
|
||||
public float Timer { get => timer; set => timer = value; }
|
||||
public float GrenadeRadius { get => grenadeRadius; set => grenadeRadius = value; }
|
||||
public bool HasExploded { get => hasExploded; set => hasExploded = value; }
|
||||
public bool IsGrenade { get => isGrenade; set => isGrenade = value; }
|
||||
public bool HasBeenThrown { get => hasBeenThrown; set => hasBeenThrown = value; }
|
||||
public float ExplosionForce { get => explosionForce; set => explosionForce = value; }
|
||||
public float DropForce { get => dropForce; set => dropForce = value; }
|
||||
|
||||
private void Start()
|
||||
{
|
||||
private void Start() {
|
||||
CurrentAmmunition = MagazinSize;
|
||||
if (weaponKind == weaponKinds.Grenade) { IsGrenade = true; }
|
||||
if (IsGrenade) { weaponKind = weaponKinds.Grenade; }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -29,20 +29,20 @@ public class WeaponManager : NetworkBehaviour
|
||||
lastWeaponIndex = currentWeaponIndex;
|
||||
activeWeapons[currentWeaponIndex].SetActive(false);
|
||||
switchWeapon(-1);
|
||||
activeWeapons[currentWeaponIndex].SetActive(true);
|
||||
}
|
||||
else if (Input.GetAxis("Mouse ScrollWheel") < 0f) { // Scroll down
|
||||
lastWeaponIndex = currentWeaponIndex;
|
||||
activeWeapons[currentWeaponIndex].SetActive(false);
|
||||
switchWeapon(1);
|
||||
activeWeapons[currentWeaponIndex].SetActive(true);
|
||||
}
|
||||
activeWeapons[currentWeaponIndex].SetActive(true);
|
||||
if (Input.GetButtonDown("Interact")) { // e
|
||||
PickupWeapon();
|
||||
|
||||
}else if (Input.GetButtonDown("Drop")) { // q Droping weapon
|
||||
if (activeWeapons[currentWeaponIndex] != null) {
|
||||
dropWeapon(); // Throws weapon away
|
||||
switchWeapon(1);
|
||||
dropWeapon(activeWeapons[currentWeaponIndex].GetComponent<Weapon>().DropForce); // Throws weapon away
|
||||
activeWeapons[currentWeaponIndex].SetActive(true);
|
||||
}
|
||||
}
|
||||
@@ -118,7 +118,7 @@ public class WeaponManager : NetworkBehaviour
|
||||
|
||||
private bool putWeaponInArray(int index, RaycastHit hit) {
|
||||
if (activeWeapons[currentWeaponIndex] != null) {
|
||||
dropWeapon(); // Throws weapon away
|
||||
dropWeapon(activeWeapons[currentWeaponIndex].GetComponent<Weapon>().DropForce); // Throws weapon away
|
||||
}
|
||||
activeWeapons[index] = hit.transform.gameObject;
|
||||
activeWeapons[index].SetActive(true);
|
||||
@@ -131,7 +131,7 @@ public class WeaponManager : NetworkBehaviour
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool dropWeapon() {
|
||||
public bool dropWeapon(float dropForce) {
|
||||
if(currentWeaponIndex != 2) {
|
||||
GameObject currentWeapon = activeWeapons[currentWeaponIndex];
|
||||
currentWeapon.SetActive(true);
|
||||
@@ -142,7 +142,7 @@ public class WeaponManager : NetworkBehaviour
|
||||
currentWeapon.GetComponent<BoxCollider>().enabled = true;
|
||||
currentWeapon.gameObject.transform.SetParent(null);
|
||||
activeWeapons[currentWeaponIndex] = null;
|
||||
|
||||
switchWeapon(1);
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
|
||||
Reference in New Issue
Block a user