Inheritance: UIRoot
Esempio n. 1
0
        protected override void AddedToScene()
        {
            base.AddedToScene();

            // Use the bounds to layout the positioning of our drawable assets
            var bounds = VisibleBoundsWorldspace;

            ContentManager content = Application.Game.Content;
            content.RootDirectory = Application.ContentRootDirectory;

            SpriteFont font = content.Load<SpriteFont>("fonts/Segoe_UI_10_Regular");
            FontManager.DefaultFont = Engine.Instance.Renderer.CreateFont(font);

            root = new BasicUI((int)bounds.Size.Width, (int)bounds.Size.Height);
            debug = new DebugViewModel(root);
            root.DataContext = new BasicUIViewModel();

            SoundManager.Instance.LoadSounds(content, "sounds");
            ImageManager.Instance.LoadImages(content);
            FontManager.Instance.LoadFonts(content, "fonts");

            Schedule(UpdateUI);

            // Register for touch events
            var touchListener = new CCEventListenerTouchAllAtOnce();
            touchListener.OnTouchesEnded = OnTouchesEnded;
            AddEventListener(touchListener, this);
        }
Esempio n. 2
0
        public override async Task Execute()
        {

            SpriteFont font = await Content.LoadAsync<SpriteFont>("Segoe_UI_10_Regular");
            FontManager.DefaultFont = Engine.Instance.Renderer.CreateFont(font);

            XenkoRenderer.GraphicsContext = Game.GraphicsContext;
            uiRoot = new BasicUI();
            debug = new DebugViewModel(uiRoot);
            uiRoot.DataContext = new BasicUIViewModel();
            
            FontManager.Instance.LoadFonts(Content);
            SoundManager.Instance.LoadSounds(Content);
            ImageManager.Instance.LoadImages(Content);
            EffectManager.Instance.LoadEffects(EffectSystem);
            
            var scene = SceneSystem.SceneInstance.Scene;
            var compositor = ((SceneGraphicsCompositorLayers)scene.Settings.GraphicsCompositor);
            compositor.Master.Renderers.Add(new SceneDelegateRenderer(Render));

            while (Game.IsRunning)
            {
                await Script.NextFrame();
                debug.Update();
                uiRoot.UpdateInput(Game.UpdateTime.Elapsed.TotalMilliseconds);
                uiRoot.UpdateLayout(Game.UpdateTime.Elapsed.TotalMilliseconds);
            }            
        }
Esempio n. 3
0
        /// <summary>
        /// Called when the program switches to the screen. This is
        /// where screen assets are loaded and resources are created.
        /// </summary>
        public override void LoadContent()
        {
            InputDevice input = Platform.Instance.InputDevice;
            input.MouseState.Visible = true;

            Font font = BaseGameProgram.Instance.ContentDatabase.Load<Font>("Segoe_UI_10_Regular");
            FontManager.DefaultFont = Engine.Instance.Renderer.CreateFont(font);
            Viewport viewport = Platform.Instance.GraphicsDevice.Viewport;

            basicUI = new BasicUI(viewport.Width, viewport.Height);
            debug = new DebugViewModel(basicUI);
            basicUI.DataContext = new BasicUIViewModel();

            FontManager.Instance.LoadFonts(BaseGameProgram.Instance.ContentDatabase);
            ImageManager.Instance.LoadImages(BaseGameProgram.Instance.ContentDatabase);
            SoundManager.Instance.LoadSounds(BaseGameProgram.Instance.ContentDatabase);

            RelayCommand command = new RelayCommand(new Action<object>(ExitEvent));

            KeyBinding keyBinding = new KeyBinding(command, KeyCode.Escape, ModifierKeys.None);
            basicUI.InputBindings.Add(keyBinding);
        }
Esempio n. 4
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            this.IsMouseVisible = true;

            SpriteFont font = Content.Load<SpriteFont>("Segoe_UI_10_Regular");
            FontManager.DefaultFont = Engine.Instance.Renderer.CreateFont(font);
            Viewport viewport = GraphicsDevice.Viewport;
            basicUI = new BasicUI(viewport.Width, viewport.Height);
            viewModel = new BasicUIViewModel();
            viewModel.Tetris = new TetrisController(basicUI.TetrisContainer, basicUI.TetrisNextContainer);
            basicUI.DataContext = viewModel;
            debug = new DebugViewModel(basicUI);

            FontManager.Instance.LoadFonts(Content);
            ImageManager.Instance.LoadImages(Content);
            SoundManager.Instance.LoadSounds(Content);

            RelayCommand command = new RelayCommand(new Action<object>(ExitEvent));

            KeyBinding keyBinding = new KeyBinding(command, KeyCode.Escape, ModifierKeys.None);
            basicUI.InputBindings.Add(keyBinding);

            RelayCommand tetrisLeft = new RelayCommand(new Action<object>(OnLeft));
            KeyBinding left = new KeyBinding(tetrisLeft, KeyCode.A, ModifierKeys.None);
            basicUI.InputBindings.Add(left);

            RelayCommand tetrisRight = new RelayCommand(new Action<object>(OnRight));
            KeyBinding right = new KeyBinding(tetrisRight, KeyCode.D, ModifierKeys.None);
            basicUI.InputBindings.Add(right);

            RelayCommand tetrisDown = new RelayCommand(new Action<object>(OnDown));
            KeyBinding down = new KeyBinding(tetrisDown, KeyCode.S, ModifierKeys.None);
            basicUI.InputBindings.Add(down);

            RelayCommand tetrisRotate = new RelayCommand(new Action<object>(OnRotate));
            KeyBinding rotate = new KeyBinding(tetrisRotate, KeyCode.W, ModifierKeys.None);
            basicUI.InputBindings.Add(rotate);
        }
Esempio n. 5
0
        protected override void LoadContent()
        {
            IsMouseVisible = true;

            FontManager.DefaultFont = Engine.Instance.Renderer.CreateFont(Content.Load<SpriteFont>("Segoe_UI_10_Regular"));

            BasicUI = new BasicUI(Graphics.PreferredBackBufferWidth, Graphics.PreferredBackBufferHeight);
            ViewModel = new BasicUIViewModel();
            BasicUI.DataContext = ViewModel;
            DebugViewMode = new DebugViewModel(BasicUI);

            FontManager.Instance.LoadFonts(Content);
            ImageManager.Instance.LoadImages(Content);
            SoundManager.Instance.LoadSounds(Content);

            BasicUI.InputBindings.Add(new KeyBinding(new RelayCommand(o => Exit()), KeyCode.Escape, ModifierKeys.None));

            SCONClient = new SCONClient(ViewModel);

            base.LoadContent();
        }
Esempio n. 6
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            this.IsMouseVisible = true;

            SpriteFont font = Content.Load<SpriteFont>("Segoe_UI_10_Regular");
            FontManager.DefaultFont = Engine.Instance.Renderer.CreateFont(font);
            Viewport viewport = GraphicsDevice.Viewport;
            basicUI = new BasicUI(viewport.Width, viewport.Height);
            viewModel = new BasicUIViewModel();
            viewModel.Tetris = new TetrisController(basicUI.TetrisContainer, basicUI.TetrisNextContainer);
            basicUI.DataContext = viewModel;
            debug = new DebugViewModel(basicUI);

            FontManager.Instance.LoadFonts(Content);
            ImageManager.Instance.LoadImages(Content);
            SoundManager.Instance.LoadSounds(Content);
            EffectManager.Instance.LoadEffects(Content);

            RelayCommand command = new RelayCommand(new Action<object>(ExitEvent));

            KeyBinding keyBinding = new KeyBinding(command, KeyCode.Escape, ModifierKeys.None);
            basicUI.InputBindings.Add(keyBinding);

            RelayCommand tetrisLeft = new RelayCommand(new Action<object>(OnLeft));
            KeyBinding left = new KeyBinding(tetrisLeft, KeyCode.A, ModifierKeys.None);
            basicUI.InputBindings.Add(left);

            RelayCommand tetrisRight = new RelayCommand(new Action<object>(OnRight));
            KeyBinding right = new KeyBinding(tetrisRight, KeyCode.D, ModifierKeys.None);
            basicUI.InputBindings.Add(right);

            RelayCommand tetrisDown = new RelayCommand(new Action<object>(OnDown));
            KeyBinding down = new KeyBinding(tetrisDown, KeyCode.S, ModifierKeys.None);
            basicUI.InputBindings.Add(down);

            RelayCommand tetrisRotate = new RelayCommand(new Action<object>(OnRotate));
            KeyBinding rotate = new KeyBinding(tetrisRotate, KeyCode.W, ModifierKeys.None);
            basicUI.InputBindings.Add(rotate);

            RelayCommand resizeCommand = new RelayCommand(new Action<object>(OnResize));
            KeyBinding resizeBinding = new KeyBinding(resizeCommand, KeyCode.R, ModifierKeys.Control);
            basicUI.InputBindings.Add(resizeBinding);

            renderTarget = new RenderTarget2D(GraphicsDevice,
                100,
                100,
                false,
                GraphicsDevice.PresentationParameters.BackBufferFormat,
                DepthFormat.Depth24Stencil8);

            viewModel.RenderTargetSource = new BitmapImage();
            var texture = Engine.Instance.Renderer.CreateTexture(renderTarget);
            viewModel.RenderTargetSource.Texture = texture;
        }
Esempio n. 7
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            _spriteBatch = new MySpriteBatch(GraphicsDevice);

            Utils.FontManager.Instance.LoadFonts(this);

            EmptyKeys.UserInterface.FontManager.DefaultFont = Engine.Instance.Renderer.CreateFont(Utils.FontManager.Instance.GetFont(FontEnum.ARIAL_16));
            Viewport viewport = GraphicsDevice.Viewport;

            _basicUI             = new EmptyKeys.UserInterface.Generated.BasicUI();
            _viewModel           = new BasicUIViewModel();
            _basicUI.DataContext = _viewModel;

            EmptyKeys.UserInterface.FontManager.Instance.LoadFonts(Content, "Fonts/");
            ImageManager.Instance.LoadImages(Content);
            SoundManager.Instance.LoadSounds(Content);

            var spriteSheet = Content.Load <Texture2D>("Textures/spritesheet");

            TextureManager = new TextureManager(spriteSheet, 32, 32);

            Lua = new LuaInterpreter();

            _threadLua = new Thread(
                new ThreadStart(ConsoleThread));
            _threadLua.Start();

            World = new World();

            var drawSystem = new DrawEntitySystem(
                1,
                new List <Type>()
            {
                typeof(SpriteComponent), typeof(TransformComponent)
            },
                World
                );

            var random = new Random();

            var player = World.CreateGameObject();

            FactoryEntity.CreatePlayer(World, player);

            var bomb = World.CreateGameObject();

            FactoryEntity.CreateBomb(World, bomb, 6, 1);

            var map = new int[MapWidth * MapHeight]
            {
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 1, 1, 1, 1, 1, 1, 1, 1, 0,
                0, 1, 2, 0, 2, 0, 2, 0, 1, 0,
                0, 1, 2, 0, 2, 0, 2, 0, 1, 0,
                0, 1, 1, 1, 1, 1, 1, 1, 1, 0,
                0, 1, 1, 1, 1, 1, 1, 1, 1, 0,
                0, 1, 0, 0, 0, 0, 0, 0, 1, 0,
                0, 1, 0, 0, 0, 0, 0, 0, 1, 0,
                0, 1, 1, 1, 1, 1, 1, 1, 1, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0
            };

            for (var i = 0; i < map.Length; i++)
            {
                var e = World.CreateGameObject();

                var value = map[i];
                switch (value)
                {
                case 0:
                    FactoryEntity.CreateHardWall(World, e, i % MapWidth, i / MapHeight);
                    break;

                case 2:
                    FactoryEntity.CreateSoftWall(World, e, i % MapWidth, i / MapHeight);
                    break;
                }
            }

            World.SystemManager.AddSystem(new UpdateSpriteSystem(0,
                                                                 new List <Type>()
            {
                typeof(SpriteComponent), typeof(SpriteAnimationComponent)
            },
                                                                 World));
            World.SystemManager.AddSystem(new UpdateInputSystem(0,
                                                                new List <Type>()
            {
                typeof(TypeEntityComponent), typeof(TransformComponent), typeof(InputComponent)
            },
                                                                World));

            World.SystemManager.AddSystem(new DrawFloorSystem(0, null, World));
            World.SystemManager.AddSystem(drawSystem);

            _stopwatch = new Stopwatch();
            _stopwatch.Start();
        }