コード例 #1
0
        public Floor()
        {
            ButtonFactory factory = new ButtonFactory();

            UpButton   = factory.GetButton(Direction.Up);
            DownButton = factory.GetButton(Direction.Down);
        }
コード例 #2
0
ファイル: LoseState.cs プロジェクト: kTindalland/oop_game
        public LoseState(ButtonFactory buttonFactory, TextFactory textFactory, IPostOfficeService postOfficeService, LeaderboardManager leaderboardManager)
        {
            _buttonFactory      = buttonFactory;
            _textFactory        = textFactory;
            _postOfficeService  = postOfficeService;
            _leaderboardManager = leaderboardManager;
            _playerScore        = 0L;

            // Check for 123456 because user cannot enter this
            _playername = "123456";

            // Ready to write to file.
            _ready = true;

            #region Button Stuff

            // Menu button stuff
            var menuArgs = new PostOfficeEventArgs()
            {
                SendAddress = "StateManager",
                MessageName = "ChangeState",
                Data        = Encoding.ASCII.GetBytes("Menu")
            };

            _menuButton = _buttonFactory.GenerateButton("Menu", 20, 400, menuArgs);

            #endregion
        }
コード例 #3
0
    void OnEnable()
    {
        button = ButtonFactory.GetPlatformSpecificButtonImplementation();
        button.Enable("Jump", pairedWithInputManager, GetComponent <GUIElement>().GetScreenRect());

        TypeSpecificOnEnable();
    }
コード例 #4
0
 public GameEngine()
 {
     this.starfield    = new StarField();
     this.inputHandler = new InputHandler();
     this.graphics     = new GraphicsDeviceManager(this)
     {
         IsFullScreen              = false,
         PreferredBackBufferWidth  = Globals.MAIN_SCREEN_WIDTH,
         PreferredBackBufferHeight = Globals.MAIN_SCREEN_HEIGHT
     };
     this.IsMouseVisible        = true;
     this.Window.Title          = "Traveling to FARCROTHU";
     this.Content.RootDirectory = "Content";
     this.mainMenuButtons       = new ButtonFactory();
     this.pauseMenuButtons      = new ButtonFactory();
     this.singleLoginButtons    = new ButtonFactory();
     this.loadButtons           = new LoadButtonFactory(new Vector2(900, 300));
     this.mainMenuForms         = new FormFactory();
     this.singleLoginForms      = new FormFactory();
     this.databaseManager       = new SaveAndLoadDbManager();
     this.userDbManager         = new UserDbManager();
     this.usersRepository       = new UsersRepository();
     this.updateStateManager    = new UpdateStateManager();
     this.drawObjectsManager    = new DrawGameObjectsManager();
     this.playManager           = new PlayGameManager();
 }
コード例 #5
0
 public override void Setup(World world, out ISystem <float> systems)
 {
     _imageFactory  = new ImageFactory(world);
     _buttonFactory = new ButtonFactory(world, _game.GraphicsDevice);
     InitializeSystems(world, out systems);
     SetupWorld();
 }
コード例 #6
0
        /**
         * Carrega os assets
         */
        protected override void LoadContent()
        {
            // ambientSound.



            content = Content;

            ButtonFactory.initialize(Content, ".\\Sprites\\GUI\\simpleButton", ".\\Sprites\\GUI\\simpleButtonXML", ".\\Sprites\\font\\Luckiest");
            _spriteBatch        = new SpriteBatch(GraphicsDevice);
            _spriteBatchIntro   = new SpriteBatch(GraphicsDevice);
            _spriteBatchPreGame = new SpriteBatch(GraphicsDevice);
            _spriteBatchShop    = new SpriteBatch(GraphicsDevice);
            _spriteBatchCard    = new SpriteBatch(GraphicsDevice);
            screenManager       = new ScreenManager();
            screenManager.addScreen(new GameScreen(ScreenLabels.GAME_SCREEN, _spriteBatch, Content));
            screenManager.addScreen(new IntroScreen(ScreenLabels.INIT_SCREEN, _spriteBatchIntro, Content));
            screenManager.addScreen(new PreGameScreen(ScreenLabels.PRE_GAME_SCREEN, _spriteBatchPreGame, Content));
            screenManager.addScreen(new ShopScreen(ScreenLabels.SHOP_SCREEN, _spriteBatchShop, Content));
            screenManager.change(ScreenLabels.INIT_SCREEN);

            infoCard.init(Content);
            statisticCard.init(Content);
            devInfoCard.init(Content);
            helpCard.init(Content);
            //SoundEffect soundEngine = Content.Load<SoundEffect>(".\\sounds\\teste");
            //soundEngine.Play();
        }
コード例 #7
0
 public LoadingScreen(Game game) : base(game)
 {
     gameManager = (IGameManager)game.Services.GetService(typeof(IGameManager));
     buttons     = ButtonFactory.CreateLoadingButtons();
     screenManager.IsTransitioning = true;
     timeToDisplay = 2.0f;
 }
コード例 #8
0
 public ExitScreen(Game game) : base(game)
 {
     procentage = 1;
     zoom       = 1;
     buttons    = ButtonFactory.CreateExitButtons();
     screenManager.IsTransitioning = true;
     timeToDisplay = 2;
 }
コード例 #9
0
 public OptionsScreen(Game game) : base(game)
 {
     buttons         = ButtonFactory.CreateOptionsButtons();
     index           = 0;
     tempSencitivity = controlManager.Mouse.Sensitivity * 1000;
     tempDimencions  = screenManager.Dimensions;
     tempFullScreen  = screenManager.Fullscreen;
 }
コード例 #10
0
        Button MakeButton()
        {
            var buttonFactory = new ButtonFactory();
            var butt          = buttonFactory.Make_Button(MyIndicators, "Hello");

            butt.SetValue(Grid.RowProperty, 2);

            return(butt);
        }
コード例 #11
0
        public GameOverScene(SpriteFont font) : base(font)
        {
            OkButton          = ButtonFactory.CreateButton(font, "Ok");
            OkButton.Position = new Vector2(Game.StandardWidth / 2.0f - OkButton.Rectangle.Width / 2.0f,
                                            Game.StandardHeight / 2.0f - OkButton.Rectangle.Height / 2.0f);

            _messagePosition = new Vector2(Game.StandardWidth / 2.0f - font.MeasureString(_message).X / 2.0f,
                                           Game.StandardHeight / 2.0f - font.MeasureString(_message).X / 2.0f);
            _messagePosition -= new Vector2(0, 350);
        }
コード例 #12
0
        public void CommandPatternTest()
        {
            var button = new ButtonFactory().Create();

            Assert.IsType <Button>(button);

            var window = new WindowFactory().Create();

            Assert.IsType <Window>(window);
        }
コード例 #13
0
        internal State UpdateSingleLoadGameMenu(ButtonFactory singleLoginButtons, StarField starfield,
                                                State gameState, GameTime gameTime)
        {
            MouseState mouseAfterLogin = Mouse.GetState();

            singleLoginButtons.CreateButton(new Vector2(500, 300), State.OnePlayer, "New Game");
            singleLoginButtons.CreateButton(new Vector2(500, 400), State.LoadGameMenu, "Load Game");
            starfield.Update(gameTime);
            return(singleLoginButtons.ReturnButtonState(mouseAfterLogin, gameState));
        }
コード例 #14
0
    private static void Main(string[] args)
    {
        ClassToMakeButtonFor1.RegisterMe();
        ClassToMakeButtonFor2.RegisterMe();
        Button b = ButtonFactory.MakeMeAButton <ClassToMakeButtonFor1>();

        Console.WriteLine(b.Whatever);
        b = ButtonFactory.MakeMeAButton <ClassToMakeButtonFor2>();
        Console.WriteLine(b.Whatever);
        Console.ReadLine();
    }
コード例 #15
0
 public static IRender GetUiObject(int type)
 {
     if (type == 1)
     {
         return(TextboxFactory.GetTextControl());
     }
     else
     {
         return(ButtonFactory.GetButtonControl());
     }
 }
コード例 #16
0
        private static IFloorLobbyButton GetDownButton(int floorID)
        {
            ButtonFactory     btnFactory = new ButtonFactory();
            IFloorLobbyButton btn        = btnFactory.CreateButton(ButtonType.FloorButton) as IFloorLobbyButton;

            btn.ButtonID     = 0;
            btn.FloorID      = floorID;
            btn.IsDownButton = true;
            btn.ButtonName   = string.Format("Down Button at Floor {0}", floorID);
            return(btn);
        }
コード例 #17
0
        internal State UpdateMenuState(ButtonFactory mainMenuButtons, FormFactory mainMenuForms, State gameState)
        {
            mainMenuButtons.CreateButton(new Vector2(500, 300), State.SingleLogInMenu, "Singleplayer Mode");
            mainMenuButtons.CreateButton(new Vector2(500, 400), State.TwoPlayers, "Multiplayer Mode");
            mainMenuButtons.CreateButton(new Vector2(500, 500), State.HighScores, "High Scores");
            mainMenuButtons.CreateButton(new Vector2(900, 500), State.Register, "Register User");

            MouseState mouse = Mouse.GetState();

            mainMenuForms.UpdateForms(mouse);
            return(mainMenuButtons.ReturnButtonState(mouse, gameState));
        }
コード例 #18
0
        public NameInputState(ButtonFactory buttonFactory, TextFactory textFactory, IPostOfficeService postOfficeService, Rectangle bounds)
        {
            // Initialise fields
            StateRegisterName = "NameInput";
            _maxLen           = 5;

            // Set up buttons
            #region Buttons

            // Buttons
            PostOfficeEventArgs args;
            _buttons = new List <Button>();

            // Back button
            args = new PostOfficeEventArgs()
            {
                SendAddress = "StateManager",
                MessageName = "ChangeState",
                Data        = Encoding.ASCII.GetBytes("Menu")
            };

            _buttons.Add(buttonFactory.GenerateButton("Back", 100, 100, args));

            // Play button
            var playArgs = new PostOfficeEventArgs()
            {
                SendAddress = "StateManager",
                MessageName = "ChangeState",
                Data        = Encoding.ASCII.GetBytes("FlavourText")
            };

            _buttons.Add(buttonFactory.GenerateButton("Play", 100, 100, playArgs));

            // Get real values
            var seperation = 100;
            var totalWidth = (_buttons[0].Width * 2) + seperation;
            var leftSpace  = bounds.Width - totalWidth;
            var margin     = leftSpace / 2;

            var yValue = 300;

            // Set real values
            _buttons[0].Position = new Vector2(margin, yValue);
            _buttons[1].Position = new Vector2(margin + seperation + _buttons[0].Width, yValue);

            #endregion

            // Initialise more fields
            _nameHelper        = new NameInputHelper(_maxLen);
            _textFactory       = textFactory;
            _postOfficeService = postOfficeService;
            _name = _textFactory.GenerateText(_nameHelper.GetName(), margin, 100);
        }
コード例 #19
0
        internal State UpdatePauseMenu(ButtonFactory pauseMenuButtons, State previousState, State gameState,
                                       StarField starfield, GameTime gameTime)
        {
            pauseMenuButtons.CreateButton(new Vector2(500, 300), State.SaveGame, "Save game");
            pauseMenuButtons.CreateButton(new Vector2(500, 400), previousState, "Continue");
            pauseMenuButtons.CreateButton(new Vector2(500, 500), State.Quit, "Quit");

            MouseState pauseMouse = Mouse.GetState();

            starfield.Update(gameTime);
            starfield.Speed = 1;
            return(pauseMenuButtons.ReturnButtonState(pauseMouse, gameState));
        }
コード例 #20
0
        Button MakeEnhancedButton()
        {
            var buttonFactory = new ButtonFactory();
            var butt          = buttonFactory.Make_Button(MyIndicators, true);

            butt.SetValue(Grid.RowProperty, 2);
            butt.HorizontalAlignment = HorizontalAlignment.Center;
            butt.VerticalAlignment   = VerticalAlignment.Center;
            butt.Width  = 210;
            butt.Margin = new Thickness(10);
            butt.SetValue(Grid.ColumnProperty, 1);
            butt.Content = "Using flashy Template";

            return(butt);
        }
コード例 #21
0
        Button MakeStandardButton()
        {
            var buttonFactory = new ButtonFactory();
            var butt          = buttonFactory.Make_Button(MyIndicators, false);

            butt.SetValue(Grid.RowProperty, 2);
            butt.HorizontalAlignment = HorizontalAlignment.Center;
            butt.VerticalAlignment   = VerticalAlignment.Center;
            butt.Width  = 210;
            butt.Margin = new Thickness(10);
            butt.SetValue(Grid.ColumnProperty, 1);
            butt.Content = "Default Styles & Template from code";

            return(butt);
        }
コード例 #22
0
        private async Task CreateButtons()
        {
            this.ClearScreen();

            for (int index = 0; index < this.intArr.Length; index++)
            {
                var item = this.intArr[index];
                var btn  = ButtonFactory.Create(item, index);
                this.buttons.Add(btn);
                this.Controls.Add(btn);
            }

            await this.Sort();

            //this.CreateSwapAnimation(buttons[0], this.buttons[2]);
        }
コード例 #23
0
        internal State UpdateSingleLoginMenu(FormFactory singleLoginForms, ButtonFactory singleLoginButtons,
                                             State gameState, UsersRepository usersRepository, StarField starfield, GameTime gameTime)
        {
            MouseState mouseLogin = Mouse.GetState();

            singleLoginForms.UpdateForms(mouseLogin);
            singleLoginButtons.CreateButton(new Vector2(900, 426), State.SingleLoadGameMenu, "LogIn");
            gameState = singleLoginButtons.ReturnButtonState(mouseLogin, gameState);
            if (gameState == State.SingleLoadGameMenu)
            {
                usersRepository.AddUser(singleLoginForms);
            }

            starfield.Update(gameTime);

            return(gameState);
        }
コード例 #24
0
ファイル: InventoryUI.cs プロジェクト: DBeumans/Puzzle_2D
    public void updateUI(int itemsToShow, string type, List <string> objName)
    {
        if (currType != type || currType == type)
        {
            int childs = inventoryPanel.transform.childCount;
            for (int i = 0; i < childs; i++)
            {
                Destroy(inventoryPanel.transform.GetChild(i).gameObject);
                currType = "";
            }
        }

        currType = type;
        Vector2 screenPos = new Vector2(buttonOffset.x, -buttonOffset.y);

        for (int i = 0; i < itemsToShow; i++)
        {
            GameObject      btn       = ButtonFactory.createButton(objName[i], new Vector2(buttonSize, buttonSize), null, screenPos, false);
            RectTransform   btnRect   = btn.GetComponent <RectTransform>();
            Button          btnButton = btn.GetComponent <Button>();
            InventoryButton invButton = btn.AddComponent <InventoryButton>();

            btnRect.SetParent(inventoryPanel.transform);

            btnRect.pivot            = new Vector2(0, 1);
            btnRect.anchorMin        = new Vector2(0, 1);
            btnRect.anchorMax        = new Vector2(0, 1);
            btnRect.localScale       = new Vector3(1, 1, 1);
            btnRect.anchoredPosition = screenPos;

            if (btnRect.anchoredPosition.x >= invPanelRectTransform.rect.width)
            {
                screenPos = new Vector2(buttonOffset.x, btnRect.anchoredPosition.y - btnRect.sizeDelta.y - buttonOffset.y);
                btnRect.anchoredPosition = screenPos;
            }
            screenPos += new Vector2(btnRect.sizeDelta.x + buttonOffset.x, 0);

            invButton.GetObjName = objName[i];
            invButton.GetObjType = currType;
            inventoryPanel.GetComponent <RectTransform>().sizeDelta = new Vector2(0, -btnRect.anchoredPosition.y + btnRect.sizeDelta.y + buttonOffset.y);
        }
    }
コード例 #25
0
ファイル: MenuState.cs プロジェクト: kTindalland/oop_game
        public MenuState(ButtonFactory buttonFactory, TextFactory textFactory)
        {
            StateRegisterName = "Menu";

            // Buttons
            _buttons = new List <Button>();

            // Play button
            var playArgs = new PostOfficeEventArgs()
            {
                SendAddress = "StateManager",
                MessageName = "ChangeState",
                Data        = Encoding.ASCII.GetBytes("NameInput")
            };

            _buttons.Add(buttonFactory.GenerateButton("Play", 100, 100, playArgs));

            // Leaderboard
            var leaderboardArgs = new PostOfficeEventArgs()
            {
                SendAddress = "StateManager",
                MessageName = "ChangeState",
                Data        = Encoding.ASCII.GetBytes("Leaderboard")
            };

            _buttons.Add(buttonFactory.GenerateButton("Leaderboard", 100, 150, leaderboardArgs));


            // Exit
            var exitArgs = new PostOfficeEventArgs()
            {
                SendAddress = "StateManager",
                MessageName = "ChangeState",
                Data        = Encoding.ASCII.GetBytes("Exit")
            };

            _buttons.Add(buttonFactory.GenerateButton("Exit", 100, 200, exitArgs));
            _textFactory = textFactory;

            _title = _textFactory.GenerateText("Siege of Brightforest", 400, 100);
        }
コード例 #26
0
        internal static IControl GetUIElement(int uiElementType, int objectType)
        {
            IControl objUIElement;

            switch (uiElementType)
            {
            case 1:
                objUIElement = ButtonFactory.GetButton(objectType);
                break;

            case 2:
                objUIElement = TextBoxFactory.GetTextBox(objectType);
                break;

            default:
                objUIElement = null;
                break;
            }

            return(objUIElement);
        }
コード例 #27
0
        public LeaderboardState(ButtonFactory buttonFactory, TextFactory textFactory, LeaderboardManager leaderboardManager)
        {
            StateRegisterName = "Leaderboard";

            // Factories and managers
            _buttonFactory      = buttonFactory;
            _textFactory        = textFactory;
            _leaderboardManager = leaderboardManager;

            // Lists
            _text    = new List <Text>();
            _buttons = new List <Button>();

            // Change the state to the menu
            var buttonArgs = new PostOfficeEventArgs()
            {
                SendAddress = "StateManager",
                MessageName = "ChangeState",
                Data        = Encoding.ASCII.GetBytes("Menu")
            };

            _buttons.Add(_buttonFactory.GenerateButton("Back", 550, 400, buttonArgs));
        }
コード例 #28
0
        public FlavourTextState(ButtonFactory buttonFactory, TextFactory textFactory)
        {
            // Fields
            _textFactory = textFactory;

            #region ContinueButton

            var continueArgs = new PostOfficeEventArgs()
            {
                SendAddress = "StateManager",
                MessageName = "ChangeState",
                Data        = Encoding.ASCII.GetBytes("Play")
            };
            _continueButton = buttonFactory.GenerateButton("Continue", 20, 400, continueArgs);



            #endregion

            #region Text Stuff

            // Lines of flavour text
            var lines = new List <string>()
            {
                "The castle is under attack!",
                "The evil fire squirrels have beseiged Brightforest.",
                "Direct orders from the crown state you are in charge",
                "of defending as long as you can.",
                "Upgrades are M30 each, a new archer is M20.",
                "Good luck."
            };

            // Get the flavour text as Text objects
            _flavourText = GenerateTexts(lines);

            #endregion
        }
コード例 #29
0
 public InfoScreen(Game game) : base(game)
 {
     buttons = ButtonFactory.CreateInfoButtons();
 }
コード例 #30
0
 public static void RegisterMe()
 {
     ButtonFactory.Register(typeof(ClassToMakeButtonFor2), new ButtonFactory2());
 }