本文整理汇总了C#中Unit.setTile方法的典型用法代码示例。如果您正苦于以下问题:C# Unit.setTile方法的具体用法?C# Unit.setTile怎么用?C# Unit.setTile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Unit
的用法示例。
在下文中一共展示了Unit.setTile方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: moveUnit
public Tile moveUnit(Unit unit, int x, int y)
{
//, GameOptions options){
int origX = (int)unit.transform.position.x; //original position.
int origY = (int)unit.transform.position.y;
unit.mov = searchForTileInRange(unit.tile.x,unit.tile.y,map[x,y],unit.mov,unit.moveCosts);//options.get(x,y); //reduces the units movement
map[origX,origY].unit = null; //remove the unit from the old tile.
map[x,y].unit = unit; //and put him on the other tile.
unit.setTile(map[x,y]);
unit.transform.position = new Vector3((float) x, (float) y, 0f);
return map[origX,origY]; //returns the tile so it can be returned to if the move is reversed.
}
示例2: revertUnitToTile
//returns a unit to a tile.
public void revertUnitToTile(Tile tile, Unit unit)
{
int x = (int) unit.transform.position.x;
int y = (int) unit.transform.position.y;
map[x,y].unit = null; //remove the unit from the old tile.
tile.unit = unit; //and put him on the other tile.
unit.setTile(tile); //tell the unit its new position.
unit.transform.position = new Vector3((float) tile.x, (float) tile.y, 0f);
unit.restoreMove();
}
示例3: unitToTile
//just moves the unit to a tile. does not adjust the movement.
private void unitToTile(Unit unit, Tile tile)
{
int origX = (int)unit.tile.x; //original position.
int origY = (int)unit.tile.y;
float scale = transform.localScale.x; //x scale should always be equal to y
map[origX,origY].unit = null; //remove the unit from the old tile.
map[tile.x,tile.y].unit = unit; //and put him on the other tile.
unit.setTile(map[tile.x,tile.y]); //updates unit info.
unit.transform.position += new Vector3((tile.x-origX)*scale,(tile.y-origY)*scale,0f);
}