我有一个包含 GameStates 类实例的 GameServices 类。
GameStates 类有一个名为 GameState 的公共枚举和一个名为 CurrentGameState 的静态变量。
我的问题是,我可以从 GameStates 类访问 CurrentGameState,但不能访问它自己的 GameState 枚举,而它是公共的。
游戏服务类
using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using SpaceGame.UI;
using SpaceGame.Content;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
namespace SpaceGame.Game
{
public class GameServices
{
public static ContentLoader ContentLoaderService;
public static UIHandler UIHandlerService;
public static GameStates GameStatesService;
public static void Initialize(ContentManager contentManager, GraphicsDevice graphicsDevice)
{
ContentLoaderService = new ContentLoader(contentManager);
UIHandlerService = new UIHandler(graphicsDevice);
GameStatesService = new GameStates();
}
}
}
GameStates 类
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace SpaceGame.Game
{
public class GameStates
{
public GameState CurrentGameState { get; set; }
public enum GameState
{
Settings,
Splash,
SpaceShipyard
}
public GameStates()
{
CurrentGameState = GameState.Splash;
}
}
}
难道我做错了什么?
提前致谢,
马克