コード例 #1
0
        public HolePunch3DBenchmark()
        {
            var sectorGraphDescriptionStore = new SectorGraphDescriptionStore();
            var snapshotCompiler            = new TerrainSnapshotCompiler(sectorGraphDescriptionStore);

            terrainService = new TerrainService(sectorGraphDescriptionStore, snapshotCompiler);
        }
コード例 #2
0
        public Game Create()
        {
            var gameTimeService        = new GameTimeService(30);
            var gameLoop               = new GameEventQueueService(gameTimeService);
            var terrainServiceStore    = new SectorGraphDescriptionStore();
            var terrainSnapshotBuilder = new TerrainSnapshotCompiler(terrainServiceStore);
            var terrainService         = new TerrainService(terrainServiceStore, terrainSnapshotBuilder);
            var entityService          = new EntityService();
            var statsCalculator        = new StatsCalculator();
            var pathfinderCalculator   = new PathfinderCalculator(terrainService, statsCalculator);
            var movementSystemService  = new MovementSystemService(entityService, gameTimeService, statsCalculator, terrainService, pathfinderCalculator);

            entityService.AddEntitySystem(movementSystemService);
            var gameLogicFacade = new GameLogicFacade(terrainService, movementSystemService);
            var gameInstance    = new Game {
                GameTimeService       = gameTimeService,
                GameEventQueueService = gameLoop,
                TerrainService        = terrainService,
                EntityService         = entityService,
                PathfinderCalculator  = pathfinderCalculator,
                MovementSystemService = movementSystemService,
                GameLogicFacade       = gameLogicFacade
            };

            gameInstance.Initialize();
            GameCreated?.Invoke(this, gameInstance);
            return(gameInstance);
        }
コード例 #3
0
        private LocalGeometryView BuildLgv(TerrainStaticMetadata mapStaticMetadata, double holeDilationRadius, params IHoleStaticMetadata[] holeMetadatas)
        {
            var store          = new SectorGraphDescriptionStore();
            var terrainService = new TerrainService(store, new TerrainSnapshotCompiler(store));

            var sector = terrainService.CreateSectorNodeDescription(mapStaticMetadata);

            sector.WorldTransform = Matrix4x4.Multiply(Matrix4x4.CreateScale(1), Matrix4x4.CreateTranslation(-500, -500, 0));
            terrainService.AddSectorNodeDescription(sector);

            var left2 = new IntLineSegment2(new IntVector2(0, 600), new IntVector2(0, 800));

            terrainService.AddSectorEdgeDescription(PortalSectorEdgeDescription.Build(sector, sector, left2, left2));

            foreach (var holeMetadata in holeMetadatas)
            {
                var terrainHole = terrainService.CreateHoleDescription(holeMetadata);
                terrainService.AddTemporaryHoleDescription(terrainHole);
            }

            var terrainOverlayNetwork = terrainService.CompileSnapshot().OverlayNetworkManager.CompileTerrainOverlayNetwork(holeDilationRadius);

            return(terrainOverlayNetwork.TerrainNodes.First().LocalGeometryView);
        }
コード例 #4
0
 public TerrainSnapshotCompiler(SectorGraphDescriptionStore descriptionStore)
 {
     this.descriptionStore = descriptionStore;
 }
コード例 #5
0
        public static void Main(string[] args)
        {
            var sectorGraphDescriptionStore = new SectorGraphDescriptionStore();
            var snapshotCompiler            = new TerrainSnapshotCompiler(sectorGraphDescriptionStore);
            var terrainService = new TerrainService(sectorGraphDescriptionStore, snapshotCompiler);

            // Add test sectors
            var leftSnd = terrainService.CreateSectorNodeDescription(SectorMetadataPresets.HashCircle2);

//         leftSnd.EnableDebugHighlight = true;
            leftSnd.WorldTransform = Matrix4x4.CreateScale(1000.0f / 60000.0f) * Matrix4x4.CreateTranslation(-1000, 0, 0);
            terrainService.AddSectorNodeDescription(leftSnd);

            var centerSnd = terrainService.CreateSectorNodeDescription(SectorMetadataPresets.Blank2D);

            centerSnd.EnableDebugHighlight = true;
            centerSnd.WorldTransform       = Matrix4x4.CreateScale(1000.0f / 60000.0f);
            terrainService.AddSectorNodeDescription(centerSnd);

            /*+		[0]	{(-30000, -18000)}	OpenMOBA.Geometry.IntVector2
             +		[1]	{(-30000, -6000)}	OpenMOBA.Geometry.IntVector2
             +		[2]	{(-6000, -6000)}	OpenMOBA.Geometry.IntVector2
             +		[3]	{(-6000, -18000)}	OpenMOBA.Geometry.IntVector2
             +		[4]	{(-30000, -18000)}	OpenMOBA.Geometry.IntVector2
             */
            var rightSnd = terrainService.CreateSectorNodeDescription(SectorMetadataPresets.HashCircle2);

            rightSnd.WorldTransform = Matrix4x4.CreateScale(1000.0f / 60000.0f) * Matrix4x4.CreateTranslation(1000, 0, 0);
            terrainService.AddSectorNodeDescription(rightSnd);

            // edges between test sectors

            var rightTopSegment    = new IntLineSegment2(new IntVector2(30000, 6000), new IntVector2(30000, 18000));
            var leftTopSegment     = new IntLineSegment2(new IntVector2(-30000, 6000), new IntVector2(-30000, 18000));
            var rightBottomSegment = new IntLineSegment2(new IntVector2(30000, -18000), new IntVector2(30000, -6000));
            var leftBottomSegment  = new IntLineSegment2(new IntVector2(-30000, -18000), new IntVector2(-30000, -6000));

            terrainService.AddSectorEdgeDescription(PortalSectorEdgeDescription.Build(
                                                        leftSnd, centerSnd,
                                                        rightTopSegment,
                                                        leftTopSegment));
            terrainService.AddSectorEdgeDescription(PortalSectorEdgeDescription.Build(
                                                        centerSnd, leftSnd,
                                                        leftTopSegment,
                                                        rightTopSegment));
            terrainService.AddSectorEdgeDescription(PortalSectorEdgeDescription.Build(
                                                        leftSnd, centerSnd,
                                                        rightBottomSegment,
                                                        leftBottomSegment));
            terrainService.AddSectorEdgeDescription(PortalSectorEdgeDescription.Build(
                                                        centerSnd, leftSnd,
                                                        leftBottomSegment,
                                                        rightBottomSegment));

            //
            terrainService.AddSectorEdgeDescription(PortalSectorEdgeDescription.Build(
                                                        centerSnd, rightSnd,
                                                        rightTopSegment,
                                                        leftTopSegment));
            terrainService.AddSectorEdgeDescription(PortalSectorEdgeDescription.Build(
                                                        rightSnd, centerSnd,
                                                        leftTopSegment,
                                                        rightTopSegment));

            terrainService.AddSectorEdgeDescription(PortalSectorEdgeDescription.Build(
                                                        centerSnd, rightSnd,
                                                        rightBottomSegment,
                                                        leftBottomSegment));
            terrainService.AddSectorEdgeDescription(PortalSectorEdgeDescription.Build(
                                                        rightSnd, centerSnd,
                                                        leftBottomSegment,
                                                        rightBottomSegment));

            // add some obstacles
//         terrainService.AddTemporaryHoleDescription(terrainService.CreateHoleDescription(
//            HoleStaticMetadata.CreateRectangleHoleMetadata(-500, 250, 60, 60, 0)));
//         terrainService.AddTemporaryHoleDescription(terrainService.CreateHoleDescription(
//            HoleStaticMetadata.CreateRectangleHoleMetadata(0, 130, 60, 60, 0)));
            for (var i = 0; i < 100; i++)
            {
                break;
                terrainService.AddTemporaryHoleDescription(terrainService.CreateHoleDescription(
                                                               HoleStaticMetadata.CreateRectangleHoleMetadata(
                                                                   random.Next(-1500, 1500),
                                                                   random.Next(-500, 500),
                                                                   random.Next(10, 50),
                                                                   random.Next(10, 50),
                                                                   random.NextDouble() * Math.PI * 2)));
            }

            var terrainSnapshot = terrainService.CompileSnapshot();
            var overlayNetwork  = terrainSnapshot.OverlayNetworkManager.CompileTerrainOverlayNetwork(30);

            for (var i = 0; i < 360; i += 10)
            {
                var canvas = host.CreateAndAddCanvas(i);
                canvas.BatchDraw(() => {
                    foreach (var terrainNode in overlayNetwork.TerrainNodes)
                    {
                        canvas.Transform = terrainNode.SectorNodeDescription.WorldTransform;
                        canvas.DrawPolyNode(terrainNode.LandPolyNode, StrokeStyle.BlackHairLineSolid, StrokeStyle.DarkRedHairLineSolid);
                    }

                    foreach (var terrainNode in overlayNetwork.TerrainNodes)
                    {
                        canvas.Transform = terrainNode.SectorNodeDescription.WorldTransform;
                        foreach (var outboundEdgeGroup in terrainNode.OutboundEdgeGroups)
                        {
                            foreach (var outboundEdge in outboundEdgeGroup.Value)
                            {
                                Console.WriteLine(outboundEdge.EdgeJob.SourceSegment);
                                canvas.DrawLine(outboundEdge.EdgeJob.SourceSegment, StrokeStyle.CyanThick3Solid);
                            }
                        }
                    }

                    foreach (var terrainNode in overlayNetwork.TerrainNodes)
                    {
                        canvas.Transform = terrainNode.SectorNodeDescription.WorldTransform;

                        foreach (var hole in terrainNode.LocalGeometryView.Job.DynamicHoles)
                        {
                            var(holeIncludedContours, holeExcludedContours) = hole.Value;
                            canvas.DrawPolygonContours(holeIncludedContours, StrokeStyle.RedHairLineSolid);
                            canvas.DrawPolygonContours(holeExcludedContours, StrokeStyle.OrangeHairLineSolid);
                        }
                    }

                    int asdfa = -1;
                    foreach (var terrainNode in overlayNetwork.TerrainNodes)
                    {
                        asdfa++;
                        canvas.Transform = terrainNode.SectorNodeDescription.WorldTransform;

                        if (terrainNode.SectorNodeDescription.EnableDebugHighlight)
                        {
                            var visibilityPolygonOrigin = IntVector2.FromRadiusAngle(50 * 60, i * Math.PI / 180) + new IntVector2(0, 0);
                            canvas.DrawCrossSectorVisibilityPolygon(terrainNode, visibilityPolygonOrigin);
                        }
                    }
                });
            }
        }