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


C# Cell.GetCellInDirection方法代码示例

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


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

示例1: OpenCellInDirection

    /// <summary>
    /// Opens the cell in direction.
    /// </summary>
    /// <param name='toOpen'>
    /// To open.
    /// </param>
    /// <param name='inDir'>
    /// In dir.
    /// </param>
    Cell OpenCellInDirection( Cell toOpen, Direction inDir )
    {
        Debug.Log ( "Opening cell " + toOpen + " in direction " + inDir );
        Cell nextCell = toOpen.GetCellInDirection ( inDir );

        if ( !toOpen.CanGoInDirection( inDir ) )
        {
            toOpen.SetOpenInDirection( inDir, true );
            if ( nextCell.room == -1 )
                Debug.LogWarning ( "Wall made to uninitialised cell" );
            nextCell.SetOpenInDirection ( Cell.ReverseDirection( inDir ), true );
            // made connection to another room. Stop.
        }
        else
        {
            // add uninited cell towards startCell to current room
            if ( nextCell.room != -1 )
            {
                Debug.LogWarning ( "No path to start, but can reach another room???" );
            }
            else
            {
                AddCellToRoom ( nextCell, toOpen.room );
            }
        }
        return nextCell;
    }
开发者ID:EddieCameron,项目名称:DoomRoom,代码行数:36,代码来源:CellMaster.cs

示例2: AddCellToRoom

    /// <summary>
    /// Adds the cell to given room.
    /// </summary>
    /// <returns>
    /// Whether the cell was added
    /// </returns>
    /// <param name='newCell'>
    /// Cell to add
    /// </param>
    /// <param name='inRoom'>
    /// Room number to add to
    /// </param>
    bool AddCellToRoom( Cell newCell, int inRoom )
    {
        // Add walls between this and cells that have been set to other rooms
        if ( newCell.room == -1 )
        {
            newCell.room = inRoom;
            if ( newCell.x > 0 && newCell.GetCellInDirection ( Direction.West ).room != -1 && newCell.GetCellInDirection ( Direction.West ).room != inRoom && Random.value < wallDensity )
                newCell.canGoWest = newCell.GetCellInDirection( Direction.West ).canGoEast = false;
            if ( newCell.x < CellsPerSide - 1 && newCell.GetCellInDirection ( Direction.East ).room != -1 && newCell.GetCellInDirection ( Direction.East ).room != inRoom && Random.value < wallDensity )
                newCell.canGoEast = newCell.GetCellInDirection ( Direction.East ).canGoWest = false;
            if ( newCell.y > 0 && newCell.GetCellInDirection ( Direction.South ).room != -1 && newCell.GetCellInDirection ( Direction.South ).room != inRoom && Random.value < wallDensity )
                newCell.canGoSouth = newCell.GetCellInDirection ( Direction.South ).canGoNorth = false;
            if ( newCell.y < CellsPerSide - 1 && newCell.GetCellInDirection ( Direction.North ).room != -1 && newCell.GetCellInDirection ( Direction.North ).room != inRoom && Random.value < wallDensity )
                newCell.canGoNorth = newCell.GetCellInDirection ( Direction.North ).canGoSouth = false;

            unassignedRooms.Remove ( newCell );

            while ( inRoom >= cellsByRoom.Count )
                cellsByRoom.Add ( new List<Cell>() );
            cellsByRoom[inRoom].Add( newCell );

            return true;
        }

        return false;
    }
开发者ID:EddieCameron,项目名称:DoomRoom,代码行数:38,代码来源:CellMaster.cs


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