49 lines
1.3 KiB
C#
49 lines
1.3 KiB
C#
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class PlayerIndicatorCanvas : MonoBehaviour
|
|
{
|
|
Transform cam;
|
|
[SerializeField] private TMP_Text playerCountText;
|
|
[SerializeField] private PlayerPawn playerPawn;
|
|
[SerializeField] private Button indicatorBtn;
|
|
|
|
private GameplayManager gameplayManager;
|
|
|
|
private void OnEnable()
|
|
{
|
|
indicatorBtn.onClick.AddListener(() => OnClickPlayer());
|
|
}
|
|
|
|
private void OnDisable()
|
|
{
|
|
indicatorBtn.onClick.RemoveListener(() => OnClickPlayer());
|
|
}
|
|
|
|
private void Start()
|
|
{
|
|
cam = GameObject.FindGameObjectWithTag("MainCamera").transform;
|
|
}
|
|
|
|
private void LateUpdate()
|
|
{
|
|
transform.LookAt(cam.forward + transform.position);
|
|
}
|
|
|
|
#if UNITY_EDITOR
|
|
public void SetPlayerCount(int count)
|
|
{
|
|
playerCountText.text = count.ToString();
|
|
}
|
|
#endif
|
|
|
|
public void OnClickPlayer()
|
|
{
|
|
// quick fix: Character selection too hard based on view
|
|
gameplayManager = gameplayManager ?? InterfaceManager.Instance.GetInterfaceInstance<GameplayManager>();
|
|
if (gameplayManager.GameManager.CurrentGameState == GameState.IsPaused || playerPawn.IsBotPlayer || !playerPawn.CanSelectPlayer) return;
|
|
|
|
gameplayManager.OnPawnSelected(playerPawn);
|
|
}
|
|
} |