Implement pre init game
This commit is contained in:
parent
93f2a11e69
commit
823025e7c8
12 changed files with 226 additions and 9 deletions
|
@ -165,6 +165,7 @@ GameObject:
|
|||
- component: {fileID: 2152024136797500473}
|
||||
- component: {fileID: 936482196064115039}
|
||||
- component: {fileID: 826719949318333507}
|
||||
- component: {fileID: 2684488013186753063}
|
||||
m_Layer: 5
|
||||
m_Name: PreStageUI
|
||||
m_TagString: Untagged
|
||||
|
@ -253,3 +254,15 @@ MonoBehaviour:
|
|||
m_BlockingMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
--- !u!114 &2684488013186753063
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 4994633962466276707}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: a89bdde63eb80ad41bb0e1472e665667, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
|
|
|
@ -480,6 +480,140 @@ Transform:
|
|||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 5
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1001 &1152312890
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
m_Modification:
|
||||
m_TransformParent: {fileID: 0}
|
||||
m_Modifications:
|
||||
- target: {fileID: 4994633962466276707, guid: 1f5ebc13237e070449ea8bc9e8b07ac8,
|
||||
type: 3}
|
||||
propertyPath: m_Name
|
||||
value: PreStageUI
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7935883257743492533, guid: 1f5ebc13237e070449ea8bc9e8b07ac8,
|
||||
type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7935883257743492533, guid: 1f5ebc13237e070449ea8bc9e8b07ac8,
|
||||
type: 3}
|
||||
propertyPath: m_LocalPosition.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7935883257743492533, guid: 1f5ebc13237e070449ea8bc9e8b07ac8,
|
||||
type: 3}
|
||||
propertyPath: m_LocalPosition.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7935883257743492533, guid: 1f5ebc13237e070449ea8bc9e8b07ac8,
|
||||
type: 3}
|
||||
propertyPath: m_LocalRotation.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7935883257743492533, guid: 1f5ebc13237e070449ea8bc9e8b07ac8,
|
||||
type: 3}
|
||||
propertyPath: m_LocalRotation.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7935883257743492533, guid: 1f5ebc13237e070449ea8bc9e8b07ac8,
|
||||
type: 3}
|
||||
propertyPath: m_LocalRotation.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7935883257743492533, guid: 1f5ebc13237e070449ea8bc9e8b07ac8,
|
||||
type: 3}
|
||||
propertyPath: m_LocalRotation.w
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7935883257743492533, guid: 1f5ebc13237e070449ea8bc9e8b07ac8,
|
||||
type: 3}
|
||||
propertyPath: m_RootOrder
|
||||
value: 9
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7935883257743492533, guid: 1f5ebc13237e070449ea8bc9e8b07ac8,
|
||||
type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7935883257743492533, guid: 1f5ebc13237e070449ea8bc9e8b07ac8,
|
||||
type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7935883257743492533, guid: 1f5ebc13237e070449ea8bc9e8b07ac8,
|
||||
type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7935883257743492533, guid: 1f5ebc13237e070449ea8bc9e8b07ac8,
|
||||
type: 3}
|
||||
propertyPath: m_AnchoredPosition.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7935883257743492533, guid: 1f5ebc13237e070449ea8bc9e8b07ac8,
|
||||
type: 3}
|
||||
propertyPath: m_AnchoredPosition.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7935883257743492533, guid: 1f5ebc13237e070449ea8bc9e8b07ac8,
|
||||
type: 3}
|
||||
propertyPath: m_SizeDelta.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7935883257743492533, guid: 1f5ebc13237e070449ea8bc9e8b07ac8,
|
||||
type: 3}
|
||||
propertyPath: m_SizeDelta.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7935883257743492533, guid: 1f5ebc13237e070449ea8bc9e8b07ac8,
|
||||
type: 3}
|
||||
propertyPath: m_AnchorMin.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7935883257743492533, guid: 1f5ebc13237e070449ea8bc9e8b07ac8,
|
||||
type: 3}
|
||||
propertyPath: m_AnchorMin.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7935883257743492533, guid: 1f5ebc13237e070449ea8bc9e8b07ac8,
|
||||
type: 3}
|
||||
propertyPath: m_AnchorMax.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7935883257743492533, guid: 1f5ebc13237e070449ea8bc9e8b07ac8,
|
||||
type: 3}
|
||||
propertyPath: m_AnchorMax.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7935883257743492533, guid: 1f5ebc13237e070449ea8bc9e8b07ac8,
|
||||
type: 3}
|
||||
propertyPath: m_Pivot.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7935883257743492533, guid: 1f5ebc13237e070449ea8bc9e8b07ac8,
|
||||
type: 3}
|
||||
propertyPath: m_Pivot.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2152024136797500473, guid: 1f5ebc13237e070449ea8bc9e8b07ac8,
|
||||
type: 3}
|
||||
propertyPath: m_Enabled
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2152024136797500473, guid: 1f5ebc13237e070449ea8bc9e8b07ac8,
|
||||
type: 3}
|
||||
propertyPath: m_PixelPerfect
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4935993846136593301, guid: 1f5ebc13237e070449ea8bc9e8b07ac8,
|
||||
type: 3}
|
||||
propertyPath: m_Text
|
||||
value:
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_SourcePrefab: {fileID: 100100000, guid: 1f5ebc13237e070449ea8bc9e8b07ac8, type: 3}
|
||||
--- !u!4 &1352658977 stripped
|
||||
Transform:
|
||||
m_CorrespondingSourceObject: {fileID: 6843575828445418654, guid: d3055091a17dc4aa1accf2e33ccef144,
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
using src.Managers;
|
||||
using UnityEngine;
|
||||
|
||||
namespace src.Helpers
|
||||
{
|
||||
public static class ApplicationActions
|
||||
{
|
||||
public static bool IsGamePaused { get; private set; }
|
||||
|
||||
private static GameStateManager _gameStateManager = GameStateManager.Instance;
|
||||
|
||||
public static void QuitGame()
|
||||
{
|
||||
Application.Quit();
|
||||
|
@ -13,19 +14,19 @@ namespace src.Helpers
|
|||
|
||||
public static void PauseGame()
|
||||
{
|
||||
IsGamePaused = true;
|
||||
_gameStateManager.IsGamePaused = true;
|
||||
Time.timeScale = 0f;
|
||||
}
|
||||
|
||||
public static void UnpauseGame()
|
||||
{
|
||||
IsGamePaused = false;
|
||||
_gameStateManager.IsGamePaused = false;
|
||||
Time.timeScale = 1f;
|
||||
}
|
||||
|
||||
public static void HandlePauseKey()
|
||||
{
|
||||
if (IsGamePaused)
|
||||
if (_gameStateManager.IsGamePaused)
|
||||
{
|
||||
UnpauseGame();
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using src.Helpers;
|
||||
using System.Collections;
|
||||
using src.Helpers;
|
||||
using UnityEngine;
|
||||
|
||||
namespace src.Managers
|
||||
|
@ -9,6 +10,7 @@ namespace src.Managers
|
|||
private LevelManager _levelManager;
|
||||
private UpgradeManager _upgradeManager;
|
||||
private BombsUtilManager _bombsUtilManager;
|
||||
private GameObject _preStageUi;
|
||||
|
||||
public void Awake()
|
||||
{
|
||||
|
@ -27,7 +29,12 @@ namespace src.Managers
|
|||
_levelManager = GetComponent<LevelManager>();
|
||||
_upgradeManager = GetComponent<UpgradeManager>();
|
||||
_bombsUtilManager = BombsUtilManager.Instance;
|
||||
_preStageUi = GameObject.Find("PreStageUI");
|
||||
}
|
||||
|
||||
public void Start()
|
||||
{
|
||||
StartCoroutine(PreInitGame());
|
||||
InitGame();
|
||||
}
|
||||
|
||||
|
@ -45,6 +52,12 @@ namespace src.Managers
|
|||
{
|
||||
_levelManager.InitLevel();
|
||||
}
|
||||
private IEnumerator PreInitGame()
|
||||
{
|
||||
_preStageUi.SetActive(true);
|
||||
yield return new WaitForSeconds(0.7f);
|
||||
_preStageUi.SetActive(false);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
|
@ -55,7 +68,6 @@ namespace src.Managers
|
|||
{
|
||||
if (Input.GetKeyDown(KeyCode.Escape))
|
||||
{
|
||||
Application.Quit();
|
||||
ApplicationActions.QuitGame();
|
||||
}
|
||||
else if (Input.GetKeyDown(KeyCode.P))
|
||||
|
|
15
Assets/Scripts/src/Managers/GameStateManager.cs
Normal file
15
Assets/Scripts/src/Managers/GameStateManager.cs
Normal file
|
@ -0,0 +1,15 @@
|
|||
namespace src.Managers
|
||||
{
|
||||
public class GameStateManager
|
||||
{
|
||||
public static GameStateManager Instance { get; } = new GameStateManager();
|
||||
public bool IsGamePaused { get; internal set; }
|
||||
public int Level { get; private set; } = 1;
|
||||
|
||||
|
||||
public void IncreaseLevel()
|
||||
{
|
||||
Level += 1;
|
||||
}
|
||||
}
|
||||
}
|
3
Assets/Scripts/src/Managers/GameStateManager.cs.meta
Normal file
3
Assets/Scripts/src/Managers/GameStateManager.cs.meta
Normal file
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 7038cabd5b7145d7bad2dc0d2dd1a8fe
|
||||
timeCreated: 1562425331
|
|
@ -2,6 +2,7 @@
|
|||
using src.Base;
|
||||
using src.Helpers;
|
||||
using src.Interfaces;
|
||||
using src.Managers;
|
||||
using UnityEngine;
|
||||
using UnityStandardAssets.CrossPlatformInput;
|
||||
|
||||
|
@ -9,6 +10,7 @@ namespace src.Player
|
|||
{
|
||||
public class PlayerController : PlayerBase
|
||||
{
|
||||
private GameStateManager _gameStateManager = GameStateManager.Instance;
|
||||
private Transform _respawnPosition;
|
||||
private BombsSpawner _bombsSpawner;
|
||||
private Animator _animator;
|
||||
|
@ -35,13 +37,13 @@ namespace src.Player
|
|||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
if (ApplicationActions.IsGamePaused) {return;}
|
||||
if (_gameStateManager.IsGamePaused) {return;}
|
||||
HandleMovement();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (ApplicationActions.IsGamePaused) {return;}
|
||||
if (_gameStateManager.IsGamePaused) {return;}
|
||||
HandleBomb();
|
||||
}
|
||||
|
||||
|
|
8
Assets/Scripts/src/UI.meta
Normal file
8
Assets/Scripts/src/UI.meta
Normal file
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: eedf5bc1f8ea9484cb1063e7b5db029d
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
18
Assets/Scripts/src/UI/PreLevelLoad.cs
Normal file
18
Assets/Scripts/src/UI/PreLevelLoad.cs
Normal file
|
@ -0,0 +1,18 @@
|
|||
using src.Managers;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace src.UI
|
||||
{
|
||||
public class PreLevelLoad : MonoBehaviour
|
||||
{
|
||||
private readonly GameStateManager _gameStateManager = GameStateManager.Instance;
|
||||
private Text _stageText;
|
||||
|
||||
public void Start()
|
||||
{
|
||||
_stageText = GetComponentInChildren<Text>();
|
||||
_stageText.text = $"Stage {_gameStateManager.Level}";
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/src/UI/PreLevelLoad.cs.meta
Normal file
11
Assets/Scripts/src/UI/PreLevelLoad.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a89bdde63eb80ad41bb0e1472e665667
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Reference in a new issue