Esempio n. 1
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
        }
 public ForwardMessageService(
     IForwardMessageRepository forwardMessageRepository,
     IPostOfficeService postOfficeService)
 {
     _forwardMessageRepository = forwardMessageRepository;
     _postOfficeService        = postOfficeService;
 }
Esempio n. 3
0
        public Button(string text, Vector2 position, Texture2D buttonSprite, SpriteFont font, IPostOfficeService postOffice, PostOfficeEventArgs args)
        {
            // Initialise local variables
            _clickReady = false;
            _guid       = Guid.NewGuid();
            _canUpdate  = true;

            // Store local variables passed in
            _text         = text;
            _position     = position;
            _buttonSprite = buttonSprite;
            _font         = font;
            _postOffice   = postOffice;
            _args         = args;

            // Register at the post office
            _postOffice.RegisterClient(this, _guid.ToString());

            // Measure and center text
            var textRadii    = _font.MeasureString(_text) / 2;
            var buttonCenter = new Vector2(_buttonSprite.Width / 2, _buttonSprite.Height / 2);
            var textOffset   = buttonCenter - textRadii;

            _textPosition = _position + textOffset;

            // Set up rectangles for collision.
            _buttonCollisionRectangle = new Rectangle((int)_position.X, (int)_position.Y, _buttonSprite.Width, _buttonSprite.Height);
        }
Esempio n. 4
0
        // Handles the players stats, like rate of fire and damage output
        public StatsManager(IPostOfficeService postOfficeService, MoneyManager moneyManager)
        {
            LetterboxName = "StatsManager";

            // Default values
            Reset();
            _postOfficeService = postOfficeService;
            _moneyManager      = moneyManager;
        }
Esempio n. 5
0
        public Game1()
        {
            _graphics             = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";

            _postOffice = new PostOfficeService();

            _stateManager = new StateManager(_postOffice);

            IsFixedTimeStep = true;
        }
Esempio n. 6
0
        public PlayerMetaDataManager(IPostOfficeService postOfficeService)
        {
            LetterboxName = "PlayerMetaData";

            // Initialises the player data.
            _playerData = new Score()
            {
                Name        = "Name Not Set",
                PlayerScore = 0
            };
            _postOfficeService = postOfficeService;
        }
Esempio n. 7
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. 8
0
 public AdminPanelController(IPostOfficeService officeService, IRegionService regionService)
 {
     _officeService = officeService;
     _regionService = regionService;
 }
Esempio n. 9
0
 public CompanyController(ICompanyService companyService, IPostOfficeService officeService, IRegionService regionService)
 {
     _companyService = companyService;
     _officeService  = officeService;
     _regionService  = regionService;
 }
 public PostOfficeController(IPostOfficeService officeService, IRegionService regionService)
 {
     _officeService = officeService;
     _regionService = regionService;
 }
Esempio n. 11
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
        }
Esempio n. 12
0
 public RegionService(IPostOfficeService officeService, IRegionRepo regionRepo, IMapper mapper)
 {
     _officeService = officeService;
     _regionRepo    = regionRepo;
     _mapper        = mapper;
 }
Esempio n. 13
0
 public MoneyManager(IPostOfficeService postOfficeService)
 {
     // Start with 50 m's
     _money = 50;
 }
Esempio n. 14
0
 public ButtonFactory(Texture2D defaultTexture, SpriteFont font, IPostOfficeService postOffice)
 {
     _defaultTexture = defaultTexture; // The texture this factory uses
     _font           = font;           // The font this facotry uses
     _postOffice     = postOffice;     // Give the buttons this post office object
 }