Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Source/NotPokemonGo/Assets/Scripts/QTESystem/QTEPhaseSetup.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using Services.QTEServices;
using UI.QTE;
using UnityEngine.UI;

Expand All @@ -18,6 +17,8 @@ public class QTEPhaseSetup
public float Offset;
public float TimeToNextTarget;

public QTETargetMovementPathConfig TargetMovementPathConfig;

// поле которое отвечает за то, через сколько появится следующая QTE
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System.Collections.Generic;
using UnityEngine;

namespace QTESystem
{
[CreateAssetMenu(fileName = nameof(QTETargetMovementPathConfig), menuName = "StaticData/QTE/" + nameof(QTETargetMovementPathConfig))]
public class QTETargetMovementPathConfig : ScriptableObject
{
[SerializeField] private RectTransform _pathSpace;
[SerializeField] private Vector2[] _splinePoints;
[SerializeField, Min(0f)] private float _tolerance = 10f;
[SerializeField, Min(0f)] private float _timeLimit = 5f;

public RectTransform PathSpace => _pathSpace;
public IReadOnlyList<Vector2> SplinePoints => _splinePoints;
public float Tolerance => _tolerance;
public float TimeLimit => _timeLimit;
}
}
4 changes: 2 additions & 2 deletions Source/NotPokemonGo/Assets/Scripts/UI/QTE/QTEButtonView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ public abstract class QTEButtonView : MonoBehaviour
public float CurrentTime { get; protected set; }

public abstract event Action<QTEButtonView> Successed;
public abstract event Action<QTEButtonView> Invalided;
public abstract event Action<QTEButtonView, QTEInvalidReason> Invalided;

public virtual void Initialize(QTEPhasePresenter qtePhasePresenter)
{ }
}
}
}
13 changes: 13 additions & 0 deletions Source/NotPokemonGo/Assets/Scripts/UI/QTE/QTEInvalidReason.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System;

namespace UI.QTE
{
[Serializable]
public enum QTEInvalidReason
{
Unknown = 0,
Timeout = 1,
OutOfBounds = 2,
WrongInput = 3,
}
}
10 changes: 4 additions & 6 deletions Source/NotPokemonGo/Assets/Scripts/UI/QTE/QTEPhasePresenter.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
using QTESystem;
using VContainer;
using QTESystem;

namespace UI.QTE
{
public class QTEPhasePresenter
{
private readonly IObjectResolver _objectResolver;
private readonly QTEButtonView _qteButtonView;
private bool _isActive;

Expand Down Expand Up @@ -37,18 +35,18 @@ public void Disable()
public bool IsActive() =>
_isActive;

private void OnInvalided(QTEButtonView qteButtonView)
private void OnInvalided(QTEButtonView qteButtonView, QTEInvalidReason reason)
{
qteButtonView.Invalided -= OnInvalided;
_isActive = false;
IsSuccess = false;
}

private void OnSuccessed(QTEButtonView qteButtonView)
{
qteButtonView.Successed -= OnSuccessed;
_isActive = false;
IsSuccess = true;
}
}
}
}
18 changes: 9 additions & 9 deletions Source/NotPokemonGo/Assets/Scripts/UI/QTE/QTERaycasterView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ public class QTERaycasterView : QTEButtonView
private int _clickCount;

public override event Action<QTEButtonView> Successed;
public override event Action<QTEButtonView> Invalided;
public override event Action<QTEButtonView, QTEInvalidReason> Invalided;

[Inject]
public void Construct(IInputReader inputReader, IRaycastService raycastService, ITargetSelector targetSelector)
{
_inputReader = inputReader;
_targetSelector = targetSelector;
_raycastService = raycastService;
_inputReader.LeftMouseButtonPressed += OnLeftMouseButtonClicked;

_units = _targetSelector.GetTargets(TargetMode.Single).Where(x => x != null).ToList();

foreach (var unit in _units)
Expand All @@ -55,7 +55,7 @@ private void Update()

if (CurrentTime >= _qtePhasePresenter.QtePhaseSetup.TargetTime)
{
Invalided?.Invoke(this);
Invalided?.Invoke(this, QTEInvalidReason.Timeout);
Debug.LogWarning("прошло время QTERaycasterView");
}
}
Expand All @@ -64,7 +64,7 @@ private void OnLeftMouseButtonClicked()
{
if (_raycastService.Raycast(out Unit unit) == false)
{
Invalided?.Invoke(this);
Invalided?.Invoke(this, QTEInvalidReason.WrongInput);

Debug.LogWarning("не попал в юнита QTERaycasterView");
return;
Expand All @@ -84,12 +84,12 @@ private void OnLeftMouseButtonClicked()
else
{
Debug.LogWarning("не попал в юнита в for QTERaycasterView");
Invalided?.Invoke(this);
Invalided?.Invoke(this, QTEInvalidReason.WrongInput);
}
}
}

if (_clickCount == _qtePhasePresenter.QtePhaseSetup.ClickCount)
if (_clickCount == _qtePhasePresenter.QtePhaseSetup.ClickCount)
Successed?.Invoke(this);
}

Expand All @@ -112,7 +112,7 @@ public void MarkProcess()
{
_renderer.material.SetColor("_Color", Color.red);
}

public void MarkInterract()
{
_renderer.material.SetColor("_Color", Color.yellow);
Expand All @@ -123,4 +123,4 @@ public void FinalizeProcess()
_renderer.material.color = _defaultColor;
}
}
}
}
6 changes: 3 additions & 3 deletions Source/NotPokemonGo/Assets/Scripts/UI/QTE/QTETapUIView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class QTETapUIView : QTEButtonView
private Vector2 _visualEndSize;

public override event Action<QTEButtonView> Successed;
public override event Action<QTEButtonView> Invalided;
public override event Action<QTEButtonView, QTEInvalidReason> Invalided;


private bool _isSuccesTime => CurrentTime >= TargetTime - Offset && CurrentTime <= TargetTime;
Expand Down Expand Up @@ -96,7 +96,7 @@ private void Clicked()
if (_isSuccesTime)
Successed?.Invoke(this);
else
Invalided?.Invoke(this);
Invalided?.Invoke(this, QTEInvalidReason.WrongInput);
}

public void Reset()
Expand All @@ -105,4 +105,4 @@ public void Reset()
rectTransform.anchoredPosition = Vector2.zero;
}
}
}
}
Loading