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


C# PhysicalObject.TileInDirection方法代码示例

本文整理汇总了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.
 }
开发者ID:ptrefall,项目名称:ForaysIntoNorrendrin,代码行数:80,代码来源:Actor.cs


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