they do not call me the ui designer
This commit is contained in:
parent
daf3218043
commit
68af10bc4d
14 changed files with 1677 additions and 125 deletions
|
|
@ -1,3 +1,4 @@
|
|||
using System;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
|
@ -21,10 +22,19 @@ public class ActionUIHandler : MonoBehaviour
|
|||
#endregion
|
||||
private PlayerEntity selectedEntity;
|
||||
private RangedWeapon possibleRanged;
|
||||
public bool opened;
|
||||
[Header("Main UI")]
|
||||
[SerializeField] private Vector3 offset;
|
||||
[SerializeField] private GameObject actionUI;
|
||||
[SerializeField] private TextMeshProUGUI actionText;
|
||||
public bool opened;
|
||||
[Header("Info UI")]
|
||||
[SerializeField] private GameObject infoUI;
|
||||
[SerializeField] private TextMeshProUGUI nameLabel;
|
||||
[SerializeField] private TextMeshProUGUI classLabel;
|
||||
[SerializeField] private Image unitPortrait;
|
||||
[SerializeField] private TextMeshProUGUI attackLabel;
|
||||
[SerializeField] private TextMeshProUGUI speedLabel;
|
||||
[SerializeField] private Transform healthBar;
|
||||
[SerializeField] private TextMeshProUGUI healthText;
|
||||
[Header("Action Buttons")]
|
||||
[SerializeField] private Button moveButton;
|
||||
[SerializeField] private Button attackButton;
|
||||
|
|
@ -37,13 +47,15 @@ public class ActionUIHandler : MonoBehaviour
|
|||
[SerializeField] private float templateButtonHeight;
|
||||
|
||||
//500 if statements in this script lol
|
||||
|
||||
public void ShowUI(PlayerEntity target)
|
||||
{
|
||||
opened = true;
|
||||
possibleRanged = null;
|
||||
selectedEntity = target;
|
||||
transform.position = Input.mousePosition + offset;
|
||||
actionUI.SetActive(true);
|
||||
actionText.gameObject.SetActive(true);
|
||||
infoUI.SetActive(true);
|
||||
UpdateUI();
|
||||
}
|
||||
|
||||
|
|
@ -53,7 +65,7 @@ public class ActionUIHandler : MonoBehaviour
|
|||
{
|
||||
possibleRanged = isRanged;
|
||||
}
|
||||
if ((!isRanged || !isRanged.fired) && !selectedEntity.hasAttacked)
|
||||
if (!isRanged || !isRanged.fired)
|
||||
{
|
||||
attackButton.gameObject.SetActive(true);
|
||||
reloadButton.gameObject.SetActive(false);
|
||||
|
|
@ -63,7 +75,7 @@ public class ActionUIHandler : MonoBehaviour
|
|||
attackButton.gameObject.SetActive(false);
|
||||
if (isRanged && isRanged.fired)
|
||||
{
|
||||
if (selectedEntity.hasMoved || selectedEntity.hasAttacked)
|
||||
if (selectedEntity.actions < 2)
|
||||
{
|
||||
reloadButton.gameObject.SetActive(false);
|
||||
}
|
||||
|
|
@ -73,27 +85,37 @@ public class ActionUIHandler : MonoBehaviour
|
|||
}
|
||||
}
|
||||
}
|
||||
if (!selectedEntity.hasMoved || !selectedEntity.hasAttacked)
|
||||
{
|
||||
moveButton.gameObject.SetActive(true);
|
||||
switchButton.gameObject.SetActive(true);
|
||||
}
|
||||
if (selectedEntity.hasAttacked && selectedEntity.hasMoved)
|
||||
moveButton.gameObject.SetActive(true);
|
||||
switchButton.gameObject.SetActive(true);
|
||||
actionText.text = $"Remaining Actions: {selectedEntity.actions}";
|
||||
UpdateInfo();
|
||||
if (selectedEntity.actions == 0)
|
||||
{
|
||||
HideUI();
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateInfo()
|
||||
{
|
||||
healthBar.localScale = new Vector3(selectedEntity.health / selectedEntity.maxHealth,1,1);
|
||||
healthText.text = $"{selectedEntity.health}/{selectedEntity.maxHealth}";
|
||||
attackLabel.text = $"Attack: {selectedEntity.currentWeapon.damage}";
|
||||
speedLabel.text = $"Speed: {selectedEntity.maxMovement}";
|
||||
}
|
||||
public void HideUI()
|
||||
{
|
||||
opened = false;
|
||||
actionUI.SetActive(false);
|
||||
weaponUIPanel.gameObject.SetActive(false);
|
||||
foreach (Transform uiObject in transform)
|
||||
{
|
||||
uiObject.gameObject.SetActive(false);
|
||||
}
|
||||
infoUI.SetActive(false);
|
||||
}
|
||||
|
||||
public void ReloadGun()
|
||||
{
|
||||
possibleRanged.Reload();
|
||||
selectedEntity.hasAttacked = true;
|
||||
selectedEntity.actions -= 2;
|
||||
HideUI();
|
||||
}
|
||||
|
||||
|
|
@ -145,7 +167,7 @@ public class ActionUIHandler : MonoBehaviour
|
|||
|
||||
public void SelectWeapon(Weapon weaponSelected)
|
||||
{
|
||||
MoveAction();
|
||||
selectedEntity.actions--;
|
||||
selectedEntity.SwitchWeapon(weaponSelected);
|
||||
HideWeaponList();
|
||||
UpdateUI();
|
||||
|
|
@ -155,15 +177,4 @@ public class ActionUIHandler : MonoBehaviour
|
|||
{
|
||||
weaponUIPanel.gameObject.SetActive(false);
|
||||
}
|
||||
private void MoveAction()
|
||||
{
|
||||
if (!selectedEntity.hasMoved)
|
||||
{
|
||||
selectedEntity.hasMoved = true;
|
||||
}
|
||||
else if (!selectedEntity.hasAttacked)
|
||||
{
|
||||
selectedEntity.hasAttacked = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue