public Vector2[] GetTilesPlacement(Road.RelativeMoveDirection relativeMoveDirection, MainSettings.Difficult difficult)
        {
            if (!tilesPlacements.ContainsKey(difficult))
            {
                RoadBuilder.Settings roadSettings = GetObject(difficult);
                tilesPlacements.Add(difficult,
                                    new Dictionary <Road.RelativeMoveDirection, Vector2[]> {
                    { Road.RelativeMoveDirection.Forward, roadSettings.ForwardMoveTilesPlacement },
                    { Road.RelativeMoveDirection.Right, roadSettings.RightMoveTilesPlacement }, {
                        Road.RelativeMoveDirection.Left,
                        roadSettings.RightMoveTilesPlacement.Select(vector => vector * new Vector2(-1, 1)).ToArray()
                    }
                });
            }

            return(tilesPlacements[difficult][relativeMoveDirection]);
        }
        public RoadPart CreateNextRoadPart(bool isSwitchDirection, bool needCrystal)
        {
            Road.AbsoluteMoveDirection newAbsoluteMoveDirection = lastAbsoluteMoveDirection;
            Road.RelativeMoveDirection newRelativeMoveDirection = Road.RelativeMoveDirection.Forward;
            if (isSwitchDirection)
            {
                switch (lastAbsoluteMoveDirection)
                {
                case Road.AbsoluteMoveDirection.Forward:
                    newAbsoluteMoveDirection = Road.AbsoluteMoveDirection.Right;
                    newRelativeMoveDirection = Road.RelativeMoveDirection.Right;
                    break;

                case Road.AbsoluteMoveDirection.Right:
                    newAbsoluteMoveDirection = Road.AbsoluteMoveDirection.Forward;
                    newRelativeMoveDirection = Road.RelativeMoveDirection.Left;
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }

            Vector2    newRoadPartPositionShift;
            Quaternion newRoadPartLocalRotationQuaternion;

            switch (newAbsoluteMoveDirection)
            {
            case Road.AbsoluteMoveDirection.Forward:
                newRoadPartPositionShift           = Vector2.up;
                newRoadPartLocalRotationQuaternion = Quaternion.identity;
                break;

            case Road.AbsoluteMoveDirection.Right:
                newRoadPartPositionShift           = Vector2.right;
                newRoadPartLocalRotationQuaternion = Quaternion.Euler(0.0f, 90.0f, 0.0f);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            Vector2 newRoadPartLocalPosition = lastRoadPartPosition + newRoadPartPositionShift;

            RoadPart newRoadPart = roadPartFactory.Create();

            Vector2[] tilesPlacement = roadBuilderSettingsGroups.GetTilesPlacement(newRelativeMoveDirection);

            Transform roadPartRoot = new GameObject($"RoadPart({newRelativeMoveDirection})").transform;

            roadPartRoot.parent = road.transform;
            roadPartRoot.transform.localPosition = newRoadPartLocalPosition.ToV3FromX0Y();
            roadPartRoot.transform.localRotation = newRoadPartLocalRotationQuaternion;

            newRoadPart.Root = roadPartRoot;

            foreach (Vector2 tilePosition in tilesPlacement)
            {
                Tile newTile = tileFactory.Create();
                newTile.transform.parent        = roadPartRoot;
                newTile.transform.localPosition = tilePosition.ToV3FromX0Y();
                newTile.transform.rotation      = road.transform.rotation;

                newRoadPart.Tiles.Add(newTile);
            }

            lastRoadPartPosition      = newRoadPartLocalPosition;
            lastAbsoluteMoveDirection = newAbsoluteMoveDirection;

            if (needCrystal)
            {
                Crystal.Crystal newCrystal = crystalFactory.Create();
                newCrystal.transform.parent        = roadPartRoot;
                newCrystal.transform.localPosition = Vector3.forward * roadBuilderSettingsGroups.GetObject().CrystalPositionShift;
                newCrystal.transform.rotation      = road.transform.rotation;
                newCrystal.transform.localScale    = Vector3.one;

                newRoadPart.Crystal = newCrystal;
            }

            AddRoadPart(newRoadPart);

            return(newRoadPart);
        }
 public Vector2[] GetTilesPlacement(Road.RelativeMoveDirection relativeMoveDirection)
 {
     return(GetTilesPlacement(relativeMoveDirection, mainSettings.OverallDifficult));
 }