コード例 #1
0
    public static Map GenerateMapFromTemplate(SegmentTemplateData template, int segmentID)
    {
        int rotation = template.SegmentID.IndexOf(segmentID);

        string definition = template.Definition;

        if (rotation == 1)
        {
            definition = RotateDefinitionCW(definition);
        }
        else if (rotation == 2)
        {
            definition = RotateDefinitionCW(definition);
            definition = RotateDefinitionCW(definition);
            //definition = FlipDefinition(definition);
        }
        else if (rotation == 3)
        {
            definition = RotateDefinitionCCW(definition);
        }

        StringDeserializeMapCreationStrategy <Map> strategy =
            new StringDeserializeMapCreationStrategy <Map>(definition);

        Map map = strategy.CreateMap();

        return(map);
    }
コード例 #2
0
    public static Map GetSegmentMap(byte segment)
    {
        Map map = new Map(MapSegment.SegmentCellWidthHeight, MapSegment.SegmentCellWidthHeight);

        Segment template;

        if (segments.TryGetValue(segment, out template))
        {
            for (int y = 0; y < MapSegment.SegmentWidthHeight; y++)
            {
                for (int x = 0; x < MapSegment.SegmentWidthHeight; x++)
                {
                    string mapString = components[(int)template.tiles[(y * 3) + x]].symbols;

                    StringDeserializeMapCreationStrategy <Map> strategy = new StringDeserializeMapCreationStrategy <Map>(mapString);
                    Map tempMap = strategy.CreateMap();

                    map.Copy(tempMap, x * MapSegment.SegmentWidthHeight, y * MapSegment.SegmentWidthHeight);
                }
            }
        }

        return(map);
    }