1
Fork 0

Add life bar

This commit is contained in:
Steffo 2019-04-28 14:41:28 +02:00
parent ce348545df
commit 33347480f6
8 changed files with 346 additions and 138 deletions

View file

@ -1,5 +1,202 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &1591973060
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1591973061}
- component: {fileID: 1591973064}
- component: {fileID: 1591973063}
- component: {fileID: 1591973062}
m_Layer: 5
m_Name: Canvas
m_TagString: Canvas
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &1591973061
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1591973060}
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: 5737868752126517729}
m_Father: {fileID: 1651829514}
m_RootOrder: 0
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!223 &1591973064
Canvas:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1591973060}
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!114 &1591973063
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1591973060}
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!114 &1591973062
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1591973060}
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!1 &1651829513
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1651829514}
m_Layer: 0
m_Name: UI
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1651829514
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1651829513}
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: 1591973061}
- {fileID: 1816923098}
m_Father: {fileID: 1419775483983031142}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1816923097
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1816923098}
- component: {fileID: 1816923100}
- component: {fileID: 1816923099}
m_Layer: 0
m_Name: EventSystem
m_TagString: EventSystem
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1816923098
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1816923097}
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: 1651829514}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1816923100
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1816923097}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: -619905303, guid: f70555f144d8491a825f0804e09c671c, type: 3}
m_Name:
m_EditorClassIdentifier:
m_FirstSelected: {fileID: 0}
m_sendNavigationEvents: 1
m_DragThreshold: 10
--- !u!114 &1816923099
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1816923097}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 1077351063, guid: f70555f144d8491a825f0804e09c671c, type: 3}
m_Name:
m_EditorClassIdentifier:
m_HorizontalAxis: Horizontal
m_VerticalAxis: Vertical
m_SubmitButton: Submit
m_CancelButton: Cancel
m_InputActionsPerSecond: 10
m_RepeatDelay: 0.5
m_ForceModuleActive: 0
--- !u!1 &1792584738874209504
GameObject:
m_ObjectHideFlags: 0
@ -29,9 +226,97 @@ Transform:
m_Children:
- {fileID: 8897064855631282258}
- {fileID: 3789201758602335435}
- {fileID: 1651829514}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &4498264905375096437
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 5737868752126517729}
- component: {fileID: 1444371758723586612}
- component: {fileID: 377224390999592314}
- component: {fileID: 964787956205872362}
m_Layer: 5
m_Name: HP Bar
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &5737868752126517729
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4498264905375096437}
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: 1591973061}
m_RootOrder: 0
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: 100, y: 100}
m_Pivot: {x: 0, y: 0}
--- !u!222 &1444371758723586612
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4498264905375096437}
m_CullTransparentMesh: 0
--- !u!114 &377224390999592314
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4498264905375096437}
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: 1}
m_RaycastTarget: 0
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: 21300000, guid: f5be5362b22aa6c48993a720ec6c9b84, type: 3}
m_Type: 3
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 2
m_FillAmount: 1
m_FillClockwise: 0
m_FillOrigin: 0
m_UseSpriteMesh: 0
--- !u!114 &964787956205872362
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4498264905375096437}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: cbf8b0d2fd980e14f9956f5345d82ddc, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &5605884945823581445
GameObject:
m_ObjectHideFlags: 0
@ -108,7 +393,7 @@ MonoBehaviour:
playerPrefab: {fileID: 2935319493830293412, guid: e8ff38be23e53db40a793f6959c6f4ec,
type: 3}
enemyPrefabs:
- {fileID: 1164136568549368904, guid: a4aeecfb369f0974490d158ef9489335, type: 3}
- {fileID: 470211819356819165, guid: 1bd6e08f590fdd844854a34504aeaa4a, type: 3}
enemiesToSpawn: 10
--- !u!1 &8733140679003710819
GameObject:

View file

@ -45,8 +45,9 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 4de6b97c3d785d146a0df2c1c078fe91, type: 3}
m_Name:
m_EditorClassIdentifier:
hpMax: 0
hp: 0
hpMax: 10
overlappable: 0
hp: 10
sprite: {fileID: 21300000, guid: 88f4c277892ae9449a57b321cd810bce, type: 3}
exp: 0
level: 0

View file

@ -187,137 +187,5 @@ PrefabInstance:
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5602184811824951751, guid: 4c25f33cb89f6624db48fc49d353a7f2,
type: 3}
propertyPath: leftWallSprites.Array.size
value: 1
objectReference: {fileID: 0}
- target: {fileID: 5602184811824951751, guid: 4c25f33cb89f6624db48fc49d353a7f2,
type: 3}
propertyPath: rightWallSprites.Array.size
value: 1
objectReference: {fileID: 0}
- target: {fileID: 5602184811824951751, guid: 4c25f33cb89f6624db48fc49d353a7f2,
type: 3}
propertyPath: topWallSprites.Array.size
value: 1
objectReference: {fileID: 0}
- target: {fileID: 5602184811824951751, guid: 4c25f33cb89f6624db48fc49d353a7f2,
type: 3}
propertyPath: lCornerWallSprites.Array.size
value: 1
objectReference: {fileID: 0}
- target: {fileID: 5602184811824951751, guid: 4c25f33cb89f6624db48fc49d353a7f2,
type: 3}
propertyPath: rCornerWallSprites.Array.size
value: 1
objectReference: {fileID: 0}
- target: {fileID: 5602184811824951751, guid: 4c25f33cb89f6624db48fc49d353a7f2,
type: 3}
propertyPath: botWallSprites.Array.size
value: 1
objectReference: {fileID: 0}
- target: {fileID: 5602184811824951751, guid: 4c25f33cb89f6624db48fc49d353a7f2,
type: 3}
propertyPath: floorSprites.Array.size
value: 10
objectReference: {fileID: 0}
- target: {fileID: 5602184811824951751, guid: 4c25f33cb89f6624db48fc49d353a7f2,
type: 3}
propertyPath: rightWallSprites.Array.data[0]
value:
objectReference: {fileID: 0}
- target: {fileID: 5602184811824951751, guid: 4c25f33cb89f6624db48fc49d353a7f2,
type: 3}
propertyPath: leftWallSprites.Array.data[0]
value:
objectReference: {fileID: 0}
- target: {fileID: 5602184811824951751, guid: 4c25f33cb89f6624db48fc49d353a7f2,
type: 3}
propertyPath: lCornerWallSprites.Array.data[0]
value:
objectReference: {fileID: 0}
- target: {fileID: 5602184811824951751, guid: 4c25f33cb89f6624db48fc49d353a7f2,
type: 3}
propertyPath: rCornerWallSprites.Array.data[0]
value:
objectReference: {fileID: 0}
- target: {fileID: 5602184811824951751, guid: 4c25f33cb89f6624db48fc49d353a7f2,
type: 3}
propertyPath: topWallSprites.Array.data[0]
value:
objectReference: {fileID: 0}
- target: {fileID: 5602184811824951751, guid: 4c25f33cb89f6624db48fc49d353a7f2,
type: 3}
propertyPath: topWallSprites.Array.data[1]
value:
objectReference: {fileID: 21300000, guid: de53d30fbdcfc2e458577832376fddc7,
type: 3}
- target: {fileID: 5602184811824951751, guid: 4c25f33cb89f6624db48fc49d353a7f2,
type: 3}
propertyPath: botWallSprites.Array.data[0]
value:
objectReference: {fileID: 21300000, guid: 82ccea6ce8f2edf4cae6f99e1127b0c3,
type: 3}
- target: {fileID: 5602184811824951751, guid: 4c25f33cb89f6624db48fc49d353a7f2,
type: 3}
propertyPath: floorSprites.Array.data[0]
value:
objectReference: {fileID: 21300000, guid: e0e60c9a4ff0b8e429e6cfe316da9bbf,
type: 3}
- target: {fileID: 5602184811824951751, guid: 4c25f33cb89f6624db48fc49d353a7f2,
type: 3}
propertyPath: floorSprites.Array.data[1]
value:
objectReference: {fileID: 21300000, guid: e0e60c9a4ff0b8e429e6cfe316da9bbf,
type: 3}
- target: {fileID: 5602184811824951751, guid: 4c25f33cb89f6624db48fc49d353a7f2,
type: 3}
propertyPath: floorSprites.Array.data[2]
value:
objectReference: {fileID: 21300000, guid: e0e60c9a4ff0b8e429e6cfe316da9bbf,
type: 3}
- target: {fileID: 5602184811824951751, guid: 4c25f33cb89f6624db48fc49d353a7f2,
type: 3}
propertyPath: floorSprites.Array.data[3]
value:
objectReference: {fileID: 21300000, guid: e0e60c9a4ff0b8e429e6cfe316da9bbf,
type: 3}
- target: {fileID: 5602184811824951751, guid: 4c25f33cb89f6624db48fc49d353a7f2,
type: 3}
propertyPath: floorSprites.Array.data[4]
value:
objectReference: {fileID: 21300000, guid: e0e60c9a4ff0b8e429e6cfe316da9bbf,
type: 3}
- target: {fileID: 5602184811824951751, guid: 4c25f33cb89f6624db48fc49d353a7f2,
type: 3}
propertyPath: floorSprites.Array.data[5]
value:
objectReference: {fileID: 21300000, guid: e0e60c9a4ff0b8e429e6cfe316da9bbf,
type: 3}
- target: {fileID: 5602184811824951751, guid: 4c25f33cb89f6624db48fc49d353a7f2,
type: 3}
propertyPath: floorSprites.Array.data[6]
value:
objectReference: {fileID: 21300000, guid: e0e60c9a4ff0b8e429e6cfe316da9bbf,
type: 3}
- target: {fileID: 5602184811824951751, guid: 4c25f33cb89f6624db48fc49d353a7f2,
type: 3}
propertyPath: floorSprites.Array.data[7]
value:
objectReference: {fileID: 21300000, guid: e0e60c9a4ff0b8e429e6cfe316da9bbf,
type: 3}
- target: {fileID: 5602184811824951751, guid: 4c25f33cb89f6624db48fc49d353a7f2,
type: 3}
propertyPath: floorSprites.Array.data[8]
value:
objectReference: {fileID: 21300000, guid: e0e60c9a4ff0b8e429e6cfe316da9bbf,
type: 3}
- target: {fileID: 5602184811824951751, guid: 4c25f33cb89f6624db48fc49d353a7f2,
type: 3}
propertyPath: floorSprites.Array.data[9]
value:
objectReference: {fileID: 21300000, guid: fa4c9841fd8a5fb4f94ff78c95301065,
type: 3}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 4c25f33cb89f6624db48fc49d353a7f2, type: 3}

View file

@ -4,11 +4,11 @@ using UnityEngine;
public class Entity : MonoBehaviour
{
public int hpMax;
public float hpMax;
public bool overlappable = false;
[AfterStartAttribute]
public int hp;
public float hp;
[BeforeStartAttribute]
public Sprite sprite;

View file

@ -0,0 +1,19 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class FillAmountFromPlayerHP : MonoBehaviour
{
private Player player;
private Image image;
private void Start() {
player = GameObject.FindGameObjectWithTag("Player").GetComponent<Player>();
image = GetComponent<Image>();
}
private void Update() {
image.fillAmount = player.hp / player.hpMax;
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: cbf8b0d2fd980e14f9956f5345d82ddc
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 100
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -69,6 +69,28 @@ TextureImporter:
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
- serializedVersion: 2
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: 4
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
- serializedVersion: 2
buildTarget: WebGL
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: 4
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
spriteSheet:
serializedVersion: 2
sprites: []

View file

@ -3,7 +3,9 @@
--- !u!78 &1
TagManager:
serializedVersion: 2
tags: []
tags:
- Canvas
- EventSystem
layers:
- Default
- TransparentFX