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


C# Unit.setTile方法代码示例

本文整理汇总了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.
    }
开发者ID:urgamedev,项目名称:TurnBasedGame,代码行数:18,代码来源:Map.cs

示例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();
    }
开发者ID:urgamedev,项目名称:TurnBasedGame,代码行数:15,代码来源:Map.cs

示例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);
    }
开发者ID:urgamedev,项目名称:TurnBasedGame,代码行数:15,代码来源:Map.cs


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