From 4549d17204e6424dd470fbe80e51fff4299ed160 Mon Sep 17 00:00:00 2001 From: Jan Date: Mon, 23 Apr 2018 13:35:56 +0200 Subject: [PATCH] add win UI --- Assets/Prefabs/UI.prefab | 7 ++++--- Assets/Scenes/CodeDEV.unity | 32 +++++++++++++++++++++++++++++++- Assets/Scripts/UIController.cs | 19 ++++++++++++++----- 3 files changed, 49 insertions(+), 9 deletions(-) diff --git a/Assets/Prefabs/UI.prefab b/Assets/Prefabs/UI.prefab index c6cd3dd..a011cfe 100644 --- a/Assets/Prefabs/UI.prefab +++ b/Assets/Prefabs/UI.prefab @@ -108,7 +108,7 @@ GameObject: - component: {fileID: 222889581033239706} - component: {fileID: 114750232192698844} m_Layer: 5 - m_Name: GameOverPanel + m_Name: RestartPanel m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 @@ -760,8 +760,9 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: notifications: {fileID: 114700265308343224} - gameOverPanel: {fileID: 1604998495297016} + restartUIPanel: {fileID: 1604998495297016} healthcontroller: {fileID: 114617351635937986} + mainMenuSceneIndex: 0 --- !u!114 &114930219842054174 MonoBehaviour: m_ObjectHideFlags: 1 @@ -1058,7 +1059,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 64.16286, y: 0} + m_AnchoredPosition: {x: 66.396866, y: 0} m_SizeDelta: {x: 0, y: 0} m_Pivot: {x: 1, y: 0.5} --- !u!224 &224218339018349506 diff --git a/Assets/Scenes/CodeDEV.unity b/Assets/Scenes/CodeDEV.unity index 45a2f30..1f71103 100644 --- a/Assets/Scenes/CodeDEV.unity +++ b/Assets/Scenes/CodeDEV.unity @@ -497,6 +497,17 @@ Prefab: propertyPath: m_IsActive value: 0 objectReference: {fileID: 0} + - target: {fileID: 114835806183609276, guid: 3d1911457c1e44f53b6b4044334db52f, + type: 2} + propertyPath: bulletSpawn + value: + objectReference: {fileID: 2032758561} + - target: {fileID: 114835806183609276, guid: 3d1911457c1e44f53b6b4044334db52f, + type: 2} + propertyPath: bulletPrefab + value: + objectReference: {fileID: 1379543051791382, guid: c6c321ecc6516374781405a54c1fa6a7, + type: 2} m_RemovedComponents: [] m_ParentPrefab: {fileID: 100100000, guid: 3d1911457c1e44f53b6b4044334db52f, type: 2} m_IsPrefabParent: 0 @@ -840,7 +851,7 @@ Prefab: - target: {fileID: 224150154901314796, guid: 460d856ea4eb14cedb5fecde1fe6d743, type: 2} propertyPath: m_AnchoredPosition.x - value: 64.16286 + value: 66.396866 objectReference: {fileID: 0} - target: {fileID: 224150154901314796, guid: 460d856ea4eb14cedb5fecde1fe6d743, type: 2} @@ -872,6 +883,15 @@ Prefab: propertyPath: m_SizeDelta.x value: 0 objectReference: {fileID: 0} + - target: {fileID: 1604998495297016, guid: 460d856ea4eb14cedb5fecde1fe6d743, type: 2} + propertyPath: m_Name + value: RestartPanel + objectReference: {fileID: 0} + - target: {fileID: 114917026543374048, guid: 460d856ea4eb14cedb5fecde1fe6d743, + type: 2} + propertyPath: restartUIPanel + value: + objectReference: {fileID: 1755791938} m_RemovedComponents: [] m_ParentPrefab: {fileID: 100100000, guid: 460d856ea4eb14cedb5fecde1fe6d743, type: 2} m_IsPrefabParent: 0 @@ -1074,6 +1094,11 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 3 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &1755791938 stripped +GameObject: + m_PrefabParentObject: {fileID: 1604998495297016, guid: 460d856ea4eb14cedb5fecde1fe6d743, + type: 2} + m_PrefabInternal: {fileID: 1379476068} --- !u!1 &1908750961 GameObject: m_ObjectHideFlags: 0 @@ -1199,6 +1224,11 @@ AudioSource: m_PreInfinity: 2 m_PostInfinity: 2 m_RotationOrder: 4 +--- !u!4 &2032758561 stripped +Transform: + m_PrefabParentObject: {fileID: 4676354101874032, guid: 3d1911457c1e44f53b6b4044334db52f, + type: 2} + m_PrefabInternal: {fileID: 865504979} --- !u!1 &2063368131 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/UIController.cs b/Assets/Scripts/UIController.cs index 337b61d..6cc50fa 100644 --- a/Assets/Scripts/UIController.cs +++ b/Assets/Scripts/UIController.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement; +using UnityEngine.UI; public class UIController : MonoBehaviour { @@ -13,7 +14,7 @@ public class UIController : MonoBehaviour NotificationManager notifications; [SerializeField] - GameObject gameOverPanel; + GameObject restartUIPanel; [SerializeField] HealthbarController healthcontroller; @@ -48,12 +49,20 @@ public class UIController : MonoBehaviour } public void ShowGameOverUI() { - if (gameOverPanel != null) { - Debug.Log("Loaded Canvas"); - gameOverPanel.SetActive(true); + ShowRestartUI(false); + } + public void ShowWinUI() { + ShowRestartUI(true); + } + + void ShowRestartUI(bool won) { + string headerText = won ? "You won!" : "Game Over"; + if (restartUIPanel != null) { + restartUIPanel.SetActive(true); + restartUIPanel.GetComponent().text = headerText; } else { - Debug.Log("No game over panel assigned"); + Debug.Log("No restart panel assigned"); } }