notification system with UI
This commit is contained in:
parent
ef8c54e9a0
commit
4119fdb2c6
5 changed files with 353 additions and 37 deletions
|
@ -448,6 +448,100 @@ CanvasRenderer:
|
|||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 216517958}
|
||||
--- !u!1 &317141282
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
serializedVersion: 5
|
||||
m_Component:
|
||||
- component: {fileID: 317141283}
|
||||
- component: {fileID: 317141286}
|
||||
- component: {fileID: 317141285}
|
||||
- component: {fileID: 317141284}
|
||||
m_Layer: 0
|
||||
m_Name: MessageUI
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &317141283
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 317141282}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 0, y: 0, z: 0}
|
||||
m_Children:
|
||||
- {fileID: 1124642283}
|
||||
m_Father: {fileID: 1487324258}
|
||||
m_RootOrder: 3
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 0, y: 0}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 0, y: 0}
|
||||
m_Pivot: {x: 0, y: 0}
|
||||
--- !u!114 &317141284
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 317141282}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 1301386320, guid: f70555f144d8491a825f0804e09c671c, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_IgnoreReversedGraphics: 1
|
||||
m_BlockingObjects: 0
|
||||
m_BlockingMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
--- !u!114 &317141285
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 317141282}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 1980459831, guid: f70555f144d8491a825f0804e09c671c, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_UiScaleMode: 0
|
||||
m_ReferencePixelsPerUnit: 100
|
||||
m_ScaleFactor: 1
|
||||
m_ReferenceResolution: {x: 800, y: 600}
|
||||
m_ScreenMatchMode: 0
|
||||
m_MatchWidthOrHeight: 0
|
||||
m_PhysicalUnit: 3
|
||||
m_FallbackScreenDPI: 96
|
||||
m_DefaultSpriteDPI: 96
|
||||
m_DynamicPixelsPerUnit: 1
|
||||
--- !u!223 &317141286
|
||||
Canvas:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 317141282}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 3
|
||||
m_RenderMode: 0
|
||||
m_Camera: {fileID: 0}
|
||||
m_PlaneDistance: 100
|
||||
m_PixelPerfect: 0
|
||||
m_ReceivesEvents: 1
|
||||
m_OverrideSorting: 0
|
||||
m_OverridePixelPerfect: 0
|
||||
m_SortingBucketNormalizedSize: 0
|
||||
m_AdditionalShaderChannelsFlag: 0
|
||||
m_SortingLayerID: 0
|
||||
m_SortingOrder: 0
|
||||
m_TargetDisplay: 0
|
||||
--- !u!1 &354516592
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -1080,6 +1174,75 @@ Canvas:
|
|||
m_SortingLayerID: 0
|
||||
m_SortingOrder: 0
|
||||
m_TargetDisplay: 0
|
||||
--- !u!1 &1124642282
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
serializedVersion: 5
|
||||
m_Component:
|
||||
- component: {fileID: 1124642283}
|
||||
- component: {fileID: 1124642285}
|
||||
- component: {fileID: 1124642284}
|
||||
m_Layer: 0
|
||||
m_Name: MessagePanel
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &1124642283
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 1124642282}
|
||||
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:
|
||||
- {fileID: 1798365688}
|
||||
m_Father: {fileID: 317141283}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0.6, y: 0.9}
|
||||
m_AnchorMax: {x: 1, y: 1}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 0, y: 0}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &1124642284
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 1124642282}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: -765806418, guid: f70555f144d8491a825f0804e09c671c, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 0.392}
|
||||
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_Sprite: {fileID: 10907, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_Type: 1
|
||||
m_PreserveAspect: 0
|
||||
m_FillCenter: 1
|
||||
m_FillMethod: 4
|
||||
m_FillAmount: 1
|
||||
m_FillClockwise: 1
|
||||
m_FillOrigin: 0
|
||||
--- !u!222 &1124642285
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 1124642282}
|
||||
--- !u!1 &1335574728
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -1192,6 +1355,7 @@ Transform:
|
|||
- {fileID: 354516593}
|
||||
- {fileID: 1607809311}
|
||||
- {fileID: 1001682581}
|
||||
- {fileID: 317141283}
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 2
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
|
@ -1285,6 +1449,80 @@ Transform:
|
|||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 3
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &1798365687
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
serializedVersion: 5
|
||||
m_Component:
|
||||
- component: {fileID: 1798365688}
|
||||
- component: {fileID: 1798365690}
|
||||
- component: {fileID: 1798365689}
|
||||
m_Layer: 0
|
||||
m_Name: MessageText
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &1798365688
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 1798365687}
|
||||
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: 1124642283}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 1, y: 1}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 0, y: 0}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &1798365689
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 1798365687}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 708705254, guid: f70555f144d8491a825f0804e09c671c, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, 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: 30
|
||||
m_FontStyle: 0
|
||||
m_BestFit: 0
|
||||
m_MinSize: 0
|
||||
m_MaxSize: 40
|
||||
m_Alignment: 4
|
||||
m_AlignByGeometry: 0
|
||||
m_RichText: 1
|
||||
m_HorizontalOverflow: 1
|
||||
m_VerticalOverflow: 1
|
||||
m_LineSpacing: 1
|
||||
m_Text: New Text
|
||||
--- !u!222 &1798365690
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 1798365687}
|
||||
--- !u!1 &2063368131
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
|
@ -4,8 +4,10 @@ using UnityEngine;
|
|||
|
||||
public class GameController : MonoBehaviour {
|
||||
|
||||
[SerializeField]
|
||||
GameObject playerPrefab;
|
||||
|
||||
|
||||
[SerializeField]
|
||||
private Room start;
|
||||
private Room finish;
|
||||
|
||||
|
@ -55,20 +57,13 @@ public class GameController : MonoBehaviour {
|
|||
GameObject RockLRD;
|
||||
|
||||
private Dictionary<GenerationProcessor.ExtendedTileType, GameObject> genPrefabs;
|
||||
[Space(10)]
|
||||
[Header("References")]
|
||||
|
||||
[SerializeField]
|
||||
private GameObject ui;
|
||||
|
||||
[SerializeField]
|
||||
private GameObject cam;
|
||||
|
||||
[SerializeField]
|
||||
GameObject playerPrefab;
|
||||
|
||||
[SerializeField]
|
||||
GameObject mapRoot;
|
||||
|
||||
private bool engineInitDone;
|
||||
private Player player;
|
||||
public static GameController instance;
|
||||
|
@ -82,29 +77,28 @@ public class GameController : MonoBehaviour {
|
|||
|
||||
// Use this for initialization
|
||||
void Start () {
|
||||
genPrefabs = new Dictionary<GenerationProcessor.ExtendedTileType, GameObject> {
|
||||
{ GenerationProcessor.ExtendedTileType.BorderOuter, BorderOuter },
|
||||
{ GenerationProcessor.ExtendedTileType.BorderInner, BorderInner },
|
||||
{ GenerationProcessor.ExtendedTileType.BorderSingle, BorderSingle },
|
||||
{ GenerationProcessor.ExtendedTileType.Rock, Rock },
|
||||
{ GenerationProcessor.ExtendedTileType.RockL, RockL },
|
||||
{ GenerationProcessor.ExtendedTileType.RockU, RockU },
|
||||
{ GenerationProcessor.ExtendedTileType.RockR, RockR },
|
||||
{ GenerationProcessor.ExtendedTileType.RockD, RockD },
|
||||
{ GenerationProcessor.ExtendedTileType.RockLU, RockLU },
|
||||
{ GenerationProcessor.ExtendedTileType.RockLR, RockLR },
|
||||
{ GenerationProcessor.ExtendedTileType.RockLD, RockLD },
|
||||
{ GenerationProcessor.ExtendedTileType.RockLURD, RockLURD },
|
||||
{ GenerationProcessor.ExtendedTileType.RockRD, RockRD },
|
||||
{ GenerationProcessor.ExtendedTileType.RockUR, RockUR },
|
||||
{ GenerationProcessor.ExtendedTileType.RockUD, RockUD },
|
||||
{ GenerationProcessor.ExtendedTileType.RockLUD, RockLUD },
|
||||
{ GenerationProcessor.ExtendedTileType.RockLUR, RockLUR },
|
||||
{ GenerationProcessor.ExtendedTileType.RockURD, RockURD },
|
||||
{ GenerationProcessor.ExtendedTileType.RockLRD, RockLRD },
|
||||
{ GenerationProcessor.ExtendedTileType.Ground, Ground },
|
||||
{ GenerationProcessor.ExtendedTileType.Door, Door }
|
||||
};
|
||||
genPrefabs = new Dictionary<GenerationProcessor.ExtendedTileType, GameObject>();
|
||||
genPrefabs.Add(GenerationProcessor.ExtendedTileType.BorderOuter, BorderOuter);
|
||||
genPrefabs.Add(GenerationProcessor.ExtendedTileType.BorderInner, BorderInner);
|
||||
genPrefabs.Add(GenerationProcessor.ExtendedTileType.BorderSingle, BorderSingle);
|
||||
genPrefabs.Add(GenerationProcessor.ExtendedTileType.Rock, Rock);
|
||||
genPrefabs.Add(GenerationProcessor.ExtendedTileType.RockL, RockL);
|
||||
genPrefabs.Add(GenerationProcessor.ExtendedTileType.RockU, RockU);
|
||||
genPrefabs.Add(GenerationProcessor.ExtendedTileType.RockR, RockR);
|
||||
genPrefabs.Add(GenerationProcessor.ExtendedTileType.RockD, RockD);
|
||||
genPrefabs.Add(GenerationProcessor.ExtendedTileType.RockLU, RockLU);
|
||||
genPrefabs.Add(GenerationProcessor.ExtendedTileType.RockLR, RockLR);
|
||||
genPrefabs.Add(GenerationProcessor.ExtendedTileType.RockLD, RockLD);
|
||||
genPrefabs.Add(GenerationProcessor.ExtendedTileType.RockLURD, RockLURD);
|
||||
genPrefabs.Add(GenerationProcessor.ExtendedTileType.RockRD, RockRD);
|
||||
genPrefabs.Add(GenerationProcessor.ExtendedTileType.RockUR, RockUR);
|
||||
genPrefabs.Add(GenerationProcessor.ExtendedTileType.RockUD, RockUD);
|
||||
genPrefabs.Add(GenerationProcessor.ExtendedTileType.RockLUD, RockLUD);
|
||||
genPrefabs.Add(GenerationProcessor.ExtendedTileType.RockLUR, RockLUR);
|
||||
genPrefabs.Add(GenerationProcessor.ExtendedTileType.RockURD, RockURD);
|
||||
genPrefabs.Add(GenerationProcessor.ExtendedTileType.RockLRD, RockLRD);
|
||||
genPrefabs.Add(GenerationProcessor.ExtendedTileType.Ground, Ground);
|
||||
genPrefabs.Add(GenerationProcessor.ExtendedTileType.Door, Door);
|
||||
|
||||
}
|
||||
|
||||
|
@ -178,10 +172,13 @@ public class GameController : MonoBehaviour {
|
|||
start.SetObjective(goal);
|
||||
start.OnPlayerEnter(player);
|
||||
player = goal.GetPlayer();
|
||||
if(player != null)
|
||||
cam.GetComponent<CameraControl>().SetFollow(player.gameObject);
|
||||
}
|
||||
|
||||
private void Starting() {
|
||||
|
||||
}
|
||||
|
||||
private void Running() {
|
||||
|
||||
}
|
||||
|
@ -197,4 +194,8 @@ public class GameController : MonoBehaviour {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public UIController GetUI() {
|
||||
return ui.GetComponent<UIController>();
|
||||
}
|
||||
}
|
||||
|
|
66
Assets/Scripts/NotificationManager.cs
Normal file
66
Assets/Scripts/NotificationManager.cs
Normal file
|
@ -0,0 +1,66 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class NotificationManager : MonoBehaviour {
|
||||
|
||||
|
||||
List<Notification> messages;
|
||||
bool showingMessage;
|
||||
float delay;
|
||||
Text text;
|
||||
|
||||
class Notification {
|
||||
string text;
|
||||
float duration;
|
||||
|
||||
public Notification(string text, float duration) {
|
||||
this.text = text;
|
||||
this.duration = duration;
|
||||
}
|
||||
|
||||
public string getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public float getDuration() {
|
||||
return duration;
|
||||
}
|
||||
}
|
||||
|
||||
// Use this for initialization
|
||||
void Start () {
|
||||
delay = 0;
|
||||
showingMessage = false;
|
||||
messages = new List<Notification>();
|
||||
text = GetComponent<Text>();
|
||||
}
|
||||
|
||||
void Update() {
|
||||
if (showingMessage) {
|
||||
if (Time.time > delay) {
|
||||
if (messages.Count == 1) {
|
||||
GetComponentInParent<Image>().enabled = false;
|
||||
messages.Remove(messages[0]);
|
||||
showingMessage = false;
|
||||
} else {
|
||||
text.text = messages[0].getText();
|
||||
delay = Time.time + messages[0].getDuration();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void showMessage(string text, float duration) {
|
||||
if (showingMessage) {
|
||||
messages.Add(new Notification(text, duration));
|
||||
} else {
|
||||
showingMessage = true;
|
||||
|
||||
GetComponent<Text>().text = text;
|
||||
delay = Time.time + duration;
|
||||
GetComponentInParent<Image>().enabled = true;
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/NotificationManager.cs.meta
Normal file
11
Assets/Scripts/NotificationManager.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: fc6d952416410413ca018a89d786a8a8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -4,11 +4,11 @@ using UnityEngine;
|
|||
|
||||
public class UIController : MonoBehaviour {
|
||||
|
||||
private GameObject score;
|
||||
private GameObject pauseMenu;
|
||||
GameObject score;
|
||||
GameObject pauseMenu;
|
||||
|
||||
[SerializeField]
|
||||
private GameObject gameOverPanel;
|
||||
GameObject gameOverPanel;
|
||||
|
||||
[SerializeField]
|
||||
private HealthbarController healthcontroller;
|
||||
|
|
Loading…
Add table
Reference in a new issue