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


C# Cell.CellInDirection方法代码示例

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


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

示例1: 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 == 0 )
		{
			newCell.room = inRoom;
			if ( newCell.x > 0 && newCell.CellInDirection( Direction.West ).room != 0 && newCell.CellInDirection( Direction.West ).room != inRoom && SimpleRNG.GetUniform() < wallDensity )
				newCell.canGoWest = newCell.CellInDirection( Direction.West ).canGoEast = false;
			if ( newCell.x < cellsPerSide - 1 && newCell.CellInDirection( Direction.East ).room != 0 && newCell.CellInDirection( Direction.East ).room != inRoom && SimpleRNG.GetUniform() < wallDensity )
				newCell.canGoEast = newCell.CellInDirection( Direction.East ).canGoWest = false;
			if ( newCell.y > 0 && newCell.CellInDirection( Direction.South ).room != 0 && newCell.CellInDirection( Direction.South ).room != inRoom && SimpleRNG.GetUniform() < wallDensity )
				newCell.canGoSouth = newCell.CellInDirection( Direction.South ).canGoNorth = false;
			if ( newCell.y < cellsPerSide - 1 && newCell.CellInDirection( Direction.North ).room != 0 && newCell.CellInDirection( Direction.North ).room != inRoom && SimpleRNG.GetUniform() < wallDensity )
				newCell.canGoNorth = newCell.CellInDirection( Direction.North ).canGoSouth = false;	
			
			unassignedRooms.Remove( newCell );
			return true;
		}
		
		return false;
	}
开发者ID:inbgche,项目名称:CellGen,代码行数:33,代码来源:CellGen.cs

示例2: 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.CellInDirection( inDir );
						
		if ( !toOpen.CanGoInDirection( inDir ) )
		{
			toOpen.SetOpenInDirection( inDir, true );
			if ( nextCell.room == 0 )
				Debug.LogWarning( "Wall made to uninitialised cell" );
			nextCell.SetOpenInDirection( Cell.Reverse( inDir ), true );
			// made connection to another room. Stop.
		}
		else
			// add uninited cell towards startCell to current room
			if ( nextCell.room != 0 )
			{
				Debug.LogWarning ( "No path to start, but can reach another room???" );
			}
			else
			{
				AddCellToRoom ( nextCell, toOpen.room );
			}
		return nextCell;
	}
开发者ID:inbgche,项目名称:CellGen,代码行数:34,代码来源:CellGen.cs


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