a ui (singular)
This commit is contained in:
parent
5776d5e889
commit
7b151c1a53
7 changed files with 1201 additions and 5 deletions
File diff suppressed because it is too large
Load diff
40
Assets/Scripts/ActionUIHandler.cs
Normal file
40
Assets/Scripts/ActionUIHandler.cs
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class ActionUIHandler : MonoBehaviour
|
||||||
|
{
|
||||||
|
#region Statication
|
||||||
|
|
||||||
|
public static ActionUIHandler instance;
|
||||||
|
|
||||||
|
private void Awake()
|
||||||
|
{
|
||||||
|
if (instance != null && instance != this)
|
||||||
|
{
|
||||||
|
Destroy(gameObject);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
instance = this;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
[Header("UI")]
|
||||||
|
[SerializeField] private Vector3 offset;
|
||||||
|
[SerializeField] private GameObject actionUI;
|
||||||
|
private Entity selectedEntity;
|
||||||
|
public void ShowUI(Entity target)
|
||||||
|
{
|
||||||
|
selectedEntity = target;
|
||||||
|
transform.position = Input.mousePosition + offset;
|
||||||
|
actionUI.SetActive(true);
|
||||||
|
}
|
||||||
|
public void HideUI()
|
||||||
|
{
|
||||||
|
actionUI.SetActive(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void MoveEntity()
|
||||||
|
{
|
||||||
|
HideUI();
|
||||||
|
PlayerEntityMovement.instance.SelectEntity(selectedEntity);
|
||||||
|
}
|
||||||
|
}
|
||||||
2
Assets/Scripts/ActionUIHandler.cs.meta
Normal file
2
Assets/Scripts/ActionUIHandler.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 0891f634b432ac024a82048b58adf276
|
||||||
6
Assets/Scripts/FollowMouse.cs
Normal file
6
Assets/Scripts/FollowMouse.cs
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
using System;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class FollowMouse : MonoBehaviour
|
||||||
|
{
|
||||||
|
}
|
||||||
2
Assets/Scripts/FollowMouse.cs.meta
Normal file
2
Assets/Scripts/FollowMouse.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 0e99d7da1e39926699841c721f75670a
|
||||||
|
|
@ -25,9 +25,9 @@ public class PlayerEntity : Entity
|
||||||
}
|
}
|
||||||
private void OnMouseDown()
|
private void OnMouseDown()
|
||||||
{
|
{
|
||||||
if (!hasMoved && !PlayerEntityMovement.instance.isMoving)
|
if ((!hasMoved) && !PlayerEntityMovement.instance.isMoving)
|
||||||
{
|
{
|
||||||
PlayerEntityMovement.instance.SelectEntity(this);
|
ActionUIHandler.instance.ShowUI(this);
|
||||||
SkipTurn();
|
SkipTurn();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -171,6 +171,7 @@ public class PlayerEntityMovement : MonoBehaviour
|
||||||
StartCoroutine(selectedEntity.MoveToLocation(pathRequested.ToArray()));
|
StartCoroutine(selectedEntity.MoveToLocation(pathRequested.ToArray()));
|
||||||
templateObject.SetActive(false);
|
templateObject.SetActive(false);
|
||||||
UncolorGrid();
|
UncolorGrid();
|
||||||
|
ActionUIHandler.instance.ShowUI(selectedEntity);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue