示例#1
0
 public Scene(SpriteBatch sb, GraphicsDeviceManager graphicsDeviceManager, GraphicsDevice gd, GameWindow window,
              ContentManager content, int FOVWidth, int FOVHeight, IDrawSystem system = null)
 {
     buffer                 = new RenderTarget2D(gd, graphicsDeviceManager.PreferredBackBufferWidth, graphicsDeviceManager.PreferredBackBufferHeight);
     GraphicsDevice         = gd;
     SpriteBatch            = sb;
     _graphicsDeviceManager = graphicsDeviceManager;
     Content                = content;
     GameWindow             = window;
     Camera                 = new Camera(this, gd.Viewport)
     {
         FOV = new Vector2(FOVWidth, FOVHeight)
     };
     Input.Instance              = new Input(this);
     GameObjects                 = new GameObjectManager(this);
     TiledPrefabs                = new Dictionary <string, Type>();
     World                       = new World(Vector2.Zero);
     Settings.AllowSleep         = true;
     Settings.VelocityIterations = 2;
     Settings.ContinuousPhysics  = true;
     DebugView                   = new DebugViewXNA(World);
     DebugView.RemoveFlags(DebugViewFlags.Shape);
     DebugView.RemoveFlags(DebugViewFlags.Joint);
     DebugView.DefaultShapeColor  = Color.LightPink;
     DebugView.SleepingShapeColor = Color.MediumPurple;
     DebugView.LoadContent(GraphicsDevice, content);
     DebugView.AppendFlags(DebugViewFlags.DebugPanel);
     DebugView.AppendFlags(DebugViewFlags.PerformanceGraph);
     Debug = true;
     LoadedTiledPrefabs = new List <TiledPrefab>();
     Pipeline           = new CludoContentPipeline(gd);
     Vector             = Pipeline.LoadContent <Texture2D>("Vector", content, true);
     Line = new Texture2D(GraphicsDevice, 1, 1);
     Line.SetData(new[] { Color.White });
     GameWindow.ClientSizeChanged +=
         (sender, args) => {
         VirtualResolutionScaler = new VirtualResolutionScaler(this,
                                                               graphicsDeviceManager.PreferredBackBufferWidth, graphicsDeviceManager.PreferredBackBufferHeight,
                                                               gd, true);
     };
     VirtualResolutionScaler = new VirtualResolutionScaler(this,
                                                           graphicsDeviceManager.PreferredBackBufferWidth, graphicsDeviceManager.PreferredBackBufferHeight,
                                                           gd, true);
     Pipeline.LoadContent <SpriteFont>("Font", Content, true);
     if (system == null)
     {
         SetDrawSystem(new NormalDrawSystem(GraphicsDevice, this,
                                            new Vector2(graphicsDeviceManager.PreferredBackBufferWidth,
                                                        graphicsDeviceManager.PreferredBackBufferHeight)));
     }
     else
     {
         SetDrawSystem(system);
     }
     StartScene();
 }
示例#2
0
文件: ECS.cs 项目: WirthLukas/Merlin
 public ECS()
 {
     _context = new EcsContext()
                .AddSystem(_drawSystem1 = new DrawSystemClass())
                .AddSystem(_drawSystem2 = new DrawSystemStruct());
 }
示例#3
0
 public void SetDrawSystem(IDrawSystem system)
 {
     this.DrawSystem = system;
 }
示例#4
0
        public World Register(IDrawSystem drawSystem)
        {
            _drawSystems.Add(drawSystem);

            return(this);
        }