Ejemplo n.º 1
0
        private void InitUI()
        {
            // Initialize Root Object
            _gameUI = new UIContainer(new Vector2f(GlobalConstants.BoardLength * GlobalConstants.SquareSize, 0),
                                      new Vector2f(GlobalConstants.WindowWidth - GlobalConstants.BoardLength * GlobalConstants.SquareSize,
                                                   GlobalConstants.SquareSize * GlobalConstants.BoardLength), new Color(215, 215, 215));

            // Move History
            moveHistory = new MoveHistory(new Vector2f(_gameUI.Position.X, _gameUI.Position.Y + GlobalConstants.SquareSize),
                                          new Vector2f(_gameUI.Shape.Size.X, _gameUI.Shape.Size.Y - (GlobalConstants.SquareSize * 2)));
            // Quit Button
            GraphicButton quitButton = new GraphicButton(
                new Vector2f(_gameUI.Position.X + _gameUI.Shape.Size.X - ButtonWidth, _gameUI.Position.Y + _gameUI.Shape.Size.Y - ButtonHeight),
                new Vector2f(ButtonWidth, ButtonHeight), new Color(100, 100, 100), new Color(150, 150, 150));

            quitButton.SetGraphics(Application.Instance().AssetManager.Textures[TextureID.ReturnIdle],
                                   Application.Instance().AssetManager.Textures[TextureID.ReturnHover]);
            quitButton.SetCommand(new GoToStateCommand(new MenuState()));
            quitButton.SetBorder(1, Color.Black);

            // New Game Button
            GraphicButton newGameButton = new GraphicButton(
                new Vector2f(_gameUI.Position.X + _gameUI.Shape.Size.X - (ButtonWidth * 2), _gameUI.Position.Y + _gameUI.Shape.Size.Y - ButtonHeight),
                new Vector2f(ButtonWidth, ButtonHeight), new Color(100, 100, 100), new Color(150, 150, 150));

            newGameButton.SetGraphics(Application.Instance().AssetManager.Textures[TextureID.NewGameIdle],
                                      Application.Instance().AssetManager.Textures[TextureID.NewGameHover]);
            newGameButton.SetCommand(new ResetGameCommand(this));
            newGameButton.SetBorder(1, Color.Black);

            // Add Elements
            _gameUI.AddElement(moveHistory);
            _gameUI.AddElement(quitButton);
            _gameUI.AddElement(newGameButton);
        }
Ejemplo n.º 2
0
        public PhoneApp(int type, SmartPhone phone, int consumeRate, Entity owner = null, string Title = "")
            : base(type, -1, owner)
        {
            this.ConsumeRate = consumeRate;
            this.phone = phone;
            this.ActiveEffects = new ItemEffect[0];
            this.PassiveEffects = new ItemEffect[0];

            //This container allows the TextSprite to be centred
            UIContainer PageTitleContainer = new UIContainer(Color.White, Color.White, Width: SmartPhone.SCREEN_RECT.Width, CursorType: CursorType.Cursor, MarginTop: 10, MarginBottom: 10, CentreHorizontal: true);

            TextSprite PageTitle = new TextSprite(Title, 2, Color.White, SmartPhone.SCREEN_RECT.Width, CursorType: CursorType.Cursor);

            PageTitleContainer.AddElement(PageTitle);
            HUD = new UIGrid(Width: SmartPhone.SCREEN_RECT.Width, Height: SmartPhone.SCREEN_RECT.Height, CursorType: CursorType.Cursor, GridColumns: 1, ColWidth: SmartPhone.SCREEN_RECT.Width);
            HUD.AddElement(PageTitleContainer);

            PageContent = new UIGrid(Width: SmartPhone.SCREEN_RECT.Width, Height: SmartPhone.SCREEN_RECT.Height - PageTitleContainer.Height, CursorType: CursorType.Cursor, GridColumns: 1, ColWidth: SmartPhone.SCREEN_RECT.Width);
            HUD.AddElement(PageContent);
        }
Ejemplo n.º 3
0
        protected UIContainer CreateSwitchAppButton(string appname, PhoneApp app)
        {
            if (app.phone != this.phone)
            {
                throw new Exception("Can't create a switch app button between two different phones!");
            }

            UIContainer btncontainer = new UIContainer(CursorType: CursorType.Cursor, Width: SmartPhone.SCREEN_RECT.Width, CentreHorizontal: true);
            Button button = new Button(Color.LightBlue, Color.LightBlue, Color.LightCyan, Color.Turquoise, Textures.SmartPhoneButton, CursorType: CursorType.Cursor, Text: appname);
            btncontainer.AddElement(button);

            button.OnPressed += obj =>
            {
                phone.SwitchTo(app);
            };
            return btncontainer;
        }
Ejemplo n.º 4
0
        private void InitBackground()
        {
            Graphic background = new Graphic(Application.Instance().AssetManager.Textures[TextureID.MenuBackground]);

            _menuUI.AddElement(background);
        }
Ejemplo n.º 5
0
        protected void CreateInstallAppButton(string appname, int apptype, SmartPhone phone, Entity owner, List<PhoneApp> InstalledApps)
        {
            UIContainer btncontainer = new UIContainer(CursorType: CursorType.Cursor, Width: SmartPhone.SCREEN_RECT.Width, CentreHorizontal: true);

            Button button = new Button(Color.LightBlue, Color.LightBlue, Color.LightCyan, Color.Turquoise, Textures.SmartPhoneButton, CursorType: CursorType.Cursor, Text: "Install " + appname);

            button.OnPressed += (obj) =>
            {
                int itemIndex = (owner as IItemHolder).GetItemIndex(apptype);
                if (itemIndex != -1)
                {
                    int consumeRate = (owner as IItemHolder).GetItem(apptype).ConsumeRate;
                    (owner as IItemHolder).TrashItem(itemIndex);
                    //Remove the item from the HUD as well
                    ((UI.Inventory_UI[itemIndex] as UIContainer)[0] as InventoryElement).Item = null;

                    //Remove this button, since it's no longer needed
                    (button.Parent as UIContainer).RemoveElement(button);

                    //Also create the button for launching the new app
                    PhoneApp newApp = phone.InstallApp(apptype, consumeRate);
                    PageContent.AddElement(CreateSwitchAppButton(appname, newApp));
                }
            };
            btncontainer.AddElement(button);
            PageContent.AddElement(btncontainer);
        }