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


C# ArrayList.AddNotNull方法代码示例

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


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

示例1: neighbours

		/*
		 * Returns all of the Bubbles which are in the immediate neighborhoud of a given location, including the bubble
		 *  in that particular location
		 * Returns null if there is no bubble in the current location
		 * @param {Vector2} location. Location of the matrix that we want to obtain the neighbours of
		 */
		public ArrayList neighbours(Vector2 location){
			int row = (int)location.x;
			int column = (int)location.y;
			
			ArrayList _neigbours = new ArrayList();
			if (row < 0 || row > this._rows -1 || column < 0 || column > this._columns -1)
				throw new System.ArgumentException("Looking for neighbors of an invalid location");	
			
			if (this._bubbleMatrix[row, column] != null){			
				_neigbours.AddNotNull(this._bubbleMatrix[row,column]);
				
				// Left and right neighbours
				if (column > 0) _neigbours.AddNotNull(this._bubbleMatrix[row,column -1]);
				if (column < this._columns-1) _neigbours.AddNotNull(this._bubbleMatrix[row,column+1]);
				
				// higher and lower neighbours
				bool isRowEven = row % 2 == 0;
				if ((isBaselineAlignedLeft && isRowEven) || (!isBaselineAlignedLeft && !isRowEven) ){
					if (row > 0){
							if (column > 0) _neigbours.AddNotNull(this._bubbleMatrix[row-1, column-1]);
							_neigbours.AddNotNull(this._bubbleMatrix[row-1, column]);
						}
						if (row < this._rows -1){
							if (column > 0) _neigbours.AddNotNull(this._bubbleMatrix[row+1, column-1]);
							_neigbours.AddNotNull(this._bubbleMatrix[row +1, column]);
						}
				}
				else{
					if (row > 0){
						_neigbours.AddNotNull(this._bubbleMatrix[row-1, column]);
						if (column < this._columns - 1) _neigbours.AddNotNull(this._bubbleMatrix[row-1, column+1]);
					}
					if (row < this._rows - 1){
						_neigbours.AddNotNull(this._bubbleMatrix[row+1, column]);
						if (column < this._columns - 1) _neigbours.AddNotNull(this._bubbleMatrix[row+1, column+1]);
					}
				}
				return _neigbours;
			}
			return null;
		}
开发者ID:GusevNikita,项目名称:bubble-shooter-unity3d,代码行数:47,代码来源:BubbleMatrix.cs


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