本文整理汇总了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;
}