示例#1
0
//----------------------------------------------------------------------------------------
void BaseLevelBuilder::createSeer()
{
	// TODO : tile physics
	if(m_level->m_levelDataReference->mapFilePointer == NULL)
		return;

	unsigned int playerType = UserData::GetUserType();
	ASSERT(m_level->m_levelDataReference->mapFilePointer != NULL, "map file is empty");	

	SpriteSeer* seer = LevelObjectCreator::sCreateSeer(UserData::Get()->getUserId(),UserData::Get()->getUserName(),
		playerType ,
		true
		);

	seer->SetID(UserData::Get()->getUserId());
	seer->setTag(MAP_TAG_SEER);
	m_level->m_pObjectsLayer->addChild(seer, LevelLayer::sCalcZorder(seer->getPosition()));

	GameManager::Get()->setHero(seer);
	GameManager::Get()->setHeroTypeId(seer->GetTypeId());

	SkillDispMgr::Get()->Load("Data/skill.bin", "Data/animationMap.bin");
	SkillDispMgr::Get()->LoadFairy("Data/fairyskill.bin", "Data/fairyanimation.bin");


	// TODO : 实际上,影子可以放到LevelLayer里,不一定要放到ObjectLayer里。
	CATLObjectLayer* pObjLayer = dynamic_cast<CATLObjectLayer*>(m_level->m_pObjectsLayer);
	if(pObjLayer)
	{
		pObjLayer->AddRoleShadow(seer);
	}
}
示例#2
0
void GameDataManager::setHeroMoveType(Move_Type type)
{
	this->heroMoveType = type;

	bool isMainLandLevel = MainLandManager::Get()->isMainLand(LevelManager::sShareInstance()->getCurMapId());
	SpriteSeer * seer = GameManager::Get()->getHero();
	if (seer && !isMainLandLevel)
	{
		seer->SetMoveType(type);
		seer->moveToTarget(seer->getPosition(), seer->getPosition());
	}

	HSJoystick * stick = HSJoystick::sharedJoystick();

	if (stick)
	{
		if (!isMainLandLevel)
		{
			stick->setIsEnable(MOVE_BY_JOY == type ? true : false);
		}
		else
		{
			stick->setIsEnable(false);
		}	
	}
}
示例#3
0
void BaseLevelBuilder::removeOtherPlayer(unsigned int uid)
{
	// Note: Remove Attach Elf 
	SpriteFactory::sharedFactory()->RemoveElfFromHero(uid);

	std::map<unsigned int, LevelLayer::WAKL_INFO>::iterator iterWalk = m_level->m_walkInfo.find(uid);
	if(iterWalk != m_level->m_walkInfo.end())
	{
		m_level->m_walkInfo.erase(iterWalk);
	}

	std::map<uint32_t, OthersPlayerInfo>::iterator itor = m_level->m_othersPlayerInfo.find(uid);
	if (itor != m_level->m_othersPlayerInfo.end())
	{
		OthersPlayerInfo playerInfo = (*itor).second;

		//
		m_level->m_othersPlayerInfo.erase(itor);

		//remove seer
		SpriteSeer* seer = playerInfo.seer;
		if (seer && m_level->m_pObjectsLayer)
		{
			seer->getRoot()->stopAllActions();
			m_level->m_pObjectsLayer->removeChild(seer, true);
		}
	}
	else
	{
		CCLog("error, the player has not add before");
	}
}
示例#4
0
//////////////////////////////////////////////////////////////////////////
//called when touch layer
//////////////////////////////////////////////////////////////////////////
void LevelLayer::ccTouchesBegan(CCSet *pTouches, CCEvent *pEvent)
{
	CCTouch* touch = (CCTouch*)pTouches->anyObject();
	CCPoint oldPT = touch->getLocationInView();
	oldPT = CCDirector::sharedDirector()->convertToGL(oldPT);	

	m_touchWinPoint = oldPT;

    float deviceScale = CCDirector::sharedDirector()->getContentScaleFactor();
    oldPT = CCPoint(oldPT.x * deviceScale, oldPT.y * deviceScale);
    
	CCPoint newPT = LevelMultiResolution::sTransformWindowPointToMap(oldPT);

	// Note: 打断自动寻路到副本显示感叹号
	TaskManager::getInstance()->InterruptAutoGoToInstanceEvent();
    
	//by benyang: deal with npc first
	if(!NPCManager::sharedManager()->processTouch(newPT))
	{
		//send touch begin event to children
		CCArray* children = this->getChildren();
		if (children)
		{
			int childrenCount = children->count();
			for (int i = 0; i < childrenCount; ++i)
			{
				CCNode* child = (CCNode* )children->objectAtIndex(i);
				ASSERT(child != NULL, "child is NULL");

				BaseListener* listener = LevelLayer::sGetListenerByTag(child->getTag());
				if (listener)
				{
					listener->HandleLayerTouchBeginEvent(child, newPT);
				}				
			}
		}
	}

	//上面的listener未命中,直接调用SpriteSeerListener
	SpriteSeer * seer = GameManager::Get()->getHero();
	if (seer)
	{
		BaseListener* listener = LevelLayer::sGetListenerByTag(seer->getTag());
		if (listener)
		{
			listener->HandleLayerTouchBeginEvent(seer, newPT);
		}		
	}

	//record touch point in map
	m_touchWinPoint = oldPT;		
}
void StoryInstanceDirector::LoadAllRoles()
{
	std::vector<unsigned int> vecOut;
	if (StoryDataCenter::Get()->GetOneItemAllRoleIds(vecOut))
	{
		size_t count = vecOut.size();
		for (size_t index = 0;index<count;index++)
		{
			unsigned int roleId = vecOut[index];
			SpriteSeer* pSeer = 0;
			if (roleId != 0)
			{
				pSeer = InsertOneRole(index+1,roleId);

				unsigned int seerTypeId = pSeer->GetTypeId();
				if (false == SpriteElfConfigFromLuaManager::getInstance()->TellIsElfId(seerTypeId))
				{
					ASprite* pAsprite = AspriteManager::getInstance()->getAsprite("spriteBin/shadow.bin");
					if(pAsprite != NULL)
					{
						CCPoint cp;
						CCSpriteBatchNode* pBatchNode = pAsprite->getSpriteBatchNodeFromFrame_Middle(0, 0, cp);
						if(pBatchNode != NULL)
						{
							pSeer->addChildToRoot(pBatchNode);
						}
					}
				}
			}
			else
			{
				pSeer = GameManager::Get()->getHero();
				pSeer = InsertOneRole(index+1,roleId,pSeer);
				if (pSeer)
				{
					m_heroIndex = index+1;
				}
			}
			if (pSeer)
			{
				pSeer->getRoot()->setVisible(false);
			}
		}
	}	
}
void StoryInstanceDirector::RemoveAndClearRcs()
{
	std::map<unsigned int,SpriteSeer*>::iterator iter = m_mapRoleIdAndInstance.begin();
	while(iter != m_mapRoleIdAndInstance.end())
	{
		SpriteSeer* pSeer = (*iter).second;
		if (m_heroIndex == (*iter).first)
		{
			pSeer->getRoot()->setVisible(true);
		}
		else
		{
			//pSeer->getParent()->removeChild(pSeer,true);
			pSeer->getRoot()->setVisible(false);
		}		

		iter ++;
	}

	m_mapRoleIdAndInstance.clear();
}
示例#7
0
bool StoryDataCenter::GetOneRoleLeftIcon(unsigned int roleIndex,std::string &iconName)
{
	std::map<unsigned int,StoryRoleBasicData>::iterator Iter = (*mCurIterator).mMapStoryRolesBasicData.find(roleIndex);
	if (Iter == (*mCurIterator).mMapStoryRolesBasicData.end())
	{
		return false;
	}

	StoryRoleBasicData basicData = (*Iter).second;
	iconName = basicData.getRoleLogoIcon();
	if (iconName == "")
	{
		SpriteSeer* pHero = GameManager::Get()->getHero();
		if (pHero)
		{
			unsigned int index = pHero->GetTypeId();
			iconName = LuaTinkerManager::Get()->getLuaConfig<const char *>("characterString", "Characters", index, "PictureFile");
		}		
	}

	return true;
}
SpriteMonster * SpriteMonsterMgr::getNearestMonster()
{
	SpriteMonster * nearestMonster = NULL;
	float distance = 10000.0f;
	SpriteSeer * hero = GameManager::Get()->getHero();
	if (!hero || m_tabMonsters.size() == 0)
	{
		return NULL;
	}

	map<int, SpriteMonster*>::iterator it = m_tabMonsters.begin();

	SpriteMonster * firstMonster = it->second;

	//能被锁定的怪物才记入数据,隐身不计入
	if (firstMonster->getCanBeFocus() && !firstMonster->getIsAlliance())
	{
		distance = ccpDistance(firstMonster->getPosition(), hero->getPosition());
		nearestMonster = firstMonster;
	}	

	for(; it != m_tabMonsters.end(); it++ )
	{
		SpriteMonster* monster = it->second;
		if (!monster->getCanBeFocus() || monster->getIsAlliance())
		{
			continue;
		}

		float dis = ccpDistance(monster->getPosition(), hero->getPosition());
		if (dis < distance && monster->fsm_rule.IsRunning())
		{
			distance = dis;
			nearestMonster = monster;
		}	
	}

	return nearestMonster;
}
示例#9
0
void GameDataManager::setHeroAutoAttack(bool autoAttack)
{
	if (heroAutoAttack == autoAttack)
	{
		return;
	}
	heroAutoAttack = autoAttack;
	SpriteSeer * seer = GameManager::Get()->getHero();
	if (GameManager::Get()->GetSceneLayer())
	{
		MainMenuLayer * mLayer = GameManager::Get()->GetSceneLayer()->getMainMenuLayer();
		if (mLayer)
		{
			BattleCoverLayer * coverLayer = mLayer->GetBattleCoverLayer();
			if (autoAttack)
			{
				coverLayer->openBattleCoverLayer(COVER_AUTOATTACK);
			}
			else
			{
				coverLayer->closeBattleCoverLayer(NULL);
			}
		}
	}

	if (seer)
	{
		if (autoAttack)
		{		
			seer->startAutoAttack();
		}
		else
		{
			seer->endAutoAttack();
		}
	}
}
示例#10
0
//----------------------------------------------------------------------------------------
//			others function means other players'
//----------------------------------------------------------------------------------------
void BaseLevelBuilder::addOtherPlayer(unsigned int uid, const char* userName,unsigned int type, cocos2d::CCPoint pt, unsigned int orient, unsigned int battleSide)
{
	std::map<uint32_t, OthersPlayerInfo>::iterator itor = m_level->m_othersPlayerInfo.find(uid);
	if (itor == m_level->m_othersPlayerInfo.end())
	{
		//
		OthersPlayerInfo playerInfo;
		playerInfo.seer = NULL;
		playerInfo.pet = NULL;
#if _DEBUG
		playerInfo.name = userName;
#endif
		//add seer
		ASSERT(m_level->m_levelDataReference->mapFilePointer != NULL, "map file is empty");
		SpriteSeer* seer = LevelObjectCreator::sCreateSeer(uid,userName,
			type, 
			false);

		if(NULL == seer)
		{
			return;
		}

		

		seer->SetID(uid);
		seer->setTag(MAP_TAG_OTHER_SEER);
		seer->setPosition(pt);
		seer->SetBattleSide(battleSide);

		if (m_level->m_pObjectsLayer)
		{
			m_level->m_pObjectsLayer->addChild(seer, LevelLayer::sCalcZorder(seer->getPosition()));

			bool isMainLand = MainLandManager::Get()->isMainLand(m_level->m_id);
			int	animID;
			if (isMainLand)
			{
				animID = kTypeIdle_FaceDown_Stand_MAIN;
			}
			else
			{
				animID = kTypeIdle_FaceDown_Stand_OTH;
			}
			
			/*switch(orient)
			{
			case DIRECTION_UP:
			animID = kTypeIdle_FaceUp_Stand_MAIN;
			break;
			case DIRECTION_LEFT:
			break;
			case DIRECTION_BOTTOM:
			break;
			case DIRECTION_RIGHT:
			break;
			default:
			break;
			}*/
			seer->SetAnim(animID,1,true);
		}

		playerInfo.seer = seer;

		//add pet
		//if (petType != 0)
		//{
		//	SpriteElf* elf = LevelObjectCreator::sCreateSpriteElf(petType, 0, true,
		//		MAP_TAG_OTHER_FOLLOW_SPRITE ,
		//		true);

		//	elf->setTag(MAP_TAG_OTHER_FOLLOW_SPRITE);
		//	elf->followSeerPosition(pt, true);
		//	m_level->addChild(elf, LevelLayer::sCalcZorder(elf->getPosition()));

		//	playerInfo.pet = elf;
		//}

		//
		m_level->m_othersPlayerInfo.insert(std::pair<uint32_t, OthersPlayerInfo>(uid, playerInfo));

		CATLObjectLayer* pObjLayer = dynamic_cast<CATLObjectLayer*>(m_level->m_pObjectsLayer);
		if(pObjLayer)
		{
			pObjLayer->AddRoleShadow(seer);
		}

	}
	else
	{
		CCLog("error, the player has add before");
	}
}
cocos2d::CCPoint ElfAimDirectionHandler::GetAimDirection()
{
	CCPoint ret = m_pElf->getDirectionVector();
	CCPoint rolePos = m_pElf->getPosition();

	
	if(LevelManager::sShareInstance()->isCurrentPVPLevel())
	{
		if(LevelManager::sShareInstance()->getCurrentLevelLayer())
		{
			float minDis = m_pSkill->longDistanceAttackRange;

			if(minDis <= 0.0f)
				minDis = 320.0f;

			minDis *= minDis;

			SpriteSeer* pNearestHero = NULL;

			std::map<unsigned int, OthersPlayerInfo>& otherPlayer = LevelManager::sShareInstance()->getCurrentLevelLayer()->m_othersPlayerInfo;

			for(std::map<unsigned int, OthersPlayerInfo>::const_iterator iter = otherPlayer.begin(); iter != otherPlayer.end(); iter++)
			{
				SpriteSeer* pOhterHero = iter->second.seer; 
				if(m_pRole == pOhterHero || pOhterHero == NULL)
					continue;

				float dis = ccpDistanceSQ(pOhterHero->getPosition(), m_pElf->getPosition());
				if( dis <= minDis)
				{
					pNearestHero = pOhterHero;
					minDis = dis;

				}
			}

			if(pNearestHero)
			{
				m_bAimMonster = true;
				m_nearestMonsterPos = pNearestHero->getPosition();
				ret = ccpSub(m_nearestMonsterPos, rolePos);
			}
		}
	}
	else
	{
		SpriteMonster* pNearestMonster = GetNearestMonster();

		if(pNearestMonster)
		{
			m_bAimMonster = true;
			m_nearestMonsterPos = pNearestMonster->getPosition();
			ret = ccpSub(m_nearestMonsterPos, rolePos);

		}
	}

	

	ret = ccpNormalize(ret);

	return ret;
}
void StoryInstanceDirector::Begin(unsigned int id,unsigned int map_id,int nWhen)
{	
	//if (IsOneInstanceExist(id))
	//{
	//	// Note: 已经播放过 无需重复播放
	//	return ;
	//}
	mID = id;
	m_cutAnimHappendWhen = nWhen;
	m_mapRoleIdAndInstance.clear();

	// Note: 初始化数据中心
	StoryDataCenter::Get()->LoadOneDataItem(id,map_id,nWhen);	

	// Note: 设置摄像机对准点模式
	CCPoint cameraPoint = StoryDataCenter::Get()->GetCameraPoint();
	CameraController::sharedCameraController()->SetFollowType(CameraController::E_FixPoint);
	CameraController::sharedCameraController()->SetFollowPoint(cameraPoint);

	// Note: 获取总帧数
	m_totalFrames = StoryDataCenter::Get()->GetTotalFrames();
	m_curFrame = -1;
	m_preFrame = -1;
	m_curKeyID = id;

	//// Note: 战斗UI面板隐藏
	m_isHSJoystickEnable = HSJoystick::sharedJoystick()->getIsEnable();
	if (m_isHSJoystickEnable)
	{
		HSJoystick::sharedJoystick()->setVisible(false);
		HSJoystick::sharedJoystick()->setIsEnable(false);
	}

	// Note: 隐藏战斗中UI
	if (nWhen == 0 || nWhen == 1)
	{
		ShowBattleUILayer(false);
	}	
	else if (nWhen == 2)
	{
		ShowMainLandUILayer(false);
		BoneNPCManager::getInstance()->ShowAllNpc(false);
	}

	// Note: 加载所有需要资源
	LoadAllNeedRcs();
	LoadAllRoles();

	// Note: 显示对话界面
	m_dialogLayer = InstanceDialogLayer::create();
	MainMenuLayer * mLayer = GameManager::Get()->GetSceneLayer()->getMainMenuLayer();
	if (mLayer)
	{
		mLayer->addChild(m_dialogLayer);
		mLayer->setVisible(true);
	}

	// Note: 黑屏Layer
	if (mLayer != 0)
	{
		m_pColorLayer = CCLayerColor::create(ccc4(0,0,0,255));
		m_pColorLayer->setVisible(false);
		mLayer->addChild(m_pColorLayer,0,1000);
	}

	// Note: 禁用主角的状态机
	SpriteSeer* pHero = GameManager::Get()->getHero();
	if (pHero)
	{
		pHero->PauseStateMachine();
	}

	if (m_cutAnimHappendWhen == 1)
	{
		PlayBecomeDarkEffect();
	}

	m_isStart = true;
}
示例#13
0
int PvAIManager::getBestSkill()
{
    int skillId = 0;
    int normalAttackId = 0;
    bool canDoSkill = false;

    SpriteSeer * hero = GameManager::Get()->getHero();
    if (!hero)
    {
        return skillId;
    }

    //循环遍历确定是否有技能正在释放
    SkillDispMgr * skillMgr = SkillDispMgr::Get();

    bool doingSkill = false;
    for (size_t i = 0; i < skills.size(); i++)
    {
        const SKILL_INFO * info = skillMgr->GetSkillInfo(skills[i]);

        if (aiPlayer->m_pStateMachine->CheckStateRuning(info->type))
        {
            doingSkill = true;
            break;
        }
    }

    //从头遍历可以释放的技能
    for (size_t i = 0; i < skills.size(); i++)
    {
        const SKILL_INFO * info = skillMgr->GetSkillInfo(skills[i]);

        //找出普通攻击id
        if (info->type == ToNormalAttack)
        {
            normalAttackId = skills[i];
            continue;
        }

        //未释放技能时才检测技能cd及距离
        if (!doingSkill)
        {

            if (skillMgr->IsCD(aiPlayerId, skills[i]))
            {
                continue;
            }

            if (ccpDistance(aiPlayer->getPosition(), hero->getPosition()) < info->longDistanceAttackRange)
            {
                canDoSkill = true;
                skillId = skills[i];

                break;
            }
        }
    }

    //普通攻击
    if (!canDoSkill && normalAttackId)
    {
        const SKILL_INFO * info = skillMgr->GetSkillInfo(normalAttackId);
        if (ccpDistance(aiPlayer->getPosition(), hero->getPosition()) < info->longDistanceAttackRange)
        {
            skillId = normalAttackId;
        }
    }


    return skillId;
}
bool StoryInstanceDirector::TrackPlayerAnim()
{
	// Note: Add To Obj Layer
	LevelLayer* pLayer = LevelManager::sShareInstance()->getCurrentLevelLayer();
	CCNode* pObjLayer = pLayer->getObjectLayer();

	std::map<unsigned int,StoryRoleBasicData> storyData = StoryDataCenter::Get()->GetStoryRoleBasicData();
	std::map<unsigned int,StoryRoleBasicData>::iterator iter = storyData.begin();
	while(iter != storyData.end())
	{
		bool bPosChanged = false;
		SpriteSeer* pCurHero = GetOneRole((*iter).first);

		std::map<unsigned int,StoryFrameData>::iterator frameIter = (*iter).second.mMapStoryFramesData.find((int)m_curFrame);
		if (frameIter != (*iter).second.mMapStoryFramesData.end())
		{
			//// Note: 当前帧存在
			StoryFrameData frameData = (*frameIter).second;
			CCPoint pos = frameData.getRolePos();						

			// Note: 位置发生变化,移动位置,或者新创建角色
			if (StoryFrameData::IsPosChanged(pos))
			{
				bPosChanged = true;

				bool bVisiable = pCurHero->getRoot()->isVisible();
				if (bVisiable == false)
				{
					pCurHero->getRoot()->setVisible(true);
				}
				pCurHero->setPosition(pos);
				pObjLayer->reorderChild(pCurHero,LevelLayer::sCalcZorder(pos));
			}

			int actorId = frameData.getActorId();
			if (actorId != -1)
			{
				pCurHero->SetAnim(actorId,0);
			}

			int nFlip = frameData.getFlip();
			if (nFlip != -1)
			{
				if (nFlip == 0)
				{
					pCurHero->SetAnimFlipX(false);
				}
				else if (nFlip == 1)
				{
					pCurHero->SetAnimFlipX(true);
				}
			}
		}

		if (false == bPosChanged)
		{
			// Note: 不存在的情况下处理移动
			if (false == bPosChanged)
			{
				unsigned int preFrameIndex = 0;
				unsigned int nextFrameIndex = 0;
				CCPoint prePoint = CCPointZero;
				CCPoint nextPoint = CCPointZero;
				if(StoryDataCenter::Get()->GetPreAndNextPointFrameData((*iter).first,(int)m_curFrame,preFrameIndex,nextFrameIndex,prePoint,nextPoint))
				{
					// Note: 处理移动

					unsigned int sumMoveFrames = (nextFrameIndex - preFrameIndex);
					unsigned int runningFrames = (int)m_curFrame - preFrameIndex;
					if (runningFrames >= sumMoveFrames)
					{
						return false;
					}
					// Note: 运动速率
					CCPoint dir = ccpSub(nextPoint,prePoint);
					float distance = sqrt(ccpLengthSQ(dir));
					float vPerFrame = distance/sumMoveFrames;
					if(dir.x == 0 && dir.y == 0)
					{
						return false;
					}
					dir = ccpNormalize(dir);

					CCPoint nowPoint = ccpAdd(prePoint,ccp(vPerFrame*runningFrames*dir.x,vPerFrame*runningFrames*dir.y));
					pCurHero->setPosition(nowPoint);
					pObjLayer->reorderChild(pCurHero,LevelLayer::sCalcZorder(nowPoint));
				}
			}
		}

		iter++;
	}

	return true;
}
示例#15
0
void PvAIManager::moveToHero()
{
    SpriteSeer * hero = GameManager::Get()->getHero();

    SkillDispMgr * skillMgr = SkillDispMgr::Get();

    int skillId = getBestSkill();
    if (skillId)
    {
        for (size_t i = 0; i < skills.size(); i++)
        {
            if (skillId == skills[i])
            {
                skills.erase(skills.begin() + i);
                skills.push_back(skillId);
                break;
            }
        }

        if (skillMgr->GetSkillInfo(skillId)->type != ToNormalAttack)
        {
            CCPoint vec = ccpSub(hero->getPosition(), aiPlayer->getPosition());
            vec = ccpNormalize(vec);
            aiPlayer->setDirection(vec);
            if(!aiPlayer->DoSkillAttack(skillId))
            {
                if (hero)
                {
                    if( aiPlayer->canMove )
                        aiPlayer->moveToTarget(hero->getPosition(), aiPlayer->getPosition());
                }
            }
        }
        else
        {
            CCPoint vec = ccpSub(hero->getPosition(), aiPlayer->getPosition());
            vec = ccpNormalize(vec);
            aiPlayer->setDirection(vec);
            aiPlayer->DoNormalAttack();
        }
    }
    else if (hero)
    {
        CCPoint pt = hero->getPosition();
        CCPoint pixPos = aiPlayer->getPosition();
        if (LevelManager::sShareInstance()->isPointReachable(pt))
        {
            aiPlayer->moveToTarget(pt, pixPos);
        }
        else
        {
            CCPoint vec = ccpNormalize(ccpSub(pt, pixPos));
            do
            {
                pt = ccpSub(pt, vec);
            } while (!LevelManager::sShareInstance()->isPointReachable(pt));
            aiPlayer->moveToTarget(pt, pixPos);
        }
    }

    return;
}
示例#16
0
//////////////////////////////////////////////////////////////////////////
//update movable objects z order 
//////////////////////////////////////////////////////////////////////////
void LevelLayer::update(float dt)
{
	//m_cameraController.Update(dt);
    CameraController::sharedCameraController()->Update(dt);
    

	for(std::map<unsigned int, WAKL_INFO>::iterator iter = m_walkInfo.begin(); iter != m_walkInfo.end(); iter++)
	{
		if(iter->second.idleTime.time <= iter->second.idleTime.curTime && !iter->second.walk.bUsed)
		{
			iter->second.walk.bUsed = true;
			updateOtherPlayer(iter->second.walk.uid, iter->second.walk.pt, iter->second.walk.animID, iter->second.walk.bFlip);
		}
		else
		{
			iter->second.idleTime.curTime += dt;
			
		}
	}

	while(!LevelManager::sShareInstance()->m_otherPlayerInfo.empty())
	{
		const LevelManager::OTHER_PLAYER_INFO& info = LevelManager::sShareInstance()->m_otherPlayerInfo.top();

		m_levelBuilder->addOtherPlayer(info.uid, info.userName.c_str(), info.type, info.pos, info.orient, info.battleSide);
		LevelManager::sShareInstance()->m_otherPlayerInfo.pop();
	}

	CCArray* children = this->getChildren();
	if (children)
	{
		int childrenCount = children->count();
		for (int i = 0; i < childrenCount; ++i)
		{
			CCNode* child = (CCNode* )children->objectAtIndex(i);
			ASSERT(child != NULL, "child is NULL");

			BaseListener* listener = LevelLayer::sGetListenerByTag(child->getTag());
			if (listener)
			{
				listener->HandleLayerUpdateEvent(child, dt);
			}			
		}
	}

	if(m_pObjectsLayer != NULL)
	{
		children = m_pObjectsLayer->getChildren();
		if (children)
		{
			int childrenCount = children->count();
			for (int i = 0; i < childrenCount; ++i)
			{
				CCNode* child = (CCNode* )children->objectAtIndex(i);
				ASSERT(child != NULL, "child is NULL");

				BaseListener* listener = LevelLayer::sGetListenerByTag(child->getTag());
				if (listener)
				{
					listener->HandleLayerUpdateEvent(child, dt);
				}				
			}
		}
	}

	// update Hero 
	SpriteSeer* hero = GameManager::Get()->getHero();
	if (hero)
	{
		hero->Update(dt);
	}

	//更新其他玩家
	std::map<uint32_t, OthersPlayerInfo>::iterator itor = m_othersPlayerInfo.begin();
	while (itor != m_othersPlayerInfo.end())
	{
		OthersPlayerInfo playerInfo = (*itor).second;

		SpriteSeer * seer = playerInfo.seer;
		if (seer)
		{
			seer->Update(dt);
		}		

		itor++;
	}

	// update ItemUpdatManager
	ItemUpdateManager::Get()->Update(dt);

	// update monster
	SpriteMonsterMgr::Get()->Update(dt);

	// update actor
	EnginePlayerManager::getInstance()->update(dt);

	// Note: Update SpriteElf
	SpriteElfManager::Get()->Update(dt);

	// Note: 剧情Update
	StoryInstanceDirector::Get()->Update(dt);

	//按住屏幕移动持续寻路
	if (pressTime < 0.1f)
	{
		pressTime += dt;
	}
	else if (m_touchWinPoint.x != 0 && m_touchWinPoint.y != 0)
	{
		float deviceScale = CCDirector::sharedDirector()->getContentScaleFactor();
		m_touchWinPoint = CCPoint(m_touchWinPoint.x * deviceScale, m_touchWinPoint.y * deviceScale);
    
		CCPoint newPT = LevelMultiResolution::sTransformWindowPointToMap(m_touchWinPoint);

		SpriteSeer * hero = GameManager::Get()->getHero();
		if (hero)
		{
			BaseListener* listener = LevelLayer::sGetListenerByTag(hero->getTag());
			if (listener)
			{
				listener->HandleLayerTouchBeginEvent(hero, newPT);
			}			
		}
		pressTime = 0.0f;
	}

	SkillDispMgr::Get()->Update(dt);

	PvAIManager::Get()->Update(dt);

}
void StoryInstanceDirector::End()
{
	if (m_cutAnimHappendWhen == 0)
	{
		PlayBecomeDarkEffect();
	}	

	// Note: 清空资源
	RemoveAndClearRcs();

	if (m_isHSJoystickEnable)
	{
		HSJoystick::sharedJoystick()->setVisible(true);
		HSJoystick::sharedJoystick()->setIsEnable(true);
	}
	
	if (m_cutAnimHappendWhen == 0 || m_cutAnimHappendWhen == 1)
	{
		ShowBattleUILayer(true);
	}	
	else if (m_cutAnimHappendWhen == 2)
	{
		ShowMainLandUILayer(true);
		BoneNPCManager::getInstance()->ShowAllNpc(true);
		ShowOtherPlayers(true);
		ShowOtherElf(true);
		StoryDataCenter::Get()->SetOneMainLandStoryOver(mID);
	}

	if (m_dialogLayer != 0)
	{
		m_dialogLayer->removeFromParent();
	}	

	CameraController::sharedCameraController()->SetFollowType(CameraController::E_FollowHero);

	if (m_cutAnimHappendWhen == 0)
	{
		// Note: 重置主角的位置
		CCPoint playerPos = InstanceManager::Get()->getPlayerPosition();
		SpriteSeer* pHero = GameManager::Get()->getHero();
		if (pHero)
		{
			pHero->setPosition(playerPos);
		}

		LevelManager::sShareInstance()->ShowMonsterOrNot(true);
		OnlineNetworkManager::sShareInstance()->sendLoadCompleteMessage();
	}
	else if (m_cutAnimHappendWhen == 1)
	{
		XLogicManager::sharedManager()->FinishBattle();
		//OnlineNetworkManager::sShareInstance()->sendOnceSetReqMessage(InstanceManager::Get()->getCurInstanceId());
	}

	SpriteSeer* pHero = GameManager::Get()->getHero();
	if (pHero)
	{
		pHero->ResumeStateMachine();
	}

	ResetData();
}
cocos2d::CCNode* ElfAttackTrigger::GetNearestMonster( void )
{
	cocos2d::CCNode* pRet = NULL;
	float minDis = 0.0f;
	minDis = m_pSkill->longDistanceAttackRange;

	if(minDis <= 0.0f)
		minDis = 320.0f;

	minDis *= minDis;
	if(LevelManager::sShareInstance()->isCurrentPVPLevel())
	{
		if(LevelManager::sShareInstance()->getCurrentLevelLayer())
		{
			USERINFO* pHeroInfo = UserData::Get()->GetUserInfo(m_pRole->GetID());

			std::map<unsigned int, OthersPlayerInfo>& otherPlayer = LevelManager::sShareInstance()->getCurrentLevelLayer()->m_othersPlayerInfo;
			for(std::map<unsigned int, OthersPlayerInfo>::const_iterator iter = otherPlayer.begin(); iter != otherPlayer.end(); iter++)
			{
				SpriteSeer* pOhterHero = iter->second.seer; 

				if(m_pRole == pOhterHero || pOhterHero == NULL)
					continue;

				USERINFO* pOtherInfo = UserData::Get()->GetUserInfo(pOhterHero->GetID());
				if(pHeroInfo && pOhterHero)
				{
					if(pHeroInfo->battleSide % 2 == pOtherInfo->battleSide % 2)
						continue;
				}

				float dis = ccpDistanceSQ(pOhterHero->getPosition(), m_pElf->getPosition());
				if( dis <= minDis)
				{
					pRet = pOhterHero;
					minDis = dis;

				}
			}

			
		}
	}
	else
	{
		const map<int, SpriteMonster*>& allMonster = SpriteMonsterMgr::Get()->GetAllMonster();
		for(map<int, SpriteMonster*>::const_iterator iter = allMonster.begin(); iter != allMonster.end(); iter++)
		{
			float dis = ccpDistanceSQ(iter->second->getPosition(), m_pElf->getPosition());
			if( dis <= minDis)
			{
				pRet = iter->second;
				minDis = dis;

			}
		}
	}
	

	return pRet;
}