Skip to content
Snippets Groups Projects
Commit c8d83283 authored by william's avatar william
Browse files

adicionado feedback visual pra barra de energia. TODO: melhorar scripts e...

adicionado feedback visual pra barra de energia. TODO: melhorar scripts e adicionar ligacao a skills de def e movimento
parent 1c8a0fc2
No related branches found
No related tags found
No related merge requests found
......@@ -350,6 +350,7 @@ MonoBehaviour:
jumpForce: 7
currentHand: 0
opponentHand: 0
maxStamina: 10
--- !u!114 &114180439832049938
MonoBehaviour:
m_ObjectHideFlags: 1
......@@ -361,6 +362,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 8d35f943c0650b44ea7bae14db2f5510, type: 3}
m_Name:
m_EditorClassIdentifier:
energyCost: 3
speedModifier: 2
--- !u!114 &114205129271451504
MonoBehaviour:
......@@ -405,6 +407,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 927f207216af6f6488fdc924b0028778, type: 3}
m_Name:
m_EditorClassIdentifier:
energyCost: 2
speedModifier: 2
--- !u!114 &114532893894701770
MonoBehaviour:
......@@ -433,6 +436,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: ff741caefd6e08c46b4842449acb8a77, type: 3}
m_Name:
m_EditorClassIdentifier:
energyCost: 0
--- !u!114 &114580466645618794
MonoBehaviour:
m_ObjectHideFlags: 1
......@@ -483,6 +487,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: dde918e167965d746ac01b8bac582d97, type: 3}
m_Name:
m_EditorClassIdentifier:
energyCost: 0
--- !u!114 &114725966455030456
MonoBehaviour:
m_ObjectHideFlags: 1
......@@ -521,6 +526,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 58d676d3c02b08c4bba0f7573a288273, type: 3}
m_Name:
m_EditorClassIdentifier:
energyCost: 1
--- !u!114 &114951972081975344
MonoBehaviour:
m_ObjectHideFlags: 1
......
......@@ -527,8 +527,9 @@ GameObject:
- component: {fileID: 1194462790}
- component: {fileID: 1194462792}
- component: {fileID: 1194462791}
- component: {fileID: 1194462793}
m_Layer: 5
m_Name: Image (1)
m_Name: Energy bar
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
......@@ -564,7 +565,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0.21875, g: 0.875, b: 0.35905167, a: 1}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
......@@ -585,6 +586,17 @@ CanvasRenderer:
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1194462789}
--- !u!114 &1194462793
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1194462789}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5de20a1632eee5a4b8bacbd9ae358cf1, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &1368919582
GameObject:
m_ObjectHideFlags: 0
......@@ -857,7 +869,7 @@ GameObject:
- component: {fileID: 2067333073}
- component: {fileID: 2067333072}
m_Layer: 5
m_Name: Image
m_Name: Energy bar background
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
......
using System.Collections;
using UnityEngine;
using UnityEngine.UI;
public class EnergyBarController : MonoBehaviour
{
private Image bar;
private void Start()
{
bar = GetComponent<Image>();
PlayerController.staminaUse += updateState;
}
private void updateState(float stamina)
{
bar.fillAmount = stamina / 10;
bar.color = Color.Lerp(Color.red, Color.green, bar.fillAmount);
}
}
fileFormatVersion: 2
guid: 5de20a1632eee5a4b8bacbd9ae358cf1
timeCreated: 1520538714
licenseType: Free
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
......@@ -3,6 +3,8 @@ using UnityEngine;
public class PlayerController : Controller
{
public static event System.Action<float> staminaUse;
[SerializeField] private float maxStamina;
private float currentStamina;
......@@ -34,7 +36,10 @@ public class PlayerController : Controller
private void updateStamina(float cost)
{
currentStamina -= cost;
Debug.Log(currentStamina);
if (staminaUse != null)
{
staminaUse(currentStamina);
}
}
private void Update()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment