//检查一个方块是否符合加入openlist的条件 符合则加入 void open_one(int x, int y, point father) { //判定方块位置合法 if (x >= 0 && y >= 0 && y < y_num && x < x_num) { output(x, y, 333); point p = mg.points[x, y]; //障碍物 是否存在 是否在closelist中存在 if (p.is_barrier == false && p != null && mg.open_list.Contains(p) == false && mg.close_list.Contains(p) == false) { //计算一下 p.parent = father; p.caculate_consume(father); mg.open_list.Add(p); } else if (p.is_barrier == false && p != null && mg.open_list.Contains(p) == true && mg.close_list.Contains(p) == false)//是否在openlist中存在 { //根据当前的父亲节点计算g g=g开启节点的g+距离开启节点的g //如果g<当前g //g替换 g更新 f更新 p.caculate_consume(father); } } }