Assets
Quantum資產是用於定義由資料驅動的容器的功能,這些容器最後在索引資料庫中成為不可變執行個體。
設置資產
ConfigAssets資產持有一個參照到在遊戲開始時設置遊戲所必需的所有其他的設置資產。它用於中心化在Unity中的初始化資產的設置,並且在Quantum中序列化它們。它也簡化新增資料資產的新的類型和/或執行個體到遊戲的流程。
為了新增新的自訂資料資產ConfigAssets,簡單地新增一個類型AssetRefYourNewAsset的公共欄位到ConfigAssets.cs;組建專案並且拖動自訂資產執行個體到在Unity中的ConfigAssets執行個體上的配對的欄位。
C#
public partial class ConfigAssets
{
public AssetRefGameConfig GameConfig;
public AssetRefTurnConfig StartCountdownConfig;
public AssetRefTurnConfig PlayTurnConfig;
public AssetRefTurnConfig CountdownTurnConfig;
}
它ConfigAssets用於初始化遊戲,其在RuntimeConfig.User.cs中被序列化。
C#
partial class RuntimeConfig {
public AssetRefConfigAssets ConfigAssets;
public Boolean IsLoadedGame;
partial void SerializeUserData(BitStream stream)
{
stream.Serialize(ref ConfigAssets.Id);
stream.Serialize(ref IsLoadedGame);
}
}
在Unity側,這個資料資產的一個執行個體與QuantumRunnerLocalDebug指令碼鏈接,以啟用在 本機偵錯模式 中遊玩。
UIRoom指令碼持有一個參照到在 線上模式 中遊玩的資產。
C#
var config = RuntimeConfigContainer != null ? RuntimeConfig.FromByteArray(RuntimeConfig.ToByteArray(RuntimeConfigContainer.Config)) : new RuntimeConfig();
config.ConfigAssets.Id = ConfigAssets.Id;
遊戲設置
GameConfig資產持有模擬的一般目的的值。
MaxStrokes:由GameEnd系統使用,以決定玩家是否仍有任何打擊。SpawnBallsNearHole:由SpawnSystem使用,以確定球是否應該在Regular或NearHole類型SpawnPoint上被生成。- 最小-最大打擊角度及力量:
PlaySystem使用的最小-最大值以夾緊一個球打擊。 ForceBarVelocity:從Unity輪詢,在玩家正在瞄準時更新一個力量條標記位置。HitHoleVelocityThreshold:其中當球觸發一個洞碰撞器時,被視為擊中洞的以下的速度大小值;HoleBumpForce:當球擊中洞時,球的速度大小高於HitHoleVelocityThreshold時,新增一個垂直的力量到球;- 洞觸發及粗糙場地圖層:分別用於洞觸發及粗糙場地的在Unity中的物理圖層名稱的字串欄位。當球擊中一個靜態碰撞器時,由
Play System用來偵測這些圖層。
C#
public partial class GameConfig {
public Int32 MaxStrokes;
public Boolean SpawnBallsNearHole;
public Int32 MinStrikeAngle;
public Int32 MaxStrikeAngle;
public Int32 MinStrikeForce;
public Int32 MaxStrikeForce;
public Int32 ForceBarVelocity;
public Int32 HitHoleVelocityThreshold;
public Int32 HoleBumpForce;
public string HoleTriggerLayer;
public string RoughFieldLayer;
}
回合設置
Quantum高爾夫範例使用一個TurnConfig資產以定義回合的核心屬性。
UsesTimer:回合的狀態是Active時,全域變數Ticks在每幀增加。TurnDurationInTicks:回合在刷新中的最大長度。IsSkippable:定義玩家是否可以略過他們自己的回合。
C#
public partial class TurnConfig
{
public Boolean UsesTimer;
public Int32 TurnDurationInTicks;
public Boolean IsSkippable;
}
可以並且應該新增更多可設置資料,以定制回合設置,來滿足您的特定設計需求。
球參數
BallSpec資產持有關於球的資料。
EndOfMovementVelocityThreshold:球仍然被視為移動中的速度大小值。EndOfMovementWaitingInTicks:PlaySystem在球停止移動之後的等待的刷新數量,直到它宣告回合結束。
C#
partial class BallSpec
{
public FP EndOfMovementVelocityThreshold;
public Int32 EndOfMovementWaitingInTicks;
}
Back to top