| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- using System;
- using System.IO;
- using System.Linq;
- using System.Reflection;
- using UnityEditor;
- using UnityEngine;
- using UnityEngine.UI;
- namespace Olympus.Editor
- {
- public static class ReferenceAudit
- {
- static BindingFlags flags=BindingFlags.Instance|BindingFlags.NonPublic;
- static T Field<T>(OlympusGame app,string key)=>(T)typeof(OlympusGame).GetField(key,flags).GetValue(app);
- static void Call(OlympusGame app,string method)=>typeof(OlympusGame).GetMethod(method,flags).Invoke(app,null);
- public static string Comparison(string page)
- {
- if(!Application.isPlaying||!SessionState.GetBool("OlympusCapture",false))throw new Exception("Use isolated editor capture save.");
- var app=UnityEngine.Object.FindFirstObjectByType<OlympusGame>();var store=Field<PlayerStore>(app,"store");var game=Field<MatchEngine>(app,"game");var config=Field<GameConfig>(app,"config");
- app.ShowPreview("Lobby");store.Reset();store.Data.avatar=1;store.Data.name="Rustic Lyra";store.Data.profileSet=true;store.Save();app.ShowPreview("Lobby");
- if(page=="Trial")
- {
- game.Start("olympus");var question=config.questions.First(q=>q.Normalized=="POSEIDON");typeof(MatchEngine).GetField("rounds",flags).SetValue(game,new[]{question,question,question,question,question});
- game.Tick(4);game.Tick(2);game.Tick(Math.Max(0,game.TimeTotal-24));
- typeof(MatchEngine).GetProperty("Reveal").SetValue(game,60d,null);Call(app,"RefreshTrial");Field<TMPro.TextMeshProUGUI>(app,"toast").gameObject.SetActive(false);var v=Field<ReferenceAView>(app,"referenceView");v.reveal.Configure(question.id,0);v.reveal.SetAmount(60);
- // Freeze the engine but let Game View render the new page before capturing it.
- app.ArtReviewMode=true;EditorApplication.isPaused=false;Canvas.ForceUpdateCanvases();
- }
- return "Native "+page+" comparison fixture ready (isolated save).";
- }
- public static string ExerciseRealms()
- {
- if(!Application.isPlaying||!SessionState.GetBool("OlympusCapture",false))throw new Exception("Use isolated editor capture save.");
- var app=UnityEngine.Object.FindFirstObjectByType<OlympusGame>();var store=Field<PlayerStore>(app,"store");var game=Field<MatchEngine>(app,"game");
- int submits=0;
- for(int realm=0;realm<4;realm++)
- {
- app.ShowPreview("Lobby");store.Reset();app.ShowPreview("Lobby");Field<ReferenceAView>(app,"referenceView").realmButtons[realm].onClick.Invoke();game.Tick(4);game.Tick(2);
- for(int round=0;round<5;round++)
- {
- var v=Field<ReferenceAView>(app,"referenceView");if(!v||!v.question.sprite)throw new Exception("Missing question binding");
- v.letterButtons[0].onClick.Invoke();string selected=v.answerText.text;if(round==0){v.itemButtons[0].onClick.Invoke();if(v.answerText.text!=selected)throw new Exception("Hint cleared selected tiles");}
- TileAnswerAudit.SelectAnswer(app,game.Current.answer);v.FindButton("OK").onClick.Invoke();if(game.Phase!=MatchPhase.Answer)throw new Exception("Answer submission failed");submits++;
- game.Tick(1.6);if(round<4){game.Continue();game.Tick(1.3);}
- }
- if(game.Phase!=MatchPhase.Result)throw new Exception("Missing results");
- }
- string report="PASS 4 realms / 20 answers selected exclusively through candidate tile buttons / 4 results\nPASS hint retains selected tiles in every realm\nPASS all question sprites bound\n";Directory.CreateDirectory("docs/验证");File.WriteAllText("docs/验证/A界面流程.txt",report);return report;
- }
- }
- }
|