Commit 2c4ad23a authored by Domm29's avatar Domm29
Browse files

healthbar verbessert

parent 1c265677
......@@ -29,6 +29,8 @@
<e p="Player.cs" t="Include" />
</e>
<e p="PostEffectScript.cs" t="Include" />
<e p="PullableObject.cs" t="Include" />
<e p="RopeSystem.cs" t="Include" />
<e p="UI_Health.cs" t="Include" />
<e p="UI_SceneManager.cs" t="Include" />
</e>
......
This diff is collapsed.
......@@ -36,6 +36,7 @@ Transform:
m_Children:
- {fileID: 264577552299148765}
- {fileID: 264577552399682111}
- {fileID: 1036972048130055170}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
......@@ -162,6 +163,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: eff681ef17b34b34e8e2ad0af641fa6d, type: 3}
m_Name:
m_EditorClassIdentifier:
rigidbody: {fileID: 0}
movementSmoothing: 0.05
jumpForce: 30
groundCheck: {fileID: 264577552299148765}
......@@ -179,6 +181,8 @@ MonoBehaviour:
Culture=neutral, PublicKeyToken=null
isSwinging: 0
ropeHook: {x: 0, y: 0}
swingForce: 2
maxSwingForce: 10
--- !u!114 &1547779245
MonoBehaviour:
m_ObjectHideFlags: 0
......@@ -193,6 +197,7 @@ MonoBehaviour:
m_EditorClassIdentifier:
player: {fileID: 1547779244}
scene: {fileID: 0}
ropesys: {fileID: 0}
--- !u!114 &-8691157065451763958
MonoBehaviour:
m_ObjectHideFlags: 0
......@@ -315,3 +320,104 @@ Transform:
m_Father: {fileID: 264577551908436770}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &6580952146038942049
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1036972048130055170}
- component: {fileID: 1192170334762939915}
- component: {fileID: 5585556793136564977}
m_Layer: 9
m_Name: RopeHingeAnchor
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1036972048130055170
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6580952146038942049}
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: 264577551908436770}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!50 &1192170334762939915
Rigidbody2D:
serializedVersion: 4
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6580952146038942049}
m_BodyType: 1
m_Simulated: 1
m_UseFullKinematicContacts: 0
m_UseAutoMass: 0
m_Mass: 1
m_LinearDrag: 0
m_AngularDrag: 0.05
m_GravityScale: 1
m_Material: {fileID: 0}
m_Interpolate: 0
m_SleepingMode: 1
m_CollisionDetection: 0
m_Constraints: 0
--- !u!212 &5585556793136564977
SpriteRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6580952146038942049}
m_Enabled: 0
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 0
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 2
m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0}
m_Color: {r: 0.7169812, g: 0, b: 0.13794921, a: 1}
m_FlipX: 0
m_FlipY: 0
m_DrawMode: 0
m_Size: {x: 0.16, y: 0.16}
m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
This diff is collapsed.
......@@ -3,7 +3,7 @@
public class InputManager : MonoBehaviour
{
[SerializeField] private Player player = null;
[SerializeField] private SceneManager scene = null;
[SerializeField] private UI_SceneManager scene = null;
[SerializeField] private RopeSystem ropesys = null;
private float horizontal;
private bool jump;
......
......@@ -5,8 +5,9 @@ using UnityEngine;
public class Life : MonoBehaviour
{
private int life;
public int life;
public GameObject hud;// The Hud with the Health Bar
// Start is called before the first frame update
void Start()
{
......@@ -21,9 +22,13 @@ public class Life : MonoBehaviour
private void OnCollisionEnter2D(Collision2D other)
{
//Layer 30 is the Damage Hazad and 31 is Damage Enemy
if (other.gameObject.layer == 30 || other.gameObject.layer == 31)
{
life--;
hud.GetComponent<UI_Health>().LifeLost(life);
}
}
}
......@@ -11,6 +11,7 @@ public class UI_Health : MonoBehaviour
public Image leaf3;
public GameObject playerObject;
private GameObject hudCanvas;
private void Awake()
{
......@@ -26,30 +27,35 @@ public class UI_Health : MonoBehaviour
private void Update()
{
if (playerObject.GetComponent<Life>().life == 3)
{
leaf1.enabled = true;
leaf2.enabled = true;
leaf3.enabled = true;
}
else if (playerObject.GetComponent<Life>().life == 2)
{
leaf1.enabled = true;
leaf2.enabled = true;
leaf3.enabled = false;
}
else if (playerObject.GetComponent<Life>().life == 1)
{
leaf1.enabled = true;
leaf2.enabled = false;
leaf3.enabled = false;
}
else if (playerObject.GetComponent<Life>().life <= 0)
}
public void LifeLost(int lifeOfPlayer)
{
switch (lifeOfPlayer)
{
leaf1.enabled = false;
leaf2.enabled = false;
leaf3.enabled = false;
hudCanvas.GetComponent<UI_SceneManager>().ReloadScene();
case 3:
leaf1.enabled = true;
leaf2.enabled = true;
leaf3.enabled = true;
break;
case 2:
leaf1.enabled = true;
leaf2.enabled = true;
leaf3.enabled = false;
break;
case 1:
leaf1.enabled = true;
leaf2.enabled = false;
leaf3.enabled = false;
break;
default:
leaf1.enabled = false;
leaf2.enabled = false;
leaf3.enabled = false;
hudCanvas.GetComponent<UI_SceneManager>().ReloadScene();
break;
}
}
}
......
......@@ -35,8 +35,8 @@ TagManager:
-
-
-
-
-
- Damage Hazad
- Damage Enemy
m_SortingLayers:
- name: Default
uniqueID: 0
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment