files arranged using assembly defn
This commit is contained in:
14
Assets/DarkMatter/Code/Core/Data/GameSession.asset
Normal file
14
Assets/DarkMatter/Code/Core/Data/GameSession.asset
Normal file
@@ -0,0 +1,14 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 19b4667bfc2bc924a80a7fb0cd8c24f9, type: 3}
|
||||
m_Name: GameSession
|
||||
m_EditorClassIdentifier: Assembly-CSharp::GameSession
|
||||
8
Assets/DarkMatter/Code/Core/Data/GameSession.asset.meta
Normal file
8
Assets/DarkMatter/Code/Core/Data/GameSession.asset.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 166236fc288d5a343ba6dd8ab704e653
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
25
Assets/DarkMatter/Code/Core/Data/GameSessionSO.cs
Normal file
25
Assets/DarkMatter/Code/Core/Data/GameSessionSO.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using Darkmatter.Core;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Darkmatter.Core
|
||||
{
|
||||
|
||||
[CreateAssetMenu(fileName = "GameSessionSO", menuName = "Scriptable Objects/GameSessionSO")]
|
||||
public class GameSessionSO : ScriptableObject, IGameSession
|
||||
{
|
||||
public bool showStartScreen { get; set; } = false;
|
||||
public bool hasGameStarted { get; set; } = false;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
showStartScreen = true;
|
||||
hasGameStarted = false;
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
showStartScreen = false;
|
||||
hasGameStarted = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/DarkMatter/Code/Core/Data/GameSessionSO.cs.meta
Normal file
2
Assets/DarkMatter/Code/Core/Data/GameSessionSO.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 19b4667bfc2bc924a80a7fb0cd8c24f9
|
||||
14
Assets/DarkMatter/Code/Core/Data/InputReaderSO.asset
Normal file
14
Assets/DarkMatter/Code/Core/Data/InputReaderSO.asset
Normal file
@@ -0,0 +1,14 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 8320650719108c947a83626711fe4964, type: 3}
|
||||
m_Name: InputReaderSO
|
||||
m_EditorClassIdentifier: Assembly-CSharp::InputReaderSO
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dfe12148dc4d7ea46b49e490c1b1aad5
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
61
Assets/DarkMatter/Code/Core/Data/InputReaderSO.cs
Normal file
61
Assets/DarkMatter/Code/Core/Data/InputReaderSO.cs
Normal file
@@ -0,0 +1,61 @@
|
||||
using Darkmatter.Core;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
|
||||
namespace Darkmatter.Core
|
||||
{
|
||||
[CreateAssetMenu(fileName = "InputReaderSO", menuName = "Scriptable Objects/InputReaderSO")]
|
||||
public class InputReaderSO : ScriptableObject, GameInputAction.IPlayerActions, IInputReader
|
||||
{
|
||||
public event Action<Vector2> OnDragValueChanged;
|
||||
public Vector2 dragInput
|
||||
{
|
||||
get => _dragInput;
|
||||
private set
|
||||
{
|
||||
_dragInput = value;
|
||||
OnDragValueChanged?.Invoke(_dragInput);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public bool isMouseButtonPressed { get; private set; }
|
||||
private Vector2 _dragInput;
|
||||
private GameInputAction action;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
if (action == null) action = new GameInputAction();
|
||||
action.Enable();
|
||||
action.Player.SetCallbacks(this);
|
||||
isMouseButtonPressed = false;
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
action.Player.Disable();
|
||||
}
|
||||
|
||||
public void OnDrag(InputAction.CallbackContext context)
|
||||
{
|
||||
dragInput = context.ReadValue<Vector2>();
|
||||
}
|
||||
|
||||
public void OnMouseClicked(InputAction.CallbackContext context)
|
||||
{
|
||||
isMouseButtonPressed = context.ReadValue<float>() == 1 ? true : false;
|
||||
}
|
||||
|
||||
public void LockInput()
|
||||
{
|
||||
action.Player.Disable();
|
||||
}
|
||||
|
||||
public void UnlockInput()
|
||||
{
|
||||
action.Player.Enable();
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/DarkMatter/Code/Core/Data/InputReaderSO.cs.meta
Normal file
2
Assets/DarkMatter/Code/Core/Data/InputReaderSO.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8320650719108c947a83626711fe4964
|
||||
33
Assets/DarkMatter/Code/Core/Data/ScoreService.cs
Normal file
33
Assets/DarkMatter/Code/Core/Data/ScoreService.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using Darkmatter.Core;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Darkmatter.Core
|
||||
{
|
||||
public class ScoreService : IScoreService
|
||||
{
|
||||
public event Action<int> OnScoreChange;
|
||||
public int score { get; private set; }
|
||||
|
||||
public int highScore { get; private set; } = PlayerPrefs.GetInt("HighScore");
|
||||
|
||||
public void AddScore()
|
||||
{
|
||||
score += 5;
|
||||
if (score > highScore)
|
||||
{
|
||||
SetNewHighScore();
|
||||
}
|
||||
OnScoreChange?.Invoke(score);
|
||||
}
|
||||
|
||||
private void SetNewHighScore()
|
||||
{
|
||||
highScore = score;
|
||||
PlayerPrefs.SetInt("HighScore", highScore);
|
||||
PlayerPrefs.Save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
2
Assets/DarkMatter/Code/Core/Data/ScoreService.cs.meta
Normal file
2
Assets/DarkMatter/Code/Core/Data/ScoreService.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 63293fe85cd298c4a81aec8cd5c0f43f
|
||||
Reference in New Issue
Block a user