示例#1
0
        private bool NearEntitiesEvent(Entity entity, StateToStateEvent stateToStateEvent)
        {
            // TODO: Calculate right min, max by using scoreAreaSize and spherical world.
            int  imin  = Math.Max(0, entity.i - 1);
            int  imax  = Math.Min(entity.i + 1, this.cells.GetLength(0) - 1);
            int  jmin  = Math.Max(0, entity.j - 1);
            int  jmax  = Math.Min(entity.j + 1, this.cells.GetLength(1) - 1);
            bool isRun = true;

            for (int i = imin; i <= imax && isRun; ++i)
            {
                for (int j = jmin; j <= jmax && isRun; ++j)
                {
                    for (int k = 0; k < cells[i, j].Count && isRun; ++k)
                    {
                        stateToStateEvent(entity, cells[i, j][k], ref isRun);
                    }
                }
            }
            return(isRun);
        }
示例#2
0
文件: World.cs 项目: Ring-r/sandbox
 private bool NearEntitiesEvent(Entity entity, StateToStateEvent stateToStateEvent)
 {
     // TODO: Calculate right min, max by using scoreAreaSize and spherical world.
     int imin = Math.Max(0, entity.i - 1);
     int imax = Math.Min(entity.i + 1, this.cells.GetLength(0) - 1);
     int jmin = Math.Max(0, entity.j - 1);
     int jmax = Math.Min(entity.j + 1, this.cells.GetLength(1) - 1);
     bool isRun = true;
     for (int i = imin; i <= imax && isRun; ++i)
     {
         for (int j = jmin; j <= jmax && isRun; ++j)
         {
             for (int k = 0; k < cells[i, j].Count && isRun; ++k)
             {
                 stateToStateEvent(entity, cells[i, j][k], ref isRun);
             }
         }
     }
     return isRun;
 }