input refactored
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Unity.Mathematics;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
@@ -15,8 +16,6 @@ public class InputReaderSO : ScriptableObject, GameInputAction.IPlayerActions ,
|
||||
}
|
||||
|
||||
public bool isMouseButtonPressed { get;private set; }
|
||||
|
||||
private bool blockedInput = false;
|
||||
private Vector2 _dragInput;
|
||||
private GameInputAction action;
|
||||
|
||||
|
||||
@@ -8,7 +8,9 @@ public class PlatformManager : MonoBehaviour,IPlatformManager
|
||||
private float yPos = 0f;
|
||||
|
||||
public float rotSpeed = 5f;
|
||||
private float rotAmount;
|
||||
|
||||
private float targetRotAmount;
|
||||
private float smoothRotAmount;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
@@ -26,7 +28,18 @@ public class PlatformManager : MonoBehaviour,IPlatformManager
|
||||
}
|
||||
private void LateUpdate()
|
||||
{
|
||||
transform.Rotate(Vector3.up * rotAmount);
|
||||
#if UNITY_EDITOR || UNITY_STANDALONE
|
||||
if (!inputReader.isMouseButtonPressed) return;
|
||||
#endif
|
||||
|
||||
smoothRotAmount = Mathf.MoveTowards(
|
||||
smoothRotAmount,
|
||||
targetRotAmount,
|
||||
Time.deltaTime * 80f
|
||||
);
|
||||
|
||||
transform.Rotate(Vector3.up * smoothRotAmount, Space.World);
|
||||
|
||||
}
|
||||
void ShowPlatforms()
|
||||
{
|
||||
@@ -47,18 +60,11 @@ public class PlatformManager : MonoBehaviour,IPlatformManager
|
||||
|
||||
private void HandleDrag(Vector2 drag)
|
||||
{
|
||||
rotAmount = -drag.normalized.x * rotSpeed;
|
||||
float raw = drag.x / Screen.width;
|
||||
|
||||
//#if UNITY_EDITOR || UNITY_STANDALONE
|
||||
// if (!inputReader.isMouseButtonPressed) return;
|
||||
// transform.Rotate(Vector3.up * rotAmount);
|
||||
|
||||
//#elif UNITY_IOS || UNITY_ANDROID
|
||||
// transform.Rotate(Vector3.up * rotAmount * DPI);
|
||||
|
||||
//#endif
|
||||
//transform.Rotate(Vector3.up * rotAmount);
|
||||
targetRotAmount = -raw * rotSpeed * 180f;
|
||||
|
||||
targetRotAmount = Mathf.Clamp(targetRotAmount, -10f,10f);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ public class DeathScreenController:IDeathScreenController
|
||||
[Inject] private IInputReader IinputReader;
|
||||
[Inject] private IAudioController IaudioController;
|
||||
[Inject] private IGameSession IgameSession;
|
||||
[Inject] private IGameScreenController IgameScreenController;
|
||||
public DeathScreenController(DeathScreenView _deathScreenView)
|
||||
{
|
||||
deathScreenView = _deathScreenView;
|
||||
@@ -21,6 +22,7 @@ public class DeathScreenController:IDeathScreenController
|
||||
|
||||
public void ShowDeathScreen()
|
||||
{
|
||||
IgameScreenController.HideGameScreen();
|
||||
deathScreenView.Show(IscoreService.score,IscoreService.highScore);
|
||||
}
|
||||
|
||||
@@ -38,6 +40,7 @@ public class DeathScreenController:IDeathScreenController
|
||||
Debug.Log("Restart Button Clicked");
|
||||
IinputReader.UnlockInput();
|
||||
IaudioController.PlayBtnPressedSound();
|
||||
IgameSession.showStartScreen = false;
|
||||
SceneManager.LoadScene(0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +33,11 @@ public class GameScreenController: IGameScreenController
|
||||
gameScreenView.Show();
|
||||
}
|
||||
|
||||
public void HideGameScreen()
|
||||
{
|
||||
gameScreenView.Hide();
|
||||
}
|
||||
|
||||
public void OnPauseButtonClicked()
|
||||
{
|
||||
IaudioController.PlayBtnPressedSound();
|
||||
@@ -45,4 +50,5 @@ public class GameScreenController: IGameScreenController
|
||||
|
||||
public interface IGameScreenController {
|
||||
void ShowGameScreen();
|
||||
void HideGameScreen();
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ public class PauseScreenController:IPauseScreenController
|
||||
private PauseScreenView pauseScreenView;
|
||||
[Inject] private IInputReader IinputReader;
|
||||
[Inject] private IAudioController IaudioController;
|
||||
[Inject] private IGameSession IgameSession;
|
||||
|
||||
public PauseScreenController(PauseScreenView _pauseScreenView)
|
||||
{
|
||||
@@ -26,6 +27,7 @@ public class PauseScreenController:IPauseScreenController
|
||||
Time.timeScale = 1.0f;
|
||||
IinputReader.UnlockInput();
|
||||
IaudioController.PlayBtnPressedSound();
|
||||
IgameSession.showStartScreen = false;
|
||||
SceneManager.LoadScene(0); //Restart This Scene
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user