コード例 #1
0
ファイル: BaseSensor.cs プロジェクト: JHaugland/WetAffairs
 public TerrainLineSummary GetTerrainHeightSummaryToTarget(BaseUnit targetUnit)
 {
     if (OwnerUnit.Position.HeightOverSeaLevelM > GameConstants.MAX_HEIGHT_TERRAIN_M &&
         targetUnit.Position.HeightOverSeaLevelM > GameConstants.MAX_HEIGHT_TERRAIN_M)
     {
         return(new TerrainLineSummary(100, 100, 0));  //if both units are over terrain, no need to check
     }
     else
     {
         return(TerrainReader.GetTerrainHeightSummary(OwnerUnit.Position.Coordinate,
                                                      targetUnit.Position.Coordinate, GameConstants.DEFAULT_NO_OF_POINTS_TERRAIN_LINE));
     }
 }
コード例 #2
0
        public void TerrainLineTest()
        {
            var    startCoord = new Coordinate(60, 4);
            var    endCoord   = new Coordinate(62, 6);
            var    noOfPoints = 10;
            double bearingDeg;
            double distanceM;
            var    distM     = MapHelper.CalculateDistanceApproxM(startCoord, endCoord);
            var    coordList = TerrainReader.GetCoordinateLine(startCoord, endCoord, noOfPoints, out bearingDeg, out distanceM);

            //TerrainReader.CloseMemoryMap();
            TerrainReader.LoadMemoryMap();
            var testHeightM = TerrainReader.GetHeightM(new Coordinate(60, 5));

            Assert.IsTrue(testHeightM != 0, "Test height should not be 0. Memory map not loaded.");
            var sw      = Stopwatch.StartNew();
            var heights = TerrainReader.GetHeightArrayM(coordList);

            sw.Stop();
            var time10coordsMs = sw.ElapsedMilliseconds;

            GameManager.Instance.Log.LogDebug("TerrainLineTest: Get 10 coords: " + time10coordsMs + " ms");
            sw.Start();
            endCoord = new Coordinate(55, 13);
            var summary10 = TerrainReader.GetTerrainHeightSummary(startCoord, endCoord, 10);

            sw.Stop();
            var time10coordsSummaryMs = sw.ElapsedMilliseconds;

            GameManager.Instance.Log.LogDebug("TerrainLineTest: Get 10 coords summary: " + time10coordsSummaryMs + " ms");
            sw.Start();
            var terrainSummary = TerrainReader.GetTerrainHeightSummary(startCoord, endCoord, 1000);

            sw.Stop();
            var time1000coordsSummaryMs = sw.ElapsedMilliseconds;

            GameManager.Instance.Log.LogDebug("TerrainLineTest: Get 1000 coords summary: " + time1000coordsSummaryMs + " ms");
            TerrainReader.CloseMemoryMap();
        }