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


C# TileMap.GetTileData方法代码示例

本文整理汇总了C#中TileMap.GetTileData方法的典型用法代码示例。如果您正苦于以下问题:C# TileMap.GetTileData方法的具体用法?C# TileMap.GetTileData怎么用?C# TileMap.GetTileData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TileMap的用法示例。


在下文中一共展示了TileMap.GetTileData方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: findAvailableTile

    public static TileStruct findAvailableTile(TileMap map, int Xoffset, int Yoffset)
    {
        TileStruct tile = new TileStruct(0,0,TileType.None);
        while (tile.Type != TileType.Dirt)
	    {

            tile = map.GetTileData(rand.Next(0, map.map[0].Length - 1) + Xoffset, rand.Next(0, map.map.Length - 1) + Yoffset);
	    }

        return tile;
    }
开发者ID:Bergendahl94,项目名称:TweetnCrawl,代码行数:11,代码来源:ObjectPlacer.cs

示例2: GetTexture

    public static Sprite GetTexture(TileStruct tile, TileMap map)
    {

        var left =  map.GetTileData(tile.X - 1, tile.Y);
        var right =    map.GetTileData(tile.X + 1, tile.Y);
        var north =    map.GetTileData(tile.X, tile.Y + 1);
        var south =    map.GetTileData(tile.X, tile.Y - 1);
        var upLeft =    map.GetTileData(tile.X - 1, tile.Y + 1);
        var upRight =    map.GetTileData(tile.X + 1, tile.Y + 1);
        var downLeft =    map.GetTileData(tile.X - 1, tile.Y - 1);
        var downRight =    map.GetTileData(tile.X + 1, tile.Y - 1);




        if (left.Type == TileType.Rock || right.Type == TileType.Rock || north.Type == TileType.Rock || south.Type == TileType.Rock || upLeft.Type == TileType.Rock || upRight.Type == TileType.Rock || downLeft.Type == TileType.Rock || downRight.Type == TileType.Rock)
        {
            tile.DecorType = DecorType.None;
        }

        if (tile.Type == TileType.Rock)
        {
            return getSpriteWithName(tile.WallTerrainType + getNumber(
            tile.WallTerrainType,
            left.GetTerrainType(),
            right.GetTerrainType(),
            north.GetTerrainType(),
            south.GetTerrainType(),
            upLeft.GetTerrainType(),
            upRight.GetTerrainType(),
            downLeft.GetTerrainType(),
            downRight.GetTerrainType()
            ),


            tile.Type);

        }




        string decor = Enum.GetName(typeof(DecorType), tile.DecorType);



        if (tile.Type == TileType.Dirt)
        {
            if (tile.DecorType == DecorType.None)
            {
                return getSpriteWithName(tile.GetTerrainType() + getNumberFloors(
                tile.GetTerrainType(),
                left.GetTerrainType(),
                right.GetTerrainType(),
                north.GetTerrainType(),
                south.GetTerrainType(),
                upLeft.GetTerrainType(),
                upRight.GetTerrainType(),
                downLeft.GetTerrainType(),
                downRight.GetTerrainType()),
                tile.Type);
            }
            else
            {
                return getSpriteWithName(tile.GetTerrainType() + decor + getNumberFloors(
                tile.GetTerrainType() + tile.GetDecorType(),
                left.GetTerrainType() + left.GetDecorType(),
                right.GetTerrainType() + right.GetDecorType(),
                north.GetTerrainType() + north.GetDecorType(),
                south.GetTerrainType() + south.GetDecorType(),
                upLeft.GetTerrainType() + upLeft.GetDecorType(),
                upRight.GetTerrainType() + upRight.GetDecorType(),
                downLeft.GetTerrainType() + downLeft.GetDecorType(),
                downRight.GetTerrainType() + downRight.GetDecorType()
                ),


                tile.Type);
            }
        }

        return null;

    }
开发者ID:Bergendahl94,项目名称:TweetnCrawl,代码行数:84,代码来源:SpriteHandler.cs


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