www.pudn.com > GameEngine_src.rar > CPathSeeker.h


// CPathSeeker.h: interface for the CPathSeeker class. 
// 
////////////////////////////////////////////////////////////////////// 
 
#ifndef CPathSeeker_h 
#define CPathSeeker_h 
 
#if _MSC_VER > 1000 
#pragma once 
#endif // _MSC_VER > 1000 
 
 
#include "CDynamicArray.h" 
#include "CMyStack.h" 
#include "CPriorityQueue.h" 
#include "CPool.h" 
#include "CBaseSprite.h" 
#include "struct.h" 
 
 
struct PATH_NODE 
{ 
	PATH_NODE() 
	{ total = known = estimate = 0; pFather = 0; } 
	 
	class Comp 
	{ 
	public: 
		static bool less( PATH_NODE *p1, PATH_NODE *p2 ) 
		{ return p1->total < p2->total; } 
	}; 
 
	CELL	cell; 
	int		total;			//移动总成本:已知成本+估计成本 
	int		known;			//已知成本 
	int		estimate;		//估计成本 
	PATH_NODE *pFather; 
}; 
 
 
class CPathSeeker   
{ 
public: 
	CPathSeeker(); 
	~CPathSeeker(); 
 
	bool Init(); 
	void Free(); 
 
	bool SeekPath( CStaticStack &path_array,  const CELL &from, const CELL &to, SPRITE_TYPE sprite_type ); 
 
	void Clear() { m_NumSeekOfLoop = 0; }		//计数器清零 
 
private: 
	inline int Estimate( const CELL &from, const CELL &to ); 
	bool OnFinish( CStaticStack &path_array, const CELL &dest, PATH_NODE *pnode ); 
 
private: 
	CMaxHeap	m_OpenList; 
	CDynamicArray				m_CloseList; 
	CPool						m_PathNodePool; 
 
	int		m_NumSeekOfLoop;		//在一次游戏主循环中的寻路次数,不包括英雄的 
}; 
 
 
 
 
#endif