Skip to content
Snippets Groups Projects
Commit dad15c0e authored by Bernardus Willson's avatar Bernardus Willson
Browse files

Merge branch 'feat/petHUD' into 'staging'

feat: pet HUD

See merge request !58
parents ab312ad9 147246f0
Branches
Tags
2 merge requests!78RELEASE,!58feat: pet HUD
This diff is collapsed.
...@@ -395,6 +395,24 @@ PrefabInstance: ...@@ -395,6 +395,24 @@ PrefabInstance:
m_AddedGameObjects: [] m_AddedGameObjects: []
m_AddedComponents: [] m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 55fecf1063fe8474493f4866aaadffbf, type: 3} m_SourcePrefab: {fileID: 100100000, guid: 55fecf1063fe8474493f4866aaadffbf, type: 3}
--- !u!1 &19533144 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 8593515693264656183, guid: 2efde1f742401b345992c5c07ac5d64d,
type: 3}
m_PrefabInstance: {fileID: 1247124631}
m_PrefabAsset: {fileID: 0}
--- !u!114 &21651978 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 6996945697729140689, guid: 2efde1f742401b345992c5c07ac5d64d,
type: 3}
m_PrefabInstance: {fileID: 1247124631}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &26782207 --- !u!1 &26782207
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
...@@ -2636,7 +2654,7 @@ GameObject: ...@@ -2636,7 +2654,7 @@ GameObject:
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0
m_IsActive: 1 m_IsActive: 0
--- !u!114 &211348305 --- !u!114 &211348305
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
...@@ -13196,6 +13214,18 @@ Transform: ...@@ -13196,6 +13214,18 @@ Transform:
type: 3} type: 3}
m_PrefabInstance: {fileID: 256249270} m_PrefabInstance: {fileID: 256249270}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
--- !u!114 &887136721 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 7238542208034607587, guid: 2efde1f742401b345992c5c07ac5d64d,
type: 3}
m_PrefabInstance: {fileID: 1247124631}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!4 &887445999 stripped --- !u!4 &887445999 stripped
Transform: Transform:
m_CorrespondingSourceObject: {fileID: 400000, guid: 55fecf1063fe8474493f4866aaadffbf, m_CorrespondingSourceObject: {fileID: 400000, guid: 55fecf1063fe8474493f4866aaadffbf,
...@@ -16792,6 +16822,18 @@ PrefabInstance: ...@@ -16792,6 +16822,18 @@ PrefabInstance:
m_AddedGameObjects: [] m_AddedGameObjects: []
m_AddedComponents: [] m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: d76a78a721a5d9d499abc8aec19fdc8b, type: 3} m_SourcePrefab: {fileID: 100100000, guid: d76a78a721a5d9d499abc8aec19fdc8b, type: 3}
--- !u!114 &1095082556 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 4826796673589713399, guid: 2efde1f742401b345992c5c07ac5d64d,
type: 3}
m_PrefabInstance: {fileID: 1247124631}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1001 &1096323825 --- !u!1001 &1096323825
PrefabInstance: PrefabInstance:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
...@@ -18209,6 +18251,46 @@ PrefabInstance: ...@@ -18209,6 +18251,46 @@ PrefabInstance:
propertyPath: m_LocalEulerAnglesHint.y propertyPath: m_LocalEulerAnglesHint.y
value: -90 value: -90
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 6678157685655472961, guid: 51cde55a2a5a5c3448cd8df1ab6225dd,
type: 3}
propertyPath: petName1
value:
objectReference: {fileID: 1182068909}
- target: {fileID: 6678157685655472961, guid: 51cde55a2a5a5c3448cd8df1ab6225dd,
type: 3}
propertyPath: petName2
value:
objectReference: {fileID: 1556941359}
- target: {fileID: 6678157685655472961, guid: 51cde55a2a5a5c3448cd8df1ab6225dd,
type: 3}
propertyPath: petHealthBar1
value:
objectReference: {fileID: 2109740425}
- target: {fileID: 6678157685655472961, guid: 51cde55a2a5a5c3448cd8df1ab6225dd,
type: 3}
propertyPath: petHealthBar2
value:
objectReference: {fileID: 19533144}
- target: {fileID: 6678157685655472961, guid: 51cde55a2a5a5c3448cd8df1ab6225dd,
type: 3}
propertyPath: backHealthBar1
value:
objectReference: {fileID: 1702992525}
- target: {fileID: 6678157685655472961, guid: 51cde55a2a5a5c3448cd8df1ab6225dd,
type: 3}
propertyPath: backHealthBar2
value:
objectReference: {fileID: 1095082556}
- target: {fileID: 6678157685655472961, guid: 51cde55a2a5a5c3448cd8df1ab6225dd,
type: 3}
propertyPath: frontHealthBar1
value:
objectReference: {fileID: 21651978}
- target: {fileID: 6678157685655472961, guid: 51cde55a2a5a5c3448cd8df1ab6225dd,
type: 3}
propertyPath: frontHealthBar2
value:
objectReference: {fileID: 887136721}
- target: {fileID: 7368169119402864002, guid: 51cde55a2a5a5c3448cd8df1ab6225dd, - target: {fileID: 7368169119402864002, guid: 51cde55a2a5a5c3448cd8df1ab6225dd,
type: 3} type: 3}
propertyPath: m_LocalPosition.x propertyPath: m_LocalPosition.x
...@@ -18794,6 +18876,18 @@ Transform: ...@@ -18794,6 +18876,18 @@ Transform:
m_Children: [] m_Children: []
m_Father: {fileID: 1721720567} m_Father: {fileID: 1721720567}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1182068909 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 2261296204684676316, guid: 2efde1f742401b345992c5c07ac5d64d,
type: 3}
m_PrefabInstance: {fileID: 1247124631}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1001 &1184138538 --- !u!1001 &1184138538
PrefabInstance: PrefabInstance:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
...@@ -20310,31 +20404,11 @@ PrefabInstance: ...@@ -20310,31 +20404,11 @@ PrefabInstance:
serializedVersion: 3 serializedVersion: 3
m_TransformParent: {fileID: 0} m_TransformParent: {fileID: 0}
m_Modifications: m_Modifications:
- target: {fileID: 1604671993335288653, guid: 2efde1f742401b345992c5c07ac5d64d,
type: 3}
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_Target
value:
objectReference: {fileID: 0}
- target: {fileID: 1604671993335288653, guid: 2efde1f742401b345992c5c07ac5d64d,
type: 3}
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_MethodName
value: ReplayGame
objectReference: {fileID: 0}
- target: {fileID: 2434625601994063327, guid: 2efde1f742401b345992c5c07ac5d64d, - target: {fileID: 2434625601994063327, guid: 2efde1f742401b345992c5c07ac5d64d,
type: 3} type: 3}
propertyPath: m_Name propertyPath: m_Name
value: PlayerHUD value: PlayerHUD
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 5675171226873387433, guid: 2efde1f742401b345992c5c07ac5d64d,
type: 3}
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_Target
value:
objectReference: {fileID: 0}
- target: {fileID: 5675171226873387433, guid: 2efde1f742401b345992c5c07ac5d64d,
type: 3}
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_MethodName
value: BackToMainMenu
objectReference: {fileID: 0}
- target: {fileID: 8743020687667344940, guid: 2efde1f742401b345992c5c07ac5d64d, - target: {fileID: 8743020687667344940, guid: 2efde1f742401b345992c5c07ac5d64d,
type: 3} type: 3}
propertyPath: m_Pivot.x propertyPath: m_Pivot.x
...@@ -24327,6 +24401,18 @@ Transform: ...@@ -24327,6 +24401,18 @@ Transform:
type: 3} type: 3}
m_PrefabInstance: {fileID: 1773797677} m_PrefabInstance: {fileID: 1773797677}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
--- !u!114 &1556941359 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 6156841489287955234, guid: 2efde1f742401b345992c5c07ac5d64d,
type: 3}
m_PrefabInstance: {fileID: 1247124631}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1001 &1557129979 --- !u!1001 &1557129979
PrefabInstance: PrefabInstance:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
...@@ -26376,6 +26462,18 @@ Transform: ...@@ -26376,6 +26462,18 @@ Transform:
m_Children: [] m_Children: []
m_Father: {fileID: 52880495} m_Father: {fileID: 52880495}
m_LocalEulerAnglesHint: {x: 0, y: 90, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 90, z: 0}
--- !u!114 &1702992525 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 2556371953134110589, guid: 2efde1f742401b345992c5c07ac5d64d,
type: 3}
m_PrefabInstance: {fileID: 1247124631}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1001 &1705026251 --- !u!1001 &1705026251
PrefabInstance: PrefabInstance:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
...@@ -32957,6 +33055,12 @@ Transform: ...@@ -32957,6 +33055,12 @@ Transform:
type: 3} type: 3}
m_PrefabInstance: {fileID: 1169456219} m_PrefabInstance: {fileID: 1169456219}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
--- !u!1 &2109740425 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 2525808155420465753, guid: 2efde1f742401b345992c5c07ac5d64d,
type: 3}
m_PrefabInstance: {fileID: 1247124631}
m_PrefabAsset: {fileID: 0}
--- !u!1001 &2110689653 --- !u!1001 &2110689653
PrefabInstance: PrefabInstance:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using TMPro;
using UnityEngine; using UnityEngine;
using UnityEngine.UI;
public class PlayerInventory : MonoBehaviour public class PlayerInventory : MonoBehaviour
{ {
...@@ -9,6 +11,21 @@ public class PlayerInventory : MonoBehaviour ...@@ -9,6 +11,21 @@ public class PlayerInventory : MonoBehaviour
private List<Pet> playerPets = new List<Pet>(); private List<Pet> playerPets = new List<Pet>();
[SerializeField] [SerializeField]
private Pet activePet; private Pet activePet;
private float lerpTimer;
public float chipSpeed = 2f;
[Header("Pet Health Bar 1")]
public GameObject petHealthBar1;
public Image frontHealthBar1;
public Image backHealthBar1;
public TextMeshProUGUI petName1;
[Header("Pet Health Bar 2")]
public GameObject petHealthBar2;
public Image frontHealthBar2;
public Image backHealthBar2;
public TextMeshProUGUI petName2;
// Start is called before the first frame update // Start is called before the first frame update
void Start() void Start()
{ {
...@@ -29,6 +46,50 @@ public class PlayerInventory : MonoBehaviour ...@@ -29,6 +46,50 @@ public class PlayerInventory : MonoBehaviour
{ {
playerPets.Remove(pet); playerPets.Remove(pet);
} }
if (playerPets.Count == 2)
{
UpdateHealthUI1(playerPets[0]);
UpdateHealthUI2(playerPets[1]);
if (playerPets[0].type == "Healer")
{
petName1.text = "Healing Orb";
}
else if (playerPets[0].type == "Attack")
{
petName1.text = "Wolf";
}
if (playerPets[1].type == "Healer")
{
petName2.text = "Healing Orb";
}
else if (playerPets[1].type == "Attack")
{
petName2.text = "Wolf";
}
petHealthBar1.SetActive(true);
petHealthBar2.SetActive(true);
}
else if (playerPets.Count == 1)
{
UpdateHealthUI1(pet);
if (pet.type == "Healer")
{
petName1.text = "Healing Orb";
}
else if (pet.type == "Attack")
{
petName1.text = "Wolf";
}
petHealthBar1.SetActive(true);
petHealthBar2.SetActive(false);
}
else if (playerPets.Count == 0)
{
petHealthBar1.SetActive(false);
petHealthBar2.SetActive(false);
}
} }
} }
...@@ -54,4 +115,50 @@ public class PlayerInventory : MonoBehaviour ...@@ -54,4 +115,50 @@ public class PlayerInventory : MonoBehaviour
{ {
return playerPets; return playerPets;
} }
public void UpdateHealthUI1(Pet pet)
{
float fillF = frontHealthBar1.fillAmount;
float fillB = backHealthBar1.fillAmount;
float hFraction = pet.health / pet.maxHealth;
if (fillB > hFraction)
{
frontHealthBar1.fillAmount = hFraction;
lerpTimer += Time.deltaTime;
float percentComplete = lerpTimer / chipSpeed;
percentComplete = percentComplete * percentComplete;
backHealthBar1.fillAmount = Mathf.Lerp(fillB, hFraction, percentComplete);
}
if (fillF < hFraction)
{
backHealthBar1.fillAmount = hFraction;
lerpTimer += Time.deltaTime;
float percentComplete = lerpTimer / chipSpeed;
percentComplete = percentComplete * percentComplete;
frontHealthBar1.fillAmount = Mathf.Lerp(fillF, backHealthBar1.fillAmount, percentComplete);
}
}
public void UpdateHealthUI2(Pet pet)
{
float fillF = frontHealthBar2.fillAmount;
float fillB = backHealthBar2.fillAmount;
float hFraction = pet.health / pet.maxHealth;
if (fillB > hFraction)
{
frontHealthBar2.fillAmount = hFraction;
lerpTimer += Time.deltaTime;
float percentComplete = lerpTimer / chipSpeed;
percentComplete = percentComplete * percentComplete;
backHealthBar2.fillAmount = Mathf.Lerp(fillB, hFraction, percentComplete);
}
if (fillF < hFraction)
{
backHealthBar2.fillAmount = hFraction;
lerpTimer += Time.deltaTime;
float percentComplete = lerpTimer / chipSpeed;
percentComplete = percentComplete * percentComplete;
frontHealthBar2.fillAmount = Mathf.Lerp(fillF, backHealthBar2.fillAmount, percentComplete);
}
}
} }
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