本文整理汇总了C#中Forays.PhysicalObject.TileInDirection方法的典型用法代码示例。如果您正苦于以下问题:C# PhysicalObject.TileInDirection方法的具体用法?C# PhysicalObject.TileInDirection怎么用?C# PhysicalObject.TileInDirection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Forays.PhysicalObject
的用法示例。
在下文中一共展示了PhysicalObject.TileInDirection方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AI_Step_Build_Direction_Lists
private static void AI_Step_Build_Direction_Lists(PhysicalObject start,PhysicalObject obj,bool flee,List<int> dirs,List<int> sideways_dirs)
{
int rowchange = 0;
int colchange = 0;
if(obj.row < start.row){
rowchange = -1;
}
if(obj.row > start.row){
rowchange = 1;
}
if(obj.col < start.col){
colchange = -1;
}
if(obj.col > start.col){
colchange = 1;
}
if(flee){
rowchange = -rowchange;
colchange = -colchange;
}
if(rowchange == -1){
if(colchange == -1){
dirs.Add(7);
}
if(colchange == 0){
dirs.Add(8);
}
if(colchange == 1){
dirs.Add(9);
}
}
if(rowchange == 0){
if(colchange == -1){
dirs.Add(4);
}
if(colchange == 1){
dirs.Add(6);
}
}
if(rowchange == 1){
if(colchange == -1){
dirs.Add(1);
}
if(colchange == 0){
dirs.Add(2);
}
if(colchange == 1){
dirs.Add(3);
}
}
if(dirs.Count == 0){ return; }
bool clockwise = R.CoinFlip();
if(obj.DistanceFrom(start.TileInDirection(dirs[0].RotateDir(true))) < obj.DistanceFrom(start.TileInDirection(dirs[0].RotateDir(false)))){
clockwise = true;
}
else{
if(obj.DistanceFrom(start.TileInDirection(dirs[0].RotateDir(false))) < obj.DistanceFrom(start.TileInDirection(dirs[0].RotateDir(true)))){
clockwise = false;
}
}
if(clockwise){
dirs.Add(dirs[0].RotateDir(true));
dirs.Add(dirs[0].RotateDir(false)); //building a list of directions to try: first the primary direction,
}
else{
dirs.Add(dirs[0].RotateDir(false));
dirs.Add(dirs[0].RotateDir(true));
}
clockwise = R.CoinFlip(); //then the ones next to it, then the ones next to THOSE(in random order, unless one is closer)
if(obj.DistanceFrom(start.TileInDirection(dirs[0].RotateDir(true,2))) < obj.DistanceFrom(start.TileInDirection(dirs[0].RotateDir(false,2)))){
clockwise = true;
}
else{
if(obj.DistanceFrom(start.TileInDirection(dirs[0].RotateDir(false,2))) < obj.DistanceFrom(start.TileInDirection(dirs[0].RotateDir(true,2)))){
clockwise = false;
}
}
sideways_dirs.Add(dirs[0].RotateDir(clockwise,2)); //these 2 are considered last.
sideways_dirs.Add(dirs[0].RotateDir(!clockwise,2)); //this completes the list of 5 directions.
}