예제 #1
0
 public BonusObject(ICellFactory cellFactory, IGameEventFactory eventFactory, IConfigurationDataProvider dataProvider)
     : base(cellFactory, eventFactory)
 {
     _random           = new Random();
     _stopwatch        = new Stopwatch();
     _remainingTime    = int.Parse(dataProvider.Get("remainingTime"));
     _bonusPossibility = int.Parse(dataProvider.Get("bonusPossibility"));
 }
예제 #2
0
 public FoodObject(ICellFactory cellFactory, IGameEventFactory eventFactory, IConfigurationDataProvider dataProvider)
     : base(cellFactory, eventFactory)
 {
     _random             = new Random();
     _stopwatch          = new Stopwatch();
     _timeFoodBeEaten    = int.Parse(dataProvider.Get("timeFoodBeEaten"));
     _remainingTimeToEat = new Info("Time to get a food", 600, ConsoleColor.DarkGreen, _timeFoodBeEaten, false);
     _info.Add(_remainingTimeToEat);
     _timeToBomb       = int.Parse(dataProvider.Get("timeToBomb"));
     _timeGetTimeBonus = int.Parse(dataProvider.Get("timeGetTimeBonus"));
 }
예제 #3
0
 public WallObject(ICellFactory cellFactory, IGameEventFactory eventFactory, IConfigurationDataProvider dataProvider)
     : base(cellFactory, eventFactory)
 {
     _random           = new Random();
     Level             = 1;
     MaxLevel          = int.Parse(dataProvider.Get("maxLevel"));
     WallSpreadDencity = int.Parse(dataProvider.Get("wallSpreadDencity"));
     MinWallLength     = int.Parse(dataProvider.Get("minWallLength"));
     MaxWallLength     = int.Parse(dataProvider.Get("maxWallLength"));
     _level            = new Info("Level", 200, ConsoleColor.DarkGray, Level, true);
     _info.Add(_level);
 }
예제 #4
0
        public SnakeObject(ICellFactory cellFactory, IGameEventFactory eventFactory, IConfigurationDataProvider dataProvider)
            : base(cellFactory, eventFactory)
        {
            _body   = new Queue <ICell>();
            _points = new Info("Points", 400, ConsoleColor.Magenta, 0, true);
            _info.Add(_points);
            _initialLifes           = int.Parse(dataProvider.Get("lifes"));
            Lifes                   = _initialLifes;
            _pointsToAdditionalLife = int.Parse(dataProvider.Get("pointsToAdditionalLife"));
            InitialLength           = int.Parse(dataProvider.Get("initialSnakeLength"));
            MaxLength               = int.Parse(dataProvider.Get("maxSnakeLength"));
            _timeToBomb             = int.Parse(dataProvider.Get("timeToBomb"));
            _bombRange              = int.Parse(dataProvider.Get("bombRange"));
            CurrentDirection        = Direction.Down;
            _stopwatch              = new Stopwatch();
            _stopwatch.Start();
            _bombCount = 0;

            _immortal = false;
            _immortalMoveStopwatch = new Stopwatch();
            _immortalMovePeriod    = int.Parse(dataProvider.Get("immortalMovePeriod"));

            _lifes = new Info("Lifes", 100, ConsoleColor.Green, Lifes, true);
            _info.Add(_lifes);
            _remainingFoods = new Info("Remaining foods", 500, ConsoleColor.Blue, MaxLength - Length, true);
            _info.Add(_remainingFoods);
            _timeToGetTimeBonus       = int.Parse(dataProvider.Get("timeGetTimeBonus"));
            _remainingTimeToTimeBonus = new Info("Time to get a timebonus", 700, ConsoleColor.Cyan, _timeToGetTimeBonus, false);
            _info.Add(_remainingTimeToTimeBonus);
            _timeToGetBomb = new Info("Time to get a bomb", 800, ConsoleColor.DarkMagenta, _timeToBomb, false);
            _info.Add(_timeToGetBomb);
            _bomb = new Info("Bombs", 900, ConsoleColor.DarkRed, _bombCount, true);
            _info.Add(_bomb);
        }
예제 #5
0
 public GameContext(IConfigurationDataProvider dataProvider, params IGameObject[] gameObjects)
 {
     Width     = int.Parse(dataProvider.Get("width"));
     Height    = int.Parse(dataProvider.Get("height"));
     PlayWidth = int.Parse(dataProvider.Get("playWidth"));
     InfoWidth = Width - PlayWidth;
     Points    = 0;
     InitializeGameField();
     _gameObjects = new List <IGameObject>(gameObjects);
     Used         = new HashSet <ICell>();
     RecycleBin   = new HashSet <ICell>();
     _infoObjects = new SortedSet <IInfo>();
     RegisterAllInfos(gameObjects);
     Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
     Console.OutputEncoding = Encoding.Unicode; //Encoding.GetEncoding(1252);
 }