示例#1
0
        public void Start()
        {
            var timeToBreak = false;

            foreach (var line in _gameMap)
            {
                var j = 0;
                foreach (var isWall in line)
                {
                    timeToBreak = !isWall;
                    if (timeToBreak)
                    {
                        for (var k = 0; k < j; ++k)
                        {
                            _player.MoveRight();
                        }
                        break;
                    }
                    ++j;
                }
                if (timeToBreak)
                {
                    break;
                }
                _player.MoveDown();
            }
            if (!timeToBreak)
            {
                throw new ArgumentException("Not a single cell for a player on the map. Argh!");
            }
            MapChanged?.Invoke(this, new GameMapChangedArgs(_gameMap, _player));
            GameContinues?.Invoke(this, EventArgs.Empty);
        }
示例#2
0
        public void NewGameIteration(object sender, KeyPressedArgs args)
        {
            switch (args.GameChange)
            {
            case KeyPressedArgs.GameChangeEnum.NewPosition:
            {
                Actions[args.Key].React(_gameMap, _player);
                break;
            }

            case KeyPressedArgs.GameChangeEnum.Cancel:
            {
                return;
            }

            default:
            {
                Console.WriteLine("Wrong key, result ignored. Remind: Q to exit, arrows to move.");
                return;
            }
            }
            MapChanged?.Invoke(this, new GameMapChangedArgs(_gameMap, _player));
            GameContinues?.Invoke(this, EventArgs.Empty);
        }