本文整理汇总了C#中TileMap类的典型用法代码示例。如果您正苦于以下问题:C# TileMap类的具体用法?C# TileMap怎么用?C# TileMap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TileMap类属于命名空间,在下文中一共展示了TileMap类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: CreateGameObjects
public void CreateGameObjects(TileMap tileMap)
{
if (_parent)
Destroy(_parent);
_parent = new GameObject("TileMap");
_tilesLeft = tileMap.Tiles.GetEnumerator();
}
开发者ID:Wudek,项目名称:Apollo,代码行数:7,代码来源:TileFactory.cs
示例2: Initialize
protected override void Initialize()
{
// Set default settings
IsMouseVisible = true;
Content.RootDirectory = "Content";
Window.Title = "Pixel Defense Force";
// Perhaps retrieve/create a settings file here?
_graphics.PreferMultiSampling = false;
_graphics.PreferredBackBufferWidth = 1280;
_graphics.PreferredBackBufferHeight = 720;
_graphics.ApplyChanges();
// Create the camera
_camera = new Camera
{
Resolution = new Point(_graphics.PreferredBackBufferWidth, _graphics.PreferredBackBufferHeight),
Position = new Vector2(0, 0),
Zoom = 2,
TileSize = new Point(32, 32)
};
// Generate a test map for now
_tileMap = new TileMap {Tiles = new Tile[16][]};
for (var x = 0; x < _tileMap.Tiles.Length; x++)
_tileMap.Tiles[x] = new Tile[16];
base.Initialize();
}
开发者ID:EdgeWorks-Games,项目名称:PixelDefenseForce,代码行数:30,代码来源:PixelDefense.cs
示例3: BuildSprite
public void BuildSprite(TileMap tileMap, float tileSize)
{
sizeX = tileMap.sizeX;
sizeY = tileMap.sizeY;
int texWidth = sizeX * tileDefs.tileResolution;
int texHeight = sizeY * tileDefs.tileResolution;
Texture2D texture = new Texture2D(texWidth, texHeight);
tileTypesDefinitions = new Dictionary<Tile.TYPE, TileTypeGraphics>();
foreach (TileTypeGraphics def in tileDefs.tileTypes)
{
tileTypesDefinitions[def.type] = def;
}
for (int y = 0; y < sizeY; y++)
{
for (int x = 0; x < sizeX; x++)
{
Sprite sprite = tileTypesDefinitions[tileMap.GetTile(x, y).type].sprite;
Color[] p = sprite.texture.GetPixels((int)(sprite.textureRect.x), (int)(sprite.textureRect.y), tileDefs.tileResolution, tileDefs.tileResolution);
texture.SetPixels(x * tileDefs.tileResolution, y * tileDefs.tileResolution, tileDefs.tileResolution, tileDefs.tileResolution, p);
}
}
texture.filterMode = FilterMode.Point;
texture.wrapMode = TextureWrapMode.Clamp;
texture.Apply();
AddTextureToSprite(tileSize, texture);
}
开发者ID:CheesusRex,项目名称:DarkReigns,代码行数:31,代码来源:TileGraphics.cs
示例4: GetLineOfSight
public static bool GetLineOfSight(TileMap tileMap, float x1, float y1, float x2, float y2)
{
float deltaX = Math.Abs(x2 - x1);
float deltaY = Math.Abs(y2 - y1);
float signX = x1 < x2 ? 1 : -1;
float signY = y1 < y2 ? 1 : -1;
float error = deltaX - deltaY;
while (true)
{
if (tileMap[(int)x1, (int)y1] == CellType.Wall) return false;
if (x1 == x2 && y1 == y2)
return true;
float error2 = error * 2;
if (error2 > -deltaY)
{
error -= deltaY;
x1 += signX;
}
else if (error2 < deltaX)
{
error += deltaX;
y1 += signY;
}
}
}
开发者ID:mokujin,项目名称:DN,代码行数:29,代码来源:FunctionHelper.cs
示例5: Initialize
public void Initialize(TileMap parent, TileMeshSettings settings)
{
if (Initialized) throw new InvalidOperationException ("Already initialized");
_parent = parent;
_settings = settings;
Initialized = true;
}
开发者ID:DarkXenoShark,项目名称:AI-ICA2-RTS,代码行数:7,代码来源:TileChunkManager.cs
示例6: Awake
[UsedImplicitly] private void Awake ()
{
self = this;
// Parse and load a map into cache.
FileParser.LoadFromFile (_map);
// Find the tilemap game object and cache the behaviour.
_tileMap = GameObject.Find ("TileMap").GetComponent<TileMap>();
if (_tileMap == null)
{
Debug.LogError ("TileMapBehaviour not found.");
return;
}
TileSheet tileSheet = _tileMap.TileSheet;
if (tileSheet.Count == 0)
{
Debug.LogError ("Add some sprites before running the game.");
return;
}
Sprite sprite = tileSheet.Get (1);
_tileMap.MeshSettings = new TileMeshSettings (new IVector2 (FileParser.Width, FileParser.Height), (int)sprite.rect.width);
// Map type of tile to sprite
_tiles = new TileEnumMapper<TileType> (_tileMap);
_tiles.Map (TileType.OUT_BOUNDS, "OutOfBound");
_tiles.Map (TileType.GRASS, "NormalGrass");
_tiles.Map (TileType.SWAMP, "SwampGrass");
_tiles.Map (TileType.WATER, "ShallowWater");
}
开发者ID:DarkXenoShark,项目名称:AI-ICA2-RTS,代码行数:33,代码来源:Level.cs
示例7: Start
void Start()
{
_grid = transform.parent.GetComponent<Grid>();
_map = transform.parent.GetComponent<TileMap>();
Coordinates = new IntVec2(-1, -1);
transform.position = _grid.ToWorld(Coordinates);
}
开发者ID:Sipaha,项目名称:MateriaTD,代码行数:7,代码来源:SCursor.cs
示例8: Initialize
protected override void Initialize()
{
UITexture = Content.Load<Texture2D> ("TDUserInterface.png", TextureConfiguration.Nearest);
SpriteSheet = new SpriteSheet2D (Content.Load<Texture2D> ("TDSheet.png", TextureConfiguration.Nearest), 16, 16);
TileMap = new TileMap (Vector2.Zero, 26 / 2, 18 / 2, new Vector2 (16, 16), 4);
TileMap.AddLayer ("GrassLayer", SpriteSheet);
for (int y = 0; y < TileMap.Height; y++)
for (int x = 0; x < TileMap.Width; x++)
TileMap.SetTile ("GrassLayer", x, y, new Tile { TileId = SpriteSheet.GetTileId(1, 1) });
TileMap.AddLayer ("Track", SpriteSheet);
var tiles = new int[][] {
new int[] { },
new int[] { 20, 1, 1, 2 },
new int[] { -1, -1, -1, 32, 1, 2 },
new int[] { 0, 1, 2, -1, -1, 16, -1, 16 },
new int[] { 16, -1, 16, -1, -1, 18, -1, 16 },
new int[] { 16, -1, 32, 1, 1, 34, -1, 16 },
new int[] { 16, -1, -1, -1, -1, -1, -1, 16 },
new int[] { 32, 1, 1, 1, 1, 1, 1, 34 }
};
for (int y = 0; y < tiles.Length; y++)
for (int x = 0; x < tiles[y].Length; x++)
TileMap.SetTile ("Track", x, y, new Tile { TileId = tiles[y][x] });
Font = Content.Load<Font> ("durselinvenice2015.ttf", 15f);
base.Initialize ();
}
开发者ID:splitandthechro,项目名称:nginz,代码行数:32,代码来源:MainGame.cs
示例9: Generate
public override void Generate()
{
tileMapObject = new GameObject(GraphName);
tileMapObject.transform.parent = GraphContainer;
tileMapObject.transform.position = GraphPosition;
tileMapObject.tag = GraphTag;
tileMap = tileMapObject.AddComponent<TileMap>();
tiles = new Tile[GraphWidth, GraphHeight];
for (int y = 0; y < GraphHeight; y++)
{
for (int x = 0; x < GraphWidth; x++)
{
tilePrefab = GetTilePrefab();
tileObject = GameObject.Instantiate(tilePrefab) as GameObject;
tile = tileObject.GetComponent<Tile>();
tileObject.name = "(" + x + ", " + y + ") " + tilePrefab.name;
tileObject.transform.parent = tileMapObject.transform;
tileObject.transform.position = new Vector3(x, y, 0);
tiles[x, y] = tile;
}
}
tileMap.SetNodes(tiles);
if (OnGenerationComplete != null)
OnGenerationComplete(GraphWidth, GraphHeight);
}
开发者ID:MitchLindsay,项目名称:red-havoc,代码行数:31,代码来源:TileMapFactory.cs
示例10: Setup
public override void Setup(Game _game, UserInput _keyboard, ScreenMessage _message)
{
base.Setup (_game, _keyboard, _message);
var map = new TileMap("pictures/testlevel.png");
m_house = new ObjectHouse(map);
StarryBackground bg = new StarryBackground(map.Size);
m_house.AddDrawable(bg);
map.Create(m_house, _game);
Magnum magnum = new Magnum(m_house);
var hero = new Hero(_keyboard, m_house);
hero.Position = new Vector2f(1f, 10f);
hero.PlaceInWorld(map);
m_house.AddDrawable(hero);
m_house.AddUpdateable(hero);
m_house.AddDrawable(magnum);
m_house.AddUpdateable(magnum);
var nHero = new NetworkHero(hero, "127.0.0.1", m_house);
m_house.AddUpdateable(nHero);
nHero.Connect();
}
开发者ID:joebain,项目名称:MagnumHouse,代码行数:27,代码来源:NetworkLevel.cs
示例11: populateFloor
//Populates the floor with enemies
public void populateFloor()
{
tileMap = GameObject.FindGameObjectWithTag("TileMap").GetComponent<TileMap>();
rooms = tileMap.getRooms();
//Try to spawn enemies in each room
for (int i = 0; i < 7; i++)
{
for(int j = 0; j < 7; j++)
{
if(rooms[i,j] == 1)
{
int spawnCheck = Random.Range(0, 2);
if(spawnCheck == 0)
{
float spawnX = transform.position.x + i * 5 + 2;
float spawnZ = transform.position.z + j * 5 + 2;
GameObject tempEnemyRef = (GameObject)GameObject.Instantiate(enemy, new Vector3(spawnX, 1, spawnZ), Quaternion.identity);
Enemy tempEnemy = enemyList[Mathf.FloorToInt(Random.value * enemyList.Count)];
tempEnemyRef.GetComponent<Enemy>().setStats(tempEnemy.charName, tempEnemy.health, tempEnemy.strength,
tempEnemy.endurance, tempEnemy.agility,tempEnemy.magicSkill,
tempEnemy.luck, tempEnemy.range, tempEnemy.drop, tempEnemy.image);
GameObject tempPrefab = Instantiate(Resources.Load<GameObject>("Enemy_Prefabs/" + tempEnemy.image));
tempPrefab.transform.position = tempEnemyRef.transform.position;
tempPrefab.transform.SetParent(tempEnemyRef.transform);
}
}
}
}
}
开发者ID:cmortimer,项目名称:403NameNotAccessible,代码行数:33,代码来源:SpawnEnemies.cs
示例12: CalculateCost
public void CalculateCost(TileMap tileMap, Creature creature, Point endPoint,byte additionalCost, bool improved)
{
//H = Math.Max(Math.Abs(Position.X - endPoint.X), Math.Abs(Position.Y - endPoint.Y)) * 30;
// H = (Math.Abs(Position.X - endPoint.X) + Math.Abs(Position.Y - endPoint.Y))*10;
//H = Math.Abs(Position.X - endPoint.X) + Math.Abs(Position.Y - endPoint.Y);
if(false)
if (!improved)
{
int xDistance = Math.Abs(PositionX - endPoint.X);
int yDistance = Math.Abs(PositionY - endPoint.Y);
if (xDistance > yDistance)
H = 14 * yDistance + 10 * (xDistance - yDistance);
else
H = 14 * xDistance + 10 * (yDistance - xDistance);
}
else
H = 0;
// H = (Math.Abs(PositionX - endPoint.X) - Math.Abs(PositionY - endPoint.Y)) * 10;
if (Parent != null)
if (type)
G = Parent.G + 10;
else
G = Parent.G + 14;
else
G = 0;
Cost = G + H;//+ (tileMap[PositionX, PositionY] != CellType.Ladder ? 10000 : 0) + additionalCost
// + (tileMap[PositionX, PositionY + 1] == CellType.Wall ? 0 : 5000);
// if (creature != null)
// Cost += (int)(100 / creature.Body.GetWalkSpeed(creature.Map.terrain[PositionX, PositionY]));
}
开发者ID:mokujin,项目名称:DN,代码行数:33,代码来源:WayPoint.cs
示例13: FindHelper
public static void FindHelper(TileMap tileMap, Tile sourceTile, int movement, int jumpHeight, Dictionary<Tile, int> tileToMaxMovement,
bool moveThroughOccupiedTiles)
{
if (!tileToMaxMovement.ContainsKey(sourceTile)) {
tileToMaxMovement[sourceTile] = movement;
} else {
int maxMove = tileToMaxMovement[sourceTile];
if (movement > maxMove) {
tileToMaxMovement[sourceTile] = movement;
} else {
return;
}
}
//if (visited.Contains(sourceTile)) {
// return;
//}
//visited.Add(sourceTile);
movement = movement - sourceTile.GetMovementCost();
if (movement <= 0) {
return;
}
if (IsTraversable(tileMap.BottomNeighbor(sourceTile), moveThroughOccupiedTiles)) {
FindHelper(tileMap, tileMap.BottomNeighbor(sourceTile), movement, jumpHeight, tileToMaxMovement, moveThroughOccupiedTiles);
}
if (IsTraversable(tileMap.TopNeighbor(sourceTile), moveThroughOccupiedTiles)) {
FindHelper(tileMap, tileMap.TopNeighbor(sourceTile), movement, jumpHeight, tileToMaxMovement, moveThroughOccupiedTiles);
}
if (IsTraversable(tileMap.LeftNeighbor(sourceTile), moveThroughOccupiedTiles)) {
FindHelper(tileMap, tileMap.LeftNeighbor(sourceTile), movement, jumpHeight, tileToMaxMovement, moveThroughOccupiedTiles);
}
if (IsTraversable(tileMap.RightNeighbor(sourceTile), moveThroughOccupiedTiles)) {
FindHelper(tileMap, tileMap.RightNeighbor(sourceTile), movement, jumpHeight, tileToMaxMovement, moveThroughOccupiedTiles);
}
}
开发者ID:Shnagenburg,项目名称:TacticsGame,代码行数:34,代码来源:FindTilesWithinRange.cs
示例14: RenderTileMap
public void RenderTileMap(TileMap map)
{
Vector3 scrollTileOffset = new Vector3(map.ScrollOffset_X % map.TileSize, map.ScrollOffset_Y % map.TileSize);
Vector3 startPos = new Vector3( (-map.ScreenWidth*0.5f) - scrollTileOffset.x , (-map.ScreenHeight*0.5f) - scrollTileOffset.y ); // Botto right
for (int row = 0; row < map.NumOfTile_ScreenHeight; ++row) // Number of rows
{
for (int col = 0; col < map.NumOfTile_ScreenWidth + 1; ++col) // Number of columns (+1 for ScrollOffset)
{
// World origin in middle (Negative half size to Positive half size)
switch (map.Map[Mathf.CeilToInt(scrollTileOffset.y) + row][Mathf.CeilToInt(scrollTileOffset.x) + col].Type)
{
case TILE_TYPE.TILE_NONE:
{
renderMap[Convert.ToInt32((row * map.NumOfTile_ScreenWidth) + col)].SetActive(false);
}
break;
case TILE_TYPE.TILE_FLOOR_1:
{
renderMap[Convert.ToInt32((row * map.NumOfTile_ScreenWidth) + col)] = tileList[Convert.ToInt32(TILE_TYPE.TILE_FLOOR_1)];
renderMap[Convert.ToInt32((row * map.NumOfTile_ScreenWidth) + col)].SetActive(true);
renderMap[Convert.ToInt32((row * map.NumOfTile_ScreenWidth) + col)].transform.Translate(startPos.x + (col * map.TileSize), startPos.y + (row * map.TileSize), 0);
}
break;
case TILE_TYPE.TILE_FLOOR_2:
{
renderMap[Convert.ToInt32((row * map.NumOfTile_ScreenWidth) + col)] = tileList[Convert.ToInt32(TILE_TYPE.TILE_FLOOR_2)];
renderMap[Convert.ToInt32((row * map.NumOfTile_ScreenWidth) + col)].SetActive(true);
renderMap[Convert.ToInt32((row * map.NumOfTile_ScreenWidth) + col)].transform.Translate(startPos.x + (col * map.TileSize), startPos.y + (row * map.TileSize), 0);
}
break;
}
}
}
}
开发者ID:Pycorax,项目名称:SquareDot,代码行数:34,代码来源:Render.cs
示例15: Setup
public override void Setup(Game _game, UserInput _keyboard, ScreenMessage _message)
{
base.Setup (_game, _keyboard, _message);
TileMap tilemap = new TileMap("pictures/empty_level.png");
m_house = new ObjectHouse(tilemap);
StarryBackground bg = new StarryBackground(tilemap.Size);
m_house.AddDrawable(bg);
Gangster gangsterNo1 = new Hero(m_keyboard, m_house);
gangsterNo1.Position = new Vector2f(1f, 10f);
gangsterNo1.PlaceInWorld(tilemap);
m_house.AddDrawable(gangsterNo1);
m_house.AddUpdateable(gangsterNo1);
m_house.Add<IShootable>(gangsterNo1);
m_game.SetCameraSubject(gangsterNo1);
tilemap.Create(m_house, _game);
Bitmap world_bmp = new Bitmap(tilemap.Width * Tile.Size, tilemap.Height * Tile.Size);
for (int i = 0 ; i < world_bmp.Width ; i++) {
for (int j = 0 ; j < world_bmp.Height; j++) {
world_bmp.SetPixel(i, j, Color.Green);
}
}
GangsterTrail trail = new GangsterTrail(gangsterNo1, new Sprite(world_bmp));
m_house.AddUpdateable(trail);
m_house.AddDrawable(trail);
}
开发者ID:joebain,项目名称:MagnumHouse,代码行数:30,代码来源:TrailLevel.cs
示例16: FindHelper
public static void FindHelper(TileMap tileMap, TileData sourceTile, int movement, FindTilesWithinRangeDTO dto)
{
if (!dto.TileToMaxMovement.ContainsKey(sourceTile)) {
dto.TileToMaxMovement[sourceTile] = movement;
} else {
int maxMove = dto.TileToMaxMovement[sourceTile];
if (movement > maxMove) {
dto.TileToMaxMovement[sourceTile] = movement;
} else {
return;
}
}
//if (visited.Contains(sourceTile)) {
// return;
//}
//visited.Add(sourceTile);
movement = movement - sourceTile.MovementCost;
if (movement <= 0) {
return;
}
if (IsTraversable(tileMap.BottomNeighbor(sourceTile), dto)) {
FindHelper(tileMap, tileMap.BottomNeighbor(sourceTile), movement, dto);
}
if (IsTraversable(tileMap.TopNeighbor(sourceTile), dto)) {
FindHelper(tileMap, tileMap.TopNeighbor(sourceTile), movement, dto);
}
if (IsTraversable(tileMap.LeftNeighbor(sourceTile), dto)) {
FindHelper(tileMap, tileMap.LeftNeighbor(sourceTile), movement, dto);
}
if (IsTraversable(tileMap.RightNeighbor(sourceTile), dto)) {
FindHelper(tileMap, tileMap.RightNeighbor(sourceTile), movement, dto);
}
}
开发者ID:Shnagenburg,项目名称:TacticsGame,代码行数:33,代码来源:FindTilesWithinRangeThreadsafe.cs
示例17: Start
void Start()
{
lineRenderer = GetComponent<LineRenderer>();
tileMap = FindObjectOfType(typeof(TileMap)) as TileMap;
enabled = tileMap != null;
}
开发者ID:GrimDerp,项目名称:TileEditor,代码行数:8,代码来源:Player.cs
示例18: MobileSprite
public MobileSprite(Texture2D texture, TileMap map)
{
sprite = new SpriteAnimation(texture);
this.map = map;
path = new Queue<Vector2>();
currentTarget = new Vector2(-1, -1);
nullTarget = new Vector2(-1, -1);
}
开发者ID:BenFradet,项目名称:IsoTileEngine,代码行数:8,代码来源:MobileSprite.cs
示例19: TileMapColliderGenerator
public TileMapColliderGenerator([NotNull] TileMap tileMap, [NotNull] SpriteSheet spriteSheet)
{
if (tileMap == null) throw new ArgumentNullException("tileMap");
if (spriteSheet == null) throw new ArgumentNullException("spriteSheet");
_tileMap = tileMap;
_spriteSheet = spriteSheet;
}
开发者ID:eriksk,项目名称:LD33,代码行数:8,代码来源:TileMapColliderGenerator.cs
示例20: Clobber
public Clobber (Unit u, TileMap m, PrefabLibrary el) : base(u, m , el)
{
damage = 30;
range = 1;
area = AreaType.Single;
targets = TargetType.Enemy;
maxCooldown = 1;
}
开发者ID:JohnEz,项目名称:TileBasedEngine,代码行数:8,代码来源:Clobber.cs
注:本文中的TileMap类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论