Esempio n. 1
0
        public Window()
        {
            _hero = new Hero();

            _level = new Level(_hero, true);
            _levelView = new LevelView(_level);
            _hud = new Hud(_hero);

            DungeonGenerator.generateDungeon(_level, 200, 200);
            _level.setHeroInLevel(false);

            _effectView = new EffectView();

            _inputManager = new InputManager();
        }
Esempio n. 2
0
        /// <summary>
        /// Updates the game engine and processes any effects
        /// </summary>
        /// <param name="keyState"></param>
        /// <returns>Returns true if the game should cease it's update loop</returns>
        public bool update(KeyboardState keyState)
        {
            if (_level.levelChange != LevelChange.None)
            {
                if (_level.levelChange == LevelChange.Down)
                {
                    _level.levelChange = LevelChange.None;
                    _level = _level.downLevel;
                    _level.setHeroInLevel(false);
                }
                else
                {
                    _level.levelChange = LevelChange.None;
                    _level = _level.upLevel;
                    _level.setHeroInLevel(true);
                }
                _levelView = new LevelView(_level);
                return true;
            }

            EffectDescription? effectDescription = _level.getEffect();
            if (effectDescription != null)
            {
                Effect effect = EffectBuilder.buildEffect(effectDescription.Value, _level.getHeroLocation());
                _effectView.addEffect(effect);
                return true;
            }

            if (_effectView.empty())
            {
                processInput(keyState);
                return _level.update();
            }
            return true;
        }