public AbilityManagerUserInterface(Vector2 position, Vector2 size, IAbilityManager abilityManager)
        {
            AbilityBootstrapper.ComposeParts(this);
            this.units  = new Units(size, position, abilityManager);
            this.window = new Window(size, position, "Ability# Manager", this.units);

            var menu   = new Menu("AbilityManagerUI", this.MainMenuManager.Value.MainMenu.Name + "abilityManagerUi");
            var enable = new ObservableMenuItem <bool>(menu.Name + "enable", "Enable");

            menu.AddItem(enable.SetValue(false));
            enable.Provider.Subscribe(new DataObserver <bool>(b => { this.window.Visible = b; }));
            this.MainMenuManager.Value.MainMenu.SettingsMenu.AddSubMenu(menu);
            Game.OnWndProc += this.Game_OnWndProc;
            Drawing.OnDraw += this.Drawing_OnDraw;
        }
Exemplo n.º 2
0
        internal AbilityManagerUserInterface(Vector2 position, Vector2 size, IAbilityManager abilityManager)
        {
            AbilityBootstrapper.ComposeParts(this);

            // this.units = new Units(size, position, abilityManager);
            this.units  = new DamageManipulation(size, position, abilityManager);
            this.window = new Window(size, position, "Ability# Manager", this.units);

            var menu   = new Menu("AbilityManagerUI", this.MainMenuManager.Value.MainMenu.Name + "abilityManagerUi");
            var enable = new ObservableMenuItem <bool>(menu.Name + "enable", "Enable");

            menu.AddItem(enable.SetValue(false));
            var subbed = false;

            enable.Provider.Subscribe(
                new DataObserver <bool>(
                    b =>
            {
                this.window.Visible = b;
                if (!b)
                {
                    if (!subbed)
                    {
                        return;
                    }

                    subbed          = false;
                    Game.OnWndProc -= this.Game_OnWndProc;
                    Drawing.OnDraw -= this.Drawing_OnDraw;
                }
                else
                {
                    if (subbed)
                    {
                        return;
                    }

                    subbed          = true;
                    Game.OnWndProc += this.Game_OnWndProc;
                    Drawing.OnDraw += this.Drawing_OnDraw;
                }
            }));
            this.MainMenuManager.Value.MainMenu.SettingsMenu.AddSubMenu(menu);

            Game.OnWndProc += this.Game_OnWndProc;
            Drawing.OnDraw += this.Drawing_OnDraw;
        }