Отладка текстового ввода
This commit is contained in:
parent
7f2ec29348
commit
eb60c917a0
@ -12,6 +12,7 @@ GameObject:
|
||||
- component: {fileID: 6526978814707206463}
|
||||
- component: {fileID: 8162617034424080788}
|
||||
- component: {fileID: 1956026621409659705}
|
||||
- component: {fileID: 8705395745706676817}
|
||||
m_Layer: 5
|
||||
m_Name: LetterSlot
|
||||
m_TagString: Untagged
|
||||
@ -95,6 +96,26 @@ MonoBehaviour:
|
||||
m_FillOrigin: 0
|
||||
m_UseSpriteMesh: 0
|
||||
m_PixelsPerUnitMultiplier: 1
|
||||
--- !u!114 &8705395745706676817
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 6701869724969323775}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 306cc8c2b49d7114eaa3623786fc2126, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.LayoutElement
|
||||
m_IgnoreLayout: 0
|
||||
m_MinWidth: -1
|
||||
m_MinHeight: -1
|
||||
m_PreferredWidth: 150
|
||||
m_PreferredHeight: -1
|
||||
m_FlexibleWidth: -1
|
||||
m_FlexibleHeight: -1
|
||||
m_LayoutPriority: 1
|
||||
--- !u!1 &7571868062296136469
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -235,7 +235,6 @@ MonoBehaviour:
|
||||
switchLetterSound: {fileID: 0}
|
||||
acceptSound: {fileID: 0}
|
||||
openSound: {fileID: 0}
|
||||
alphabetString: 0123456789
|
||||
MaxSpeedLetterPerSecond: 8
|
||||
MinSpeedLetterPerSecond: 3
|
||||
MaxSpeedTime: 3
|
||||
@ -249,6 +248,7 @@ GameObject:
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 1609170722057679483}
|
||||
- component: {fileID: 4666876617388708064}
|
||||
m_Layer: 5
|
||||
m_Name: Cells root
|
||||
m_TagString: Untagged
|
||||
@ -275,3 +275,29 @@ RectTransform:
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: -100, y: 100}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &4666876617388708064
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 4081094104680176696}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 30649d3a9faa99c48a7b1166b86bf2a0, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.HorizontalLayoutGroup
|
||||
m_Padding:
|
||||
m_Left: 0
|
||||
m_Right: 0
|
||||
m_Top: 0
|
||||
m_Bottom: 0
|
||||
m_ChildAlignment: 4
|
||||
m_Spacing: 15
|
||||
m_ChildForceExpandWidth: 0
|
||||
m_ChildForceExpandHeight: 0
|
||||
m_ChildControlWidth: 1
|
||||
m_ChildControlHeight: 0
|
||||
m_ChildScaleWidth: 0
|
||||
m_ChildScaleHeight: 0
|
||||
m_ReverseArrangement: 0
|
||||
File diff suppressed because it is too large
Load Diff
@ -3,7 +3,8 @@
|
||||
public const string PRIZES_AVAILABLE = "PrizesAvailable";
|
||||
public const string PRIZING_ERROR_REGISTRED = "PrizeError";
|
||||
|
||||
public const string NUMBER_TECH = "NumberTech";
|
||||
public const string NUMBER_SUPPORT = "NumberTech";
|
||||
public const string NUMBER_ADMIN = "NumberAdmin";
|
||||
public const string PRIZE_ERROR = "PrizeError";
|
||||
|
||||
//счетчики
|
||||
|
||||
@ -16,15 +16,15 @@ public class LetterSlot : MonoBehaviour
|
||||
private int _symbolIndex;
|
||||
private string _alphabet;
|
||||
private Sequence _animation;
|
||||
|
||||
public char Symbol { get; private set; }
|
||||
|
||||
public char Symbol => _alphabet[_symbolIndex];
|
||||
|
||||
private void OnDestroy() => StopAnimation();
|
||||
|
||||
public void Init(char symbol, string alphabet)
|
||||
{
|
||||
_alphabet = alphabet;
|
||||
_symbolIndex = _alphabet.IndexOf(symbol);
|
||||
_symbolIndex = _alphabet.IndexOf(symbol);
|
||||
if( _symbolIndex < 0 ) _symbolIndex = 0;
|
||||
|
||||
SetSymbol(_symbolIndex);
|
||||
@ -59,9 +59,18 @@ public class LetterSlot : MonoBehaviour
|
||||
|
||||
public void SetSymbol(int index)
|
||||
{
|
||||
Symbol = _alphabet[index];
|
||||
_symbolIndex = index;
|
||||
_label.text = Symbol.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
public void SetSymbol(char symbol)
|
||||
{
|
||||
int index = _alphabet.IndexOf(symbol);
|
||||
if (index < 0)
|
||||
SetSymbol(0);
|
||||
else
|
||||
SetSymbol(index);
|
||||
}
|
||||
|
||||
private void StopAnimation()
|
||||
{
|
||||
|
||||
@ -29,6 +29,7 @@ public class SettingsScreen : MonoBehaviour, IControlable
|
||||
private BaseSettingView SelectedSetting => settings[activeSettingIndex];
|
||||
private HoldTimer _exitTimer;
|
||||
public bool ControlsEnabled { get; set; } = false;
|
||||
private bool controlsBlocked = false;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
@ -44,6 +45,12 @@ public class SettingsScreen : MonoBehaviour, IControlable
|
||||
|
||||
public void UpdateControls()
|
||||
{
|
||||
if(controlsBlocked && In.GetButtonAnyPlayer(PlayerAction.action) == false)
|
||||
controlsBlocked = false;
|
||||
|
||||
if (controlsBlocked)
|
||||
return;
|
||||
|
||||
int switchDirection = -In.GetAxis(switchAxis, JoystickSide.Both);
|
||||
|
||||
if (switchDirection != 0)
|
||||
@ -72,6 +79,8 @@ public class SettingsScreen : MonoBehaviour, IControlable
|
||||
ControlsEnabled = true;
|
||||
}
|
||||
|
||||
public void BlockControls() => controlsBlocked = true;
|
||||
|
||||
private void SwitchSetting(int switchDirection)
|
||||
{
|
||||
SelectedSetting.Deselect();
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
public class TextInput : MonoBehaviour
|
||||
public class TextInput : MonoBehaviour, IControlable
|
||||
{
|
||||
public event Action<string> OnComplete;
|
||||
|
||||
@ -26,19 +26,12 @@ public class TextInput : MonoBehaviour
|
||||
private float switchDelayRest = 1;
|
||||
|
||||
private int _slotIndex = 0;
|
||||
|
||||
private LetterSlot[] _slots;
|
||||
|
||||
|
||||
private LetterSlot _activeSlot => _slots[_slotIndex];
|
||||
|
||||
private bool completionRequested = false;
|
||||
private bool completeUnpressed = false;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
string initial = PlayerPrefs.GetString(PrefsKeyVault.NUMBER_TECH, "");
|
||||
Initialize(11, Alphabets.DIGITS, initial);
|
||||
}
|
||||
public bool ControlsEnabled { get; set; } = true;
|
||||
private LetterSlot ActiveSlot => _slots[_slotIndex];
|
||||
|
||||
public void Initialize(int cellsAmount, string alphabet, string initialString = "")
|
||||
{
|
||||
@ -46,7 +39,7 @@ public class TextInput : MonoBehaviour
|
||||
InitializeSlots(initialString);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
public void UpdateControls()
|
||||
{
|
||||
int dir_h = In.GetAxis(Axis.Horizontal, JoystickSide.Both, InteractMode.Discrete);
|
||||
SwitchSlot(dir_h);
|
||||
@ -54,8 +47,11 @@ public class TextInput : MonoBehaviour
|
||||
int dir_v = In.GetAxis(Axis.Vertical, JoystickSide.Both, InteractMode.Continious);
|
||||
SwitchLetter(dir_v);
|
||||
|
||||
if(In.GetButtonAnyPlayer(PlayerAction.action) == false)
|
||||
completeUnpressed = true;
|
||||
|
||||
completionRequested = In.GetButtonAnyPlayer(PlayerAction.action);
|
||||
if (completionRequested)
|
||||
if (completionRequested && completeUnpressed)
|
||||
Complete();
|
||||
}
|
||||
|
||||
@ -63,7 +59,7 @@ public class TextInput : MonoBehaviour
|
||||
{
|
||||
string result = CollectText();
|
||||
OnComplete?.Invoke(result);
|
||||
gameObject.SetActive(false);
|
||||
Destroy(gameObject);
|
||||
}
|
||||
|
||||
private void Generate(int cellsAmount, string alphabet)
|
||||
@ -100,9 +96,9 @@ public class TextInput : MonoBehaviour
|
||||
{
|
||||
if (dir == 0) return;
|
||||
|
||||
_activeSlot.SetSelected(false);
|
||||
ActiveSlot.SetSelected(false);
|
||||
_slotIndex = Mathf.Clamp(_slotIndex + dir, 0, _slots.Length);
|
||||
_activeSlot.SetSelected(true);
|
||||
ActiveSlot.SetSelected(true);
|
||||
}
|
||||
|
||||
public void SwitchLetter(int dir)
|
||||
@ -116,7 +112,7 @@ public class TextInput : MonoBehaviour
|
||||
|
||||
if (switchDelayRest < 0)
|
||||
{
|
||||
_activeSlot.ChangeSymbol(dir);
|
||||
ActiveSlot.ChangeSymbol(dir);
|
||||
recalculateRest();
|
||||
}
|
||||
|
||||
|
||||
@ -3,6 +3,11 @@ using UnityEngine;
|
||||
|
||||
public class SettingFunctions : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private TextInput _textInputPrefab;
|
||||
[SerializeField] private RectTransform _canvas;
|
||||
[SerializeField] private SettingsScreen _settingsScreen;
|
||||
|
||||
|
||||
public void ResetBalance() => PaymentSystem.ResetBalance();
|
||||
|
||||
public void ResetPrizeError() => PrizeSystemManager.SetPrizingError(false);
|
||||
@ -14,12 +19,38 @@ public class SettingFunctions : MonoBehaviour
|
||||
|
||||
public void EnterNumberAdmin()
|
||||
{
|
||||
string oldNumber = PlayerPrefs.GetString(PrefsKeyVault.NUMBER_ADMIN);
|
||||
|
||||
var textInput = Instantiate(_textInputPrefab, _canvas);
|
||||
textInput.Initialize(11, Alphabets.DIGITS, oldNumber);
|
||||
ControlsPerformer.Instance.SetControlable(textInput);
|
||||
|
||||
textInput.OnComplete += (result) =>
|
||||
{
|
||||
PlayerPrefs.SetString(PrefsKeyVault.NUMBER_ADMIN, result);
|
||||
SettingsManager.TriggerSettingsChanged();
|
||||
_settingsScreen.BlockControls();
|
||||
ControlsPerformer.Instance.SetControlable(_settingsScreen);
|
||||
Destroy(textInput.gameObject);
|
||||
};
|
||||
}
|
||||
|
||||
public void EnterNumberSupport()
|
||||
{
|
||||
string oldNumber = PlayerPrefs.GetString(PrefsKeyVault.NUMBER_SUPPORT);
|
||||
|
||||
var textInput = Instantiate(_textInputPrefab, _canvas);
|
||||
textInput.Initialize(11, Alphabets.DIGITS, oldNumber);
|
||||
ControlsPerformer.Instance.SetControlable(textInput);
|
||||
|
||||
textInput.OnComplete += (result) =>
|
||||
{
|
||||
PlayerPrefs.SetString(PrefsKeyVault.NUMBER_SUPPORT, result);
|
||||
SettingsManager.TriggerSettingsChanged();
|
||||
_settingsScreen.BlockControls();
|
||||
ControlsPerformer.Instance.SetControlable(_settingsScreen);
|
||||
Destroy(textInput.gameObject);
|
||||
};
|
||||
}
|
||||
|
||||
public void ScreenTest()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user