本文整理汇总了C#中Coord.nextCoord方法的典型用法代码示例。如果您正苦于以下问题:C# Coord.nextCoord方法的具体用法?C# Coord.nextCoord怎么用?C# Coord.nextCoord使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Coord
的用法示例。
在下文中一共展示了Coord.nextCoord方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Start
// Use this for initialization
void Start () {
supportive = GetComponent<AudioSource>();
// This is some instantiation.
// We want it so that if the player is within a + direction from the particle, they will get hurt.
GameObject player = GameObject.FindGameObjectWithTag("Player");
int playerX = (int)player.transform.position.x;
int playerY = (int)player.transform.position.y;
Coord myPlace = new Coord((int)this.transform.position.x, (int)this.transform.position.y);
Coord playerCoord = new Coord(playerX, playerY);
Coord n, w, s, e;
n = playerCoord.nextCoord (Direction.North);
w = playerCoord.nextCoord (Direction.West);
s = playerCoord.nextCoord (Direction.South);
e = playerCoord.nextCoord (Direction.East);
if( myPlace.isEqual (playerCoord) ||
myPlace.isEqual (n) ||
myPlace.isEqual (w) ||
myPlace.isEqual (s) ||
myPlace.isEqual (e) ) {
PlayerMovement hitPlayer = player.GetComponent<PlayerMovement>();
supportive.PlayOneShot(haha,1f);
hitPlayer.LoseHealth(750); }
Destroy (this.gameObject, 3);
}
示例2: makeKey
/**
* Generates a hexadecimal key corresponding its surroundings.
* This should yield back the appropriate key that can be used for the tileDictionary,
* which can then correspond with placing the appropriate graphic.
*/
public int makeKey(Tile[,] map, Coord target) {
int key = 0;
// NORTH
if( mvf.isSolid (map, target.nextCoord (Direction.North)) ) {
key += 0x80;
// W AND NW
if ( mvf.isSolid (map, target.nextCoord (Direction.West)) && mvf.isSolid (map, target.crossCoord (Direction.North, Direction.West)) )
key += 0x40;
// E and NE
if( mvf.isSolid (map, target.nextCoord (Direction.East)) && mvf.isSolid (map, target.crossCoord (Direction.North, Direction.East)) )
key += 0x01;
}
// SOUTH
if( mvf.isSolid (map, target.nextCoord (Direction.South)) ) {
key += 0x08;
// W AND SW
if ( mvf.isSolid (map, target.nextCoord (Direction.West)) && mvf.isSolid (map, target.crossCoord (Direction.South, Direction.West)) )
key += 0x10;
// E and SE
if( mvf.isSolid (map, target.nextCoord (Direction.East)) && mvf.isSolid (map, target.crossCoord (Direction.South, Direction.East)) )
key += 0x04;
}
// WEST
if( mvf.isSolid (map, target.nextCoord (Direction.West)) ) {
key += 0x20;
}
// EAST
if( mvf.isSolid (map, target.nextCoord (Direction.East)) ) {
key += 0x02;
}
//Debug.Log ("Given coord (" + target.x.ToString () + "," + target.y.ToString() + "), key is " + key.ToString ("X2"));
return key;
}
示例3: FloodFillCheck
public void FloodFillCheck(Tile[,] map, Coord current, Coord stop) {
// The recursive algorithm. Starting at x and y, traverse down adjacent tiles and mark them if travelled, find the exit from the entrance
int mapWidth = map.GetLength(0);
int mapHeight = map.GetLength(1);
int x = current.x;
int y = current.y;
//Debug.Log (x.ToString() + " and " + y.ToString () );
if (map[x,y].mark != 0)
// Base case. If the current tile is marked, then do nothing.
return;
// Change the current tile as marked
map[x,y].mark = 1;
if ( stop.isEqual (current) ) {
Debug.Log ("Flood Fill found, flagging clearable: " + current.x.ToString() + " " + current.y.ToString ());
clearable = true;
return;
}
// Recursive calls. Make a recursive call as long as we are not on the
// boundary (which would cause an Index Error.)
if (x > 0 && !isSolid (map, current.nextCoord (Direction.West)) ) // left
FloodFillCheck(map, current.nextCoord (Direction.West), stop);
if (y > 0 && !isSolid (map, current.nextCoord (Direction.South)) ) // up
FloodFillCheck(map, current.nextCoord (Direction.South), stop);
if (x < mapWidth-1 && !isSolid (map, current.nextCoord (Direction.East)) ) // right
FloodFillCheck(map, current.nextCoord (Direction.East), stop);
if (y < mapHeight-1 && !isSolid (map, current.nextCoord (Direction.North)) ) // down
FloodFillCheck(map, current.nextCoord (Direction.North), stop);
}