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


C++ PathNode::set方法代码示例

本文整理汇总了C++中PathNode::set方法的典型用法代码示例。如果您正苦于以下问题:C++ PathNode::set方法的具体用法?C++ PathNode::set怎么用?C++ PathNode::set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PathNode的用法示例。


在下文中一共展示了PathNode::set方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: countRoute

void EnemyData::countRoute(short routeIndex, vector<CCPoint> *pathData)
{
	CCPoint tpoint = EnemyData::data->getTerminalPoint();
	CCPoint endPoint;
	endPoint.x = tpoint.x;
	endPoint.y = tpoint.y;
	list<PathNode*> openList;
	list<PathNode*> closeList;

	//0.\u00F8\u2019\u00B5\u0192  1.\u2018\u2044close\u00BF\u00D4\u221A\u00CA  2.\u2018\u2044open\u00BF\u00D4\u221A\u00CA
	short closeData[mapCol][mapRow];
	for (short i = 0; i < mapCol; ++i)
	{
		for (short j = 0; j < mapRow; ++j)
		{
			closeData[i][j] = 0;
		}
	}

	PathNode *panode = NULL;

	panode = new PathNode(routeStartPoint[routeIndex].x, routeStartPoint[routeIndex].y);
	panode->set(0, fabs(panode->col - endPoint.x) + fabs(panode->row - endPoint.y));
	panode->setFather(NULL);
	openList.push_back(panode);
	short col = 0;
	short row = 0;
	//\u2248\u2013\u2202\u0153\u00A0\u00AB\u2211\u00D2\u2019\u201C\u00B5\u03A9\u00AC\u2211\u00E6\u2202\u00A1\u00C0
	bool is = false;
	//\u25CA\u00D3\u00F7\u2019\u00B5\u201E
	PathNode *end = NULL;
	while (!openList.empty())
	{
		PathNode *node = openList.front();
		openList.pop_front();
		closeList.push_back(node);
		closeData[node->col][node->row] = 1;
		col = node->col;
		row = node->row;

		PathNode *node1;
		if (row - 1 >= 0) //\u25CA\u00DB\u00B1\uFB02
		{
			if (EnemyData::data->mapData[col][row - 1] != 1
				&& closeData[col][row - 1] != 1)
			{
				if (closeData[col][row - 1] != 2) //\u2248\u2013\u2202\u0153\u00A0\u00AB\u2211\u00D2\u2018\u2044Open\u00BF\u00D4\u221A\u00CA
				{
					node1 = new PathNode(col, row - 1);
					node1->set(node->G + 1, fabs(node1->col - endPoint.x) + fabs(node1->row - endPoint.y)); //\u2026\u00CB\u00F7\u221AFGH
					node1->setFather(node); //\u2026\u00CB\u00F7\u221A\u220F\u220F\u03A9\u2044\u00B5\u201E\u0152\u00AA\u00F7\u221A
					openList.push_back(node1);
					closeData[col][row - 1] = 2;
					if (node1->col == endPoint.x && node1->row == endPoint.y)
					{
						is = true;
						end = node1;
						break;
					}
				}
			}
		}
		if (row + 1 < mapRow) //\u25CA\u00DB\u00B1\uFB02
		{
			if (EnemyData::data->mapData[col][row + 1] != 1
				&& closeData[col][row + 1] != 1)
			{
				if (closeData[col][row + 1] != 2) //\u2248\u2013\u2202\u0153\u00A0\u00AB\u2211\u00D2\u2018\u2044Open\u00BF\u00D4\u221A\u00CA
				{
					node1 = new PathNode(col, row + 1);
					node1->set(node->G + 1, fabs(node1->col - endPoint.x) + fabs(node1->row - endPoint.y)); //\u2026\u00CB\u00F7\u221AFGH
					node1->setFather(node); //\u2026\u00CB\u00F7\u221A\u220F\u220F\u03A9\u2044\u00B5\u201E\u0152\u00AA\u00F7\u221A
					openList.push_back(node1);
					closeData[col][row + 1] = 2;
					if (node1->col == endPoint.x && node1->row == endPoint.y)
					{
						is = true;
						end = node1;
						break;
					}
				}
			}
		}
		if (col - 1 >= 0) //\u2026\u0153\u00B1\uFB02
		{
			if (EnemyData::data->mapData[col - 1][row] != 1
				&& closeData[col - 1][row] != 1)
			{
				if (closeData[col - 1][row] != 2)
				{
					node1 = new PathNode(col - 1, row);
					node1->set(node->G + 1, fabs(node1->col - endPoint.x) + fabs(node1->row - endPoint.y)); //\u2026\u00CB\u00F7\u221AFGH
					node1->setFather(node); //\u2026\u00CB\u00F7\u221A\u220F\u220F\u03A9\u2044\u00B5\u201E\u0152\u00AA\u00F7\u221A
					openList.push_back(node1);
					closeData[col - 1][row] = 2;
					if (node1->col == endPoint.x && node1->row == endPoint.y)
					{
						is = true;
						end = node1;
						break;
//.........这里部分代码省略.........
开发者ID:joyfish,项目名称:Zombie,代码行数:101,代码来源:EnemyData.cpp


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