Added pause and pause view, added restriction of input while in paused state

Upgraded Input system to fit demands of paused game (no movement inputs allowed!)
This commit is contained in:
VladimirPirozhenko 2022-08-12 05:38:17 +03:00
parent e15e453c8e
commit 6999e84b65
34 changed files with 2446 additions and 1240 deletions

View File

@ -10,10 +10,11 @@ Material:
m_Name: sky___soil_AlbedoTransparency m_Name: sky___soil_AlbedoTransparency
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
m_ValidKeywords: m_ValidKeywords:
- _EMISSION
- _METALLICGLOSSMAP - _METALLICGLOSSMAP
- _NORMALMAP - _NORMALMAP
m_InvalidKeywords: [] m_InvalidKeywords: []
m_LightmapFlags: 5 m_LightmapFlags: 1
m_EnableInstancingVariants: 0 m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0 m_DoubleSidedGI: 0
m_CustomRenderQueue: -1 m_CustomRenderQueue: -1
@ -64,11 +65,15 @@ Material:
- _Cutoff: 0.5 - _Cutoff: 0.5
- _DetailNormalMapScale: 1 - _DetailNormalMapScale: 1
- _DstBlend: 0 - _DstBlend: 0
- _GlossMapScale: 1
- _Glossiness: 0 - _Glossiness: 0
- _GlossyReflections: 1
- _Metallic: 0 - _Metallic: 0
- _Mode: 0 - _Mode: 0
- _OcclusionStrength: 1 - _OcclusionStrength: 1
- _Parallax: 0.02 - _Parallax: 0.02
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1 - _SrcBlend: 1
- _UVSec: 0 - _UVSec: 0
- _ZWrite: 1 - _ZWrite: 1

View File

@ -10,10 +10,11 @@ Material:
m_Name: sky__trims_AlbedoTransparency m_Name: sky__trims_AlbedoTransparency
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
m_ValidKeywords: m_ValidKeywords:
- _EMISSION
- _METALLICGLOSSMAP - _METALLICGLOSSMAP
- _NORMALMAP - _NORMALMAP
m_InvalidKeywords: [] m_InvalidKeywords: []
m_LightmapFlags: 5 m_LightmapFlags: 1
m_EnableInstancingVariants: 0 m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0 m_DoubleSidedGI: 0
m_CustomRenderQueue: -1 m_CustomRenderQueue: -1
@ -64,11 +65,15 @@ Material:
- _Cutoff: 0.5 - _Cutoff: 0.5
- _DetailNormalMapScale: 1 - _DetailNormalMapScale: 1
- _DstBlend: 0 - _DstBlend: 0
- _GlossMapScale: 1
- _Glossiness: 0.5 - _Glossiness: 0.5
- _GlossyReflections: 1
- _Metallic: 0 - _Metallic: 0
- _Mode: 0 - _Mode: 0
- _OcclusionStrength: 1 - _OcclusionStrength: 1
- _Parallax: 0.02 - _Parallax: 0.02
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1 - _SrcBlend: 1
- _UVSec: 0 - _UVSec: 0
- _ZWrite: 1 - _ZWrite: 1

View File

@ -10,11 +10,12 @@ Material:
m_Name: sky_floor m_Name: sky_floor
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
m_ValidKeywords: m_ValidKeywords:
- _EMISSION
- _METALLICGLOSSMAP - _METALLICGLOSSMAP
- _NORMALMAP - _NORMALMAP
m_InvalidKeywords: m_InvalidKeywords:
- _SPECGLOSSMAP - _SPECGLOSSMAP
m_LightmapFlags: 5 m_LightmapFlags: 1
m_EnableInstancingVariants: 0 m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0 m_DoubleSidedGI: 0
m_CustomRenderQueue: -1 m_CustomRenderQueue: -1
@ -69,11 +70,15 @@ Material:
- _Cutoff: 0.5 - _Cutoff: 0.5
- _DetailNormalMapScale: 1 - _DetailNormalMapScale: 1
- _DstBlend: 0 - _DstBlend: 0
- _GlossMapScale: 1
- _Glossiness: 0.5 - _Glossiness: 0.5
- _GlossyReflections: 1
- _Metallic: 0 - _Metallic: 0
- _Mode: 0 - _Mode: 0
- _OcclusionStrength: 1 - _OcclusionStrength: 1
- _Parallax: 0.02 - _Parallax: 0.02
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1 - _SrcBlend: 1
- _UVSec: 0 - _UVSec: 0
- _ZWrite: 1 - _ZWrite: 1

View File

@ -0,0 +1,81 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &4889749525435056361
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 4889749525435056362}
- component: {fileID: 4889749525435056364}
- component: {fileID: 4889749525435056363}
m_Layer: 5
m_Name: HeartsView
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &4889749525435056362
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4889749525435056361}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 30.610992, y: -24.999878}
m_SizeDelta: {x: 61.222, y: 50}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &4889749525435056364
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4889749525435056361}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: a8f1b9f18845ec2479033a7baae9cfb7, type: 3}
m_Name:
m_EditorClassIdentifier:
heartImage: {fileID: 4188111242084732431, guid: 7f981bb9ccc6edc45a781d06e68372aa, type: 3}
heartSize: {x: 0, y: 0}
gapBetweenHearts: 0
--- !u!114 &4889749525435056363
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4889749525435056361}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 30649d3a9faa99c48a7b1166b86bf2a0, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Padding:
m_Left: 0
m_Right: 0
m_Top: 5
m_Bottom: 0
m_ChildAlignment: 1
m_Spacing: 5
m_ChildForceExpandWidth: 0
m_ChildForceExpandHeight: 0
m_ChildControlWidth: 0
m_ChildControlHeight: 0
m_ChildScaleWidth: 1
m_ChildScaleHeight: 1
m_ReverseArrangement: 0

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 14c24fef9917a7445a67e6acdb9a0c0e
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,6 +1,6 @@
%YAML 1.1 %YAML 1.1
%TAG !u! tag:unity3d.com,2011: %TAG !u! tag:unity3d.com,2011:
--- !u!1 &4290235790453130573 --- !u!1 &6634832997822410793
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0} m_CorrespondingSourceObject: {fileID: 0}
@ -8,9 +8,9 @@ GameObject:
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
serializedVersion: 6 serializedVersion: 6
m_Component: m_Component:
- component: {fileID: 4290235790453130572} - component: {fileID: 6634832997822410792}
- component: {fileID: 4290235790453130570} - component: {fileID: 6634832997822410798}
- component: {fileID: 4290235790453130571} - component: {fileID: 6634832997822410799}
m_Layer: 0 m_Layer: 0
m_Name: Score m_Name: Score
m_TagString: Untagged m_TagString: Untagged
@ -18,41 +18,41 @@ GameObject:
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0
m_IsActive: 1 m_IsActive: 1
--- !u!224 &4290235790453130572 --- !u!224 &6634832997822410792
RectTransform: RectTransform:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0} m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4290235790453130573} m_GameObject: {fileID: 6634832997822410793}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, 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: 4290235790731771775} m_Father: {fileID: 6634832998035864265}
m_RootOrder: 0 m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMin: {x: 1, y: 1}
m_AnchorMax: {x: 0.5, y: 0.5} m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 24.4056} m_AnchoredPosition: {x: -83.073, y: -19.628418}
m_SizeDelta: {x: 200, y: 98.8112} m_SizeDelta: {x: 166.15, y: 39.2575}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &4290235790453130570 --- !u!222 &6634832997822410798
CanvasRenderer: CanvasRenderer:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0} m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4290235790453130573} m_GameObject: {fileID: 6634832997822410793}
m_CullTransparentMesh: 1 m_CullTransparentMesh: 1
--- !u!114 &4290235790453130571 --- !u!114 &6634832997822410799
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0} m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4290235790453130573} m_GameObject: {fileID: 6634832997822410793}
m_Enabled: 1 m_Enabled: 1
m_EditorHideFlags: 0 m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3} m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3}
@ -68,15 +68,15 @@ MonoBehaviour:
m_Calls: [] m_Calls: []
m_text: New Text m_text: New Text
m_isRightToLeft: 0 m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} m_fontAsset: {fileID: 11400000, guid: 125cb55b44b24c4393181402bc6200e6, type: 2}
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} m_sharedMaterial: {fileID: 2100000, guid: 125cb55b44b24c4393181402bc6200e6, type: 2}
m_fontSharedMaterials: [] m_fontSharedMaterials: []
m_fontMaterial: {fileID: 0} m_fontMaterial: {fileID: 0}
m_fontMaterials: [] m_fontMaterials: []
m_fontColor32: m_fontColor32:
serializedVersion: 2 serializedVersion: 2
rgba: 4294967295 rgba: 4294967040
m_fontColor: {r: 1, g: 1, b: 1, a: 1} m_fontColor: {r: 0, g: 1, b: 1, a: 1}
m_enableVertexGradient: 0 m_enableVertexGradient: 0
m_colorMode: 3 m_colorMode: 3
m_fontColorGradient: m_fontColorGradient:
@ -93,14 +93,14 @@ MonoBehaviour:
m_faceColor: m_faceColor:
serializedVersion: 2 serializedVersion: 2
rgba: 4294967295 rgba: 4294967295
m_fontSize: 24 m_fontSize: 36.9
m_fontSizeBase: 24 m_fontSizeBase: 48
m_fontWeight: 400 m_fontWeight: 400
m_enableAutoSizing: 0 m_enableAutoSizing: 1
m_fontSizeMin: 18 m_fontSizeMin: 18
m_fontSizeMax: 72 m_fontSizeMax: 72
m_fontStyle: 0 m_fontStyle: 0
m_HorizontalAlignment: 2 m_HorizontalAlignment: 1
m_VerticalAlignment: 512 m_VerticalAlignment: 512
m_textAlignment: 65535 m_textAlignment: 65535
m_characterSpacing: 0 m_characterSpacing: 0
@ -129,13 +129,13 @@ MonoBehaviour:
m_VertexBufferAutoSizeReduction: 0 m_VertexBufferAutoSizeReduction: 0
m_useMaxVisibleDescender: 1 m_useMaxVisibleDescender: 1
m_pageToDisplay: 1 m_pageToDisplay: 1
m_margin: {x: 0, y: 0, z: 0, w: 0} m_margin: {x: 1.1188736, y: 0, z: -0.0848007, w: 0}
m_isUsingLegacyAnimationComponent: 0 m_isUsingLegacyAnimationComponent: 0
m_isVolumetricText: 0 m_isVolumetricText: 0
m_hasFontAssetChanged: 0 m_hasFontAssetChanged: 0
m_baseMaterial: {fileID: 0} m_baseMaterial: {fileID: 0}
m_maskOffset: {x: 0, y: 0, z: 0, w: 0} m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
--- !u!1 &4290235790731771760 --- !u!1 &6634832998035864266
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0} m_CorrespondingSourceObject: {fileID: 0}
@ -143,46 +143,55 @@ GameObject:
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
serializedVersion: 6 serializedVersion: 6
m_Component: m_Component:
- component: {fileID: 4290235790731771775} - component: {fileID: 6634832998035864265}
- component: {fileID: 4290235790731771774} - component: {fileID: 6634832998035864271}
m_Layer: 0 - component: {fileID: 6634832998035864270}
m_Name: PlayerHUDView m_Layer: 5
m_Name: PlayerHudView
m_TagString: Untagged m_TagString: Untagged
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0
m_IsActive: 1 m_IsActive: 1
--- !u!224 &4290235790731771775 --- !u!224 &6634832998035864265
RectTransform: RectTransform:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0} m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4290235790731771760} m_GameObject: {fileID: 6634832998035864266}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 13.627879} m_LocalPosition: {x: 0, y: 0, z: 0}
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:
- {fileID: 4290235790453130572} - {fileID: 6634832997822410792}
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 0 m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0.5, y: 0.5} m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: -503.97754, y: -306.70767} m_AnchoredPosition: {x: -0.000061035156, y: 0.099975586}
m_SizeDelta: {x: 129.7112, y: 113.6766} m_SizeDelta: {x: 0, y: -0.19000244}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &4290235790731771774 --- !u!222 &6634832998035864271
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6634832998035864266}
m_CullTransparentMesh: 1
--- !u!114 &6634832998035864270
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0} m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4290235790731771760} m_GameObject: {fileID: 6634832998035864266}
m_Enabled: 1 m_Enabled: 1
m_EditorHideFlags: 0 m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4455696a3efdf814b87c6437a9202967, type: 3} m_Script: {fileID: 11500000, guid: 5c5f5b343424dcf418dec07a24e1e6bd, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
scoreText: {fileID: 4290235790453130571} scoreText: {fileID: 6634832997822410799}

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 55f88c84fe939f54b897e6afb2e26cbf guid: 68d36a24cad029f4a91d5c8e7aa18281
PrefabImporter: PrefabImporter:
externalObjects: {} externalObjects: {}
userData: userData:

File diff suppressed because it is too large Load Diff

View File

@ -13,6 +13,6 @@ MonoBehaviour:
m_Name: PlayerData m_Name: PlayerData
m_EditorClassIdentifier: m_EditorClassIdentifier:
<InvincibilityTime>k__BackingField: 3 <InvincibilityTime>k__BackingField: 3
<JumpHeight>k__BackingField: 5 <JumpHeight>k__BackingField: 5.3
<LaneSwitchSpeed>k__BackingField: 25 <LaneSwitchSpeed>k__BackingField: 25
<Speed>k__BackingField: 20 <Speed>k__BackingField: 20

View File

@ -1,19 +1,25 @@
using System.Collections; using System.Collections;
using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using UnityEngine.SceneManagement;
public class GameSession : MonoBehaviour,IResettable
public class GameSession : MonoBehaviour
{ {
public InputTranslator<KeyBinding> InputTranslator; private InputTranslator<KeyBinding> InputTranslator;
public static GameSession Instance { get; private set; } public static GameSession Instance { get; private set; }
[SerializeField] private Player currentPlayer;
private void Awake() private void Awake()
{ {
Instance = this; Instance = this;
Init(); Init();
} }
private void Update()
{
InputTranslator.Tick();
}
private void Init() private void Init()
{ {
InputTranslator = new InputTranslator<KeyBinding>(); InputTranslator = new InputTranslator<KeyBinding>();
@ -21,8 +27,32 @@ public class GameSession : MonoBehaviour
InputTranslator.Init(holder); InputTranslator.Init(holder);
} }
private void Update() public void AddCommandTranslator(ICommandTranslator translator)
{ {
InputTranslator.Tick(); InputTranslator.AddCommandTranslator(translator);
}
public void PauseSession(bool isPaused)
{
Time.timeScale = isPaused ? 0 : 1;
List<ECommand> commands = new List<ECommand>();
ECommand[] commandRange = { ECommand.LEFT,ECommand.RIGHT,ECommand.UP,ECommand.DOWN,ECommand.SHOOT};
commands.AddRange(commandRange);
InputTranslator.RestictTranslation(commands,isPaused);
}
public void RestartSession()
{
SceneManager.LoadScene("GameScene", LoadSceneMode.Single);
ResetToDefault();
}
public void GoToMainMenu()
{
SceneManager.LoadScene("MainMenu", LoadSceneMode.Single);
ResetToDefault();
}
public void ResetToDefault()
{
PauseSession(false);
currentPlayer.ResetToDefault();
} }
} }

View File

@ -14,7 +14,8 @@ public class KeyBindingHolder : IBindingHolder<KeyBinding>
{ECommand.UP, new KeyBinding(KeyCode.UpArrow,KeyCode.W)}, {ECommand.UP, new KeyBinding(KeyCode.UpArrow,KeyCode.W)},
{ECommand.LEFT, new KeyBinding(KeyCode.LeftArrow,KeyCode.A)}, {ECommand.LEFT, new KeyBinding(KeyCode.LeftArrow,KeyCode.A)},
{ECommand.RIGHT, new KeyBinding(KeyCode.RightArrow,KeyCode.D)}, {ECommand.RIGHT, new KeyBinding(KeyCode.RightArrow,KeyCode.D)},
{ECommand.OPEN_SCOREBOARD, new KeyBinding(KeyCode.Tab)} {ECommand.OPEN_SCOREBOARD, new KeyBinding(KeyCode.Tab)},
{ECommand.OPEN_PAUSE_MENU, new KeyBinding(KeyCode.Escape)}
}; };
public void Init() public void Init()

View File

@ -5,4 +5,5 @@ public interface IBinding
{ {
public bool IsPressed { get; } public bool IsPressed { get; }
public bool IsReleased { get; } public bool IsReleased { get; }
public bool IsRestricted { get; set; }
} }

View File

@ -6,11 +6,13 @@ public class KeyBinding : IBinding
private KeyCode alternativeKeyBinding; private KeyCode alternativeKeyBinding;
public bool IsPressed => Input.GetKeyDown(keyBinding) || Input.GetKeyDown(alternativeKeyBinding); public bool IsPressed => Input.GetKeyDown(keyBinding) || Input.GetKeyDown(alternativeKeyBinding);
public bool IsReleased => Input.GetKeyUp(keyBinding) || Input.GetKeyUp(alternativeKeyBinding); public bool IsReleased => Input.GetKeyUp(keyBinding) || Input.GetKeyUp(alternativeKeyBinding);
public bool IsRestricted { get; set; }
public KeyBinding(KeyCode key,KeyCode alternative = KeyCode.None) public KeyBinding(KeyCode key,KeyCode alternative = KeyCode.None)
{ {
keyBinding = key; keyBinding = key;
alternativeKeyBinding = alternative; alternativeKeyBinding = alternative;
IsRestricted = false;
} }
public void UpdateBinding(KeyCode key) public void UpdateBinding(KeyCode key)

View File

@ -7,5 +7,6 @@ public enum ECommand
UP = 3, UP = 3,
DOWN = 4, DOWN = 4,
OPEN_SCOREBOARD = 5, OPEN_SCOREBOARD = 5,
SHOOT = 6 SHOOT = 6,
OPEN_PAUSE_MENU = 7
} }

View File

@ -4,6 +4,7 @@ public class InputTranslator<T> where T : IBinding
{ {
private List<ICommandTranslator> commandTranslators; private List<ICommandTranslator> commandTranslators;
private IBindingHolder<T> bindingHolder; private IBindingHolder<T> bindingHolder;
private bool isTranslating = true;
public void Init(IBindingHolder<T> holder) public void Init(IBindingHolder<T> holder)
{ {
@ -26,8 +27,20 @@ public class InputTranslator<T> where T : IBinding
commandTranslators.Remove(translator); commandTranslators.Remove(translator);
} }
public void RestictTranslation(List<ECommand> commands, bool isRestricted)
{
foreach (var keyBinding in bindingHolder.InputBindings)
{
if (commands.Contains(keyBinding.Key))
{
keyBinding.Value.IsRestricted = isRestricted;
}
}
}
public void Tick() public void Tick()
{ {
if (!isTranslating)
return;
if (commandTranslators.Count == 0) if (commandTranslators.Count == 0)
return; return;
@ -35,6 +48,8 @@ public class InputTranslator<T> where T : IBinding
foreach (var keyBinding in bindingHolder.InputBindings) foreach (var keyBinding in bindingHolder.InputBindings)
{ {
if (keyBinding.Value.IsRestricted)
continue;
if (keyBinding.Value.IsPressed) if (keyBinding.Value.IsPressed)
commands.Add(keyBinding.Key, new PressedState(keyBinding.Value.IsPressed, keyBinding.Value.IsReleased)); commands.Add(keyBinding.Key, new PressedState(keyBinding.Value.IsPressed, keyBinding.Value.IsReleased));
if (keyBinding.Value.IsReleased) if (keyBinding.Value.IsReleased)

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: f64d9358868bc0446b724397a1121308
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,27 @@
using System.Collections;
using UnityEngine;
public class Pause : MonoBehaviour,ICommandTranslator
{
private bool isOpened = false;
private void Start()
{
GameSession.Instance.AddCommandTranslator(this);
}
public void TranslateCommand(ECommand command, PressedState state)
{
if (state.IsPressed == true)
{
switch (command)
{
case ECommand.OPEN_PAUSE_MENU:
isOpened = isOpened ? false : true;
ViewManager.Instance.Show<PausedView>(isOpened);
GameSession.Instance.PauseSession(isOpened);
break;
}
}
}
}

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 971587f518b0d594a95bd841dd258b6e guid: 6283c0dac8dcd214093c89fbf6a2e55c
MonoImporter: MonoImporter:
externalObjects: {} externalObjects: {}
serializedVersion: 2 serializedVersion: 2

View File

@ -24,8 +24,6 @@ public class Health : MonoBehaviour, IDamageable,IHealable, IResettable
{ {
public int MaxHealth { get; private set; } public int MaxHealth { get; private set; }
public int CurrentHealth { get; private set; } public int CurrentHealth { get; private set; }
public bool IsInvincible { get; private set; }
public float InvincibilityTime { get; private set; } //PLAYER DATA ScriptableObject
[SerializeField] private HeartsBarView healthBarView; [SerializeField] private HeartsBarView healthBarView;
@ -34,7 +32,6 @@ public class Health : MonoBehaviour, IDamageable,IHealable, IResettable
public event Action OnOutOfHealth; public event Action OnOutOfHealth;
private int defaultMaxLives = 4;//PLAYER DATA ScriptableObject private int defaultMaxLives = 4;//PLAYER DATA ScriptableObject
private float defaultInvincibilityTime = 2.5f;//PLAYER DATA ScriptableObject
void Awake() void Awake()
{ {
MaxHealth = 4; MaxHealth = 4;
@ -60,17 +57,10 @@ public class Health : MonoBehaviour, IDamageable,IHealable, IResettable
OnHealthChanged(this, healthArgs.GetUpdatedArgs(CurrentHealth, MaxHealth)); OnHealthChanged(this, healthArgs.GetUpdatedArgs(CurrentHealth, MaxHealth));
healthBarView.UpdateHealthBar(this, healthArgs.GetUpdatedArgs(CurrentHealth, MaxHealth)); healthBarView.UpdateHealthBar(this, healthArgs.GetUpdatedArgs(CurrentHealth, MaxHealth));
} }
public IEnumerator GrantInvincibility()
{
IsInvincible = true;
yield return new WaitForSeconds(InvincibilityTime);
IsInvincible = false;
}
public void ResetToDefault() public void ResetToDefault()
{ {
MaxHealth = defaultMaxLives; // PlayerData.MaxHealth MaxHealth = defaultMaxLives; // PlayerData.MaxHealth
CurrentHealth = MaxHealth; CurrentHealth = MaxHealth;
InvincibilityTime = defaultInvincibilityTime; //PlayerData/InvincibilityTimer
OnHealthChanged(this, healthArgs.GetUpdatedArgs(CurrentHealth, MaxHealth)); OnHealthChanged(this, healthArgs.GetUpdatedArgs(CurrentHealth, MaxHealth));
healthBarView.UpdateHealthBar(this, healthArgs.GetUpdatedArgs(CurrentHealth, MaxHealth)); healthBarView.UpdateHealthBar(this, healthArgs.GetUpdatedArgs(CurrentHealth, MaxHealth));
} }

View File

@ -1,9 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public interface IHealth
{
public void TakeDamage();
public void Heal();
}

View File

@ -47,7 +47,7 @@ public class Player : MonoBehaviour,IResettable, ICommandTranslator
private void Awake() private void Awake()
{ {
GameSession.Instance.InputTranslator.AddCommandTranslator(this); GameSession.Instance.AddCommandTranslator(this);
animator = GetComponent<Animator>(); animator = GetComponent<Animator>();
if (animator) if (animator)
PlayerAnimator = new PlayerAnimator(animator); PlayerAnimator = new PlayerAnimator(animator);
@ -129,37 +129,6 @@ public class Player : MonoBehaviour,IResettable, ICommandTranslator
Physics.SyncTransforms(); Physics.SyncTransforms();
ReloadAnimator(); ReloadAnimator();
} }
public void RestartSession()
{
SceneManager.LoadScene("GameScene", LoadSceneMode.Single);
ResetToDefault();
}
public void GoToMainMenu()
{
SceneManager.LoadScene("MainMenu", LoadSceneMode.Single);
ResetToDefault();
}
public void TranslateCommand(ECommand command)
{
switch (command)
{
case ECommand.RIGHT:
PlayerStateMachine.IncreaseTargetLane();
break;
case ECommand.LEFT:
PlayerStateMachine.DecreaseTargetLane();
break;
case ECommand.UP:
PlayerStateMachine.SetState(PlayerStateMachine.PlayerJumpState);
break;
case ECommand.DOWN:
PlayerStateMachine.SetState(PlayerStateMachine.PlayerSlideState);
break;
default:
break;
}
}
public void TranslateCommand(ECommand command, PressedState state) public void TranslateCommand(ECommand command, PressedState state)
{ {

View File

@ -12,7 +12,7 @@ public class Statistics : MonoBehaviour,IResettable
public event Action<int> OnCoinCountChanged = delegate { }; public event Action<int> OnCoinCountChanged = delegate { };
public event Action<float> OnDistanceChanged = delegate { }; public event Action<float> OnDistanceChanged = delegate { };
public event Action<int> OnScoreCalculated = delegate { }; public event Action<int> OnScoreCalculated = delegate { };
[SerializeField] PlayerScoreView PlayerHUD; [SerializeField] private PlayerHUDView PlayerHUD;
private void Awake() private void Awake()
{ {
ResetToDefault(); ResetToDefault();

View File

@ -20,7 +20,7 @@ public class Scoreboard : MonoBehaviour, ICommandTranslator
} }
private void Start() private void Start()
{ {
GameSession.Instance.InputTranslator.AddCommandTranslator(this); GameSession.Instance.AddCommandTranslator(this);
string jsonScoreboardEntries = PlayerPrefs.GetString("ScoreboardEntriesTableT1"); //Binary file string jsonScoreboardEntries = PlayerPrefs.GetString("ScoreboardEntriesTableT1"); //Binary file
ScoreboardEntriesTable entriesTable = JsonUtility.FromJson<ScoreboardEntriesTable>(jsonScoreboardEntries); ScoreboardEntriesTable entriesTable = JsonUtility.FromJson<ScoreboardEntriesTable>(jsonScoreboardEntries);
if (entriesTable == null) if (entriesTable == null)

View File

@ -0,0 +1,31 @@
using System.Collections;
using UnityEngine;
using UnityEngine.UI;
public class PausedView : BaseView
{
[SerializeField] private Button resumeButton;
[SerializeField] private Button mainMenuButton;
[SerializeField] private Button restartButton;
public override void Init()
{
resumeButton.onClick.AddListener(() =>
{
GameSession.Instance.PauseSession(false);
Show(false);
});
//mainMenuButton.onClick.AddListener(() =>
//{
//});
restartButton.onClick.AddListener(() =>
{
GameSession.Instance.RestartSession();
});
base.Init();
}
}

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 4455696a3efdf814b87c6437a9202967 guid: 36a98ac82a5f2d34cad6a17cd8b178b8
MonoImporter: MonoImporter:
externalObjects: {} externalObjects: {}
serializedVersion: 2 serializedVersion: 2

View File

@ -1,9 +1,10 @@
using System.Collections; using System.Collections;
using TMPro; using TMPro;
using UnityEngine; using UnityEngine;
using UnityEngine.UI;
[RequireComponent(typeof(RectTransform))] [RequireComponent(typeof(RectTransform))]
public class PlayerScoreView : BaseView public class PlayerHUDView : BaseView
{ {
[SerializeField] private TMP_Text scoreText; [SerializeField] private TMP_Text scoreText;
public override void Init() public override void Init()

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 5c5f5b343424dcf418dec07a24e1e6bd
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -11,7 +11,6 @@ public struct PlayerScoreboardCardData
this.playerScore = playerScore; this.playerScore = playerScore;
} }
} }
public class PlayerScoreboardCard : MonoBehaviour public class PlayerScoreboardCard : MonoBehaviour
{ {
[SerializeField] private TextMeshProUGUI playerName; [SerializeField] private TextMeshProUGUI playerName;

View File

@ -3,16 +3,9 @@ using UnityEngine;
public class ScoreboardView : BaseView public class ScoreboardView : BaseView
{ {
//public static ScoreboardView Instance { get; private set; } [SerializeField] private PlayerScoreboardCard cardPrefab;
[SerializeField] PlayerScoreboardCard cardPrefab;
private readonly Dictionary<string,PlayerScoreboardCard> playerCards = new Dictionary<string, PlayerScoreboardCard>(); private readonly Dictionary<string,PlayerScoreboardCard> playerCards = new Dictionary<string, PlayerScoreboardCard>();
private void Awake()
{
//Instance = this;
}
public void AddPlayerCards(List<PlayerScoreboardCardData> cardsData) public void AddPlayerCards(List<PlayerScoreboardCardData> cardsData)
{ {
foreach (var cardData in cardsData) foreach (var cardData in cardsData)

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

View File

@ -0,0 +1,158 @@
fileFormatVersion: 2
guid: 4b9b93b089a2d304a87402fde2bea669
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 11
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMasterTextureLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 1
wrapV: 1
wrapW: 0
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Server
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Android
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: WebGL
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Windows Store Apps
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID: 5e97eb03825dee720800000000000000
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
nameFileIdTable: {}
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long