Пример #1
0
    private Wall GetWall(int row, int column, DirectionEnum direction)
    {
        var nextPosition     = PositionHelper.GetNextPosition(row, column, direction);
        var reverseDirection = DirectionHelper.GetReverseDirection(direction);

        return(_wallFilter.ToEntitiesList().FirstOrDefault(w => {
            return (w.Row == row && w.Column == column && w.Direction == direction) ||
            (w.Row == nextPosition.Row && w.Column == nextPosition.Column && w.Direction == reverseDirection);
        }));
    }
Пример #2
0
    private bool IsElementAvailable(int column, int row, int round, int number, DirectionEnum direction)
    {
        var position = PositionHelper.GetNextPosition(column, row, direction);
        var element  = GetBoardElement(position);
        var wall     = GetWall(position, DirectionHelper.GetReverseDirection(direction));

        if (
            wall != null ||
            (element.ContainsSnakeStep && element.Round == round) ||
            (element.ContainsTarget && element.Round == round && !TargetHelper.CanGetTargetElement(number))
            )
        {
            return(false);
        }

        return(true);
    }
        private void CloseWall(Wall wallEntity, Wall wall)
        {
            wallEntity.Row       = wall.Row;
            wallEntity.Column    = wall.Column;
            wallEntity.Direction = wall.Direction;

            var nextPosition     = PositionHelper.GetNextPosition(wall.Row, wall.Column, wall.Direction);
            var reverseDirection = DirectionHelper.GetReverseDirection(wall.Direction);

            GameObject wallObject        = null;
            GameObject reverseWallObject = null;

            foreach (var wallObj in _wallGameObjects)
            {
                var wallElement = wallObj.transform.GetComponent <WallElement>();
                if (
                    wallElement.Row == wall.Row &&
                    wallElement.Column == wall.Column &&
                    wallElement.Direction == wall.Direction
                    )
                {
                    wallObject = wallObj;
                }

                if (
                    wallElement.Row == nextPosition.Row &&
                    wallElement.Column == nextPosition.Column &&
                    wallElement.Direction == reverseDirection
                    )
                {
                    reverseWallObject = wallObj;
                }
            }

            wallEntity.Transforms = new List <Transform>();
            if (wallObject != null)
            {
                wallEntity.Transforms.Add(wallObject.transform);
                wallObject.SetActive(true);
            }
            if (reverseWallObject != null)
            {
                wallEntity.Transforms.Add(reverseWallObject.transform);
                reverseWallObject.SetActive(true);
            }
        }
Пример #4
0
    private Wall GetWall(PositionModel position, DirectionEnum direction)
    {
        var nextPosition     = PositionHelper.GetNextPosition(position.Row, position.Column, direction);
        var reverseDirection = DirectionHelper.GetReverseDirection(direction);

        return(_wallsFilter
               .ToEntitiesList()
               .FirstOrDefault(e =>
                               (
                                   e.Row == position.Row &&
                                   e.Column == position.Column &&
                                   e.Direction == direction
                               ) ||
                               (
                                   e.Row == nextPosition.Row &&
                                   e.Column == nextPosition.Column &&
                                   e.Direction == reverseDirection
                               )
                               ));
    }