Add prototype gameplay loop with character/battlefield assets and server game APIs.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
udx
2026-10-20 18:50:00 +08:00
co-authored by Cursor
parent 79369e4473
commit 6c64210331
833 changed files with 998079 additions and 1042 deletions
@@ -19,6 +19,32 @@ namespace HotUpdate.UI
Button _close;
Action _onOk;
Action _onCancel;
RectTransform _okRect;
Vector2 _okAnchorMin, _okAnchorMax, _okPivot, _okPosition;
ScrollRect _messageScroll;
public struct ViewState
{
public string Title, Message;
public bool Visible, ShowCancel;
public Action OnOk, OnCancel;
}
public ViewState CaptureState() => new ViewState
{
Title = _title != null ? _title.text : string.Empty,
Message = _message != null ? _message.text : string.Empty,
Visible = gameObject.activeSelf,
ShowCancel = _cancel != null && _cancel.gameObject.activeSelf,
OnOk = _onOk,
OnCancel = _onCancel
};
public void RestoreState(ViewState state)
{
Show(state.Title, state.Message, state.OnOk, state.OnCancel, state.ShowCancel);
if (!state.Visible) Hide();
}
public void Bind()
{
@@ -27,6 +53,15 @@ namespace HotUpdate.UI
_ok = FindBtn("Btn_Ok");
_cancel = FindBtn("Btn_Cancel");
_close = FindBtn("Btn_Close");
if (_ok != null)
{
_okRect = _ok.GetComponent<RectTransform>();
_okAnchorMin = _okRect.anchorMin;
_okAnchorMax = _okRect.anchorMax;
_okPivot = _okRect.pivot;
_okPosition = _okRect.anchoredPosition;
}
_messageScroll = GetComponentInChildren<ScrollRect>(true);
Wire(_ok, () => { _onOk?.Invoke(); Hide(); });
Wire(_cancel, () => { _onCancel?.Invoke(); Hide(); });
@@ -45,6 +80,18 @@ namespace HotUpdate.UI
_onOk = onOk;
_onCancel = onCancel;
if (_cancel != null) _cancel.gameObject.SetActive(showCancel);
if (_okRect != null)
{
_okRect.anchorMin = showCancel ? _okAnchorMin : new Vector2(0.5f, _okAnchorMin.y);
_okRect.anchorMax = showCancel ? _okAnchorMax : new Vector2(0.5f, _okAnchorMax.y);
_okRect.pivot = showCancel ? _okPivot : new Vector2(0.5f, _okPivot.y);
_okRect.anchoredPosition = showCancel ? _okPosition : new Vector2(0, _okPosition.y);
}
if (_messageScroll != null && _messageScroll.content != null)
{
_messageScroll.StopMovement();
_messageScroll.content.anchoredPosition = Vector2.zero;
}
gameObject.SetActive(true);
}