Esempio n. 1
0
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            uiContext = new UIContext(new InputManager(), this);
            // view from slightly above and to the right, but far away TODO: for some reason we aren't looking at 0, 0, 0??
            uiContext.Camera = new FPSCamera(new Vector3(-2, 2, -10), new Vector3(0, 0, 0));
            var renderSubject = TemplateManager.Load("zdata.txt", "Spaceship1", GraphicsDevice);

            mainGameObject = new MainGameObject(uiContext, renderSubject);
            mainGameObject.Focus();
            int radii = 5;

            cursorTexture = new Texture2D(GraphicsDevice, radii * 2 + 1, radii * 2 + 1);
            Color[] data = new Color[(radii * 2 + 1) * (radii * 2 + 1)];
            for (int i = 0; i < radii * 2 + 1; i++)
            {
                data[i + (radii * 2 + 1) * radii] = Color.White; // horizontal
                data[i * (radii * 2 + 1) + radii] = Color.White; // vertical
            }
            cursorTexture.SetData(data);

            GlobalContent.Init(this.Content);

            int w = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width - 40;
            int h = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height - 40 - 45;

            _graphics.PreferredBackBufferWidth  = w;
            _graphics.PreferredBackBufferHeight = h;
            Window.Position = new Point(20, 20);
            //_graphics.IsFullScreen = true;
            _graphics.ApplyChanges();

            base.Initialize();
        }
Esempio n. 2
0
 public MainGameObject(UIContext uiContext, ZGameObject renderSubject)
 {
     this.uiContext     = uiContext;
     this.renderSubject = renderSubject;
     RegisterListener(new InputListener(Trigger.E, x =>
     {
         editMode         = true;
         uiContext.Camera = new EditorCamera(uiContext.Camera.GetPosition(), uiContext.Camera.GetTarget());
         renderSubject.Focus();
         renderSubject.RegisterListener(new InputListener(Trigger.Escape, y =>
         {
             this.Focus();
             renderSubject.UnregisterListener(y);
             editMode         = false;
             uiContext.Camera = new FPSCamera(uiContext.Camera.GetPosition(), uiContext.Camera.GetTarget());
         }));
     }));
     RegisterGlobalListener(new InputListener(Trigger.CtrlS, x =>
     {
         TemplateManager.Save("zdata.txt");
     }));
     RegisterListener(new InputListener(Trigger.Escape, x =>
     {
         uiContext.Exit();
     }));
 }
Esempio n. 3
0
 public GameObject GetGameObject(ZGameObject gameObject)
 {
     return(_gameObjects[gameObject.GameObjectId]);
 }