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: 2152024136797500473}
|
||||||
- component: {fileID: 936482196064115039}
|
- component: {fileID: 936482196064115039}
|
||||||
- component: {fileID: 826719949318333507}
|
- component: {fileID: 826719949318333507}
|
||||||
|
- component: {fileID: 2684488013186753063}
|
||||||
m_Layer: 5
|
m_Layer: 5
|
||||||
m_Name: PreStageUI
|
m_Name: PreStageUI
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
|
@ -253,3 +254,15 @@ MonoBehaviour:
|
||||||
m_BlockingMask:
|
m_BlockingMask:
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_Bits: 4294967295
|
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_Father: {fileID: 0}
|
||||||
m_RootOrder: 5
|
m_RootOrder: 5
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
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
|
--- !u!4 &1352658977 stripped
|
||||||
Transform:
|
Transform:
|
||||||
m_CorrespondingSourceObject: {fileID: 6843575828445418654, guid: d3055091a17dc4aa1accf2e33ccef144,
|
m_CorrespondingSourceObject: {fileID: 6843575828445418654, guid: d3055091a17dc4aa1accf2e33ccef144,
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
|
using src.Managers;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace src.Helpers
|
namespace src.Helpers
|
||||||
{
|
{
|
||||||
public static class ApplicationActions
|
public static class ApplicationActions
|
||||||
{
|
{
|
||||||
public static bool IsGamePaused { get; private set; }
|
private static GameStateManager _gameStateManager = GameStateManager.Instance;
|
||||||
|
|
||||||
public static void QuitGame()
|
public static void QuitGame()
|
||||||
{
|
{
|
||||||
|
@ -13,19 +14,19 @@ namespace src.Helpers
|
||||||
|
|
||||||
public static void PauseGame()
|
public static void PauseGame()
|
||||||
{
|
{
|
||||||
IsGamePaused = true;
|
_gameStateManager.IsGamePaused = true;
|
||||||
Time.timeScale = 0f;
|
Time.timeScale = 0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void UnpauseGame()
|
public static void UnpauseGame()
|
||||||
{
|
{
|
||||||
IsGamePaused = false;
|
_gameStateManager.IsGamePaused = false;
|
||||||
Time.timeScale = 1f;
|
Time.timeScale = 1f;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void HandlePauseKey()
|
public static void HandlePauseKey()
|
||||||
{
|
{
|
||||||
if (IsGamePaused)
|
if (_gameStateManager.IsGamePaused)
|
||||||
{
|
{
|
||||||
UnpauseGame();
|
UnpauseGame();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using src.Helpers;
|
using System.Collections;
|
||||||
|
using src.Helpers;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace src.Managers
|
namespace src.Managers
|
||||||
|
@ -9,6 +10,7 @@ namespace src.Managers
|
||||||
private LevelManager _levelManager;
|
private LevelManager _levelManager;
|
||||||
private UpgradeManager _upgradeManager;
|
private UpgradeManager _upgradeManager;
|
||||||
private BombsUtilManager _bombsUtilManager;
|
private BombsUtilManager _bombsUtilManager;
|
||||||
|
private GameObject _preStageUi;
|
||||||
|
|
||||||
public void Awake()
|
public void Awake()
|
||||||
{
|
{
|
||||||
|
@ -27,7 +29,12 @@ namespace src.Managers
|
||||||
_levelManager = GetComponent<LevelManager>();
|
_levelManager = GetComponent<LevelManager>();
|
||||||
_upgradeManager = GetComponent<UpgradeManager>();
|
_upgradeManager = GetComponent<UpgradeManager>();
|
||||||
_bombsUtilManager = BombsUtilManager.Instance;
|
_bombsUtilManager = BombsUtilManager.Instance;
|
||||||
|
_preStageUi = GameObject.Find("PreStageUI");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Start()
|
||||||
|
{
|
||||||
|
StartCoroutine(PreInitGame());
|
||||||
InitGame();
|
InitGame();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,6 +52,12 @@ namespace src.Managers
|
||||||
{
|
{
|
||||||
_levelManager.InitLevel();
|
_levelManager.InitLevel();
|
||||||
}
|
}
|
||||||
|
private IEnumerator PreInitGame()
|
||||||
|
{
|
||||||
|
_preStageUi.SetActive(true);
|
||||||
|
yield return new WaitForSeconds(0.7f);
|
||||||
|
_preStageUi.SetActive(false);
|
||||||
|
}
|
||||||
|
|
||||||
private void Update()
|
private void Update()
|
||||||
{
|
{
|
||||||
|
@ -55,7 +68,6 @@ namespace src.Managers
|
||||||
{
|
{
|
||||||
if (Input.GetKeyDown(KeyCode.Escape))
|
if (Input.GetKeyDown(KeyCode.Escape))
|
||||||
{
|
{
|
||||||
Application.Quit();
|
|
||||||
ApplicationActions.QuitGame();
|
ApplicationActions.QuitGame();
|
||||||
}
|
}
|
||||||
else if (Input.GetKeyDown(KeyCode.P))
|
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.Base;
|
||||||
using src.Helpers;
|
using src.Helpers;
|
||||||
using src.Interfaces;
|
using src.Interfaces;
|
||||||
|
using src.Managers;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityStandardAssets.CrossPlatformInput;
|
using UnityStandardAssets.CrossPlatformInput;
|
||||||
|
|
||||||
|
@ -9,6 +10,7 @@ namespace src.Player
|
||||||
{
|
{
|
||||||
public class PlayerController : PlayerBase
|
public class PlayerController : PlayerBase
|
||||||
{
|
{
|
||||||
|
private GameStateManager _gameStateManager = GameStateManager.Instance;
|
||||||
private Transform _respawnPosition;
|
private Transform _respawnPosition;
|
||||||
private BombsSpawner _bombsSpawner;
|
private BombsSpawner _bombsSpawner;
|
||||||
private Animator _animator;
|
private Animator _animator;
|
||||||
|
@ -35,13 +37,13 @@ namespace src.Player
|
||||||
|
|
||||||
private void FixedUpdate()
|
private void FixedUpdate()
|
||||||
{
|
{
|
||||||
if (ApplicationActions.IsGamePaused) {return;}
|
if (_gameStateManager.IsGamePaused) {return;}
|
||||||
HandleMovement();
|
HandleMovement();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Update()
|
private void Update()
|
||||||
{
|
{
|
||||||
if (ApplicationActions.IsGamePaused) {return;}
|
if (_gameStateManager.IsGamePaused) {return;}
|
||||||
HandleBomb();
|
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