<commit_before>#include "NpcController.h"
#include "cocos2d.h"
#include <ctime>
#include "Obstacle.h"
#include "Coin.h"
#include "MapSequences.h"
#include "Player.h"
#include "MoveAbleElemManager.h"
#include "MoveAbleElemTypeDefines.h"

USING_NS_CC;


#define TRACK_0 0
#define TRACK_1 1
#define TRACK_2 2

#ifdef STD_VECTOR_ELEM
#define pushBack push_back
#define popBack pop_back
#endif

NpcController::NpcController() :_pCurMapSequences(nullptr), _pPlayer(nullptr), _pGameLayer(nullptr), _fRecationDt(1.0f)
{
	//ʱ亯ʼ
	srand(static_cast<unsigned int>(clock()));
}

NpcController::~NpcController()
{
	Director::getInstance()->getScheduler()->unscheduleUpdate(this);
	if (_pCurMapSequences !=nullptr)
	{
		_pCurMapSequences = nullptr;
	}

	for (auto it = _vSequencesPtr.begin(); it != _vSequencesPtr.end(); ++it)
	{
		delete (*it);
	}
	_vSequencesPtr.clear();

#ifdef STD_VECTOR_ELEM
	vpMoveableElems.clear();
#else
	vpMoveableElems.clear();
#endif


	CC_SAFE_RELEASE_NULL(_pPlayer);

	CC_SAFE_RELEASE_NULL(_pGameLayer);
}
//ʹãٵģṹ
bool NpcController::init(Player * pPlayer, cocos2d::Layer * pGameLayer)
{

	CC_SAFE_RETAIN(pPlayer);
	CC_SAFE_RETAIN(pGameLayer);

	CC_SAFE_RELEASE_NULL(_pPlayer);
	CC_SAFE_RELEASE_NULL(_pGameLayer);

	_pPlayer = pPlayer;
	_pGameLayer = pGameLayer;

	this->insertMapSequence(new MapSequences());

	//todo
	auto temp1 = MoveAbleElemManager::getInstance()->GenerateOneElem(OBSTACLE__ID);
	_diffObstacleWithPlay = calcuratePosWillHit(temp1, pPlayer, _fRecationDt * 5);
	MoveAbleElemManager::getInstance()->recycleElem(temp1);

	auto temp2 = MoveAbleElemManager::getInstance()->GenerateOneElem(COIN_TYPE_ID);
	_diffCoinWithPlay = calcuratePosWillHit(temp2, pPlayer, _fRecationDt * 5);
	MoveAbleElemManager::getInstance()->recycleElem(temp2);


	Director::getInstance()->getScheduler()->scheduleUpdate(this, 0, false);

	return true;
}

void NpcController::update(float delta)
{
	
	//todo ײͷײ
	for (auto it = vpMoveableElems.begin(); it != vpMoveableElems.end();)
	{<commit_msg>becuase of having lessened 3D view length<commit_after>#include "NpcController.h"
#include "cocos2d.h"
#include <ctime>
#include "Obstacle.h"
#include "Coin.h"
#include "MapSequences.h"
#include "Player.h"
#include "MoveAbleElemManager.h"
#include "MoveAbleElemTypeDefines.h"

USING_NS_CC;


#define TRACK_0 0
#define TRACK_1 1
#define TRACK_2 2

#ifdef STD_VECTOR_ELEM
#define pushBack push_back
#define popBack pop_back
#endif

NpcController::NpcController() :_pCurMapSequences(nullptr), _pPlayer(nullptr), _pGameLayer(nullptr), _fRecationDt(1.0f)
{
	//ʱ亯ʼ
	srand(static_cast<unsigned int>(clock()));
}

NpcController::~NpcController()
{
	Director::getInstance()->getScheduler()->unscheduleUpdate(this);
	if (_pCurMapSequences !=nullptr)
	{
		_pCurMapSequences = nullptr;
	}

	for (auto it = _vSequencesPtr.begin(); it != _vSequencesPtr.end(); ++it)
	{
		delete (*it);
	}
	_vSequencesPtr.clear();

#ifdef STD_VECTOR_ELEM
	vpMoveableElems.clear();
#else
	vpMoveableElems.clear();
#endif


	CC_SAFE_RELEASE_NULL(_pPlayer);

	CC_SAFE_RELEASE_NULL(_pGameLayer);
}
//ʹãٵģṹ
bool NpcController::init(Player * pPlayer, cocos2d::Layer * pGameLayer)
{

	CC_SAFE_RETAIN(pPlayer);
	CC_SAFE_RETAIN(pGameLayer);

	CC_SAFE_RELEASE_NULL(_pPlayer);
	CC_SAFE_RELEASE_NULL(_pGameLayer);

	_pPlayer = pPlayer;
	_pGameLayer = pGameLayer;

	this->insertMapSequence(new MapSequences());

	//todo
	auto temp1 = MoveAbleElemManager::getInstance()->GenerateOneElem(OBSTACLE__ID);
	_diffObstacleWithPlay = calcuratePosWillHit(temp1, pPlayer, _fRecationDt * 4);
	MoveAbleElemManager::getInstance()->recycleElem(temp1);

	auto temp2 = MoveAbleElemManager::getInstance()->GenerateOneElem(COIN_TYPE_ID);
	_diffCoinWithPlay = calcuratePosWillHit(temp2, pPlayer, _fRecationDt * 4);
	MoveAbleElemManager::getInstance()->recycleElem(temp2);


	Director::getInstance()->getScheduler()->scheduleUpdate(this, 0, false);

	return true;
}

void NpcController::update(float delta)
{
	
	//todo ײͷײ
	for (auto it = vpMoveableElems.begin(); it != vpMoveableElems.end();)
	{
{'fraction_non_alphanumeric': 0.1353495290034705, 'fraction_numerical': 0.009667823500247892, 'mean_word_length': 7.285420944558521, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7524714', 'n_tokens_mistral': 1632, 'n_tokens_neox': 1564, 'n_words': 248}