Beispiel #1
0
        public List <GeoDataElement> GetGeoData(Point3 <int> pointFrom, Point3 <int> pointTo)
        {
            List <GeoDataElement> geoDataList = new List <GeoDataElement>();

            lock (_terrainDetailsLock)
            {
                pointFrom.X = Measure.Clamp(0, _terrainDetails.GetLength(0) - 1, pointFrom.X);
                pointFrom.Y = Measure.Clamp(0, _terrainDetails.GetLength(1) - 1, pointFrom.Y);
                pointFrom.Z = Measure.Clamp(0, _terrainDetails.GetLength(2) - 1, pointFrom.Z);
                pointTo.X   = Measure.Clamp(0, _terrainDetails.GetLength(0) - 1, pointTo.X);
                pointTo.Y   = Measure.Clamp(0, _terrainDetails.GetLength(1) - 1, pointTo.Y);
                pointTo.Z   = Measure.Clamp(0, _terrainDetails.GetLength(2) - 1, pointTo.Z);

                PlaceInstanceTerrainDetails details;
                DbTerrainObjectDefinitions  terrainDefinition;
                Point3 <int>        location;
                Point3 <int>        colliderSize;
                GeoDataElement.Type elementType = GeoDataElement.Type.None;
                bool isExit = false;


                for (int z = pointFrom.Z; z <= pointTo.Z; z++)
                {
                    for (int y = pointFrom.Y; y <= pointTo.Y; y++)
                    {
                        for (int x = pointFrom.X; x <= pointTo.X; x++)
                        {
                            details = _terrainDetails[x, y, z];
                            if (details == null)
                            {
                                continue;
                            }

                            terrainDefinition = details.TerrainDefinition;

                            if (!terrainDefinition.IsTerrain && !terrainDefinition.IsPlatform && !terrainDefinition.IsObstacle)
                            {
                                continue;
                            }

                            if (terrainDefinition.IsObstacle)
                            {
                                elementType = GeoDataElement.Type.Obstacle;
                            }
                            else if (terrainDefinition.IsTerrain)
                            {
                                elementType = GeoDataElement.Type.Terrain;
                            }
                            else if (terrainDefinition.IsPlatform)
                            {
                                elementType = GeoDataElement.Type.Platform;
                            }
                            else
                            {
                                elementType = GeoDataElement.Type.None;
                            }

                            location     = new Point3 <int>(details.LocalPosX, details.LocalPosY, details.LocalPosZ);
                            colliderSize = new Point3 <int>(terrainDefinition.CollisionX, terrainDefinition.CollisionY, terrainDefinition.CollisionZ);
                            isExit       = details.IsExit;

                            GeoDataElement geoDataElement = new GeoDataElement(location, colliderSize, elementType, isExit);
                            geoDataList.Add(geoDataElement);
                        }
                    }
                }
            }

            return(geoDataList);
        }
Beispiel #2
0
        public List <GeoDataElement> GetGeoDataOfExitElements()
        {
            List <GeoDataElement> geoDataList = new List <GeoDataElement>();

            lock (_terrainDetailsLock)
            {
                PlaceInstanceTerrainDetails details;
                DbTerrainObjectDefinitions  terrainDefinition;
                Point3 <int>        location;
                Point3 <int>        colliderSize;
                GeoDataElement.Type elementType = GeoDataElement.Type.None;
                bool isExit = false;

                int x, y, z;

                foreach (Tuple <int, int, int> indexes in _exitElementsIndexList)
                {
                    x = indexes.Item1;
                    y = indexes.Item2;
                    z = indexes.Item3;

                    details = _terrainDetails[x, y, z];
                    if (details == null)
                    {
                        continue;
                    }

                    terrainDefinition = details.TerrainDefinition;

                    if (!terrainDefinition.IsTerrain && !terrainDefinition.IsPlatform && !terrainDefinition.IsObstacle)
                    {
                        continue;
                    }

                    if (terrainDefinition.IsObstacle)
                    {
                        elementType = GeoDataElement.Type.Obstacle;
                    }
                    else if (terrainDefinition.IsTerrain)
                    {
                        elementType = GeoDataElement.Type.Terrain;
                    }
                    else if (terrainDefinition.IsPlatform)
                    {
                        elementType = GeoDataElement.Type.Platform;
                    }
                    else
                    {
                        elementType = GeoDataElement.Type.None;
                    }

                    location     = new Point3 <int>(details.LocalPosX, details.LocalPosY, details.LocalPosZ);
                    colliderSize = new Point3 <int>(terrainDefinition.CollisionX, terrainDefinition.CollisionY, terrainDefinition.CollisionZ);
                    isExit       = details.IsExit;

                    GeoDataElement geoDataElement = new GeoDataElement(location, colliderSize, elementType, isExit);
                    geoDataList.Add(geoDataElement);
                }
            }

            return(geoDataList);
        }