uChema
4 年前
当前提交
be536522
共有 34 个文件被更改,包括 2716 次插入 和 1780 次删除
-
13UOP1_Project/Assets/Prefabs/UI/ButtonChoice.prefab
-
13UOP1_Project/Assets/Prefabs/UI/ButtonMenu.prefab
-
32UOP1_Project/Assets/Prefabs/UI/Canvas-MainMenu.prefab
-
18UOP1_Project/Assets/Prefabs/UI/EventSystem.prefab
-
13UOP1_Project/Assets/Prefabs/UI/InventoryItem.prefab
-
13UOP1_Project/Assets/Prefabs/UI/Popup/PopupButton.prefab
-
13UOP1_Project/Assets/Prefabs/UI/UnpauseButton.prefab
-
481UOP1_Project/Assets/Prefabs/UI/WIP/Credits_Panel.prefab
-
172UOP1_Project/Assets/Prefabs/UI/WIP/Settings/Settings_Panel.prefab
-
40UOP1_Project/Assets/Scenes/Managers/Gameplay.unity
-
556UOP1_Project/Assets/Scenes/Menus/MainMenu.unity
-
2UOP1_Project/Assets/Scripts/.DS_Store
-
8UOP1_Project/Assets/Scripts/Events/ScriptableObjects/BoolEventChannelSO.cs
-
43UOP1_Project/Assets/Scripts/Gameplay/GameManager.cs
-
968UOP1_Project/Assets/Scripts/Input/GameInput.cs
-
76UOP1_Project/Assets/Scripts/Input/InputReader.cs
-
49UOP1_Project/Assets/Scripts/Inventory/UIInventoryManager.cs
-
22UOP1_Project/Assets/Scripts/Menu/MenuSelectionHandler.cs
-
1UOP1_Project/Assets/Scripts/Menu/MultiInputButton.cs
-
4UOP1_Project/Assets/Scripts/UI/UIManager.cs
-
18UOP1_Project/Assets/Scripts/UI/UIMenuManager.cs
-
24UOP1_Project/Assets/Scripts/UI/UISettingFieldsFiller.cs
-
4UOP1_Project/Assets/Scripts/UI/UISettingItemFiller.cs
-
10UOP1_Project/Assets/Scripts/UI/UISettingManager.cs
-
714UOP1_Project/Assets/Settings/Input/GameInput.inputactions
-
16UOP1_Project/UserSettings/EditorUserSettings.asset
-
8UOP1_Project/Assets/WIP/UI.meta
-
611UOP1_Project/Assets/WIP/UI/UIHealtDisplay.prefab
-
78UOP1_Project/Assets/WIP/UI/UIHealthBarManager.cs
-
394UOP1_Project/Assets/Prefabs/UI/WIP/UIHealthbar.prefab
-
82UOP1_Project/Assets/Scripts/UI/UIHealthBarManager.cs
-
0/UOP1_Project/Assets/WIP/UI/UIHealtDisplay.prefab.meta
-
0/UOP1_Project/Assets/WIP/UI/UIHealthBarManager.cs.meta
2
UOP1_Project/Assets/Scripts/.DS_Store
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
968
UOP1_Project/Assets/Scripts/Input/GameInput.cs
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
fileFormatVersion: 2 |
|||
guid: e60ab1220e5534fda8f605fcf71d161d |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
%YAML 1.1 |
|||
%TAG !u! tag:unity3d.com,2011: |
|||
--- !u!1 &455196798932656325 |
|||
GameObject: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
serializedVersion: 6 |
|||
m_Component: |
|||
- component: {fileID: 358584537197172349} |
|||
- component: {fileID: 1599723359886217568} |
|||
- component: {fileID: 5138323859197390585} |
|||
m_Layer: 9 |
|||
m_Name: Heart (2) |
|||
m_TagString: Untagged |
|||
m_Icon: {fileID: 0} |
|||
m_NavMeshLayer: 0 |
|||
m_StaticEditorFlags: 0 |
|||
m_IsActive: 1 |
|||
--- !u!224 &358584537197172349 |
|||
RectTransform: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 455196798932656325} |
|||
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: 6352810064952983069} |
|||
m_RootOrder: 2 |
|||
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.5, y: 0.5} |
|||
--- !u!222 &1599723359886217568 |
|||
CanvasRenderer: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 455196798932656325} |
|||
m_CullTransparentMesh: 1 |
|||
--- !u!114 &5138323859197390585 |
|||
MonoBehaviour: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 455196798932656325} |
|||
m_Enabled: 1 |
|||
m_EditorHideFlags: 0 |
|||
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, 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_Sprite: {fileID: 10911, 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 |
|||
m_UseSpriteMesh: 0 |
|||
m_PixelsPerUnitMultiplier: 1 |
|||
--- !u!1 &2696794833251330545 |
|||
GameObject: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
serializedVersion: 6 |
|||
m_Component: |
|||
- component: {fileID: 3545734335979156956} |
|||
- component: {fileID: 7627857720743474821} |
|||
- component: {fileID: 4923575773365521623} |
|||
m_Layer: 9 |
|||
m_Name: Heart (3) |
|||
m_TagString: Untagged |
|||
m_Icon: {fileID: 0} |
|||
m_NavMeshLayer: 0 |
|||
m_StaticEditorFlags: 0 |
|||
m_IsActive: 1 |
|||
--- !u!224 &3545734335979156956 |
|||
RectTransform: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 2696794833251330545} |
|||
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: 6352810064952983069} |
|||
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.5, y: 0.5} |
|||
--- !u!222 &7627857720743474821 |
|||
CanvasRenderer: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 2696794833251330545} |
|||
m_CullTransparentMesh: 1 |
|||
--- !u!114 &4923575773365521623 |
|||
MonoBehaviour: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 2696794833251330545} |
|||
m_Enabled: 1 |
|||
m_EditorHideFlags: 0 |
|||
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, 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_Sprite: {fileID: 10911, 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 |
|||
m_UseSpriteMesh: 0 |
|||
m_PixelsPerUnitMultiplier: 1 |
|||
--- !u!1 &2815881603653157998 |
|||
GameObject: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
serializedVersion: 6 |
|||
m_Component: |
|||
- component: {fileID: 6352810064952983069} |
|||
- component: {fileID: 6395593152779691077} |
|||
- component: {fileID: 7686382842736750647} |
|||
- component: {fileID: 4731765889197187948} |
|||
- component: {fileID: 7057594148529581253} |
|||
- component: {fileID: 5382124729891650614} |
|||
m_Layer: 9 |
|||
m_Name: UIHealtDisplay |
|||
m_TagString: Untagged |
|||
m_Icon: {fileID: 0} |
|||
m_NavMeshLayer: 0 |
|||
m_StaticEditorFlags: 0 |
|||
m_IsActive: 1 |
|||
--- !u!224 &6352810064952983069 |
|||
RectTransform: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 2815881603653157998} |
|||
m_LocalRotation: {x: 0.011508226, y: -0.9995812, z: 0.00209032, w: 0.026469946} |
|||
m_LocalPosition: {x: 0, y: 0, z: -0} |
|||
m_LocalScale: {x: 0.015, y: 0.015, z: 1} |
|||
m_Children: |
|||
- {fileID: 479493725024631163} |
|||
- {fileID: 805034800503573862} |
|||
- {fileID: 358584537197172349} |
|||
- {fileID: 3545734335979156956} |
|||
- {fileID: 6087809287161891054} |
|||
- {fileID: 2889208702305137056} |
|||
m_Father: {fileID: 0} |
|||
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.010009766, y: 0.2800293} |
|||
m_SizeDelta: {x: 100, y: 20} |
|||
m_Pivot: {x: 0.5, y: 0.5} |
|||
--- !u!223 &6395593152779691077 |
|||
Canvas: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 2815881603653157998} |
|||
m_Enabled: 1 |
|||
serializedVersion: 3 |
|||
m_RenderMode: 2 |
|||
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 &7686382842736750647 |
|||
MonoBehaviour: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 2815881603653157998} |
|||
m_Enabled: 1 |
|||
m_EditorHideFlags: 0 |
|||
m_Script: {fileID: 11500000, guid: 0cd44c1031e13a943bb63640046fad76, 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 |
|||
m_PresetInfoIsWorld: 1 |
|||
--- !u!114 &4731765889197187948 |
|||
MonoBehaviour: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 2815881603653157998} |
|||
m_Enabled: 1 |
|||
m_EditorHideFlags: 0 |
|||
m_Script: {fileID: 11500000, guid: dc42784cf147c0c48a680349fa168899, type: 3} |
|||
m_Name: |
|||
m_EditorClassIdentifier: |
|||
m_IgnoreReversedGraphics: 1 |
|||
m_BlockingObjects: 0 |
|||
m_BlockingMask: |
|||
serializedVersion: 2 |
|||
m_Bits: 4294967295 |
|||
--- !u!114 &7057594148529581253 |
|||
MonoBehaviour: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 2815881603653157998} |
|||
m_Enabled: 1 |
|||
m_EditorHideFlags: 0 |
|||
m_Script: {fileID: 11500000, guid: f8dfad91156ef4bff806fff3c3f9eacd, type: 3} |
|||
m_Name: |
|||
m_EditorClassIdentifier: |
|||
_heartImages: |
|||
- {fileID: 3647031815024279509} |
|||
- {fileID: 5054149388442712904} |
|||
- {fileID: 5138323859197390585} |
|||
- {fileID: 4923575773365521623} |
|||
- {fileID: 3799196531022497756} |
|||
healthText: {fileID: 1164434712947447015} |
|||
_setHealthBar: {fileID: 11400000, guid: 22e3f27f002de44b4948988138dd9377, type: 2} |
|||
_inflictDamage: {fileID: 11400000, guid: be921b398c68d450e9e3c55dde697149, type: 2} |
|||
_restoreHealth: {fileID: 11400000, guid: de4a39f85969d44cba990125224ff7ef, type: 2} |
|||
--- !u!114 &5382124729891650614 |
|||
MonoBehaviour: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 2815881603653157998} |
|||
m_Enabled: 1 |
|||
m_EditorHideFlags: 0 |
|||
m_Script: {fileID: 11500000, guid: 30649d3a9faa99c48a7b1166b86bf2a0, type: 3} |
|||
m_Name: |
|||
m_EditorClassIdentifier: |
|||
m_Padding: |
|||
m_Left: 0 |
|||
m_Right: 0 |
|||
m_Top: 0 |
|||
m_Bottom: 0 |
|||
m_ChildAlignment: 0 |
|||
m_Spacing: 0 |
|||
m_ChildForceExpandWidth: 1 |
|||
m_ChildForceExpandHeight: 1 |
|||
m_ChildControlWidth: 1 |
|||
m_ChildControlHeight: 1 |
|||
m_ChildScaleWidth: 0 |
|||
m_ChildScaleHeight: 0 |
|||
m_ReverseArrangement: 0 |
|||
--- !u!1 &2976475603547307888 |
|||
GameObject: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
serializedVersion: 6 |
|||
m_Component: |
|||
- component: {fileID: 479493725024631163} |
|||
- component: {fileID: 9010055178346947484} |
|||
- component: {fileID: 3647031815024279509} |
|||
m_Layer: 9 |
|||
m_Name: Heart |
|||
m_TagString: Untagged |
|||
m_Icon: {fileID: 0} |
|||
m_NavMeshLayer: 0 |
|||
m_StaticEditorFlags: 0 |
|||
m_IsActive: 1 |
|||
--- !u!224 &479493725024631163 |
|||
RectTransform: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 2976475603547307888} |
|||
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: 6352810064952983069} |
|||
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.5, y: 0.5} |
|||
--- !u!222 &9010055178346947484 |
|||
CanvasRenderer: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 2976475603547307888} |
|||
m_CullTransparentMesh: 1 |
|||
--- !u!114 &3647031815024279509 |
|||
MonoBehaviour: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 2976475603547307888} |
|||
m_Enabled: 1 |
|||
m_EditorHideFlags: 0 |
|||
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, 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_Sprite: {fileID: 10911, 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 |
|||
m_UseSpriteMesh: 0 |
|||
m_PixelsPerUnitMultiplier: 1 |
|||
--- !u!1 &5235661441434354422 |
|||
GameObject: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
serializedVersion: 6 |
|||
m_Component: |
|||
- component: {fileID: 805034800503573862} |
|||
- component: {fileID: 5549412471662682713} |
|||
- component: {fileID: 5054149388442712904} |
|||
m_Layer: 9 |
|||
m_Name: Heart (1) |
|||
m_TagString: Untagged |
|||
m_Icon: {fileID: 0} |
|||
m_NavMeshLayer: 0 |
|||
m_StaticEditorFlags: 0 |
|||
m_IsActive: 1 |
|||
--- !u!224 &805034800503573862 |
|||
RectTransform: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 5235661441434354422} |
|||
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: 6352810064952983069} |
|||
m_RootOrder: 1 |
|||
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.5, y: 0.5} |
|||
--- !u!222 &5549412471662682713 |
|||
CanvasRenderer: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 5235661441434354422} |
|||
m_CullTransparentMesh: 1 |
|||
--- !u!114 &5054149388442712904 |
|||
MonoBehaviour: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 5235661441434354422} |
|||
m_Enabled: 1 |
|||
m_EditorHideFlags: 0 |
|||
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, 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_Sprite: {fileID: 10911, 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 |
|||
m_UseSpriteMesh: 0 |
|||
m_PixelsPerUnitMultiplier: 1 |
|||
--- !u!1 &5249698992990008558 |
|||
GameObject: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
serializedVersion: 6 |
|||
m_Component: |
|||
- component: {fileID: 2889208702305137056} |
|||
- component: {fileID: 6012636341666066465} |
|||
- component: {fileID: 1164434712947447015} |
|||
m_Layer: 9 |
|||
m_Name: Text |
|||
m_TagString: Untagged |
|||
m_Icon: {fileID: 0} |
|||
m_NavMeshLayer: 0 |
|||
m_StaticEditorFlags: 0 |
|||
m_IsActive: 1 |
|||
--- !u!224 &2889208702305137056 |
|||
RectTransform: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 5249698992990008558} |
|||
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: 6352810064952983069} |
|||
m_RootOrder: 5 |
|||
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.5, y: 0.5} |
|||
--- !u!222 &6012636341666066465 |
|||
CanvasRenderer: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 5249698992990008558} |
|||
m_CullTransparentMesh: 1 |
|||
--- !u!114 &1164434712947447015 |
|||
MonoBehaviour: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 5249698992990008558} |
|||
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: 14 |
|||
m_FontStyle: 0 |
|||
m_BestFit: 0 |
|||
m_MinSize: 10 |
|||
m_MaxSize: 40 |
|||
m_Alignment: 0 |
|||
m_AlignByGeometry: 0 |
|||
m_RichText: 1 |
|||
m_HorizontalOverflow: 0 |
|||
m_VerticalOverflow: 0 |
|||
m_LineSpacing: 1 |
|||
m_Text: New Text |
|||
--- !u!1 &8406566819066868502 |
|||
GameObject: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
serializedVersion: 6 |
|||
m_Component: |
|||
- component: {fileID: 6087809287161891054} |
|||
- component: {fileID: 7055524750633899273} |
|||
- component: {fileID: 3799196531022497756} |
|||
m_Layer: 9 |
|||
m_Name: Heart (4) |
|||
m_TagString: Untagged |
|||
m_Icon: {fileID: 0} |
|||
m_NavMeshLayer: 0 |
|||
m_StaticEditorFlags: 0 |
|||
m_IsActive: 1 |
|||
--- !u!224 &6087809287161891054 |
|||
RectTransform: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 8406566819066868502} |
|||
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: 6352810064952983069} |
|||
m_RootOrder: 4 |
|||
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.5, y: 0.5} |
|||
--- !u!222 &7055524750633899273 |
|||
CanvasRenderer: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 8406566819066868502} |
|||
m_CullTransparentMesh: 1 |
|||
--- !u!114 &3799196531022497756 |
|||
MonoBehaviour: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 8406566819066868502} |
|||
m_Enabled: 1 |
|||
m_EditorHideFlags: 0 |
|||
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, 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_Sprite: {fileID: 10911, 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 |
|||
m_UseSpriteMesh: 0 |
|||
m_PixelsPerUnitMultiplier: 1 |
|
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
using UnityEngine; |
|||
using UnityEngine.UI; |
|||
public class UIHealthBarManager : MonoBehaviour |
|||
{ |
|||
Transform target; |
|||
int maxHealth=0; |
|||
int currentHealth=0; |
|||
[SerializeField] private Image[] _heartImages = default; |
|||
[SerializeField] private Text healthText = default; |
|||
|
|||
[Header("Listening to")] |
|||
[SerializeField] private IntEventChannelSO _setHealthBar = default; |
|||
[SerializeField] private IntEventChannelSO _inflictDamage = default; |
|||
[SerializeField] private IntEventChannelSO _restoreHealth = default; |
|||
|
|||
|
|||
private void OnEnable() |
|||
{ |
|||
|
|||
_setHealthBar.OnEventRaised += SetHealthBar; |
|||
|
|||
_inflictDamage.OnEventRaised += InflictDamage; |
|||
|
|||
_restoreHealth.OnEventRaised += RestoreHealth; |
|||
|
|||
} |
|||
private void OnDestroy() |
|||
{ |
|||
|
|||
_setHealthBar.OnEventRaised -= SetHealthBar; |
|||
|
|||
_inflictDamage.OnEventRaised -= InflictDamage; |
|||
|
|||
_restoreHealth.OnEventRaised -= RestoreHealth; |
|||
|
|||
} |
|||
public void SetHealthBar(int _maxHealth) |
|||
{ |
|||
maxHealth = _maxHealth; |
|||
currentHealth = _maxHealth; |
|||
setHeartImages(); |
|||
|
|||
} |
|||
public void InflictDamage(int _damage) |
|||
{ |
|||
currentHealth -= _damage; |
|||
setHeartImages(); |
|||
} |
|||
public void RestoreHealth(int _healthToAdd) |
|||
{ |
|||
currentHealth += _healthToAdd; |
|||
setHeartImages(); |
|||
} |
|||
|
|||
void setHeartImages() |
|||
{ |
|||
//clamp current value
|
|||
currentHealth = Mathf.Clamp(currentHealth, 0, maxHealth); |
|||
healthText.text = currentHealth + "/" + maxHealth; |
|||
//find max heart index
|
|||
int heartIndex = Mathf.CeilToInt( ((float)currentHealth / (float)maxHealth) * _heartImages.Length); |
|||
|
|||
for (int i = 0; i < _heartImages.Length; i++) |
|||
{ |
|||
_heartImages[i].color = Color.red; |
|||
if (_heartImages.Length > heartIndex) |
|||
{ |
|||
_heartImages[i].gameObject.SetActive(i <= heartIndex); |
|||
} |
|||
} |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
} |
|
|||
%YAML 1.1 |
|||
%TAG !u! tag:unity3d.com,2011: |
|||
--- !u!1 &129456778788504016 |
|||
GameObject: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
serializedVersion: 6 |
|||
m_Component: |
|||
- component: {fileID: 4477411494155732534} |
|||
- component: {fileID: 8675558951552184746} |
|||
m_Layer: 9 |
|||
m_Name: SliderHealth |
|||
m_TagString: Untagged |
|||
m_Icon: {fileID: 0} |
|||
m_NavMeshLayer: 0 |
|||
m_StaticEditorFlags: 0 |
|||
m_IsActive: 1 |
|||
--- !u!224 &4477411494155732534 |
|||
RectTransform: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 129456778788504016} |
|||
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: 3377568230114908328} |
|||
- {fileID: 7579906292151165910} |
|||
m_Father: {fileID: 6352810064952983069} |
|||
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 &8675558951552184746 |
|||
MonoBehaviour: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 129456778788504016} |
|||
m_Enabled: 1 |
|||
m_EditorHideFlags: 0 |
|||
m_Script: {fileID: 11500000, guid: 67db9e8f0e2ae9c40bc1e2b64352a6b4, type: 3} |
|||
m_Name: |
|||
m_EditorClassIdentifier: |
|||
m_Navigation: |
|||
m_Mode: 0 |
|||
m_WrapAround: 0 |
|||
m_SelectOnUp: {fileID: 0} |
|||
m_SelectOnDown: {fileID: 0} |
|||
m_SelectOnLeft: {fileID: 0} |
|||
m_SelectOnRight: {fileID: 0} |
|||
m_Transition: 1 |
|||
m_Colors: |
|||
m_NormalColor: {r: 1, g: 1, b: 1, a: 1} |
|||
m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} |
|||
m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} |
|||
m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} |
|||
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} |
|||
m_ColorMultiplier: 1 |
|||
m_FadeDuration: 0.1 |
|||
m_SpriteState: |
|||
m_HighlightedSprite: {fileID: 0} |
|||
m_PressedSprite: {fileID: 0} |
|||
m_SelectedSprite: {fileID: 0} |
|||
m_DisabledSprite: {fileID: 0} |
|||
m_AnimationTriggers: |
|||
m_NormalTrigger: Normal |
|||
m_HighlightedTrigger: Highlighted |
|||
m_PressedTrigger: Pressed |
|||
m_SelectedTrigger: Selected |
|||
m_DisabledTrigger: Disabled |
|||
m_Interactable: 0 |
|||
m_TargetGraphic: {fileID: 0} |
|||
m_FillRect: {fileID: 9168795744388526357} |
|||
m_HandleRect: {fileID: 0} |
|||
m_Direction: 0 |
|||
m_MinValue: 0 |
|||
m_MaxValue: 1 |
|||
m_WholeNumbers: 0 |
|||
m_Value: 0.558 |
|||
m_OnValueChanged: |
|||
m_PersistentCalls: |
|||
m_Calls: [] |
|||
--- !u!1 &2717470933152208211 |
|||
GameObject: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
serializedVersion: 6 |
|||
m_Component: |
|||
- component: {fileID: 7579906292151165910} |
|||
m_Layer: 9 |
|||
m_Name: Fill Area |
|||
m_TagString: Untagged |
|||
m_Icon: {fileID: 0} |
|||
m_NavMeshLayer: 0 |
|||
m_StaticEditorFlags: 0 |
|||
m_IsActive: 1 |
|||
--- !u!224 &7579906292151165910 |
|||
RectTransform: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 2717470933152208211} |
|||
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: 9168795744388526357} |
|||
m_Father: {fileID: 4477411494155732534} |
|||
m_RootOrder: 1 |
|||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} |
|||
m_AnchorMin: {x: 0, y: 0.25} |
|||
m_AnchorMax: {x: 1, y: 0.75} |
|||
m_AnchoredPosition: {x: -5, y: 0} |
|||
m_SizeDelta: {x: -20, y: 0} |
|||
m_Pivot: {x: 0.5, y: 0.5} |
|||
--- !u!1 &2770995023073704661 |
|||
GameObject: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
serializedVersion: 6 |
|||
m_Component: |
|||
- component: {fileID: 3377568230114908328} |
|||
- component: {fileID: 3660815796988947421} |
|||
- component: {fileID: 3283600458638593579} |
|||
m_Layer: 9 |
|||
m_Name: Background |
|||
m_TagString: Untagged |
|||
m_Icon: {fileID: 0} |
|||
m_NavMeshLayer: 0 |
|||
m_StaticEditorFlags: 0 |
|||
m_IsActive: 1 |
|||
--- !u!224 &3377568230114908328 |
|||
RectTransform: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 2770995023073704661} |
|||
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: 4477411494155732534} |
|||
m_RootOrder: 0 |
|||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} |
|||
m_AnchorMin: {x: 0, y: 0.25} |
|||
m_AnchorMax: {x: 1, y: 0.75} |
|||
m_AnchoredPosition: {x: 0, y: 0} |
|||
m_SizeDelta: {x: 0, y: 0} |
|||
m_Pivot: {x: 0.5, y: 0.5} |
|||
--- !u!222 &3660815796988947421 |
|||
CanvasRenderer: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 2770995023073704661} |
|||
m_CullTransparentMesh: 1 |
|||
--- !u!114 &3283600458638593579 |
|||
MonoBehaviour: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 2770995023073704661} |
|||
m_Enabled: 1 |
|||
m_EditorHideFlags: 0 |
|||
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, 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_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 |
|||
m_UseSpriteMesh: 0 |
|||
m_PixelsPerUnitMultiplier: 1 |
|||
--- !u!1 &2815881603653157998 |
|||
GameObject: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
serializedVersion: 6 |
|||
m_Component: |
|||
- component: {fileID: 6352810064952983069} |
|||
- component: {fileID: 6395593152779691077} |
|||
- component: {fileID: 7686382842736750647} |
|||
- component: {fileID: 4731765889197187948} |
|||
- component: {fileID: 7057594148529581253} |
|||
m_Layer: 9 |
|||
m_Name: UIHealthbar |
|||
m_TagString: Untagged |
|||
m_Icon: {fileID: 0} |
|||
m_NavMeshLayer: 0 |
|||
m_StaticEditorFlags: 0 |
|||
m_IsActive: 1 |
|||
--- !u!224 &6352810064952983069 |
|||
RectTransform: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 2815881603653157998} |
|||
m_LocalRotation: {x: 0.011508226, y: -0.9995812, z: 0.00209032, w: 0.026469946} |
|||
m_LocalPosition: {x: 0, y: 0, z: -0} |
|||
m_LocalScale: {x: 0.015, y: 0.015, z: 1} |
|||
m_Children: |
|||
- {fileID: 4477411494155732534} |
|||
m_Father: {fileID: 0} |
|||
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.010009766, y: 0.2800293} |
|||
m_SizeDelta: {x: 100, y: 20} |
|||
m_Pivot: {x: 0.5, y: 0.5} |
|||
--- !u!223 &6395593152779691077 |
|||
Canvas: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 2815881603653157998} |
|||
m_Enabled: 1 |
|||
serializedVersion: 3 |
|||
m_RenderMode: 2 |
|||
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 &7686382842736750647 |
|||
MonoBehaviour: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 2815881603653157998} |
|||
m_Enabled: 1 |
|||
m_EditorHideFlags: 0 |
|||
m_Script: {fileID: 11500000, guid: 0cd44c1031e13a943bb63640046fad76, 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 |
|||
m_PresetInfoIsWorld: 0 |
|||
--- !u!114 &4731765889197187948 |
|||
MonoBehaviour: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 2815881603653157998} |
|||
m_Enabled: 1 |
|||
m_EditorHideFlags: 0 |
|||
m_Script: {fileID: 11500000, guid: dc42784cf147c0c48a680349fa168899, type: 3} |
|||
m_Name: |
|||
m_EditorClassIdentifier: |
|||
m_IgnoreReversedGraphics: 1 |
|||
m_BlockingObjects: 0 |
|||
m_BlockingMask: |
|||
serializedVersion: 2 |
|||
m_Bits: 4294967295 |
|||
--- !u!114 &7057594148529581253 |
|||
MonoBehaviour: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 2815881603653157998} |
|||
m_Enabled: 1 |
|||
m_EditorHideFlags: 0 |
|||
m_Script: {fileID: 11500000, guid: f8dfad91156ef4bff806fff3c3f9eacd, type: 3} |
|||
m_Name: |
|||
m_EditorClassIdentifier: |
|||
_healthBar: {fileID: 8675558951552184746} |
|||
_setHealthBar: {fileID: 11400000, guid: 22e3f27f002de44b4948988138dd9377, type: 2} |
|||
_inflictDamage: {fileID: 11400000, guid: be921b398c68d450e9e3c55dde697149, type: 2} |
|||
_restoreHealth: {fileID: 11400000, guid: de4a39f85969d44cba990125224ff7ef, type: 2} |
|||
--- !u!1 &8076465948275431472 |
|||
GameObject: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
serializedVersion: 6 |
|||
m_Component: |
|||
- component: {fileID: 9168795744388526357} |
|||
- component: {fileID: 6388844992306058055} |
|||
- component: {fileID: 8967380021000610061} |
|||
m_Layer: 9 |
|||
m_Name: Fill |
|||
m_TagString: Untagged |
|||
m_Icon: {fileID: 0} |
|||
m_NavMeshLayer: 0 |
|||
m_StaticEditorFlags: 0 |
|||
m_IsActive: 1 |
|||
--- !u!224 &9168795744388526357 |
|||
RectTransform: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 8076465948275431472} |
|||
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: 7579906292151165910} |
|||
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: 10, y: 0} |
|||
m_Pivot: {x: 0.5, y: 0.5} |
|||
--- !u!222 &6388844992306058055 |
|||
CanvasRenderer: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 8076465948275431472} |
|||
m_CullTransparentMesh: 1 |
|||
--- !u!114 &8967380021000610061 |
|||
MonoBehaviour: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 8076465948275431472} |
|||
m_Enabled: 1 |
|||
m_EditorHideFlags: 0 |
|||
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, 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_Sprite: {fileID: 10905, 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 |
|||
m_UseSpriteMesh: 0 |
|||
m_PixelsPerUnitMultiplier: 1 |
|
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
using UnityEngine; |
|||
using UnityEngine.UI; |
|||
|
|||
public class UIHealthBarManager : MonoBehaviour |
|||
{ |
|||
Transform target; |
|||
int maxHealth = 0; |
|||
int currentHealth = 0; |
|||
[SerializeField] private Slider _healthBar = default; |
|||
|
|||
[Header("Listening to")] |
|||
[SerializeField] private IntEventChannelSO _setHealthBar = default; |
|||
[SerializeField] private IntEventChannelSO _inflictDamage = default; |
|||
[SerializeField] private IntEventChannelSO _restoreHealth = default; |
|||
|
|||
private void OnEnable() |
|||
{ |
|||
|
|||
if ((GetComponent<Canvas>() != null) && (Camera.main != null)) |
|||
{ |
|||
GetComponent<Canvas>().worldCamera = Camera.main; |
|||
target = Camera.main.transform; |
|||
|
|||
} |
|||
} |
|||
private void Start() |
|||
{ |
|||
|
|||
_setHealthBar.OnEventRaised += SetHealthBar; |
|||
|
|||
_inflictDamage.OnEventRaised += InflictDamage; |
|||
|
|||
_restoreHealth.OnEventRaised += RestoreHealth; |
|||
|
|||
} |
|||
private void OnDestroy() |
|||
{ |
|||
|
|||
_setHealthBar.OnEventRaised -= SetHealthBar; |
|||
|
|||
_inflictDamage.OnEventRaised -= InflictDamage; |
|||
|
|||
_restoreHealth.OnEventRaised -= RestoreHealth; |
|||
|
|||
} |
|||
public void SetHealthBar(int _maxHealth) |
|||
{ |
|||
maxHealth = _maxHealth; |
|||
currentHealth = _maxHealth; |
|||
setSlider(); |
|||
|
|||
} |
|||
public void InflictDamage(int _damage) |
|||
{ |
|||
currentHealth -= _damage; |
|||
setSlider(); |
|||
} |
|||
public void RestoreHealth(int _healthToAdd) |
|||
{ |
|||
currentHealth += _healthToAdd; |
|||
setSlider(); |
|||
} |
|||
|
|||
void setSlider() |
|||
{ |
|||
//clamp current value
|
|||
currentHealth = Mathf.Clamp(currentHealth, 0, maxHealth); |
|||
//find new slider value
|
|||
float sliderValue = 0; |
|||
sliderValue = currentHealth / maxHealth; |
|||
_healthBar.value = sliderValue; |
|||
|
|||
} |
|||
|
|||
private void Update() |
|||
{ |
|||
if (target != null) |
|||
transform.LookAt(target, Vector3.down); |
|||
} |
|||
} |
撰写
预览
正在加载...
取消
保存
Reference in new issue