From c19bf50e2fa6d283ee401098017fa79101abff91 Mon Sep 17 00:00:00 2001 From: MartinRemi Date: Mon, 30 Nov 2015 18:46:24 -0500 Subject: [PATCH] Added death text --- Assets/Scenes/MasterScene.unity | 81 ++++++++++++++++++++++++++++++++ Assets/Scripts/PlayerBehavior.cs | 5 ++ 2 files changed, 86 insertions(+) diff --git a/Assets/Scenes/MasterScene.unity b/Assets/Scenes/MasterScene.unity index 08926fb..580f9e1 100644 --- a/Assets/Scenes/MasterScene.unity +++ b/Assets/Scenes/MasterScene.unity @@ -144,6 +144,7 @@ RectTransform: m_Children: - {fileID: 1972685053} - {fileID: 1113329688} + - {fileID: 481658569} m_Father: {fileID: 0} m_RootOrder: 6 m_AnchorMin: {x: 0, y: 0} @@ -259,6 +260,78 @@ Transform: m_Children: [] m_Father: {fileID: 645992365} m_RootOrder: 0 +--- !u!1 &481658568 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 224: {fileID: 481658569} + - 222: {fileID: 481658571} + - 114: {fileID: 481658570} + m_Layer: 5 + m_Name: DeathText + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &481658569 +RectTransform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 481658568} + 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_Children: [] + m_Father: {fileID: 237529558} + m_RootOrder: 2 + m_AnchorMin: {x: .5, y: .5} + m_AnchorMax: {x: .5, y: .5} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 100, y: 100} + m_Pivot: {x: .5, y: .5} +--- !u!114 &481658570 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 481658568} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 708705254, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, + Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 14 + m_FontStyle: 0 + m_BestFit: 0 + m_MinSize: 10 + m_MaxSize: 40 + m_Alignment: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: +--- !u!222 &481658571 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 481658568} --- !u!1 &645992364 GameObject: m_ObjectHideFlags: 0 @@ -446,6 +519,14 @@ Prefab: propertyPath: m_RootOrder value: 2 objectReference: {fileID: 0} + - target: {fileID: 11413024, guid: b7819e17682d74b45a71d6831a413e0b, type: 2} + propertyPath: death + value: + objectReference: {fileID: 0} + - target: {fileID: 11413024, guid: b7819e17682d74b45a71d6831a413e0b, type: 2} + propertyPath: deathText + value: + objectReference: {fileID: 481658570} m_RemovedComponents: [] m_ParentPrefab: {fileID: 100100000, guid: b7819e17682d74b45a71d6831a413e0b, type: 2} m_IsPrefabParent: 0 diff --git a/Assets/Scripts/PlayerBehavior.cs b/Assets/Scripts/PlayerBehavior.cs index 8f92a29..2a6e535 100644 --- a/Assets/Scripts/PlayerBehavior.cs +++ b/Assets/Scripts/PlayerBehavior.cs @@ -1,5 +1,6 @@ using UnityEngine; using System.Collections; +using UnityEngine.UI; public class PlayerBehavior : MonoBehaviour { @@ -21,6 +22,8 @@ public class PlayerBehavior : MonoBehaviour private Animator anim; private bool facingRight = true; + public Text deathText; + // Use this for initialization void Start() { @@ -89,10 +92,12 @@ public class PlayerBehavior : MonoBehaviour { Application.LoadLevel(Application.loadedLevelName); Time.timeScale = 1f; + deathText.text = ""; } public void Death() { + deathText.text = "You died"; StartCoroutine(ResetAfterSeconds(5)); Time.timeScale = 0f; }