Beispiel #1
0
        /// <summary>
        /// Constructs and initializes the editor
        /// </summary>
        /// <param name="document">Reference to a document to edit</param>
        public SqlSourceEditor(IDocument document) : base(document)
        {
            if (!(document is ISqlSource))
            {
                throw new ArgumentException(Resources.Error_UnsupportedDocument, "document");
            }

            InitializeComponent();
            Font f = FontsAndColors.GetFont("Text Editor");

            sqlEditor.Font = f;
        }
Beispiel #2
0
        public LogsOverlay(ApplicationLogger applicationLogger, FontsAndColors fontsAndColors, GameBus bus)
        {
            _applicationLogger = applicationLogger;
            _fontsAndColors    = fontsAndColors;

            bus.Subscribe <KeyReleased>(message =>
            {
                switch (message.Key)
                {
                case Keys.L:
                    _showLogs = !_showLogs;
                    break;
                }
            });
        }
        public Enemy(
            EnemySettings settings,
            GraphicsTracker graphicsTracker,
            GameBus bus,
            FontsAndColors fontsAndColors,
            SpriteSheets spriteSheets)
        {
            _graphicsTracker = graphicsTracker;
            _bus             = bus;
            _fontsAndColors  = fontsAndColors;
            _spriteSheets    = spriteSheets;
            _health          = new EntitysHealth {
                Health = settings.Health
            };
            _waypoints = settings.Waypoints;

            SpriteWithDirectionsRenderer = CreateSprite(settings.EnemyType);
        }
Beispiel #4
0
        public GameLevel(
            GameLevelSettings settings,
            InputManager inputManager,
            TowerFactory towerFactory,
            GraphicsTracker graphicsTracker,
            MouseDragControl mouseDragControl,
            FontsAndColors fontsAndColors,
            GameBus bus,
            GameMapOverlay gameMapOverlay,
            ApplicationLogger logger,
            EnemyFactory enemyFactory)
        {
            _settings           = settings;
            _towerFactory       = towerFactory;
            _graphicsTracker    = graphicsTracker;
            _fontsAndColors     = fontsAndColors;
            _gameMapOverlay     = gameMapOverlay;
            _logger             = logger;
            _enemyFactory       = enemyFactory;
            _stringFormatCenter = new StringFormat
            {
                LineAlignment = StringAlignment.Center,
                Alignment     = StringAlignment.Center
            };
            _gameMapOverlay.SetMap(settings.Map);

            inputManager.OnMouseDragged  += mouseDragControl.InputManagerOnMouseDrag;
            inputManager.OnMouseReleased += mouseDragControl.InputManagerOnMouseRelease;
            _enemySpawner = new EnemySpawner(_time, settings.SpawnFrequency);

            bus.Subscribe <EnemyReachedGoal>(message =>
            {
                if (IsVisible)
                {
                    _gameState = GameState.Lost;
                }
            });

            bus.Subscribe <GameStateChange>(message =>
            {
                if (IsVisible && message.GameLevel == this)
                {
                    _gameState = message.GameState;
                }
            });

            bus.Subscribe <EnemyDespawned>(message =>
            {
                if (IsVisible)
                {
                    CurrentEnemiesNew.Remove(message.Enemy);
                    if (CurrentEnemiesNew.Count == 0 && _monstersLeftToSpawn.Count == 0)
                    {
                        _gameState = GameState.Won;
                    }
                }
            });

            bus.Subscribe <MouseClicked>(message =>
            {
                if (IsVisible && message.EventArgs.Button == MouseButtons.Left)
                {
                    if (_towerBeingPlaced != null)
                    {
                        // There is a tower being placed and mouse was clicked => place it.
                        PlaceTower(_towerBeingPlaced);
                    }
                }
            });

            bus.Subscribe <KeyReleased>(message =>
            {
                if (IsVisible)
                {
                    if (_gameState == GameState.Won)
                    {
                        bus.Publish(new GameStateChange(GameState.Won, this));
                        CurrentEnemiesNew.Clear();
                        return;
                    }
                    if (_gameState == GameState.Lost)
                    {
                        bus.Publish(new GameStateChange(GameState.Lost, this));
                        CurrentEnemiesNew.Clear();
                        return;
                    }

                    switch (message.Key)
                    {
                    case Keys.Space:
                        TogglePause();
                        break;

                    case Keys.D1:
                        StartPlacingTower();
                        break;
                    }
                }
            });
        }
Beispiel #5
0
 public GameMapOverlay(SpriteSheets spriteSheets, GraphicsTracker graphicsTracker, FontsAndColors fontsAndColors)
 {
     _spriteSheets    = spriteSheets;
     _graphicsTracker = graphicsTracker;
     _fontsAndColors  = fontsAndColors;
 }