예제 #1
0
        // Sets up rects for location area and border ready for circumnavigation
        protected bool SetLocationRects(DFPosition targetPixel, DFPosition targetMPworld)
        {
            GameObject terrainObject = GameManager.Instance.StreamingWorld.GetTerrainFromPixel(targetPixel);

            if (terrainObject)
            {
                DaggerfallTerrain dfTerrain = terrainObject.GetComponent <DaggerfallTerrain>();
                if (dfTerrain && dfTerrain.MapData.hasLocation)
                {
                    float      locBorder = 1;
                    DFLocation location  = DaggerfallUnity.Instance.ContentReader.MapFileReader.GetLocation(dfTerrain.MapData.mapRegionIndex, dfTerrain.MapData.mapLocationIndex);
                    if (location.Loaded && location.MapTableData.LocationType == DFRegion.LocationTypes.TownCity)
                    {
                        locBorder = 1.5f;
                    }

                    Rect locationTileRect = dfTerrain.MapData.locationRect;
                    locationTileRect.xMin += 1;
                    locationTileRect.yMin += 1;
                    locationBorderRect.Set(targetMPworld.X + (locationTileRect.x * TSize), targetMPworld.Y + (locationTileRect.y * TSize), locationTileRect.width * TSize, locationTileRect.height * TSize);

                    locationTileRect.xMin += locBorder;
                    locationTileRect.xMax -= locBorder;
                    locationTileRect.yMin += locBorder;
                    locationTileRect.yMax -= locBorder;
                    locationRect.Set(targetMPworld.X + (locationTileRect.x * TSize), targetMPworld.Y + (locationTileRect.y * TSize), locationTileRect.width * TSize, locationTileRect.height * TSize);

                    return(!location.HasCustomLocationPosition());   // Only aim for location center if it's centered in the map pixel
                }
            }
            locationBorderRect.Set(0, 0, 0, 0);
            locationRect.Set(0, 0, 0, 0);
            return(false);
        }
예제 #2
0
        // Determines tile origin of location inside terrain area.
        // This is not always centred precisely but rather seems to follow some other
        // logic/formula for locations of certain RMB dimensions (e.g. 1x1).
        // Unknown if there are more exceptions or if a specific formula is needed.
        // This method will be used in the interim pending further research.
        public static DFPosition GetLocationTerrainTileOrigin(DFLocation location)
        {
            // Get map width and height
            int width  = location.Exterior.ExteriorData.Width;
            int height = location.Exterior.ExteriorData.Height;

            // Centring works nearly all the time
            DFPosition result = new DFPosition();

            result.X = (RMBLayout.RMBTilesPerTerrain - width * RMBLayout.RMBTilesPerBlock) / 2;
            result.Y = (RMBLayout.RMBTilesPerTerrain - height * RMBLayout.RMBTilesPerBlock) / 2;

            // Handle custom 1x1 location position
            if (location.HasCustomLocationPosition())
            {
                result.X = 72;
                result.Y = 55;
            }
            return(result);
        }