Esempio n. 1
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);
        }
Esempio n. 2
0
        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
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
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));
        }
Esempio n. 5
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
        }
Esempio n. 6
0
        public PlayState(IPostOfficeService postOfficeService, SquirrelFactory squirrelFactory, ButtonFactory buttonFactory, TextFactory textFactory, StatsManager statsManager, MoneyManager moneyManager, Texture2D background, Rectangle bounds, Texture2D upgradebar, Texture2D stone, Gate gate)
        {
            _inWave  = true;
            _wave    = 0;
            _enemies = new List <Squirrel>();
            _archers = new List <Archer>();


            StateRegisterName  = "Play";
            _postOfficeService = postOfficeService;
            _squirrelFactory   = squirrelFactory;
            _buttonFactory     = buttonFactory;
            _textFactory       = textFactory;
            _statsManager      = statsManager;
            _moneyManager      = moneyManager;
            _background        = background;
            _stone             = stone;
            _gate   = gate;
            _bounds = new Rectangle(bounds.X, bounds.Y, bounds.Width, bounds.Height - 100);

            _upgradesBar = new UpgradesBar(new Vector2(0, _bounds.Height), new Rectangle(0, 0, _bounds.Width, 100), upgradebar);


            #region UpgradeButtons

            _upgradeButtons = new List <Button>();

            // Add archer
            var addArcherArgs = new PostOfficeEventArgs()
            {
                SendAddress = "PlayState",
                MessageName = "AddArcher",
                Data        = new byte[0]
            };

            _upgradeButtons.Add(_buttonFactory.GenerateButton("New Archer", 30, _bounds.Height + 5, addArcherArgs));

            // Increase Rate of Fire

            var rateOfFireArgs = new PostOfficeEventArgs()
            {
                SendAddress = "StatsManager",
                MessageName = "ModifyRateOfFire",
                Data        = new byte[0]
            };

            _upgradeButtons.Add(_buttonFactory.GenerateButton("RoF++", 230, _bounds.Height + 5, rateOfFireArgs));

            // Increase damage modifier

            var damageArgs = new PostOfficeEventArgs()
            {
                SendAddress = "StatsManager",
                MessageName = "ModifyArrowDamage",
                Data        = new byte[0]
            };

            _upgradeButtons.Add(_buttonFactory.GenerateButton("Damage++", 430, _bounds.Height + 5, damageArgs));

            #endregion


            #region Text

            // Generate the text objects

            _amountOfArchers =
                _textFactory.GenerateText($"{_archers.Count.ToString()} Archer(s)", 30, _bounds.Height + 55);

            _rofLevel = _textFactory.GenerateText($"Level {_statsManager.RateOfFireLevel}", 230, _bounds.Height + 55);

            _damageLevel =
                _textFactory.GenerateText($"{_statsManager.DamageModifier}x Damage", 430, _bounds.Height + 55);

            _money = _textFactory.GenerateText($"Current Funds: M{_moneyManager.Money}", 20, 20);

            _waveText = _textFactory.GenerateText($"Wave {_wave}", 20, 70);

            _gateHealth = _textFactory.GenerateText($"Gate Health: {_gate.Health}", 20, 120);

            #endregion

            #region Quit Button

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

            _quitButton = buttonFactory.GenerateButton("Quit", 600, 20, quitArgs);

            #endregion
        }