当前位置: 首页>>代码示例>>C#>>正文


C# FileFormats.Map类代码示例

本文整理汇总了C#中OpenRA.FileFormats.Map的典型用法代码示例。如果您正苦于以下问题:C# Map类的具体用法?C# Map怎么用?C# Map使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Map类属于OpenRA.FileFormats命名空间,在下文中一共展示了Map类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Extract

        public static int[,] Extract(Map m, Func<int, int, int> f)
        {
            var result = new int[m.MapSize, m.MapSize];
            var types = new int[m.MapSize, m.MapSize];
            var d = new Dictionary<int, Node>();
            var n = 1;

            for( var j = m.YOffset; j < m.YOffset + m.Height; j++ )
                for (var i = m.XOffset; i < m.XOffset + m.Width; i++)
                {
                    types[i, j] = f(i, j);

                    var k = n;

                    foreach (var a in Neighbors)
                        if (types[i + a.X, j + a.Y] == types[i, j])
                            k = (k == n)
                                ? result[i + a.X, j + a.Y]
                                : Union( d, k, result[i+a.X, j+a.Y] );

                    result[i,j] = k;
                    if (k == n) MakeSet(d, n++);
                }

            for (var j = m.YOffset; j < m.YOffset + m.Height; j++)
                for (var i = m.XOffset; i < m.XOffset + m.Width; i++)
                    result[i, j] = Find(d, result[i, j]);

            return result;
        }
开发者ID:comradpara,项目名称:OpenRA,代码行数:30,代码来源:ConnectedComponents.cs

示例2: TerrainRenderer

        public TerrainRenderer(World world, WorldRenderer wr)
        {
            this.world = world;
            this.map = world.Map;

            var tileSize = new Size( Game.CellSize, Game.CellSize );
            var tileMapping = new Cache<TileReference<ushort,byte>, Sprite>(
                x => Game.modData.SheetBuilder.Add(world.TileSet.GetBytes(x), tileSize));

            var vertices = new Vertex[4 * map.Bounds.Height * map.Bounds.Width];

            terrainSheet = tileMapping[map.MapTiles.Value[map.Bounds.Left, map.Bounds.Top]].sheet;

            int nv = 0;

            var terrainPalette = wr.Palette("terrain").Index;

            for( int j = map.Bounds.Top; j < map.Bounds.Bottom; j++ )
                for( int i = map.Bounds.Left; i < map.Bounds.Right; i++ )
                {
                    var tile = tileMapping[map.MapTiles.Value[i, j]];
                    // TODO: move GetPaletteIndex out of the inner loop.
                    Util.FastCreateQuad(vertices, Game.CellSize * new float2(i, j), tile, terrainPalette, nv, tile.size);
                    nv += 4;

                    if (tileMapping[map.MapTiles.Value[i, j]].sheet != terrainSheet)
                        throw new InvalidOperationException("Terrain sprites span multiple sheets");
                }

            vertexBuffer = Game.Renderer.Device.CreateVertexBuffer( vertices.Length );
            vertexBuffer.SetData( vertices, nv );
        }
开发者ID:nevelis,项目名称:OpenRA,代码行数:32,代码来源:TerrainRenderer.cs

示例3: MapList_SelectedIndexChanged

        void MapList_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (MapList.SelectedItems.Count == 1)
            {
                txtNew.Text = MapList.SelectedItems[0].Text;
                txtNew.Tag = MapList.SelectedItems[0].Tag;

                var map = new Map(txtNew.Tag as string);
                txtTitle.Text = map.Title;
                txtAuthor.Text = map.Author;
                txtTheater.Text = map.Tileset;
                txtDesc.Text = map.Description;
                pbMinimap.Image = null;

                try
                {
                    pbMinimap.Image = Minimap.AddStaticResources(map, Minimap.TerrainBitmap(map, true));
                }
                catch (Exception ed)
                {
                    Console.WriteLine("No map preview image found: {0}", ed.ToString());
                }
                finally { }
            }
        }
开发者ID:gitTerebi,项目名称:OpenRA,代码行数:25,代码来源:MapSelect.cs

示例4: UnitInfluence

        public UnitInfluence( World world )
        {
            map = world.Map;
            influence = new InfluenceNode[world.Map.MapSize.X, world.Map.MapSize.Y];

            world.ActorRemoved += a => Remove( a, a.TraitOrDefault<IOccupySpace>() );
        }
开发者ID:pdovy,项目名称:OpenRA,代码行数:7,代码来源:UnitInfluence.cs

示例5: SmudgeRenderer

        public SmudgeRenderer( Renderer renderer, Map map )
        {
            this.spriteRenderer = new SpriteRenderer( renderer, true );
            this.map = map;

            smudgeSprites = smudgeSpriteNames.SelectMany(f => SpriteSheetBuilder.LoadAllSprites(f)).ToArray();
        }
开发者ID:comradpara,项目名称:OpenRA,代码行数:7,代码来源:SmudgeRenderer.cs

示例6: MapPreviewWidget

 protected MapPreviewWidget(MapPreviewWidget other)
     : base(other)
 {
     lastMap = other.lastMap;
     Map = other.Map;
     SpawnColors = other.SpawnColors;
 }
开发者ID:jeff-1amstudios,项目名称:OpenRA,代码行数:7,代码来源:MapPreviewWidget.cs

示例7: AddStaticResources

        // Add the static resources defined in the map; if the map lives
        // in a world use AddCustomTerrain instead
        public static Bitmap AddStaticResources(Map map, Bitmap terrainBitmap)
        {
            Bitmap terrain = new Bitmap(terrainBitmap);
            var tileset = Rules.TileSets[map.Tileset];

            var bitmapData = terrain.LockBits(new Rectangle(0, 0, terrain.Width, terrain.Height),
                ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);

            unsafe
            {
                int* c = (int*)bitmapData.Scan0;

                for (var x = 0; x < map.Bounds.Width; x++)
                    for (var y = 0; y < map.Bounds.Height; y++)
                    {
                        var mapX = x + map.Bounds.Left;
                        var mapY = y + map.Bounds.Top;
                        if (map.MapResources.Value[mapX, mapY].type == 0)
                            continue;

                        var res = Rules.Info["world"].Traits.WithInterface<ResourceTypeInfo>()
                                .Where(t => t.ResourceType == map.MapResources.Value[mapX, mapY].type)
                                .Select(t => t.TerrainType).FirstOrDefault();
                        if (res == null)
                            continue;

                        *(c + (y * bitmapData.Stride >> 2) + x) = tileset.Terrain[res].Color.ToArgb();
                    }
            }
            terrain.UnlockBits(bitmapData);

            return terrain;
        }
开发者ID:FMode,项目名称:OpenRA,代码行数:35,代码来源:Minimap.cs

示例8: Bind

		public void Bind(Map m, TileSet ts, Palette p)
		{
			Map = m;
			TileSet = ts;
			Palette = p;
			Brush = null;
			Chunks.Clear();
		}
开发者ID:mgatland,项目名称:OpenRA,代码行数:8,代码来源:Surface.cs

示例9: Bind

		public void Bind(Map m, TileSet ts, Palette p)
		{
			Map = m;
			TileSet = ts;
			Palette = p;
			PlayerPalettes = null;
			Chunks.Clear();
			Tool = null;
		}
开发者ID:katzsmile,项目名称:OpenRA,代码行数:9,代码来源:Surface.cs

示例10: GetSpawnColors

 public static Dictionary<int2, Color> GetSpawnColors(OrderManager orderManager, Map map)
 {
     var spawns = map.GetSpawnPoints();
     return orderManager.LobbyInfo.Clients
         .Where( c => c.SpawnPoint != 0 )
         .ToDictionary(
             c => spawns[c.SpawnPoint - 1],
             c => c.ColorRamp.GetColor(0));
 }
开发者ID:sonygod,项目名称:OpenRA-Dedicated-20120504,代码行数:9,代码来源:LobbyUtils.cs

示例11: GetSpawnClients

 public static Dictionary<int2, Session.Client> GetSpawnClients(OrderManager orderManager, Map map)
 {
     var spawns = map.GetSpawnPoints();
     return orderManager.LobbyInfo.Clients
         .Where(c => c.SpawnPoint != 0)
             .ToDictionary(
                 c => spawns[c.SpawnPoint - 1],
                 c => c);
 }
开发者ID:Tsher,项目名称:OpenRA,代码行数:9,代码来源:LobbyUtils.cs

示例12: MapChooserLogic

        internal MapChooserLogic(Widget widget, string initialMap, Action onExit, Action<Map> onSelect)
        {
            map = Game.modData.AvailableMaps[WidgetUtils.ChooseInitialMap(initialMap)];

            widget.Get<ButtonWidget>("BUTTON_OK").OnClick = () => { Ui.CloseWindow(); onSelect(map); };
            widget.Get<ButtonWidget>("BUTTON_CANCEL").OnClick = () => { Ui.CloseWindow(); onExit(); };

            scrollpanel = widget.Get<ScrollPanelWidget>("MAP_LIST");
            scrollpanel.ScrollVelocity = 40f;
            scrollpanel.Layout = new GridLayout(scrollpanel);

            itemTemplate = scrollpanel.Get<ScrollItemWidget>("MAP_TEMPLATE");

            var gameModeDropdown = widget.GetOrNull<DropDownButtonWidget>("GAMEMODE_FILTER");
            if (gameModeDropdown != null)
            {
                var selectableMaps = Game.modData.AvailableMaps.Where(m => m.Value.Selectable).ToList();
                var gameModes = selectableMaps
                    .GroupBy(m => m.Value.Type)
                    .Select(g => Pair.New(g.Key, g.Count())).ToList();

                // 'all game types' extra item
                gameModes.Insert(0, Pair.New(null as string, selectableMaps.Count()));

                Func<Pair<string, int>, string> showItem =
                    x => "{0} ({1})".F(x.First ?? "All Game Types", x.Second);

                Func<Pair<string, int>, ScrollItemWidget, ScrollItemWidget> setupItem = (ii, template) =>
                {
                    var item = ScrollItemWidget.Setup(template,
                        () => gameMode == ii.First,
                        () => { gameMode = ii.First; EnumerateMaps(onSelect); });
                    item.Get<LabelWidget>("LABEL").GetText = () => showItem(ii);
                    return item;
                };

                gameModeDropdown.OnClick = () =>
                    gameModeDropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 210, gameModes, setupItem);

                gameModeDropdown.GetText = () => showItem(gameModes.First(m => m.First == gameMode));
            }

            var randomMapButton = widget.GetOrNull<ButtonWidget>("RANDOMMAP_BUTTON");
            if (randomMapButton != null)
            {
                randomMapButton.OnClick = () =>
                {
                    var kv = visibleMaps.Random(Game.CosmeticRandom);
                    map = kv.Value;
                    scrollpanel.ScrollToItem(kv.Key);
                };
                randomMapButton.IsDisabled = () => visibleMaps == null || visibleMaps.Count == 0;
            }

            EnumerateMaps(onSelect);
        }
开发者ID:Generalcamo,项目名称:OpenRA,代码行数:56,代码来源:MapChooserLogic.cs

示例13: UpgradeMap

        public static void UpgradeMap(string[] args)
        {
            var map = new Map(args[1]);
            var engineDate = Exts.ParseIntegerInvariant(args[2]);

            Game.modData = new ModData(map.RequiresMod);
            UpgradeWeaponRules(engineDate, ref map.WeaponDefinitions, null, 0);
            UpgradeActorRules(engineDate, ref map.RuleDefinitions, null, 0);
            map.Save(args[1]);
        }
开发者ID:RunCraze,项目名称:OpenRA,代码行数:10,代码来源:UpgradeRules.cs

示例14: Initialize

 public static void Initialize( Map map )
 {
     exts = new[] {
         "." + map.Theater.Substring( 0, 3 ).ToLowerInvariant(),
         ".shp",
         ".tem",
         ".sno",
         ".int" };
     sprites = new Cache<string, Sprite[]>( LoadSprites );
 }
开发者ID:comradpara,项目名称:OpenRA,代码行数:10,代码来源:SpriteSheetBuilder.cs

示例15: MapPreviewWidget

 protected MapPreviewWidget(MapPreviewWidget other)
     : base(other)
 {
     lastMap = other.lastMap;
     Map = other.Map;
     SpawnClients = other.SpawnClients;
     ShowSpawnPoints = other.ShowSpawnPoints;
     TooltipTemplate = other.TooltipTemplate;
     TooltipContainer = other.TooltipContainer;
     tooltipContainer = Lazy.New(() => Ui.Root.Get<TooltipContainerWidget>(TooltipContainer));
 }
开发者ID:TiriliPiitPiit,项目名称:OpenRA,代码行数:11,代码来源:MapPreviewWidget.cs


注:本文中的OpenRA.FileFormats.Map类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。