files arranged using assembly defn

This commit is contained in:
Mausham
2025-12-16 18:12:45 -08:00
parent 4f1a6365fe
commit 04b1e3127c
144 changed files with 1207 additions and 1425 deletions

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: bf7cffabcb2056547812696e0254bfb2
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,58 @@
using Darkmatter.Core;
using UnityEngine;
using VContainer;
namespace Darkmatter.Presentation
{
public class AudioController : MonoBehaviour, IAudioController
{
[SerializeField] private AudioSource MusicSource;
[SerializeField] private AudioSource SFXSource;
public AudioClip backgroundMusicClip;
public AudioClip jumpClip;
public AudioClip deathClip;
public AudioClip btnPressedClip;
public AudioClip scoredClip;
[Inject] private IGameSession IgameSession;
private void Start()
{
MusicSource.clip = backgroundMusicClip;
MusicSource.loop = true;
MusicSource.Play();
}
public void PlaySfx(AudioClip clip)
{
if (!IgameSession.hasGameStarted) return;
SFXSource.ignoreListenerPause = true;
SFXSource.PlayOneShot(clip);
}
public void PlayJumpSound()
{
PlaySfx(jumpClip);
}
public void PlayDeathSound()
{
PlaySfx(deathClip);
}
public void PlayBtnPressedSound()
{
PlaySfx(btnPressedClip);
}
public void PlayScoredSound()
{
PlaySfx(scoredClip);
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 6359276e3f19a0e439ff6d871c3aee67

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 35a5e635888ca7046b748dc77720ba6e
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,88 @@
using Darkmatter.Core;
using Darkmatter.Domain;
using System.Collections.Generic;
using UnityEngine;
using VContainer;
public class Platform : MonoBehaviour, IPlatform
{
[SerializeField] private List<GameObject> _platformPiece = new List<GameObject>();
[SerializeField] private Material _safeMaterial;
[SerializeField] private Material _deathMaterial;
[SerializeField] private ParticleSystem _particleSystem;
[SerializeField]private Color[] safeMaterialColors;
[SerializeField] private Color[] deathMaterialColors;
public List<GameObject> platformPiece => _platformPiece;
public Material safeMaterial => _safeMaterial;
public Material deathMaterial => _deathMaterial;
private IPlatformRule _platformRule;
private bool hasAchievedScore = false;
[Inject] Player player;
[Inject] IPool<Platform> pool;
[Inject] IPlatformManager platformManager;
[Inject] IScoreService IscoreService;
[Inject] IAudioController IaudioController;
private void Start()
{
if(_particleSystem == null) _particleSystem = GetComponent<ParticleSystem>();
_safeMaterial.color = ReturnMaterialColor(safeMaterialColors);
_deathMaterial.color = ReturnMaterialColor(deathMaterialColors);
}
Color ReturnMaterialColor(Color[] color)
{
return color[Random.Range(0,color.Length)];
}
public void SetPlatformRule(IPlatformRule platformRule)
{
_platformRule = platformRule;
_platformRule.Execute(this);
}
private void OnTriggerEnter(Collider other)
{
if(other.CompareTag("Player") && !hasAchievedScore)
{
hasAchievedScore = true;
Debug.Log("Score Increased");
IscoreService.AddScore();
IaudioController.PlayScoredSound();
_particleSystem.Play();
HideThisPlatfromPiece();
}
}
void HideThisPlatfromPiece()
{
foreach(var piece in _platformPiece)
{
piece.gameObject.SetActive(false);
}
}
private void Update()
{
if (player.transform.position.y < transform.position.y-5f)
{
hasAchievedScore = false;
pool.ReturnToPool(this);
platformManager.BuildNewPlatform();
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 428d0179d16f0ec4a8923516aeff1a94

View File

@@ -0,0 +1,64 @@
using Darkmatter.Core;
using UnityEngine;
using VContainer;
public class PlatformManager : MonoBehaviour,IPlatformManager
{
[Inject] private IPool<Platform> pool;
[Inject] private IInputReader inputReader;
private float yPos = 0f;
[SerializeField] private float inputScale = 360f;
float rotAmount = 0;
private void Start()
{
ShowPlatforms();
}
private void OnEnable()
{
inputReader.OnDragValueChanged += HandleDrag;
}
private void OnDisable()
{
inputReader.OnDragValueChanged -= HandleDrag;
}
private void LateUpdate()
{
#if UNITY_EDITOR || UNITY_STANDALONE
if (!inputReader.isMouseButtonPressed) return;
#endif
// Apply rotation
transform.Rotate(Vector3.up * rotAmount, Space.World);
}
private void HandleDrag(Vector2 drag)
{
rotAmount = -drag.x/Screen.width * inputScale;
}
private void ShowPlatforms()
{
foreach (Platform platform in pool.All)
{
platform.gameObject.SetActive(true);
platform.transform.position = new Vector3(0, yPos, 0);
yPos--;
}
}
public void BuildNewPlatform()
{
Platform platform = pool.GetFromPool();
platform.transform.position = new Vector3(0, yPos, 0);
yPos--;
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 393df497de02fce4399040e619446397

View File

@@ -0,0 +1,63 @@
using Darkmatter.Core;
using Darkmatter.Domain;
using System.Collections.Generic;
using UnityEngine;
using VContainer;
public class PlatformPool : MonoBehaviour, IPool<Platform>
{
[SerializeField] private Platform platformPrefab;
[SerializeField] private Transform platformParent;
[SerializeField] private int poolSize = 10;
private Queue<Platform> _queue = new Queue<Platform>();
public IReadOnlyCollection<Platform> All => _queue;
[Inject] IObjectResolver resolver;
private void Awake()
{
SetupPool();
}
void SetupPool()
{
Platform instance = null;
for(int i = 0; i < poolSize; i++)
{
instance = Instantiate(platformPrefab,platformParent);
resolver.Inject(instance);
if (i == 0) instance.SetPlatformRule(new FirstPlatform());
else instance.SetPlatformRule(new OtherPlatform());
instance.gameObject.SetActive(false);
_queue.Enqueue(instance);
}
}
public Platform GetFromPool()
{
if(_queue.Count == 0)
{
Platform newObj = Instantiate(platformPrefab,platformParent);
newObj.SetPlatformRule(new OtherPlatform());
_queue.Enqueue(newObj);
return newObj;
}
Platform pooledObj = _queue.Dequeue();
pooledObj.SetPlatformRule(new OtherPlatform());
pooledObj.gameObject.SetActive(true);
return pooledObj;
}
public void ReturnToPool(Platform obj)
{
obj.gameObject.SetActive(false);
_queue.Enqueue(obj);
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 4977d8686efb09b40a678a0fb6037eee

View File

@@ -0,0 +1,19 @@
{
"name": "PresentationAssembly",
"rootNamespace": "Darkmatter.Presentation",
"references": [
"GUID:8bce7b1d1a7647841855dfbbfa883cd6",
"GUID:b0214a6008ed146ff8f122a6a9c2f6cc",
"GUID:6055be8ebefd69e48b49212b09b47b2f",
"GUID:219208e14f3a1e1439abafd1ff0ae402"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 09dab6049e43dd9449335e6d3f51f72e
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: fbdfa4d2bcf3bcf4b90151362beecf8e
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,48 @@
using Darkmatter.Core;
using UnityEngine;
using UnityEngine.SceneManagement;
using VContainer;
namespace Darkmatter.Presentation
{
public class DeathScreenController : IDeathScreenController
{
private DeathScreenView deathScreenView;
[Inject] private IScoreService IscoreService;
[Inject] private IInputReader IinputReader;
[Inject] private IAudioController IaudioController;
[Inject] private IGameSession IgameSession;
[Inject] private IGameScreenController IgameScreenController;
public DeathScreenController(DeathScreenView _deathScreenView)
{
deathScreenView = _deathScreenView;
deathScreenView.restartBtn.onClick.AddListener(OnRestartButtonClicked);
deathScreenView.exitBtn.onClick.AddListener(OnExitButtonClicked);
}
public void ShowDeathScreen()
{
IgameScreenController.HideGameScreen();
deathScreenView.Show(IscoreService.score, IscoreService.highScore);
}
private void OnExitButtonClicked()
{
Debug.Log("Exit Button Clicked");
IinputReader.UnlockInput();
IaudioController.PlayBtnPressedSound();
IgameSession.showStartScreen = true;
SceneManager.LoadScene(0);
}
private void OnRestartButtonClicked()
{
Debug.Log("Restart Button Clicked");
IinputReader.UnlockInput();
IaudioController.PlayBtnPressedSound();
IgameSession.showStartScreen = false;
SceneManager.LoadScene(0);
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 92c6fccb35ce2e64a820ecbc0fff7477

View File

@@ -0,0 +1,27 @@
using TMPro;
using UnityEngine;
using UnityEngine.UI;
namespace Darkmatter.Presentation
{
public class DeathScreenView : MonoBehaviour
{
[SerializeField] private GameObject deathScreen;
public Button restartBtn;
public Button exitBtn;
public TextMeshProUGUI score;
public TextMeshProUGUI highScore;
public void Show(int _score, int _highScore)
{
this.score.text = _score.ToString();
this.highScore.text = _highScore.ToString();
deathScreen.SetActive(true);
}
public void Hide()
{
deathScreen.SetActive(false);
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 4aab9e4cddc66e44e90193677b63e24e

View File

@@ -0,0 +1,50 @@
using Darkmatter.Core;
using UnityEngine;
using VContainer;
namespace Darkmatter.Presentation
{
public class GameScreenController : IGameScreenController
{
GameScreenView gameScreenView;
[Inject] private IScoreService IscoreService;
[Inject] private IPauseScreenController IpauseScreenController;
[Inject] private IInputReader IinputReader;
[Inject] private IAudioController IaudioController;
public GameScreenController(GameScreenView _gameScreenView, IScoreService _IscoreService, IPauseScreenController _IpauseScreenController)
{
this.gameScreenView = _gameScreenView;
IscoreService = _IscoreService;
IpauseScreenController = _IpauseScreenController;
IscoreService.OnScoreChange += UpdateScore;
gameScreenView.pauseBtn.onClick.AddListener(OnPauseButtonClicked);
}
private void UpdateScore(int score)
{
Debug.Log("calling Score");
gameScreenView.UpdateScore(score);
}
public void ShowGameScreen()
{
gameScreenView.Show();
}
public void HideGameScreen()
{
gameScreenView.Hide();
}
public void OnPauseButtonClicked()
{
IaudioController.PlayBtnPressedSound();
Time.timeScale = 0f;
IinputReader.LockInput();
IpauseScreenController.ShowPauseScreen();
}
}
}

View File

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

View File

@@ -0,0 +1,28 @@
using TMPro;
using UnityEngine;
using UnityEngine.UI;
namespace Darkmatter.Presentation
{
public class GameScreenView : MonoBehaviour
{
[SerializeField] private GameObject gameScreen;
public Button pauseBtn;
[SerializeField] private TextMeshProUGUI scoreText;
public void UpdateScore(int score)
{
scoreText.text = score.ToString();
}
public void Show()
{
gameScreen.SetActive(true);
}
public void Hide()
{
gameScreen.SetActive(false);
}
}
}

View File

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

View File

@@ -0,0 +1,46 @@
using Darkmatter.Core;
using UnityEngine;
using UnityEngine.SceneManagement;
using VContainer;
namespace Darkmatter.Presentation
{
public class PauseScreenController : IPauseScreenController
{
private PauseScreenView pauseScreenView;
[Inject] private IInputReader IinputReader;
[Inject] private IAudioController IaudioController;
[Inject] private IGameSession IgameSession;
public PauseScreenController(PauseScreenView _pauseScreenView)
{
pauseScreenView = _pauseScreenView;
pauseScreenView.resumeBtn.onClick.AddListener(OnResumeButtonClicked);
pauseScreenView.restartBtn.onClick.AddListener(OnRestartButtonClicked);
}
public void ShowPauseScreen()
{
pauseScreenView.Show();
}
private void OnRestartButtonClicked()
{
Time.timeScale = 1.0f;
IinputReader.UnlockInput();
IaudioController.PlayBtnPressedSound();
IgameSession.showStartScreen = false;
SceneManager.LoadScene(0); //Restart This Scene
}
private void OnResumeButtonClicked()
{
Time.timeScale = 1.0f;
pauseScreenView.Hide();
IinputReader.UnlockInput();
IaudioController.PlayBtnPressedSound();
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 682db5ec0dd207b4fb4122bc7798ffc4

View File

@@ -0,0 +1,22 @@
using UnityEngine;
using UnityEngine.UI;
namespace Darkmatter.Presentation
{
public class PauseScreenView : MonoBehaviour
{
[SerializeField] public GameObject pauseScreen;
public Button resumeBtn;
public Button restartBtn;
public void Show()
{
pauseScreen.SetActive(true);
}
public void Hide()
{
pauseScreen.SetActive(false);
}
}
}

View File

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

View File

@@ -0,0 +1,49 @@
using Darkmatter.Core;
using UnityEngine;
using VContainer;
using VContainer.Unity;
namespace Darkmatter.Presentation
{
public class StartScreenController : IStartable
{
private StartScreenView startScreenView;
[Inject] IGameScreenController gameScreenController;
[Inject] IInputReader IinputReader;
[Inject] private IAudioController IaudioController;
[Inject] private IGameSession IgameSession;
public StartScreenController(StartScreenView _startScreenView, IGameScreenController _gameScreenController)
{
Debug.Log("StartScreenController Constructor Called");
startScreenView = _startScreenView;
gameScreenController = _gameScreenController;
startScreenView.tapToStartButton.onClick.AddListener(OnTapToStartButtonClicked);
}
public void Start()
{
if (IgameSession.showStartScreen)
{
startScreenView.Show();
IinputReader.LockInput();
IgameSession.showStartScreen = false;
IgameSession.hasGameStarted = false;
}
else
{
gameScreenController.ShowGameScreen();
IgameSession.hasGameStarted = true;
}
}
private void OnTapToStartButtonClicked()
{
IaudioController.PlayBtnPressedSound();
startScreenView.Hide();
IinputReader.UnlockInput();
gameScreenController.ShowGameScreen();
IgameSession.hasGameStarted = true;
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 3f1b78c138759874ab695ee6697c16a4

View File

@@ -0,0 +1,23 @@
using UnityEngine;
using UnityEngine.UI;
namespace Darkmatter.Presentation
{
public class StartScreenView : MonoBehaviour
{
[SerializeField] private GameObject startScreen;
public Button tapToStartButton;
public void Show()
{
startScreen.SetActive(true);
}
public void Hide()
{
startScreen.SetActive(false);
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 3fccddd791b55e446a7a091823024f34