Exemple #1
0
 public void BuildSplitTracks(GroupBranch groupBranch, List<SplitTrack> tracks)
 {
     foreach (SubTrack subTrack in groupBranch.Tracks.SelectMany(track => track.SubTracks))
     {
         BuildSplitTrack(groupBranch, subTrack);
     }
 }
Exemple #2
0
 private Controller[] CreateJunctionControllers(GroupBranch groupBranch, IList<Junction> junctions)
 {
     GameObject arrowPrefab = groupBranch.Level.Prefabs.ArrowPrefab;
     GameObject junctionPrefab = groupBranch.Level.Prefabs.PointerPrefab;
     return junctions.Select(junction => new JunctionController(groupBranch, arrowPrefab, junctionPrefab, groupBranch.Level.ConnectionResolver, junction))
         .Cast<Controller>().ToArray();
 }
Exemple #3
0
        private void AttachGameObject(MeshBlock meshBlock, GroupBranch groupBranch, AdjacencyCalculator adjacencyCalculator)
        {
            SplitBoundsBranch splitBoundsBranch = groupBranch.SplitBoundsBranchContaining(meshBlock.SplittedRegion);

            var meshBuilder = new MeshBuilder();
            adjacencyCalculator.SetupNext(groupBranch.SplittedMeshBlocks, groupBranch.Splits, meshBlock);

            for (var x = (int)meshBlock.OriginalBounds.MinX; x < meshBlock.OriginalBounds.MaxX; x++)
            {
                for (var y = (int)meshBlock.OriginalBounds.MinY; y < meshBlock.OriginalBounds.MaxY; y++)
                {
                    for (var z = (int)meshBlock.OriginalBounds.MinZ; z < meshBlock.OriginalBounds.MaxZ; z++)
                    {
                        AdjacencyMatrix adjacencyMatrix = adjacencyCalculator.CalculateAdjacency(x, y, z);
                        if (!adjacencyMatrix.IsVisible()) continue;

                        var clipBounds = new BlockBounds(x, y, z, x + 1, y + 1, z + 1);
                        clipBounds.ClipToBounds(groupBranch.Splits);
                        meshBlock.MeshSource.Build(new Vector3(x, y, z) - meshBlock.OriginalBounds.Position, adjacencyMatrix, meshBlock, meshBuilder, clipBounds);
                    }
                }
            }

            GameObject blockGameObject = Object.Instantiate(groupBranch.Level.Prefabs.BlockPrefab);
            blockGameObject.name = meshBlock.Id;
            blockGameObject.transform.localPosition = meshBlock.OriginalBounds.Position;
            splitBoundsBranch.BlocksLeaf.Attach(blockGameObject);

            Mesh mesh = meshBuilder.DoneCreateMesh();
            blockGameObject.GetComponent<MeshFilter>().mesh = mesh;
        }
Exemple #4
0
 public void BuildBlocks(GroupBranch groupBranch, List<MeshBlock> meshBlocks)
 {
     var adjacencyCalculator = new AdjacencyCalculator();
     foreach (MeshBlock block in groupBranch.SplittedMeshBlocks)
     {
         AttachGameObject(block, groupBranch, adjacencyCalculator);
     }
 }
Exemple #5
0
 public JunctionController(GroupBranch groupBranch, GameObject arrowPrefab, GameObject pointerPrefab, TrackConnectionResolver connectionResolver, Junction junction)
 {
     _junction = junction;
     _connectionResolver = connectionResolver;
     _arrowPrefab = arrowPrefab;
     _pointerPrefab = pointerPrefab;
     _groupBranch = groupBranch;
     _pointerInstance = InstantiatePointer();
 }
Exemple #6
0
 internal SplitSide(LevelTree levelTree, Split split, bool lhs)
 {
     _split = split;
     Lhs = lhs;
     Group = levelTree.GetGroupBranch(split.Group);
     AttachedRotateables = split.AttachedGroups
         .Where(attached => attached.Lhs == lhs)
         .Select(attached => levelTree.GetGroupBranch(attached.AttachedGroup))
         .ToArray();
 }
Exemple #7
0
        public SplitBoundsBranch(string name, SplittedRegion splittedRegion, Vector3 pos, RotationData data, GroupBranch group) : base (name, pos, data, group)
        {
            BaseTree staticBranch = new BaseTree("Static", new Vector3(), this, NodeConfig.StaticAndPropogate);
            TracksLeaf = new BaseTree("Tracks", new Vector3(), staticBranch, NodeConfig.StaticAndPropogate);
            BlocksLeaf = new BaseTree("Blocks", new Vector3(), staticBranch, NodeConfig.StaticAndPropogate);
            OthersLeaf = new BaseTree("Others", new Vector3(), this, NodeConfig.Dynamic);

            SplittedRegion = splittedRegion;
            Group = group;
            group.AddSplitBoundsBranch(this);
            Name = name;
        }
Exemple #8
0
        private void BuildSplitTrack(GroupBranch groupBranch, SubTrack track)
        {
            SplitBoundsBranch splitBranch = groupBranch.SplitBoundsBranchContaining(track.SplittedRegion);

            GameObject gameObj = new GameObject(track.Id);
            TrackExtruder trackExtruder = new TrackExtruder(TrackBuilderConfiguration.DefaultConfig);

            foreach (SubTrackGroup subTrackGroup in track.TrackGroups)
            {
                BezierSpline spline = subTrackGroup.Spline;
                Mesh trackMesh = trackExtruder.ExtrudeAlong(spline, track.SplitTrack.InitialDown);
                GameObject childTrack = GameObjectUtils.AsChildOf(gameObj.transform, new Vector3(), Object.Instantiate(groupBranch.Level.Prefabs.TrackPrefab));
                childTrack.name = subTrackGroup.Id;
                childTrack.GetComponent<MeshFilter>().mesh = trackMesh;
            }

            splitBranch.TracksLeaf.Attach(gameObj);
        }
Exemple #9
0
 public void AddGroupBranch(GroupBranch groupBranch)
 {
     _groupBranches.Add(groupBranch.GroupData.Group, groupBranch);
 }
Exemple #10
0
 public static SplitBoundsBranch CreateAndAttachTo(int count, SplittedRegion splittedRegion, GroupBranch groupBranch, RotationData rotationData)
 {
     string name = "split_" + count;
     return new SplitBoundsBranch(name, splittedRegion, new Vector3(), rotationData, groupBranch);
 }
Exemple #11
0
 public void OnAttachedToGroupBranch(GroupBranch groupBranch)
 {
     GroupBranch = groupBranch;
 }
Exemple #12
0
 public BaseTree GetSplitBoundsBranch(GroupBranch groupBranch)
 {
     return groupBranch.SplitBoundsBranchContaining(BranchDefault.SubTrack.SplittedRegion);
 }