Commit 41cf3a1e authored by Martin Mihálik's avatar Martin Mihálik 🔥
Browse files

Interface

parent d698b2a7
......@@ -219,6 +219,85 @@ Transform:
m_Father: {fileID: 2028534472}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &254580161
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 254580162}
- component: {fileID: 254580164}
- component: {fileID: 254580163}
m_Layer: 5
m_Name: StartGameNotice
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &254580162
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 254580161}
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: 816713382}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 100}
m_SizeDelta: {x: 400, y: 30}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &254580163
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 254580161}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_FontData:
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
m_FontSize: 26
m_FontStyle: 1
m_BestFit: 0
m_MinSize: 2
m_MaxSize: 40
m_Alignment: 1
m_AlignByGeometry: 0
m_RichText: 1
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text: Press Enter to start
--- !u!222 &254580164
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 254580161}
m_CullTransparentMesh: 1
--- !u!1 &318166511
GameObject:
m_ObjectHideFlags: 0
......@@ -228,6 +307,7 @@ GameObject:
serializedVersion: 6
m_Component:
- component: {fileID: 318166512}
- component: {fileID: 318166513}
m_Layer: 0
m_Name: UI
m_TagString: Untagged
......@@ -251,6 +331,20 @@ Transform:
m_Father: {fileID: 0}
m_RootOrder: 10
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &318166513
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 318166511}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 309cedcfa070e544cbfc812dfde5eca4, type: 3}
m_Name:
m_EditorClassIdentifier:
m_StartingScreen: {fileID: 816713381}
m_EndingScreen: {fileID: 1916288481}
--- !u!1001 &400810249
PrefabInstance:
m_ObjectHideFlags: 0
......@@ -608,6 +702,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 384f8f188b664b745bc1f34d36ce528e, type: 3}
m_Name:
m_EditorClassIdentifier:
m_DeadFace: {fileID: -5477932474858569004, guid: b9c664e75e5258a4c950b2cf2ffc4d9e, type: 3}
--- !u!114 &512397507
MonoBehaviour:
m_ObjectHideFlags: 0
......@@ -654,8 +749,20 @@ MonoBehaviour:
m_OnDeath:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 1654006375}
m_TargetAssemblyTypeName: GameController, Assembly-CSharp
m_MethodName: EndGame
m_Mode: 1
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
- m_Target: {fileID: 512397506}
m_TargetAssemblyTypeName: PlayerControls, Assembly-CSharp
m_TargetAssemblyTypeName: PlayerController, Assembly-CSharp
m_MethodName: OnDeath
m_Mode: 1
m_Arguments:
......@@ -1171,6 +1278,130 @@ Transform:
m_Father: {fileID: 2028534472}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &816713381
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 816713382}
- component: {fileID: 816713383}
m_Layer: 5
m_Name: StartingScreen
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &816713382
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 816713381}
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: 254580162}
m_Father: {fileID: 2075556115}
m_RootOrder: 2
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!222 &816713383
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 816713381}
m_CullTransparentMesh: 1
--- !u!1 &1005609306
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1005609307}
- component: {fileID: 1005609309}
- component: {fileID: 1005609308}
m_Layer: 5
m_Name: RestartNotice
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &1005609307
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1005609306}
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: 1916288482}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 100}
m_SizeDelta: {x: 400, y: 30}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1005609308
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1005609306}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_FontData:
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
m_FontSize: 26
m_FontStyle: 1
m_BestFit: 0
m_MinSize: 2
m_MaxSize: 40
m_Alignment: 1
m_AlignByGeometry: 0
m_RichText: 1
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text: Press R to restart
--- !u!222 &1005609309
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1005609306}
m_CullTransparentMesh: 1
--- !u!1 &1052020042
GameObject:
m_ObjectHideFlags: 0
......@@ -1684,6 +1915,7 @@ GameObject:
serializedVersion: 6
m_Component:
- component: {fileID: 1654006369}
- component: {fileID: 1654006375}
- component: {fileID: 1654006368}
- component: {fileID: 1654006372}
- component: {fileID: 1654006370}
......@@ -1691,7 +1923,7 @@ GameObject:
- component: {fileID: 1654006373}
- component: {fileID: 1654006374}
m_Layer: 0
m_Name: Settings
m_Name: State
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
......@@ -1709,18 +1941,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: fdc0f0ef9127c834abc75473807ed5a2, type: 3}
m_Name:
m_EditorClassIdentifier:
m_BeforePauseHooks:
m_PersistentCalls:
m_Calls: []
m_AfterPauseHooks:
m_PersistentCalls:
m_Calls: []
m_BeforeResumeHooks:
m_PersistentCalls:
m_Calls: []
m_AfterResumeHooks:
m_PersistentCalls:
m_Calls: []
m_StartPaused: 1
--- !u!4 &1654006369
Transform:
m_ObjectHideFlags: 0
......@@ -1824,6 +2045,19 @@ MonoBehaviour:
m_Grid: {fileID: 1364465087}
m_StartingHealth: 3
m_BuildingCost: 5
--- !u!114 &1654006375
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1654006367}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fd85951a965d45d4d870df79413cac7f, type: 3}
m_Name:
m_EditorClassIdentifier:
m_UIController: {fileID: 318166513}
--- !u!1 &1695424172
GameObject:
m_ObjectHideFlags: 0
......@@ -2721,6 +2955,143 @@ Rigidbody2D:
m_SleepingMode: 1
m_CollisionDetection: 0
m_Constraints: 0
--- !u!1 &1880272046
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1880272047}
- component: {fileID: 1880272049}
- component: {fileID: 1880272048}
- component: {fileID: 1880272050}
m_Layer: 5
m_Name: TimeDisplay
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &1880272047
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1880272046}
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: 2075556115}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 1, y: 0}
m_AnchorMax: {x: 1, y: 0}
m_AnchoredPosition: {x: -100, y: 40}
m_SizeDelta: {x: 160, y: 30}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1880272048
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1880272046}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_FontData:
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
m_FontSize: 26
m_FontStyle: 1
m_BestFit: 0
m_MinSize: 2
m_MaxSize: 40
m_Alignment: 2
m_AlignByGeometry: 0
m_RichText: 1
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text: 0
--- !u!222 &1880272049
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1880272046}
m_CullTransparentMesh: 1
--- !u!114 &1880272050
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1880272046}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 9c8b0159f88e59c4eaecb772edb68986, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &1916288481
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1916288482}
- component: {fileID: 1916288483}
m_Layer: 5
m_Name: EndingScreen
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &1916288482
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1916288481}
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: 1005609307}
m_Father: {fileID: 2075556115}
m_RootOrder: 3
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!222 &1916288483
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1916288481}
m_CullTransparentMesh: 1
--- !u!1 &1952676060
GameObject:
m_ObjectHideFlags: 0
......@@ -3009,6 +3380,9 @@ RectTransform:
m_LocalScale: {x: 0, y: 0, z: 0}
m_Children:
- {fileID: 712401121}
- {fileID: 1880272047}
- {fileID: 816713382}
- {fileID: 1916288482}
m_Father: {fileID: 318166512}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
......
......@@ -23,13 +23,18 @@ public class DamageTaker : MonoBehaviour
}
private void OnTriggerEnter2D(Collider2D collision)
{
TryTakeDamage(collision.gameObject);
}
private void TryTakeDamage(GameObject damageSource)
{
if (Dead)
{
return;
}
var dealer = collision.gameObject.GetComponent<DamageDealer>();
var dealer = damageSource.GetComponent<DamageDealer>();
if (dealer == null)
{
......@@ -43,14 +48,24 @@ public class DamageTaker : MonoBehaviour
if (Health <= dealer.Damage)
{
Health = 0;
m_OnDeath.Invoke();
Die();
}
else
{
Health -= dealer.Damage;
m_OnDamageTaken.Invoke();
m_DamageSources.Add(dealer.Id);
TakeDamage(dealer);
}
}
private void Die()
{
Health = 0;
m_OnDeath.Invoke();
}
private void TakeDamage(DamageDealer source)
{
Health -= source.Damage;
m_DamageSources.Add(source.Id);
m_OnDamageTaken.Invoke();
}
}
using UnityEngine;
using UnityEngine.SceneManagement;
public class GameController : MonoBehaviour
{
[SerializeField] private UIController m_UIController;
private PauseController m_PauseController;
public bool Started { get; private set; }
public bool Running { get; private set; }
private void Start()
{
m_PauseController = GetComponent<PauseController>();
}
private void Update()
{
TryStartGame();
TryRestartGame();
}
public void StartGame()
{
m_UIController.HideStartingScreen();
m_PauseController.Resume();
Started = true;
Running = true;
}
public void EndGame()
{
Running = false;
m_PauseController.Pause();
m_UIController.ShowEndingScreen();
}
public void RestartGame()
{
SceneManager