很多更新,服务端连接,新UI和系统
This commit is contained in:
@@ -7,11 +7,15 @@ using UnityEngine.SceneManagement;
|
||||
using System.Collections;
|
||||
using UnityEngine.Audio;
|
||||
using DG.Tweening;
|
||||
using GameServer.Client;
|
||||
|
||||
public class settlementController : MonoBehaviour
|
||||
{
|
||||
public static event Action OnSettlementCompleted;
|
||||
|
||||
[Header("ranking List")]
|
||||
public rankingList rl;
|
||||
|
||||
[Header("Inspector")]
|
||||
[SerializeField] private BeatmapManager bmm;
|
||||
[SerializeField] private ScoreManager sm;
|
||||
@@ -154,6 +158,7 @@ public class settlementController : MonoBehaviour
|
||||
private bool hasCachedIntroMvpBaseLocalPos;
|
||||
private bool settlementHistoryRecorded;
|
||||
private bool settlementHeroStatsRecorded;
|
||||
private bool roomScoreSubmitTriggered;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
@@ -168,6 +173,11 @@ public class settlementController : MonoBehaviour
|
||||
exit_toSelectSongs.onClick.AddListener(OnExitButtonClicked);
|
||||
}
|
||||
|
||||
if (display_rankList != null)
|
||||
{
|
||||
display_rankList.onClick.AddListener(OnDisplayRankListClicked);
|
||||
}
|
||||
|
||||
// Documentation text normalized.
|
||||
if (cdm != null)
|
||||
{
|
||||
@@ -216,6 +226,11 @@ public class settlementController : MonoBehaviour
|
||||
exit_toSelectSongs.onClick.RemoveListener(OnExitButtonClicked);
|
||||
}
|
||||
|
||||
if (display_rankList != null)
|
||||
{
|
||||
display_rankList.onClick.RemoveListener(OnDisplayRankListClicked);
|
||||
}
|
||||
|
||||
// Documentation text normalized.
|
||||
if (musicTransitionCoroutine != null)
|
||||
{
|
||||
@@ -252,6 +267,26 @@ public class settlementController : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDisplayRankListClicked()
|
||||
{
|
||||
if (rl == null)
|
||||
{
|
||||
Debug.LogWarning("[settlementController] rankingList reference is missing.");
|
||||
return;
|
||||
}
|
||||
|
||||
SongData songData = thisSong_so != null ? thisSong_so : (bmm != null ? bmm.assignedSongData : null);
|
||||
string songId = songData != null ? songData.songID.ToString() : string.Empty;
|
||||
string songName = songData != null ? songData.songName : string.Empty;
|
||||
if (string.IsNullOrWhiteSpace(songId))
|
||||
{
|
||||
Debug.LogWarning("[settlementController] Cannot open ranking list because song id is missing.");
|
||||
return;
|
||||
}
|
||||
|
||||
rl.Open(songId, songName);
|
||||
}
|
||||
|
||||
private void RegisterCurrentLineupDeployCount()
|
||||
{
|
||||
HashSet<int> uniqueHeroIds = new HashSet<int>();
|
||||
@@ -491,6 +526,7 @@ public class settlementController : MonoBehaviour
|
||||
settlementUiInitialized = true;
|
||||
settlementHistoryRecorded = false;
|
||||
settlementHeroStatsRecorded = false;
|
||||
roomScoreSubmitTriggered = false;
|
||||
OnSettlementCompleted?.Invoke();
|
||||
equipSmelt.NotifySettlementCompleted();
|
||||
|
||||
@@ -605,6 +641,8 @@ public class settlementController : MonoBehaviour
|
||||
float avg = sm.offsetCount > 0 ? sm.totalOffsetMs / sm.offsetCount : 0f;
|
||||
avgOffset_Text.text = avg.ToString("F2") + " ms";
|
||||
}
|
||||
|
||||
TrySubmitArenaRoomScore();
|
||||
}
|
||||
else Debug.LogError("score manager is null");
|
||||
|
||||
@@ -1813,17 +1851,70 @@ public class settlementController : MonoBehaviour
|
||||
// Ensure time scale restored
|
||||
try { Time.timeScale = 1f; } catch {}
|
||||
|
||||
string targetScene = "selectYourSongFirst";
|
||||
ArenaRoomService arenaRoomService = ArenaRoomService.Instance;
|
||||
if (arenaRoomService != null && arenaRoomService.IsInRoom)
|
||||
{
|
||||
arenaRoomService.RequestReturnToRoomUi();
|
||||
targetScene = arenaRoomService.RoomSceneName;
|
||||
}
|
||||
|
||||
// If GameManager and its blackMaskImage available, start coroutine on gm to fade to black then load
|
||||
if (gm != null && gm.blackMaskImage != null)
|
||||
{
|
||||
gm.StartCoroutine(FadeToBlackAndLoadOnGM("selectYourSongFirst", 0.25f));
|
||||
gm.StartCoroutine(FadeToBlackAndLoadOnGM(targetScene, 0.25f));
|
||||
}
|
||||
else
|
||||
{
|
||||
StartCoroutine(LoadSceneAsync("selectYourSongFirst"));
|
||||
StartCoroutine(LoadSceneAsync(targetScene));
|
||||
}
|
||||
}
|
||||
|
||||
private void TrySubmitArenaRoomScore()
|
||||
{
|
||||
if (roomScoreSubmitTriggered)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ArenaRoomService arenaRoomService = ArenaRoomService.Instance;
|
||||
if (arenaRoomService == null || !arenaRoomService.IsInRoom)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
roomScoreSubmitTriggered = true;
|
||||
_ = SubmitArenaRoomScoreAsync(arenaRoomService);
|
||||
}
|
||||
|
||||
private async System.Threading.Tasks.Task SubmitArenaRoomScoreAsync(ArenaRoomService arenaRoomService)
|
||||
{
|
||||
try
|
||||
{
|
||||
await arenaRoomService.SubmitScore(
|
||||
targetTotalScore,
|
||||
GetArenaGrade(targetTotalScore),
|
||||
targetPmScore,
|
||||
targetIdolScore);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogWarning($"[settlementController] Arena room score submit failed: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
private static string GetArenaGrade(long totalScore)
|
||||
{
|
||||
if (totalScore >= 960000) return "SSS";
|
||||
if (totalScore >= 920000) return "SS";
|
||||
if (totalScore >= 880000) return "S";
|
||||
if (totalScore >= 820000) return "A";
|
||||
if (totalScore >= 720000) return "B";
|
||||
if (totalScore >= 600000) return "C";
|
||||
if (totalScore >= 400000) return "D";
|
||||
return "F";
|
||||
}
|
||||
|
||||
// Coroutine that will be started on the GameManager instance so that the gm's MonoBehaviour runs it
|
||||
private IEnumerator FadeToBlackAndLoadOnGM(string sceneName, float duration)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user