Added a functionality on tab hold

This commit is contained in:
Alicja 2022-12-18 19:19:57 +01:00
parent fc4ef01514
commit 5bdac7a034
11 changed files with 348 additions and 2 deletions

View File

@ -0,0 +1,24 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DisplayExpStatus : MonoBehaviour
{
public GameObject expText;
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.Tab))
{
expText.SetActive(true);
}
if (Input.GetKeyUp(KeyCode.Tab))
{
expText.SetActive(false);
}
}
}

View File

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

View File

@ -0,0 +1,26 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class DisplayHealthStatus : MonoBehaviour
{
public GameObject healthText;
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.Tab))
{
healthText.SetActive(true);
}
if (Input.GetKeyUp(KeyCode.Tab))
{
healthText.SetActive(false);
}
}
}

View File

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

18
Assets/ManageExpBar.cs Normal file
View File

@ -0,0 +1,18 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ManageExpBar : MonoBehaviour
{
public GameObject levelNumber;
void OnEnable()
{
levelNumber.SetActive(false);
}
void OnDisable()
{
levelNumber.SetActive(true);
}
}

View File

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

View File

@ -20654,6 +20654,85 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 318506650}
m_CullTransparentMesh: 1
--- !u!1 &328577119
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 328577120}
- component: {fileID: 328577124}
- component: {fileID: 328577123}
m_Layer: 5
m_Name: GameObject
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
--- !u!224 &328577120
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 328577119}
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: 378577487}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 40, y: 15}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &328577123
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 328577119}
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: 12800000, guid: f00af03777ec0764c9988b7276259e03, type: 2}
m_FontSize: 0
m_FontStyle: 0
m_BestFit: 0
m_MinSize: 0
m_MaxSize: 40
m_Alignment: 4
m_AlignByGeometry: 0
m_RichText: 1
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text:
--- !u!222 &328577124
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 328577119}
m_CullTransparentMesh: 1
--- !u!1 &340745810
GameObject:
m_ObjectHideFlags: 0
@ -25756,6 +25835,7 @@ GameObject:
- component: {fileID: 378577487}
- component: {fileID: 378577489}
- component: {fileID: 378577488}
- component: {fileID: 378577490}
m_Layer: 5
m_Name: Health Bar
m_TagString: Untagged
@ -25777,6 +25857,7 @@ RectTransform:
- {fileID: 562803613}
- {fileID: 564650393}
- {fileID: 1290527201}
- {fileID: 328577120}
m_Father: {fileID: 184083800}
m_RootOrder: 11
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
@ -25800,6 +25881,10 @@ MonoBehaviour:
slider: {fileID: 378577489}
maxHealth: 0
health: 0
displayText: {fileID: 328577123}
currentHealth: 0
maxHealthString:
currentHealthString:
--- !u!114 &378577489
MonoBehaviour:
m_ObjectHideFlags: 0
@ -25851,6 +25936,19 @@ MonoBehaviour:
m_OnValueChanged:
m_PersistentCalls:
m_Calls: []
--- !u!114 &378577490
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 378577486}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: b56dee52b87a0224dbc8ff52ed83a5a3, type: 3}
m_Name:
m_EditorClassIdentifier:
healthText: {fileID: 328577119}
--- !u!1 &379044509
GameObject:
m_ObjectHideFlags: 0
@ -39630,6 +39728,99 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1081484090}
m_CullTransparentMesh: 1
--- !u!1 &1087002496
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1087002497}
- component: {fileID: 1087002499}
- component: {fileID: 1087002498}
- component: {fileID: 1087002500}
m_Layer: 5
m_Name: expText
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
--- !u!224 &1087002497
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1087002496}
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: 1751060206}
m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 40, y: 15}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1087002498
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1087002496}
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: 12800000, guid: f00af03777ec0764c9988b7276259e03, type: 2}
m_FontSize: 0
m_FontStyle: 0
m_BestFit: 0
m_MinSize: 0
m_MaxSize: 40
m_Alignment: 4
m_AlignByGeometry: 0
m_RichText: 1
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text:
--- !u!222 &1087002499
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1087002496}
m_CullTransparentMesh: 1
--- !u!114 &1087002500
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1087002496}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 231253ef9edb84948a1defaa79c31079, type: 3}
m_Name:
m_EditorClassIdentifier:
levelNumber: {fileID: 1925227433}
--- !u!1 &1102795096
GameObject:
m_ObjectHideFlags: 0
@ -145988,6 +146179,7 @@ GameObject:
- component: {fileID: 1751060206}
- component: {fileID: 1751060208}
- component: {fileID: 1751060207}
- component: {fileID: 1751060209}
m_Layer: 5
m_Name: Level Bar
m_TagString: Untagged
@ -146010,6 +146202,7 @@ RectTransform:
- {fileID: 265628973}
- {fileID: 1055977145}
- {fileID: 1925227434}
- {fileID: 1087002497}
m_Father: {fileID: 184083800}
m_RootOrder: 12
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
@ -146033,6 +146226,9 @@ MonoBehaviour:
slider: {fileID: 1751060208}
maxExp: 0
exp: 0
maxExpString:
expString:
displayText: {fileID: 1087002498}
--- !u!114 &1751060208
MonoBehaviour:
m_ObjectHideFlags: 0
@ -146084,6 +146280,19 @@ MonoBehaviour:
m_OnValueChanged:
m_PersistentCalls:
m_Calls: []
--- !u!114 &1751060209
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1751060205}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 05516c4d688c3c14f97aa79ae39828bd, type: 3}
m_Name:
m_EditorClassIdentifier:
expText: {fileID: 1087002496}
--- !u!1 &1754712845
GameObject:
m_ObjectHideFlags: 0
@ -146856,7 +147065,7 @@ GameObject:
- component: {fileID: 1925227436}
- component: {fileID: 1925227435}
m_Layer: 5
m_Name: GameObject
m_Name: LevelNumber
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0

View File

@ -8,7 +8,12 @@ public class HealthBar : MonoBehaviour
public Slider slider;
public float maxHealth;
public float health;
public Text displayText;
public float currentHealth;
public string maxHealthString;
public string currentHealthString;
public void SetMaxHealth(float health)
{
@ -27,6 +32,11 @@ public class HealthBar : MonoBehaviour
health = PlayerPrefs.GetFloat("health");
slider.maxValue = maxHealth;
slider.value = health;
currentHealth = PlayerPrefs.GetFloat("health");
maxHealthString = maxHealth.ToString();
currentHealthString = currentHealth.ToString();
displayText.text = currentHealthString + "/" + maxHealthString;
//SetExp(exp);
}
}

View File

@ -8,6 +8,9 @@ public class LevelBar : MonoBehaviour
public Slider slider;
public float maxExp;
public float exp;
public string maxExpString;
public string expString;
public Text displayText;
public void SetStartExp(float exp)
{
@ -22,6 +25,10 @@ public class LevelBar : MonoBehaviour
exp = PlayerPrefs.GetFloat("exp");
slider.maxValue = maxExp;
slider.value = exp;
maxExpString = maxExp.ToString();
expString = exp.ToString();
displayText.text = expString + "/" + maxExpString;
//SetExp(exp);
}

8
Assets/healthText.cs Normal file
View File

@ -0,0 +1,8 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class healthText : MonoBehaviour
{
}

11
Assets/healthText.cs.meta Normal file
View File

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