added sound script and menu

This commit is contained in:
Mausham
2025-12-12 16:16:37 -08:00
parent 2118bb7c36
commit 06ca472bb3
33 changed files with 1842 additions and 181 deletions

View File

@@ -2,7 +2,7 @@
- Project name: HelixJump - Project name: HelixJump
- Unity version: Unity 6000.3.0f1 - Unity version: Unity 6000.3.0f1
- Active game object: - Active game object:
- Name: GameNameText - Name: Soccer Ball
- Tag: Untagged - Tag: Player
- Layer: UI - Layer: Default
<!-- UNITY CODE ASSIST INSTRUCTIONS END --> <!-- UNITY CODE ASSIST INSTRUCTIONS END -->

View File

@@ -2712,7 +2712,7 @@ Material:
- _ColorMask: 15 - _ColorMask: 15
- _CullMode: 0 - _CullMode: 0
- _Diffuse: 0.5 - _Diffuse: 0.5
- _FaceDilate: 0 - _FaceDilate: 0.1
- _FaceUVSpeedX: 0 - _FaceUVSpeedX: 0
- _FaceUVSpeedY: 0 - _FaceUVSpeedY: 0
- _GlowInner: 0.05 - _GlowInner: 0.05
@@ -2730,8 +2730,8 @@ Material:
- _PerspectiveFilter: 0.875 - _PerspectiveFilter: 0.875
- _Reflectivity: 10 - _Reflectivity: 10
- _ScaleRatioA: 0.85714287 - _ScaleRatioA: 0.85714287
- _ScaleRatioB: 0.6964286 - _ScaleRatioB: 0.6107143
- _ScaleRatioC: 0.6964286 - _ScaleRatioC: 0.6107143
- _ScaleX: 1 - _ScaleX: 1
- _ScaleY: 1 - _ScaleY: 1
- _ShaderFlags: 0 - _ShaderFlags: 0
@@ -2758,11 +2758,11 @@ Material:
- _FaceColor: {r: 1, g: 1, b: 1, a: 1} - _FaceColor: {r: 1, g: 1, b: 1, a: 1}
- _GlowColor: {r: 0, g: 1, b: 0, a: 0.5} - _GlowColor: {r: 0, g: 1, b: 0, a: 0.5}
- _MaskCoord: {r: 0, g: 0, b: 32767, a: 32767} - _MaskCoord: {r: 0, g: 0, b: 32767, a: 32767}
- _OutlineColor: {r: 0, g: 0, b: 0, a: 1} - _OutlineColor: {r: 1, g: 1, b: 1, a: 1}
- _ReflectFaceColor: {r: 0, g: 0, b: 0, a: 1} - _ReflectFaceColor: {r: 0, g: 0, b: 0, a: 1}
- _ReflectOutlineColor: {r: 0, g: 0, b: 0, a: 1} - _ReflectOutlineColor: {r: 0, g: 0, b: 0, a: 1}
- _SpecularColor: {r: 1, g: 1, b: 1, a: 1} - _SpecularColor: {r: 1, g: 1, b: 1, a: 1}
- _UnderlayColor: {r: 0, g: 0, b: 0, a: 0.5} - _UnderlayColor: {r: 1, g: 0, b: 0, a: 0.5}
m_BuildTextureStacks: [] m_BuildTextureStacks: []
m_AllowLocking: 1 m_AllowLocking: 1
--- !u!28 &6974779904690115925 --- !u!28 &6974779904690115925

View File

@@ -130,8 +130,8 @@ Material:
- _XRMotionVectorsPass: 1 - _XRMotionVectorsPass: 1
- _ZWrite: 1 - _ZWrite: 1
m_Colors: m_Colors:
- _BaseColor: {r: 0.32805273, g: 0.7169812, b: 0.34573126, a: 1} - _BaseColor: {r: 0, g: 0, b: 0, a: 1}
- _Color: {r: 0.3280527, g: 0.7169812, b: 0.34573123, a: 1} - _Color: {r: 0, g: 0, b: 0, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1} - _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1} - _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
m_BuildTextureStacks: [] m_BuildTextureStacks: []

View File

@@ -130,8 +130,8 @@ Material:
- _XRMotionVectorsPass: 1 - _XRMotionVectorsPass: 1
- _ZWrite: 1 - _ZWrite: 1
m_Colors: m_Colors:
- _BaseColor: {r: 0.6603774, g: 0.20870416, b: 0.23180114, a: 1} - _BaseColor: {r: 1, g: 0.7709646, b: 0.042452812, a: 1}
- _Color: {r: 0.6603774, g: 0.20870411, b: 0.2318011, a: 1} - _Color: {r: 1, g: 0.7709646, b: 0.042452782, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1} - _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1} - _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
m_BuildTextureStacks: [] m_BuildTextureStacks: []

View File

@@ -117,8 +117,8 @@ Material:
- _XRMotionVectorsPass: 1 - _XRMotionVectorsPass: 1
- _ZWrite: 1 - _ZWrite: 1
m_Colors: m_Colors:
- _BaseColor: {r: 0.4245283, g: 0.16620682, b: 0.38762525, a: 1} - _BaseColor: {r: 1, g: 0, b: 0.12657738, a: 1}
- _Color: {r: 0.42452827, g: 0.16620678, b: 0.38762522, a: 1} - _Color: {r: 1, g: 0, b: 0.12657735, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1} - _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1} - _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
m_BuildTextureStacks: [] m_BuildTextureStacks: []

View File

@@ -0,0 +1,138 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!243 &-8831058657413029340
AudioMixerGroupController:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Music
m_AudioMixer: {fileID: 24100000}
m_GroupID: f1ae2adfbfaeff14a9f193be36741c4e
m_Children: []
m_Volume: 2d19250e973c23344a281c603c6065d1
m_Pitch: 25937b384f00e374ea27bb4e02e82217
m_Send: 00000000000000000000000000000000
m_Effects:
- {fileID: 8181215133031441206}
m_UserColorIndex: 0
m_Mute: 0
m_Solo: 0
m_BypassEffects: 0
--- !u!241 &24100000
AudioMixerController:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: MyAudioMixture
m_OutputGroup: {fileID: 0}
m_MasterGroup: {fileID: 24300002}
m_Snapshots:
- {fileID: 24500006}
m_StartSnapshot: {fileID: 24500006}
m_SuspendThreshold: -80
m_EnableSuspend: 1
m_UpdateMode: 0
m_ExposedParameters: []
m_AudioMixerGroupViews:
- guids:
- 3c8c1f75bf405bc4fb347b7841dac474
- 12bca093bf3e172418b2c4a88ca255d2
- f1ae2adfbfaeff14a9f193be36741c4e
name: View
m_CurrentViewIndex: 0
m_TargetSnapshot: {fileID: 24500006}
--- !u!243 &24300002
AudioMixerGroupController:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Master
m_AudioMixer: {fileID: 24100000}
m_GroupID: 3c8c1f75bf405bc4fb347b7841dac474
m_Children:
- {fileID: 476787803277615442}
- {fileID: -8831058657413029340}
m_Volume: 7c7fc98f76562b843b0c6e977632bf0f
m_Pitch: 2911bf9829c28e7458b8aed4e3b354b6
m_Send: 00000000000000000000000000000000
m_Effects:
- {fileID: 24400004}
m_UserColorIndex: 0
m_Mute: 0
m_Solo: 0
m_BypassEffects: 0
--- !u!244 &24400004
AudioMixerEffectController:
m_ObjectHideFlags: 3
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_EffectID: cec723379451d644198904eb98e8ad4e
m_EffectName: Attenuation
m_MixLevel: 5edf877350af05b46a26f10e359d92fd
m_Parameters: []
m_SendTarget: {fileID: 0}
m_EnableWetMix: 0
m_Bypass: 0
--- !u!245 &24500006
AudioMixerSnapshotController:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Snapshot
m_AudioMixer: {fileID: 24100000}
m_SnapshotID: 3e9eaba2fea808941821d6b1fa7e328c
m_FloatValues: {}
m_TransitionOverrides: {}
--- !u!243 &476787803277615442
AudioMixerGroupController:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: SFX
m_AudioMixer: {fileID: 24100000}
m_GroupID: 12bca093bf3e172418b2c4a88ca255d2
m_Children: []
m_Volume: 8e91b42dd1c915d48b968a6ed5f724bf
m_Pitch: 8ed3575242a65224687722f4e0be7771
m_Send: 00000000000000000000000000000000
m_Effects:
- {fileID: 1624205512258791657}
m_UserColorIndex: 0
m_Mute: 0
m_Solo: 0
m_BypassEffects: 0
--- !u!244 &1624205512258791657
AudioMixerEffectController:
m_ObjectHideFlags: 3
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_EffectID: 18c0f47e5a8d8fc4bb90b10dfd8a4975
m_EffectName: Attenuation
m_MixLevel: f289dfd806f021d488343bafbe22400d
m_Parameters: []
m_SendTarget: {fileID: 0}
m_EnableWetMix: 0
m_Bypass: 0
--- !u!244 &8181215133031441206
AudioMixerEffectController:
m_ObjectHideFlags: 3
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_EffectID: 643f46936710ebb44b01ff90fe5c8e54
m_EffectName: Attenuation
m_MixLevel: 034274d9a73d83b419d39de899faa698
m_Parameters: []
m_SendTarget: {fileID: 0}
m_EnableWetMix: 0
m_Bypass: 0

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 1968fc068ac0c464288e3960a124abbb
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 24100000
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,93 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &7150388944573096077
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 7664502907771428115}
- component: {fileID: 8389856267355716442}
m_Layer: 0
m_Name: splash
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &7664502907771428115
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7150388944573096077}
serializedVersion: 2
m_LocalRotation: {x: 0.66816735, y: -0, z: -0, w: 0.74401104}
m_LocalPosition: {x: 0.0096, y: 1.9088, z: -0.8008}
m_LocalScale: {x: 0.2150172, y: 0.21501724, z: 0.21501724}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 83.852, y: 0, z: 0}
--- !u!212 &8389856267355716442
SpriteRenderer:
serializedVersion: 2
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7150388944573096077}
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_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: 9dfc825aed78fcd4ba02077103263b40, 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: 0
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_Sprite: {fileID: 21300000, guid: 4ef0e94c708ac774d91a9b5ac8f1df8d, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 0.5372549}
m_FlipX: 0
m_FlipY: 0
m_DrawMode: 0
m_Size: {x: 0.46, y: 0.46}
m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0
m_WasSpriteAssigned: 1
m_SpriteSortPoint: 0

View File

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

File diff suppressed because it is too large Load Diff

View File

@@ -5,4 +5,6 @@ public interface IInputReader
Vector2 dragInput{get;} Vector2 dragInput{get;}
float clickInput { get;} float clickInput { get;}
bool isclicked { get;} bool isclicked { get;}
bool isBlocked { get; set; }
} }

View File

@@ -6,6 +6,7 @@ using UnityEngine.InputSystem;
public class InputReader : ScriptableObject, IInputReader, GameInput.IPlayerActions public class InputReader : ScriptableObject, IInputReader, GameInput.IPlayerActions
{ {
public Action<Vector2> OnDragValueChanged; public Action<Vector2> OnDragValueChanged;
public bool isBlocked { get; set;}
public Vector2 _dragInput; public Vector2 _dragInput;
public Vector2 dragInput public Vector2 dragInput
@@ -32,7 +33,7 @@ public class InputReader : ScriptableObject, IInputReader, GameInput.IPlayerActi
inputActions = new GameInput(); inputActions = new GameInput();
inputActions.Player.SetCallbacks(this); inputActions.Player.SetCallbacks(this);
} }
isBlocked = false;
inputActions.Enable(); inputActions.Enable();
} }
@@ -42,12 +43,13 @@ public class InputReader : ScriptableObject, IInputReader, GameInput.IPlayerActi
} }
public void OnDrag(InputAction.CallbackContext context) public void OnDrag(InputAction.CallbackContext context)
{ { if (isBlocked) { Debug.Log("InputBlocked"); return; }
dragInput = context.ReadValue<Vector2>(); dragInput = context.ReadValue<Vector2>();
} }
public void OnClick(InputAction.CallbackContext context) public void OnClick(InputAction.CallbackContext context)
{ {
if(isBlocked) return;
clickInput = context.ReadValue<float>(); clickInput = context.ReadValue<float>();
isclicked = clickInput == 1? true : false; isclicked = clickInput == 1? true : false;
Debug.Log(isclicked); Debug.Log(isclicked);

View File

@@ -8,6 +8,8 @@ public class GameLifeTimeScope : LifetimeScope
[SerializeField] private InputReader _inputReader; [SerializeField] private InputReader _inputReader;
[SerializeField] private DeathScreenView deathview; [SerializeField] private DeathScreenView deathview;
[SerializeField] private StartScreenView startView; [SerializeField] private StartScreenView startView;
[SerializeField] private GameScreenView gameScreenView;
[SerializeField] private PauseScreenView pauseScreenView;
private void Start() private void Start()
{ {
@@ -19,10 +21,14 @@ public class GameLifeTimeScope : LifetimeScope
builder.RegisterComponentInHierarchy<PlatformPool>(); builder.RegisterComponentInHierarchy<PlatformPool>();
builder.RegisterComponentInHierarchy<Player>(); builder.RegisterComponentInHierarchy<Player>();
builder.RegisterComponentInHierarchy<PlatformManager>(); builder.RegisterComponentInHierarchy<PlatformManager>();
builder.RegisterComponentInHierarchy<AudioController>();
builder.RegisterInstance(_inputReader).As<IInputReader>(); builder.RegisterInstance(_inputReader).As<IInputReader>();
builder.Register<ScoreService>(Lifetime.Singleton); builder.Register<ScoreService>(Lifetime.Singleton);
builder.Register<DeathScreenController>(Lifetime.Singleton).WithParameter(deathview); builder.Register<DeathScreenController>(Lifetime.Singleton).WithParameter(deathview);
builder.Register<StartScreenController>(Lifetime.Singleton).WithParameter(startView); builder.Register<StartScreenController>(Lifetime.Singleton).WithParameter(startView);
builder.Register<GameScreenController>(Lifetime.Singleton).WithParameter(gameScreenView);
builder.Register<PauseScreenController>(Lifetime.Singleton).WithParameter(pauseScreenView);
} }
} }

View File

@@ -1,25 +0,0 @@
using UnityEngine;
using VContainer;
public class JumpingBall : MonoBehaviour
{
public float jumpforce = 4f;
public Rigidbody BallRb;
void Start()
{
if(BallRb==null)
{
BallRb = GetComponent<Rigidbody>();
}
}
void OnCollisionEnter(Collision collision)
{
if(collision.collider.CompareTag("Platform"))
{
BallRb.linearVelocity = new Vector3(0, jumpforce, 0);
}
}
}

View File

@@ -1,2 +0,0 @@
fileFormatVersion: 2
guid: 747f7dce18fb6a548bafaf8388f331e4

View File

@@ -1,3 +1,4 @@
using System.Collections;
using UnityEngine; using UnityEngine;
using VContainer; using VContainer;
@@ -7,12 +8,15 @@ public class Player : MonoBehaviour, IPlayer
public Rigidbody BallRb; public Rigidbody BallRb;
public bool isDead { get; private set; } public bool isDead { get; private set; }
public GameObject splashObject;
[Inject] ScoreService scoreService; [Inject] ScoreService scoreService;
[Inject] InputReader inputReader; [Inject] InputReader inputReader;
[Inject] DeathScreenController deathScreenController; [Inject] DeathScreenController deathScreenController;
void Start() void Start()
{ {
if (BallRb == null) if (BallRb == null)
{ {
BallRb = GetComponent<Rigidbody>(); BallRb = GetComponent<Rigidbody>();
@@ -23,7 +27,11 @@ public class Player : MonoBehaviour, IPlayer
{ {
if (collision.collider.CompareTag("Platform") && !isDead) if (collision.collider.CompareTag("Platform") && !isDead)
{ {
ContactPoint contact = collision.contacts[0];
Vector3 contactOffset = new Vector3(0, 0.1f, 0);
GameObject currentSplash = Instantiate(splashObject, contact.point+contactOffset,splashObject.transform.rotation);
BallRb.linearVelocity = new Vector3(0, jumpforce, 0); BallRb.linearVelocity = new Vector3(0, jumpforce, 0);
Destroy(currentSplash,0.2f);
} }
else if (collision.collider.CompareTag("Death")) else if (collision.collider.CompareTag("Death"))
{ {
@@ -35,7 +43,15 @@ public class Player : MonoBehaviour, IPlayer
{ {
Debug.Log("Player is Dead"); Debug.Log("Player is Dead");
isDead = true; isDead = true;
deathScreenController.ShowDeathScreen(scoreService.score,scoreService.GetHighscore()); StartCoroutine(DieRoutine());
}
IEnumerator DieRoutine()
{
inputReader.isBlocked = true;
yield return new WaitForSeconds(1f);
Time.timeScale = 0;
deathScreenController.ShowDeathScreen(scoreService.score, scoreService.GetHighscore());
} }

View File

@@ -1,18 +1,20 @@
using System; using System;
using Unity.VisualScripting; using Unity.VisualScripting;
using UnityEngine; using UnityEngine;
using VContainer;
public class ScoreService public class ScoreService
{ {
public Action<int> onScoreUpdate;
public int score { get; private set; } public int score { get; private set; }
public int HighScore = PlayerPrefs.GetInt("HighScore", 0); public int HighScore = PlayerPrefs.GetInt("HighScore", 0);
[Inject] GameScreenController gameScreenController;
[Inject] StartScreenController startScreenController;
public void AddScore() public void AddScore()
{ {
if (!startScreenController.hasGameStarted) return;
score += 5; score += 5;
onScoreUpdate?.Invoke(score); gameScreenController.UpdateScore(score);
if(score>HighScore) if(score>HighScore)
{ {
SetHighScore(); SetHighScore();

View File

@@ -0,0 +1,22 @@
using UnityEngine;
public class AudioController:MonoBehaviour
{
public AudioSource SFXSource;
public AudioSource MusicSource;
//public AudioClip backgroundclip;
// public AudioClip deadClip;
//public AudioClip jumpClip;
private void Start()
{
///MusicSource.clip = backgroundclip;
// MusicSource.Play();
}
public void PlaySFX(AudioClip clip)
{
SFXSource.PlayOneShot(clip);
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 8e85ac425eb34fa41af76223e92aec68

View File

@@ -0,0 +1,8 @@
using UnityEngine;
public class AudioVIew : MonoBehaviour
{
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 63a465db551023e4899a8803730af5a0

View File

@@ -8,6 +8,8 @@ public class DeathScreenController
private DeathScreenView _view; private DeathScreenView _view;
[Inject] private StartScreenController startScreenController; [Inject] private StartScreenController startScreenController;
[Inject] private GameScreenController gameScreenController;
[Inject] private InputReader _inputReader;
public DeathScreenController(DeathScreenView view) public DeathScreenController(DeathScreenView view)
{ {
_view = view; _view = view;
@@ -22,18 +24,26 @@ public class DeathScreenController
private void OnReplayBtnClicked() private void OnReplayBtnClicked()
{ {
HideDeathScreen(); HideDeathScreen();
Time.timeScale = 1;
_inputReader.isBlocked = false;
SceneManager.LoadScene(0); SceneManager.LoadScene(0);
Debug.Log("Game Replayed"); Debug.Log("Game Replayed");
} }
private void OnBackBtnClicked() private void OnBackBtnClicked()
{ {
HideDeathScreen(); HideDeathScreen();
Time.timeScale = 1;
_inputReader.isBlocked = false;
SceneManager.LoadScene(0); SceneManager.LoadScene(0);
} }
public void ShowDeathScreen(int score, int highscore) public void ShowDeathScreen(int score, int highscore)
{ {
gameScreenController.HideGameScreen();
_view.Show(score,highscore); _view.Show(score,highscore);
} }
} }

View File

@@ -0,0 +1,38 @@
using System;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.SocialPlatforms.Impl;
using VContainer;
public class GameScreenController
{
private GameScreenView gameScreenView;
[Inject] private PauseScreenController pauseScreenController;
public GameScreenController (GameScreenView gameScreenView)
{
this.gameScreenView = gameScreenView;
this.gameScreenView.pauseBtn.onClick.AddListener(PauseBtnClicked);
}
public void ShowGameScreen()
{
gameScreenView.Show();
}
public void HideGameScreen()
{
gameScreenView.Hide();
}
private void PauseBtnClicked()
{
Time.timeScale = 0;
pauseScreenController.ShowPauseScreen();
}
public void UpdateScore(int score)
{
gameScreenView.SetScore(score);
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 0e9850b4745033047ad9293264a28101

View File

@@ -0,0 +1,33 @@
using TMPro;
using UnityEngine;
using UnityEngine.UI;
using VContainer;
public class GameScreenView : MonoBehaviour
{
public GameObject gameScreen;
public TextMeshProUGUI ScoreText;
public Button pauseBtn;
private void Start()
{
ScoreText.text = "0";
gameScreen.SetActive(false);
}
public void Show()
{
gameScreen.SetActive(true);
}
public void Hide()
{
gameScreen.SetActive(false);
}
public void SetScore(int score)
{
ScoreText.text = score.ToString();
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: dca5ef66eb1c58a419af8a5c2b4b3886

View File

@@ -0,0 +1,38 @@
using System;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.SceneManagement;
using VContainer;
public class PauseScreenController
{
private PauseScreenView _pauseScreenView;
[Inject]private InputReader _inputReader;
public PauseScreenController(PauseScreenView pauseScreenView)
{
this._pauseScreenView = pauseScreenView;
_pauseScreenView.resumeBtn.onClick.AddListener( ResumeBtnClicked);
_pauseScreenView.BackBtn.onClick.AddListener(BackBtnClicked);
}
public void ShowPauseScreen()
{
_inputReader.isBlocked = true;
_pauseScreenView.Show();
}
private void ResumeBtnClicked()
{
_inputReader.isBlocked = false;
Time.timeScale = 1.0f;
_pauseScreenView.Hide();
}
public void BackBtnClicked()
{
_inputReader.isBlocked = false;
_pauseScreenView.Hide();
Time.timeScale = 1.0f;
SceneManager.LoadScene(0);
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: e684a4de28d7cdc48994f59a24f98908

View File

@@ -0,0 +1,24 @@
using UnityEngine;
using UnityEngine.UI;
public class PauseScreenView : MonoBehaviour
{
public GameObject pauseScreen;
public Button resumeBtn;
public Button BackBtn;
private void Start()
{
pauseScreen.SetActive(false);
}
public void Show()
{
pauseScreen.SetActive(true);
}
public void Hide()
{
pauseScreen.SetActive(false);
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 00144c3e01b1f804cbf7b44181344295

View File

@@ -5,6 +5,7 @@ public class StartScreenController
{ {
private StartScreenView _view; private StartScreenView _view;
public bool hasGameStarted = false; public bool hasGameStarted = false;
[Inject] GameScreenController gameScreenController;
public StartScreenController(StartScreenView view) public StartScreenController(StartScreenView view)
{ {
@@ -18,6 +19,7 @@ public class StartScreenController
{ {
_view.Hide(); _view.Hide();
hasGameStarted = true; hasGameStarted = true;
gameScreenController.ShowGameScreen();
} }
public void ShowStartScreen() public void ShowStartScreen()

View File

@@ -7,6 +7,11 @@ public class StartScreenView : MonoBehaviour
public GameObject startScreen; public GameObject startScreen;
public Button playBtn; public Button playBtn;
private void Start()
{
startScreen.SetActive(true);
}
public void Hide() public void Hide()
{ {
startScreen.SetActive(false); startScreen.SetActive(false);

File diff suppressed because one or more lines are too long