Exemplo n.º 1
0
        /// <summary>
        /// Базовый конструктор
        /// Base constructor
        /// </summary>
        /// <param name="snakeFactory">Производство змеек/Snakes factory</param>
        /// <param name="mapSideSize">Сторона карты/Map's edge</param>
        /// <param name="foodCount">Максимальное колличество еды/Max amount of food</param>
        public GameLogicBase(HashSet <GameLogicsAttributes.GameoverPredicates> gameoverPredicates,
                             ISnakeFactory snakeFactory, int mapSideSize, int foodCount, List <string> snakeNames, bool leftDeadSnakeBody = false,
                             GameLogicsAttributes.Barriers barriers = GameLogicsAttributes.Barriers.None)
        {
            BarriersType        = barriers;
            this.SnakeFactory   = snakeFactory;
            this.SnakesForLogic = new GameLogicsAttributes.SnakesForLogic();
            Map = new PlayingMap(mapSideSize, foodCount);
            LeftDeadSnakeBody = leftDeadSnakeBody;
            InitialGameoverPredicate(gameoverPredicates);

            if (snakeNames.Count == 0)
            {
                snakeNames.Add(nameof(PlayerArrows));
            }
            var snakesCordinates = GetInitialSnakesCordinates(mapSideSize, snakeNames.Count);

            for (int i = 0; i < snakeNames.Count; i++)
            {
                var snake = snakeFactory.GetSnakeByName(snakeNames[i], snakesCordinates[i]);
                snake.ID = i;
                SnakesForLogic.Snakes.Add(snake);
            }

            foreach (var snake in SnakesForLogic.Snakes)
            {
                Map.Snake.Add(new PlayingMapAttributes.Snake(snake.SnakeName, snake.SnakeBody, snake, snake.Statistics));
            }

            InsertBarriers(Map);
            InsertFood(Map);
        }
Exemplo n.º 2
0
        public CustomisingLogic(HashSet <GameLogicsAttributes.GameoverPredicates> gameoverPredicates,
                                List <string> snakeNames, ISnakeFactory snakeFactory,
                                int mapSideSize, int foodCount, bool leftDeadSnakeBody, GameLogicsAttributes.Barriers barriers = GameLogicsAttributes.Barriers.None)
            : base(gameoverPredicates, snakeFactory, mapSideSize, foodCount, snakeNames, leftDeadSnakeBody, barriers)
        {
            var situations = SituationsInit.Instance.GetSituationsObjects();

            AchievedLength       = situations.AchievedLength;
            CollisionWithBarrier = situations.CollisionWithBarrier;
            CollisionWithFood    = situations.CollisionWithFood;
            CollisionWithSnake   = situations.CollisionWithSnake;
            DidStepsWithoutFood  = situations.DidStepsWithoutFood;
        }
        private SnakeGameManager(Graphics graphics, SizeF screenSize)
        {
            _graphics   = graphics;
            _screenSize = screenSize;
            _drawer     = new XDrawer(_graphics);

            // Initialize Board
            _board = new XBoard(_drawer, _screenSize.Width, _screenSize.Height);

            // Level Initialization
            _snakeFactory     = new SnakeFactory();
            _levelInitializer = new XLevelInitializer(_snakeFactory);
            _levelInitializer.InitializeLevel(_board, GameMode.Easy);
            _levelInitializer.SnakeColided += () => { SnakeColided?.Invoke(); };
        }
Exemplo n.º 4
0
 public LevelInitializer(ISnakeFactory snakeFactory)
 {
     _snakeFactory = snakeFactory;
 }
Exemplo n.º 5
0
 public StandartLogic(HashSet <GameLogicsAttributes.GameoverPredicates> gameoverPredicates,
                      List <string> snakeNames, ISnakeFactory snakeFactory,
                      int mapSideSize, int foodCount, bool leftDeadSnakeBody)
     : base(gameoverPredicates, snakeFactory, mapSideSize, foodCount, snakeNames, leftDeadSnakeBody)
 {
 }
Exemplo n.º 6
0
 public XLevelInitializer(ISnakeFactory _snakeFactory) : base(_snakeFactory)
 {
 }