feat(Connect): 完成连线基本玩法,
This commit is contained in:
@@ -2,11 +2,13 @@ using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using Script.Gameplay.Global;
|
||||
using TMPro;
|
||||
|
||||
namespace UI
|
||||
{
|
||||
public class GameCountDownViewer : MonoBehaviour
|
||||
{
|
||||
public Text countdownText;
|
||||
public TMP_Text countdownText;
|
||||
private GameCountdownManager _countdownManager;
|
||||
|
||||
private void Start()
|
||||
|
63
Assets/Script/Gameplay/UI/PlayerConnectViewer.cs
Normal file
63
Assets/Script/Gameplay/UI/PlayerConnectViewer.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
using System;
|
||||
using Core;
|
||||
using Gameplay.Player;
|
||||
using Script.Gameplay.Connect;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UI
|
||||
{
|
||||
public class PlayerConnectViewer : UIBase
|
||||
{
|
||||
public TMP_Text inputText;
|
||||
public TMP_Text outputText;
|
||||
private PlayerConnectController _playerConnectController;
|
||||
private PlayerWatchModeController _playerWatchModeController;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
ControllerLocator.Instance.TryGetWait<PlayerConnectController>(OnGetConnectController);
|
||||
ControllerLocator.Instance.TryGetWait<PlayerWatchModeController>(OnGetWatchModeController);
|
||||
}
|
||||
|
||||
private void OnGetConnectController(PlayerConnectController controller)
|
||||
{
|
||||
_playerConnectController = controller;
|
||||
_playerConnectController.OnSetInputTarget += UpdateInputText;
|
||||
_playerConnectController.OnSetOutputTarget += UpdateOutputText;
|
||||
UpdateInputText(null);
|
||||
UpdateOutputText(null);
|
||||
}
|
||||
|
||||
private void UpdateInputText(IConnectable input)
|
||||
{
|
||||
string text = input != null ? input.GetConnectableName() : "None";
|
||||
if (inputText != null)
|
||||
{
|
||||
inputText.text = "Input: " + text;
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateOutputText(IConnectable output)
|
||||
{
|
||||
string text = output != null ? output.GetConnectableName() : "None";
|
||||
if (outputText != null)
|
||||
{
|
||||
outputText.text = "Output: " + text;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnGetWatchModeController(PlayerWatchModeController controller)
|
||||
{
|
||||
_playerWatchModeController = controller;
|
||||
_playerWatchModeController.OnEnterWatchMode += (mode) =>
|
||||
{
|
||||
if (mode == WatchMode.Outside) Show();
|
||||
};
|
||||
_playerWatchModeController.OnExitWatchMode += (mode) =>
|
||||
{
|
||||
if (mode == WatchMode.Outside) Hide();
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
3
Assets/Script/Gameplay/UI/PlayerConnectViewer.cs.meta
Normal file
3
Assets/Script/Gameplay/UI/PlayerConnectViewer.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f22aa900f1d1442e9f5ae9750b6ead86
|
||||
timeCreated: 1760842150
|
@@ -56,13 +56,12 @@ namespace UI
|
||||
public void OnExitInsideWatchMode()
|
||||
{
|
||||
this.gameObject.SetActive(false);
|
||||
|
||||
|
||||
ClearComponentUI();
|
||||
if (noEditableTargetPanel != null)
|
||||
{
|
||||
noEditableTargetPanel.SetActive(false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 获取 PlayerEditController 的回调
|
||||
@@ -76,8 +75,17 @@ namespace UI
|
||||
private void GetPlayerWatchModeControllerHandle(PlayerWatchModeController watchModeCtrl)
|
||||
{
|
||||
watchModeController = watchModeCtrl;
|
||||
watchModeController.OnEnterInsideWatchMode += OnEnterInsideWatchMode;
|
||||
watchModeController.OnExitInsideWatchMode += OnExitInsideWatchMode;
|
||||
watchModeController.OnEnterWatchMode += (WatchMode mode) =>
|
||||
{
|
||||
if (mode == WatchMode.Inside)
|
||||
OnEnterInsideWatchMode();
|
||||
};
|
||||
watchModeController.OnExitWatchMode += (WatchMode mode) =>
|
||||
{
|
||||
if (mode == WatchMode.Inside)
|
||||
OnExitInsideWatchMode();
|
||||
};
|
||||
|
||||
//Debug.Log("PlayerEditViewer subscribed to WatchMode events.");
|
||||
}
|
||||
|
||||
|
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using Core;
|
||||
using Gameplay.Player;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
@@ -9,7 +10,7 @@ namespace UI
|
||||
public class PlayerHpViewer : UIBase
|
||||
{
|
||||
private PlayerController _playerController;
|
||||
public Text hpText;
|
||||
public TMP_Text hpText;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
@@ -20,11 +21,12 @@ namespace UI
|
||||
{
|
||||
_playerController = playerController;
|
||||
_playerController.OnHealthChanged += UpdateHpText;
|
||||
UpdateHpText(_playerController.CurrentHealth);
|
||||
}
|
||||
|
||||
private void UpdateHpText(int currentHealth)
|
||||
{
|
||||
hpText.text = "HP: " + currentHealth;
|
||||
hpText.text = "HP: " + currentHealth.ToString();
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
|
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using Core;
|
||||
using Gameplay.Player;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
@@ -9,25 +10,18 @@ namespace UI
|
||||
public class PlayerWatchModeViewer : UIBase
|
||||
{
|
||||
private PlayerWatchModeController watchModeController;
|
||||
[SerializeField] private Text modeText;
|
||||
[SerializeField] private TMP_Text modeText;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
ControllerLocator.Instance.TryGetWait<PlayerWatchModeController>(OnGet);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (watchModeController != null)
|
||||
{
|
||||
modeText.text = "Watch Mode: " + watchModeController.CurrentWatchMode.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void OnGet(PlayerWatchModeController watchModeCtrl)
|
||||
{
|
||||
watchModeController = watchModeCtrl;
|
||||
//Debug.Log("PlayerWatchModeViewer obtained PlayerWatchModeController.");
|
||||
modeText.text = "Watch Mode: " + watchModeController.CurrentWatchMode;
|
||||
watchModeController.OnEnterWatchMode += mode => modeText.text = "Watch Mode: " + mode;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user