diff --git a/Assets/Scenes/Gameplay.unity b/Assets/Scenes/Gameplay.unity index cbadc69..013322d 100644 --- a/Assets/Scenes/Gameplay.unity +++ b/Assets/Scenes/Gameplay.unity @@ -2243,6 +2243,7 @@ Transform: m_ConstrainProportionsScale: 0 m_Children: - {fileID: 1629330312} + - {fileID: 1994755325} m_Father: {fileID: 1623199034} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &168045785 @@ -5688,6 +5689,39 @@ Transform: m_Children: [] m_Father: {fileID: 769222176} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &461917474 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 461917475} + m_Layer: 0 + m_Name: Aim + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &461917475 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 461917474} + serializedVersion: 2 + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: -0.0041900612, z: -0.005500138} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 1643280327} + - {fileID: 2030201540} + m_Father: {fileID: 1994755325} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &464155046 GameObject: m_ObjectHideFlags: 0 @@ -7540,6 +7574,10 @@ MonoBehaviour: m_EditorClassIdentifier: Assembly-CSharp::AmmoScreenView ReloadBar: {fileID: 1331867753} FillMaxSpeed: 14 + TorpedoAmmoLabel: {fileID: 41323151} + MissileAmmoLabel: {fileID: 99217483} + TorpedoPointer: {fileID: 996847068} + MissilePointer: {fileID: 661622936} --- !u!1 &564995249 GameObject: m_ObjectHideFlags: 0 @@ -20202,6 +20240,7 @@ MonoBehaviour: ChangeWeapon: 1 weaponsContainer: - {fileID: 1629330313} + - {fileID: 1994755327} UpPoint: {fileID: 1214476300} DownPoint: {fileID: 1373082368} MaxSpeed: 3 @@ -20407,6 +20446,7 @@ MonoBehaviour: ShootPoint: {fileID: 1629330312} ReloadInterval: 5 Owner: {fileID: 1623199033} + Ammo: 20 TorpedoSpeed: 200 TorpedoLifetime: 15 TorpedoDamage: 10 @@ -20681,6 +20721,96 @@ Transform: - {fileID: 1991256914} m_Father: {fileID: 1376677946} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &1643280326 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1643280327} + - component: {fileID: 1643280329} + - component: {fileID: 1643280328} + m_Layer: 0 + m_Name: CenterLine + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &1643280327 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1643280326} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0.7072302, z: 0.7069834, w: 0} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 0.87, y: 914.9, z: 100} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 461917475} + m_LocalEulerAnglesHint: {x: -89.98, y: 180, z: 0} +--- !u!23 &1643280328 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1643280326} + 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_RayTracingAccelStructBuildFlagsOverride: 0 + m_RayTracingAccelStructBuildFlags: 1 + m_SmallMeshCulling: 1 + m_ForceMeshLod: -1 + m_MeshLodSelectionBias: 0 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 2100000, guid: 82d684f1a0ac1384ab280445ee52ca34, 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_GlobalIlluminationMeshLod: 0 + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_MaskInteraction: 0 + m_AdditionalVertexStreams: {fileID: 0} +--- !u!33 &1643280329 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1643280326} + m_Mesh: {fileID: -462981019419857548, guid: 1240020e2374c48428ad8b2fb7164901, type: 3} --- !u!1 &1644178611 GameObject: m_ObjectHideFlags: 0 @@ -24537,6 +24667,158 @@ Transform: - {fileID: 848832610} m_Father: {fileID: 1641911111} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &1994755324 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1994755325} + - component: {fileID: 1994755327} + - component: {fileID: 1994755326} + m_Layer: 0 + m_Name: Missile weapon + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &1994755325 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1994755324} + serializedVersion: 2 + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0.03899013, z: 0.23370013} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 461917475} + m_Father: {fileID: 156761210} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!82 &1994755326 +AudioSource: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1994755324} + m_Enabled: 1 + serializedVersion: 4 + OutputAudioMixerGroup: {fileID: -7085291298577199494, guid: 9e60f4c98f741874887713174defa070, type: 2} + m_audioClip: {fileID: 0} + m_Resource: {fileID: 8300000, guid: 6c87789de020fec43985abd1c1079ac0, type: 3} + m_PlayOnAwake: 0 + m_Volume: 1 + m_Pitch: 1 + Loop: 0 + Mute: 0 + Spatialize: 0 + SpatializePostEffects: 0 + Priority: 128 + DopplerLevel: 1 + MinDistance: 1 + MaxDistance: 500 + Pan2D: 0 + rolloffMode: 0 + BypassEffects: 0 + BypassListenerEffects: 0 + BypassReverbZones: 0 + rolloffCustomCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + - serializedVersion: 3 + time: 1 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + panLevelCustomCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + spreadCustomCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + reverbZoneMixCustomCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 +--- !u!114 &1994755327 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1994755324} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 759ea400a395baf489cb4ad9c43d2f31, type: 3} + m_Name: + m_EditorClassIdentifier: Assembly-CSharp::TorpedoWeapon + ProjectilePrefab: {fileID: 7116828759653182887, guid: cc524b2665ddc094290e1daa0ba30693, type: 3} + ShootPoint: {fileID: 1994755325} + ReloadInterval: 5 + Owner: {fileID: 1623199033} + Ammo: 20 + TorpedoSpeed: 200 + TorpedoLifetime: 15 + TorpedoDamage: 10 + ShootAudio: {fileID: 1994755326} --- !u!1 &1997120112 GameObject: m_ObjectHideFlags: 0 @@ -24927,6 +25209,96 @@ Transform: m_Children: [] m_Father: {fileID: 314928456} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &2030201539 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2030201540} + - component: {fileID: 2030201542} + - component: {fileID: 2030201541} + m_Layer: 0 + m_Name: OuterField + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &2030201540 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2030201539} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0.7072302, z: 0.7069834, w: 0} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 27.7, y: 914.9, z: 100} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 461917475} + m_LocalEulerAnglesHint: {x: -89.98, y: 180, z: 0} +--- !u!23 &2030201541 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2030201539} + 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_RayTracingAccelStructBuildFlagsOverride: 0 + m_RayTracingAccelStructBuildFlags: 1 + m_SmallMeshCulling: 1 + m_ForceMeshLod: -1 + m_MeshLodSelectionBias: 0 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 2100000, guid: 905d9b24ba2e9d349ac115f02dcbe3af, 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_GlobalIlluminationMeshLod: 0 + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_MaskInteraction: 0 + m_AdditionalVertexStreams: {fileID: 0} +--- !u!33 &2030201542 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2030201539} + m_Mesh: {fileID: -462981019419857548, guid: 1240020e2374c48428ad8b2fb7164901, type: 3} --- !u!1001 &2033326613 PrefabInstance: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/Gameplay/Core/UI/AmmoScreenView.cs b/Assets/Scripts/Gameplay/Core/UI/AmmoScreenView.cs index 5142046..aab066f 100644 --- a/Assets/Scripts/Gameplay/Core/UI/AmmoScreenView.cs +++ b/Assets/Scripts/Gameplay/Core/UI/AmmoScreenView.cs @@ -1,4 +1,5 @@ -using UnityEngine; +using TMPro; +using UnityEngine; using UnityEngine.UI; public class AmmoScreenView : MonoBehaviour @@ -6,12 +7,37 @@ public class AmmoScreenView : MonoBehaviour [SerializeField] private Image ReloadBar; [SerializeField] private float FillMaxSpeed = 10; + [SerializeField] private TextMeshProUGUI TorpedoAmmoLabel; + [SerializeField] private TextMeshProUGUI MissileAmmoLabel; + [SerializeField] private GameObject TorpedoPointer; + [SerializeField] private GameObject MissilePointer; + WeaponModel model; public void Initialize(WeaponModel weaponModel) { model = weaponModel; + weaponModel.OnUpdate += Refresh; } + + private void Refresh(WeaponModel model) + { + TorpedoAmmoLabel.text = model.Weapons[0].Ammo.ToString(); + MissileAmmoLabel.text = model.Weapons[1].Ammo.ToString(); + + if (model.CurrentWeapon == model.Weapons[0]) + { + TorpedoPointer.SetActive(true); + MissilePointer.SetActive(false); + } + else + { + TorpedoPointer.SetActive(false); + MissilePointer.SetActive(true); + } + + } + private void Update() { if (model == null) return; @@ -19,4 +45,6 @@ public class AmmoScreenView : MonoBehaviour float progress = Mathf.MoveTowards(ReloadBar.fillAmount, model.CurrentWeapon.ReloadPercent, FillMaxSpeed * Time.deltaTime); ReloadBar.fillAmount = progress; } + + } diff --git a/Assets/Scripts/Gameplay/Core/Weapons/MissileWeapon.cs b/Assets/Scripts/Gameplay/Core/Weapons/MissileWeapon.cs new file mode 100644 index 0000000..ed9e77c --- /dev/null +++ b/Assets/Scripts/Gameplay/Core/Weapons/MissileWeapon.cs @@ -0,0 +1,36 @@ +using UnityEngine; +//Это копия торпеды. Надо переработать в ракету. +public class MissileWeapon : Weapon +{ + [Header("Настройки снаряда")] + [SerializeField] private float MissileSpeed = 20; + [SerializeField] private float MissileLifetime = 20; + [SerializeField] private float MissileDamage = 10; + + [Header("Звук")] + [SerializeField] private AudioSource ShootAudio; + + public override void Shoot() + { + if (!CanShoot) return; + + var go = Instantiate(ProjectilePrefab, ShootPoint.position, ShootPoint.rotation); + if (go.TryGetComponent(out Torpedo torpedo)) + { + torpedo.Setup(MissileSpeed, MissileLifetime); + ShootAudio.Play(); + lastShootTime = Time.time; + + go.GetComponent().Initialize(Owner, MissileDamage); + Ammo -= 1; + InvokeShoot(torpedo); + } + else + { + Destroy(go); + Debug.LogWarning("На префабе нет компонента Missile", this); + } + + + } +} diff --git a/Assets/Scripts/Gameplay/Core/Weapons/MissileWeapon.cs.meta b/Assets/Scripts/Gameplay/Core/Weapons/MissileWeapon.cs.meta new file mode 100644 index 0000000..68f52e9 --- /dev/null +++ b/Assets/Scripts/Gameplay/Core/Weapons/MissileWeapon.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 6329e1246acb2f84fb93d95c4436ccc1 diff --git a/Assets/Scripts/Gameplay/Core/Weapons/TorpedoWeapon.cs b/Assets/Scripts/Gameplay/Core/Weapons/TorpedoWeapon.cs index 7cf383e..78a07b8 100644 --- a/Assets/Scripts/Gameplay/Core/Weapons/TorpedoWeapon.cs +++ b/Assets/Scripts/Gameplay/Core/Weapons/TorpedoWeapon.cs @@ -22,7 +22,7 @@ public class TorpedoWeapon : Weapon lastShootTime = Time.time; go.GetComponent().Initialize(Owner, TorpedoDamage); - + Ammo -= 1; InvokeShoot(torpedo); } else diff --git a/Assets/Scripts/Gameplay/Core/Weapons/Weapon.cs b/Assets/Scripts/Gameplay/Core/Weapons/Weapon.cs index 5a9703c..23da6a0 100644 --- a/Assets/Scripts/Gameplay/Core/Weapons/Weapon.cs +++ b/Assets/Scripts/Gameplay/Core/Weapons/Weapon.cs @@ -10,13 +10,14 @@ public abstract class Weapon : MonoBehaviour [Header("Настройки оружия")] [SerializeField] protected float ReloadInterval = 5; public GameObject Owner; + public int Ammo = 20; public event Action OnShoot; protected float lastShootTime = 0; public float ReloadPercent => Mathf.Clamp01((Time.time - lastShootTime) / ReloadInterval); - public bool CanShoot => Time.time - lastShootTime >= ReloadInterval; + public bool CanShoot => Time.time - lastShootTime >= ReloadInterval && Ammo > 0; public abstract void Shoot(); diff --git a/Assets/Scripts/Gameplay/Player.cs b/Assets/Scripts/Gameplay/Player.cs index 803dc81..694383b 100644 --- a/Assets/Scripts/Gameplay/Player.cs +++ b/Assets/Scripts/Gameplay/Player.cs @@ -83,6 +83,7 @@ public class Player : MonoBehaviour { print("Смена оружия"); weaponIndex = (weaponIndex + 1) % weaponsContainer.Count; + GameState.WeaponModel.WeaponChangeHandler(ActiveWeapon); } private void Shoot()