Skip to content

Commit

Permalink
Game Prototype V0.23.1 Game Manager
Browse files Browse the repository at this point in the history
- Add GameOver Menu
- Fix Game State
  • Loading branch information
Kong-TH committed Feb 26, 2024
1 parent e8ef1ba commit 3ad2495
Show file tree
Hide file tree
Showing 10 changed files with 1,052 additions and 13 deletions.
869 changes: 869 additions & 0 deletions Assets/Prefabs/UI/GameOverMenu.prefab

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions Assets/Prefabs/UI/GameOverMenu.prefab.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Assets/Prefabs/UI/PauseMenu.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ MonoBehaviour:
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_text: Back to MainMenu
m_text: MainMenu
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
Expand Down Expand Up @@ -275,7 +275,7 @@ Canvas:
m_SortingBucketNormalizedSize: 0
m_AdditionalShaderChannelsFlag: 25
m_SortingLayerID: 0
m_SortingOrder: 0
m_SortingOrder: 10
m_TargetDisplay: 0
--- !u!114 &1247892556584948906
MonoBehaviour:
Expand Down Expand Up @@ -447,7 +447,7 @@ MonoBehaviour:
m_PressedTrigger: Pressed
m_SelectedTrigger: Selected
m_DisabledTrigger: Disabled
m_Interactable: 1
m_Interactable: 0
m_TargetGraphic: {fileID: 1247892556777278880}
m_OnClick:
m_PersistentCalls:
Expand Down Expand Up @@ -746,7 +746,7 @@ GameObject:
- component: {fileID: 1247892557749356140}
- component: {fileID: 1247892557749356141}
m_Layer: 5
m_Name: Back to MainMenu
m_Name: MainMenu
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
Expand Down
5 changes: 5 additions & 0 deletions Assets/Scenes/GameScene/LoginScene.unity
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,11 @@ PrefabInstance:
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 423250219549192737, guid: c6525255d3471a540a2d08ab5ff1e386,
type: 3}
propertyPath: _GI.HP
value: 25
objectReference: {fileID: 0}
- target: {fileID: 1659570200318343430, guid: c6525255d3471a540a2d08ab5ff1e386,
type: 3}
propertyPath: m_Name
Expand Down
128 changes: 126 additions & 2 deletions Assets/Scenes/UITest.unity
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ RenderSettings:
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
m_IndirectSpecularColor: {r: 262.11768, g: 324.74365, b: 429.81006, a: 1}
m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:
Expand Down Expand Up @@ -5633,7 +5633,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!65 &1186333449
BoxCollider:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -10181,6 +10181,125 @@ PrefabInstance:
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: dd27f74880ca05948922fe56b975edce, type: 3}
--- !u!1001 &2661274881376880085
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 8983843913552823907, guid: 413ddc7f38bb46645a4a16fe4ce3ba20,
type: 3}
propertyPath: m_Pivot.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8983843913552823907, guid: 413ddc7f38bb46645a4a16fe4ce3ba20,
type: 3}
propertyPath: m_Pivot.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8983843913552823907, guid: 413ddc7f38bb46645a4a16fe4ce3ba20,
type: 3}
propertyPath: m_RootOrder
value: 12
objectReference: {fileID: 0}
- target: {fileID: 8983843913552823907, guid: 413ddc7f38bb46645a4a16fe4ce3ba20,
type: 3}
propertyPath: m_AnchorMax.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8983843913552823907, guid: 413ddc7f38bb46645a4a16fe4ce3ba20,
type: 3}
propertyPath: m_AnchorMax.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8983843913552823907, guid: 413ddc7f38bb46645a4a16fe4ce3ba20,
type: 3}
propertyPath: m_AnchorMin.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8983843913552823907, guid: 413ddc7f38bb46645a4a16fe4ce3ba20,
type: 3}
propertyPath: m_AnchorMin.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8983843913552823907, guid: 413ddc7f38bb46645a4a16fe4ce3ba20,
type: 3}
propertyPath: m_SizeDelta.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8983843913552823907, guid: 413ddc7f38bb46645a4a16fe4ce3ba20,
type: 3}
propertyPath: m_SizeDelta.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8983843913552823907, guid: 413ddc7f38bb46645a4a16fe4ce3ba20,
type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8983843913552823907, guid: 413ddc7f38bb46645a4a16fe4ce3ba20,
type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8983843913552823907, guid: 413ddc7f38bb46645a4a16fe4ce3ba20,
type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8983843913552823907, guid: 413ddc7f38bb46645a4a16fe4ce3ba20,
type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 8983843913552823907, guid: 413ddc7f38bb46645a4a16fe4ce3ba20,
type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8983843913552823907, guid: 413ddc7f38bb46645a4a16fe4ce3ba20,
type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8983843913552823907, guid: 413ddc7f38bb46645a4a16fe4ce3ba20,
type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8983843913552823907, guid: 413ddc7f38bb46645a4a16fe4ce3ba20,
type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8983843913552823907, guid: 413ddc7f38bb46645a4a16fe4ce3ba20,
type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8983843913552823907, guid: 413ddc7f38bb46645a4a16fe4ce3ba20,
type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8983843913552823907, guid: 413ddc7f38bb46645a4a16fe4ce3ba20,
type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8983843913552823907, guid: 413ddc7f38bb46645a4a16fe4ce3ba20,
type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8983843913552823918, guid: 413ddc7f38bb46645a4a16fe4ce3ba20,
type: 3}
propertyPath: m_Name
value: GameOverMenu
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 413ddc7f38bb46645a4a16fe4ce3ba20, type: 3}
--- !u!1001 &3335522309377103210
PrefabInstance:
m_ObjectHideFlags: 0
Expand All @@ -10193,6 +10312,11 @@ PrefabInstance:
propertyPath: m_Name
value: NextLevelUI
objectReference: {fileID: 0}
- target: {fileID: 3879681091590505466, guid: 476a96f039cd6f0489f2cdf79df29b7e,
type: 3}
propertyPath: m_IsActive
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3879681091590505470, guid: 476a96f039cd6f0489f2cdf79df29b7e,
type: 3}
propertyPath: m_Pivot.x
Expand Down
5 changes: 4 additions & 1 deletion Assets/Scripts/Systems/Character/Player/PlayerSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,10 @@ public void OnEnterSpinWheel(Collider other)

public override void OnReviveTriggerEnter(Collider other)
{
base.OnReviveTriggerEnter(other);
if (GM.gameState == GameState.GameOver && _reviveUI != null)
_reviveUI.gameObject.SetActive(false);
else
base.OnReviveTriggerEnter(other);
}

public override void OnReviveTriggerExit(Collider other)
Expand Down
36 changes: 31 additions & 5 deletions Assets/Scripts/Systems/Manager/GameManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ public class GameManager : DontDestroy_Singleton<GameManager>
//Pause Menu
[SerializeField] private GameObject m_pauseMenu;

//GameOver Menu
[SerializeField] private GameObject m_gameOverMenu;

//Game Setting
[Header("Finding System")]
[SerializeField]
Expand Down Expand Up @@ -64,7 +67,8 @@ public class GameManager : DontDestroy_Singleton<GameManager>
private DataBaseController DBC;
private Canvas_Element_List _warningUI;
private GameObject pauseMenu;
private GameState _gameState;
private GameObject gameOverMenu;
private GameState _gameState = GameState.Playing;
private float openSceneTime = 0;

public GameInstance gameInstance
Expand Down Expand Up @@ -179,16 +183,29 @@ void Update()

UpdateTimeWarningUI(openSceneTime);

if (m_enemies.Count > 0)
_gameState = enemies.Count > 0 ? GameState.Playing : GameState.Win;

PlayerAllDown();
}

public void PlayerAllDown()
{
bool isAllPlayerDown = false;
foreach (var player in m_players)
{
_gameState = GameState.Playing;
isAllPlayerDown = player.Key.GetHP() <= 0;

if(!isAllPlayerDown)
break;
}
else

if (isAllPlayerDown)
{
_gameState = GameState.GameOver;
CreateOrOpenGameOverMenu();
}
}

public void CreateOrOpenPauseMenu()
{
if (pauseMenu == null)
Expand All @@ -201,6 +218,14 @@ public void CreateOrOpenPauseMenu()
}
}

public void CreateOrOpenGameOverMenu()
{
if (gameOverMenu == null)
gameOverMenu = Instantiate(m_gameOverMenu, Vector3.zero, quaternion.identity);
else
gameOverMenu.SetActive(true);
}

public void ResetGird()
{
_grid = new Grid((int)m_mapWidth, m_cellSize, enemies.Count);
Expand Down Expand Up @@ -278,6 +303,7 @@ private void HideWarningUI()

public void ResetGameInstance()
{
print("Reset GameInstance");
_GI = new GameInstance();
}

Expand Down
2 changes: 2 additions & 0 deletions Assets/Scripts/Systems/Manager/GameManager.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ MonoBehaviour:
secondaryAttachmentSkill: -1
m_pauseMenu: {fileID: 1247892556584948905, guid: 2ed1333d6fb01e540847d52d6ae45d5f,
type: 3}
m_gameOverMenu: {fileID: 8983843913552823918, guid: 413ddc7f38bb46645a4a16fe4ce3ba20,
type: 3}
m_players:
_serializedList: []
m_player_layer: {fileID: 0}
Expand Down
1 change: 1 addition & 0 deletions Assets/Scripts/Systems/Manager/GameState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
public enum GameState
{
Playing,
Win,
GameOver
}
}
4 changes: 3 additions & 1 deletion Assets/Scripts/Systems/UI/NextLevelUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ private void Start()

private void Update()
{
if(GM.gameState == GameState.GameOver)
if(GM.gameState == GameState.Win)
m_UI.SetActive(true);
else
m_UI.SetActive(false);
}
}
}

0 comments on commit 3ad2495

Please sign in to comment.