Added death text

This commit is contained in:
MartinRemi 2015-11-30 18:46:24 -05:00
parent 86f815f3b2
commit c19bf50e2f
2 changed files with 86 additions and 0 deletions

View File

@ -144,6 +144,7 @@ RectTransform:
m_Children: m_Children:
- {fileID: 1972685053} - {fileID: 1972685053}
- {fileID: 1113329688} - {fileID: 1113329688}
- {fileID: 481658569}
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 6 m_RootOrder: 6
m_AnchorMin: {x: 0, y: 0} m_AnchorMin: {x: 0, y: 0}
@ -259,6 +260,78 @@ Transform:
m_Children: [] m_Children: []
m_Father: {fileID: 645992365} m_Father: {fileID: 645992365}
m_RootOrder: 0 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 --- !u!1 &645992364
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -446,6 +519,14 @@ Prefab:
propertyPath: m_RootOrder propertyPath: m_RootOrder
value: 2 value: 2
objectReference: {fileID: 0} 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_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: b7819e17682d74b45a71d6831a413e0b, type: 2} m_ParentPrefab: {fileID: 100100000, guid: b7819e17682d74b45a71d6831a413e0b, type: 2}
m_IsPrefabParent: 0 m_IsPrefabParent: 0

View File

@ -1,5 +1,6 @@
using UnityEngine; using UnityEngine;
using System.Collections; using System.Collections;
using UnityEngine.UI;
public class PlayerBehavior : MonoBehaviour public class PlayerBehavior : MonoBehaviour
{ {
@ -21,6 +22,8 @@ public class PlayerBehavior : MonoBehaviour
private Animator anim; private Animator anim;
private bool facingRight = true; private bool facingRight = true;
public Text deathText;
// Use this for initialization // Use this for initialization
void Start() void Start()
{ {
@ -89,10 +92,12 @@ public class PlayerBehavior : MonoBehaviour
{ {
Application.LoadLevel(Application.loadedLevelName); Application.LoadLevel(Application.loadedLevelName);
Time.timeScale = 1f; Time.timeScale = 1f;
deathText.text = "";
} }
public void Death() public void Death()
{ {
deathText.text = "You died";
StartCoroutine(ResetAfterSeconds(5)); StartCoroutine(ResetAfterSeconds(5));
Time.timeScale = 0f; Time.timeScale = 0f;
} }