public void Reset(CEPathFindBasic _holder, int _startTileX, int _startTileY, int _endTileX, int _endTileY) { mHolder = _holder; mStarNode = GetNewNode(); mStarNode.x = _startTileX; mStarNode.y = _startTileY; mStarNode.isWalkable = mHolder.isTileWalkable(mStarNode.x, mStarNode.y); mEndNode = GetNewNode(); mEndNode.x = _endTileX; mEndNode.y = _endTileY; mEndNode.isWalkable = mHolder.isTileWalkable(mEndNode.x, mEndNode.y); mCurrentNode = mStarNode; mCurrentNode.isWalkable = mHolder.isTileWalkable(mCurrentNode.x, mCurrentNode.y); }
public static void FindPath(int _starTileX, int _starTileY, int _endTileX, int _endTileY, CEPathFindBasic _findEngine, Action <CEPathFindResult> _finishCallback) { if (mInstance == null) { Debug.LogError("you should attack CEPathFind to an gameobject and call FindPath after it have been init"); } else { var agentProxy = new CEPathFindAgentProxy(); agentProxy.agent = new CEPathFindAgent(); agentProxy.agent.Reset(_findEngine, _starTileX, _starTileY, _endTileX, _endTileY); agentProxy.callback += _finishCallback; mInstance.AddAgentProxy(agentProxy); } }
public static CEPathFindResult FindPath(int _starTileX, int _starTileY, int _endTileX, int _endTileY, CEPathFindBasic _findEngine) { if (mShareAgent == null) { mShareAgent = new CEPathFindAgent(); } mShareAgent.Reset(_findEngine, _starTileX, _starTileY, _endTileX, _endTileY); CEPathFindResult result = null; bool isFinish = false; while (!isFinish) { mShareAgent.TickSearch(out isFinish, out result); } return(result); }