Fixed bugs with input if a player is unplayable and pause is set

Input translator upgraded
This commit is contained in:
VladimirPirozhenko 2022-08-15 20:57:11 +03:00
parent 9067758171
commit e1c8070226
7 changed files with 78 additions and 1143 deletions

View File

@ -472,12 +472,12 @@ Transform:
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 214096428} m_GameObject: {fileID: 214096428}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -503.04962, y: -330.63593, z: 15.289003} m_LocalPosition: {x: -2.6219482, y: 1.454071, z: 13.627879}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 245285643} m_Father: {fileID: 0}
m_RootOrder: 2 m_RootOrder: 9
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &220002225 --- !u!1 &220002225
GameObject: GameObject:
@ -574,7 +574,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0} m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1} m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: -1.076828} m_AnchoredPosition: {x: 0, y: -1.0769043}
m_SizeDelta: {x: -534.24976, y: -25.013092} m_SizeDelta: {x: -534.24976, y: -25.013092}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &245285642 --- !u!1 &245285642
@ -607,10 +607,9 @@ Transform:
m_Children: m_Children:
- {fileID: 1858832248} - {fileID: 1858832248}
- {fileID: 1791311983} - {fileID: 1791311983}
- {fileID: 214096430}
- {fileID: 378990291} - {fileID: 378990291}
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 9 m_RootOrder: 10
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &377940177 --- !u!1 &377940177
GameObject: GameObject:
@ -759,7 +758,7 @@ GameObject:
- component: {fileID: 378990294} - component: {fileID: 378990294}
- component: {fileID: 378990293} - component: {fileID: 378990293}
- component: {fileID: 378990292} - component: {fileID: 378990292}
m_Layer: 0 m_Layer: 5
m_Name: ScoreCanvas m_Name: ScoreCanvas
m_TagString: Untagged m_TagString: Untagged
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
@ -780,7 +779,7 @@ RectTransform:
m_Children: m_Children:
- {fileID: 678372250} - {fileID: 678372250}
m_Father: {fileID: 245285643} m_Father: {fileID: 245285643}
m_RootOrder: 3 m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0} m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0}
@ -816,7 +815,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 0cd44c1031e13a943bb63640046fad76, type: 3} m_Script: {fileID: 11500000, guid: 0cd44c1031e13a943bb63640046fad76, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
m_UiScaleMode: 0 m_UiScaleMode: 1
m_ReferencePixelsPerUnit: 100 m_ReferencePixelsPerUnit: 100
m_ScaleFactor: 1 m_ScaleFactor: 1
m_ReferenceResolution: {x: 800, y: 600} m_ReferenceResolution: {x: 800, y: 600}
@ -2855,6 +2854,34 @@ PrefabInstance:
m_Modification: m_Modification:
m_TransformParent: {fileID: 378990291} m_TransformParent: {fileID: 378990291}
m_Modifications: m_Modifications:
- target: {fileID: 6634832997822410792, guid: 68d36a24cad029f4a91d5c8e7aa18281, type: 3}
propertyPath: m_SizeDelta.x
value: 149.1162
objectReference: {fileID: 0}
- target: {fileID: 6634832997822410792, guid: 68d36a24cad029f4a91d5c8e7aa18281, type: 3}
propertyPath: m_SizeDelta.y
value: 43.772
objectReference: {fileID: 0}
- target: {fileID: 6634832997822410792, guid: 68d36a24cad029f4a91d5c8e7aa18281, type: 3}
propertyPath: m_AnchoredPosition.x
value: -74.558
objectReference: {fileID: 0}
- target: {fileID: 6634832997822410792, guid: 68d36a24cad029f4a91d5c8e7aa18281, type: 3}
propertyPath: m_AnchoredPosition.y
value: -21.886
objectReference: {fileID: 0}
- target: {fileID: 6634832997822410793, guid: 68d36a24cad029f4a91d5c8e7aa18281, type: 3}
propertyPath: m_Layer
value: 5
objectReference: {fileID: 0}
- target: {fileID: 6634832997822410799, guid: 68d36a24cad029f4a91d5c8e7aa18281, type: 3}
propertyPath: m_fontSize
value: 28.65
objectReference: {fileID: 0}
- target: {fileID: 6634832997822410799, guid: 68d36a24cad029f4a91d5c8e7aa18281, type: 3}
propertyPath: m_margin.w
value: 13.257981
objectReference: {fileID: 0}
- target: {fileID: 6634832998035864265, guid: 68d36a24cad029f4a91d5c8e7aa18281, type: 3} - target: {fileID: 6634832998035864265, guid: 68d36a24cad029f4a91d5c8e7aa18281, type: 3}
propertyPath: m_Pivot.x propertyPath: m_Pivot.x
value: 0.5 value: 0.5
@ -2877,19 +2904,19 @@ PrefabInstance:
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 6634832998035864265, guid: 68d36a24cad029f4a91d5c8e7aa18281, type: 3} - target: {fileID: 6634832998035864265, guid: 68d36a24cad029f4a91d5c8e7aa18281, type: 3}
propertyPath: m_AnchorMin.x propertyPath: m_AnchorMin.x
value: 0 value: 1
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 6634832998035864265, guid: 68d36a24cad029f4a91d5c8e7aa18281, type: 3} - target: {fileID: 6634832998035864265, guid: 68d36a24cad029f4a91d5c8e7aa18281, type: 3}
propertyPath: m_AnchorMin.y propertyPath: m_AnchorMin.y
value: 0 value: 1
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 6634832998035864265, guid: 68d36a24cad029f4a91d5c8e7aa18281, type: 3} - target: {fileID: 6634832998035864265, guid: 68d36a24cad029f4a91d5c8e7aa18281, type: 3}
propertyPath: m_SizeDelta.x propertyPath: m_SizeDelta.x
value: -93.99994 value: 161.66
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 6634832998035864265, guid: 68d36a24cad029f4a91d5c8e7aa18281, type: 3} - target: {fileID: 6634832998035864265, guid: 68d36a24cad029f4a91d5c8e7aa18281, type: 3}
propertyPath: m_SizeDelta.y propertyPath: m_SizeDelta.y
value: -60.33316 value: 36.7283
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 6634832998035864265, guid: 68d36a24cad029f4a91d5c8e7aa18281, type: 3} - target: {fileID: 6634832998035864265, guid: 68d36a24cad029f4a91d5c8e7aa18281, type: 3}
propertyPath: m_LocalScale.x propertyPath: m_LocalScale.x
@ -2933,11 +2960,11 @@ PrefabInstance:
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 6634832998035864265, guid: 68d36a24cad029f4a91d5c8e7aa18281, type: 3} - target: {fileID: 6634832998035864265, guid: 68d36a24cad029f4a91d5c8e7aa18281, type: 3}
propertyPath: m_AnchoredPosition.x propertyPath: m_AnchoredPosition.x
value: -0.000061035156 value: -90.33002
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 6634832998035864265, guid: 68d36a24cad029f4a91d5c8e7aa18281, type: 3} - target: {fileID: 6634832998035864265, guid: 68d36a24cad029f4a91d5c8e7aa18281, type: 3}
propertyPath: m_AnchoredPosition.y propertyPath: m_AnchoredPosition.y
value: 0.111572266 value: -18.084717
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 6634832998035864265, guid: 68d36a24cad029f4a91d5c8e7aa18281, type: 3} - target: {fileID: 6634832998035864265, guid: 68d36a24cad029f4a91d5c8e7aa18281, type: 3}
propertyPath: m_LocalEulerAnglesHint.x propertyPath: m_LocalEulerAnglesHint.x
@ -2978,11 +3005,11 @@ PrefabInstance:
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 6190724271798382203, guid: 99d72c8750358d54c8647747f3a9a236, type: 3} - target: {fileID: 6190724271798382203, guid: 99d72c8750358d54c8647747f3a9a236, type: 3}
propertyPath: m_AnchoredPosition.x propertyPath: m_AnchoredPosition.x
value: -0.00015258789 value: -0.00012207031
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 6190724271798382203, guid: 99d72c8750358d54c8647747f3a9a236, type: 3} - target: {fileID: 6190724271798382203, guid: 99d72c8750358d54c8647747f3a9a236, type: 3}
propertyPath: m_AnchoredPosition.y propertyPath: m_AnchoredPosition.y
value: 2.418396 value: 2.418457
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 7641310222228061956, guid: 99d72c8750358d54c8647747f3a9a236, type: 3} - target: {fileID: 7641310222228061956, guid: 99d72c8750358d54c8647747f3a9a236, type: 3}
propertyPath: m_Pivot.x propertyPath: m_Pivot.x

View File

@ -12,7 +12,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 9055f72a604bc3f4ba01bc120f0643d2, type: 3} m_Script: {fileID: 11500000, guid: 9055f72a604bc3f4ba01bc120f0643d2, type: 3}
m_Name: PlayerData m_Name: PlayerData
m_EditorClassIdentifier: m_EditorClassIdentifier:
<InvincibilityTime>k__BackingField: 300 <InvincibilityTime>k__BackingField: 3
<JumpHeight>k__BackingField: 5.3 <JumpHeight>k__BackingField: 5.3
<LaneSwitchSpeed>k__BackingField: 25 <LaneSwitchSpeed>k__BackingField: 25
<Speed>k__BackingField: 20 <Speed>k__BackingField: 20

View File

@ -5,12 +5,14 @@ using UnityEngine.SceneManagement;
public class GameSession : MonoBehaviour,IResettable public class GameSession : MonoBehaviour,IResettable
{ {
private InputTranslator<KeyBinding> InputTranslator; public static GameSession Instance { get; private set; }
public static GameSession Instance { get; private set; }
[SerializeField] private Player currentPlayer; [SerializeField] private Player currentPlayer;
private InputTranslator<KeyBinding> InputTranslator;
private bool isSessionPaused = false;
private bool isInputAlreadyRestricted = false;
private void Awake() private void Awake()
{ {
Instance = this; Instance = this;
@ -34,11 +36,25 @@ public class GameSession : MonoBehaviour,IResettable
InputTranslator.AddCommandTranslator(translator); InputTranslator.AddCommandTranslator(translator);
} }
public void PauseSession(bool isPaused) public void PauseSession(bool isPaused)
{ {
Time.timeScale = isPaused ? 0 : 1; Time.timeScale = isPaused ? 0 : 1;
if (InputTranslator.IsTranslationResticted(InputConstants.InGameCommands)) if (!isSessionPaused && InputTranslator.IsTranslationResticted(InputConstants.InGameCommands))
{
isInputAlreadyRestricted = true;
isSessionPaused = isPaused;
return; return;
}
if (!InputTranslator.IsTranslationResticted(InputConstants.InGameCommands))
{
isInputAlreadyRestricted = false;
}
isSessionPaused = isPaused;
if (isInputAlreadyRestricted)
{
return;
}
RestrictInputs(InputConstants.InGameCommands,isRestricted: isPaused); RestrictInputs(InputConstants.InGameCommands,isRestricted: isPaused);
} }

View File

@ -12,8 +12,6 @@ public class InputTranslator<T> where T : IBinding
bindingHolder.Init(); bindingHolder.Init();
} }
public void AddCommandTranslator(ICommandTranslator translator) public void AddCommandTranslator(ICommandTranslator translator)
{ {
if (commandTranslators.Contains(translator)) if (commandTranslators.Contains(translator))

View File

@ -9,6 +9,7 @@ public class DeadState : PlayerState
public override void OnStateEnter() public override void OnStateEnter()
{ {
playerSM.PlayDeadAnimation(true); playerSM.PlayDeadAnimation(true);
playerSM.PlayerTransform.position = new Vector3(playerSM.PlayerTransform.position.x,0.38f, playerSM.PlayerTransform.position.z);
playerSM.VerticalDeltaPosition = 0; playerSM.VerticalDeltaPosition = 0;
playerSM.HorizontalDeltaPosition = Vector3.zero; playerSM.HorizontalDeltaPosition = Vector3.zero;
GameSession.Instance.RestrictInputs(InputConstants.InGameCommands, true); GameSession.Instance.RestrictInputs(InputConstants.InGameCommands, true);

View File

@ -13,8 +13,9 @@ public class PausedView : BaseView
{ {
resumeButton.onClick.AddListener(() => resumeButton.onClick.AddListener(() =>
{ {
GameSession.Instance.PauseSession(false);
Show(false); Show(false);
GameSession.Instance.PauseSession(false);
}); });
scoreboardButton.onClick.AddListener(() => scoreboardButton.onClick.AddListener(() =>

File diff suppressed because one or more lines are too long