Ejemplo n.º 1
0
void DramaCommandCamera::ExcuteMovePostion()
{
	NDAsssert(DCT_MOVECAMERA == m_kParam.type);

	DramaScene* dramaScene = GetDramaScene();

	if (!dramaScene)
	{
		SetFinish(true);
		return;
	}

	bool bXArrive = false;
	bool bYArrive = false;
	CCPoint curPos = dramaScene->GetCenter();
	if (abs(int(curPos.x) - m_kParam.u1.nToPosX) <= m_kParam.u3.nMoveStep)
	{
		curPos.x = m_kParam.u1.nToPosX;
		bXArrive = true;
	}
	else if (int(curPos.x) > m_kParam.u1.nToPosX)
	{
		curPos.x -= m_kParam.u3.nMoveStep;
	}
	else if (int(curPos.x) < m_kParam.u1.nToPosX)
	{
		curPos.x += m_kParam.u3.nMoveStep;
	}

	if (abs(int(curPos.y) - m_kParam.u2.nToPosY) <= m_kParam.u3.nMoveStep)
	{
		curPos.y = m_kParam.u2.nToPosY;
		bYArrive = true;
	}
	else if (int(curPos.y) > m_kParam.u2.nToPosY)
	{
		curPos.y -= m_kParam.u3.nMoveStep;
	}
	else if (int(curPos.y) < m_kParam.u2.nToPosY)
	{
		curPos.y += m_kParam.u3.nMoveStep;
	}

	//越界判定
	bool bOverBoder = dramaScene->SetCenter(curPos);

	if ((bXArrive && bYArrive) || bOverBoder)
	{
		SetFinish(true);
	}
}
Ejemplo n.º 2
0
void DramaCommandSprite::ExcuteSpriteEffect()
{
	NDAsssert(DCT_SETSPRITEPOS == m_kParam.type);
	SetFinish(true);

	DramaScene* dramaScene	= GetDramaScene();
	if (!dramaScene)
	{
		return;
	}

	NDSprite* sprite = dramaScene->GetSprite(m_kParam.nKey);
}
Ejemplo n.º 3
0
void DramaCommandCamera::ExcuteSetPosition()
{
	NDAsssert(DCT_SETCAMERA == m_kParam.type);

	SetFinish(true);

	DramaScene* dramaScene = GetDramaScene();

	if (!dramaScene)
	{
		return;
	}

	dramaScene->SetCenter(ccp(m_kParam.u1.nPosX, m_kParam.u2.nPoxY));
}
Ejemplo n.º 4
0
void DramaCommandWait::ExcuteWaitPreActionAndClick()
{
	NDAsssert(DCT_WAITPREACTFINISHANDCLICK == m_kParam.type);

	DramaScene* dramaScene = GetDramaScene();

	if (!dramaScene)
	{
		SetFinish(true);
		SetCanExcuteNextCommand(true);
	}

	if (!IsPreCommandsFinish())
	{
		dramaScene->ConsumeClick();
		return;
	}

	if (dramaScene->ConsumeClick())
	{
		SetFinish(true);
		SetCanExcuteNextCommand(true);
	}
}
Ejemplo n.º 5
0
void DramaCommandScene::ExcuteRemoveEraseScene()
{
	NDAsssert(DCT_REMOVEERASESCENE == m_kParam.type);

	SetFinish(true);

	DramaScene* pkDramaScene = GetDramaScene();

	if (!pkDramaScene)
	{
		return;
	}

	pkDramaScene->RemoveScene(m_kParam.u3.nTargetKey);
	DeAllocKey(m_kParam.u3.nTargetKey);
}
Ejemplo n.º 6
0
void DramaCommandWait::ExcuteWaitPreAction()
{
	NDAsssert(DCT_WAITPREACTFINISH == m_kParam.type);

	DramaScene* dramaScene = GetDramaScene();

	if (!dramaScene || IsPreCommandsFinish())
	{
		SetFinish(true);
		SetCanExcuteNextCommand(true);
	}
	else
	{
		dramaScene->ConsumeClick();
	}
}
Ejemplo n.º 7
0
void DramaCommandDlg::excute()
{
	SetFinish(true);

	DramaScene* pkDramaScene = GetDramaScene();

	if (!pkDramaScene)
	{
		return;
	}

	if (DCT_OPEN == m_kParam.type)
	{
		pkDramaScene->OpenChat(m_kParam.u3.bLeft);
	}
	else if (DCT_CLOSE == m_kParam.type)
	{
		pkDramaScene->CloseChat(m_kParam.u3.bLeft);
	}
	else if (DCT_SETDLGFIG == m_kParam.type)
	{
		pkDramaScene->SetChatFigure(m_kParam.u3.bLeft, m_kParam.str, m_kParam.u1.bReverse,
			                    m_kParam.m_Pic_CellX, m_kParam.m_Pic_CellY);
	}
	else if (DCT_SETDLGTITLE == m_kParam.type)
	{
		if (0 == m_kParam.nKey)
		{
			pkDramaScene->SetChatTitle(m_kParam.u3.bLeft, m_kParam.str,
					m_kParam.u2.nFontSize, m_kParam.u1.nFontColor);
		}
		else
		{
			pkDramaScene->SetChatTitleBySpriteKey(m_kParam.u3.bLeft, m_kParam.nKey,
					m_kParam.u2.nFontSize, m_kParam.u1.nFontColor);
		}
	}
	else if (DCT_SETDLGCONTENT == m_kParam.type)
	{
		pkDramaScene->SetChatContent(m_kParam.u3.bLeft, m_kParam.str,
				m_kParam.u2.nFontSize, m_kParam.u1.nFontColor);
	}
	else if (DCT_SHOWTIPDLG == m_kParam.type)
	{
		pkDramaScene->ShowTipDlg(m_kParam.str);
	}
}
Ejemplo n.º 8
0
void DramaCommandScene::ExcuteLoadDramaScene()
{
	NDAsssert(DCT_LOADMAPSCENE == m_kParam.type);

	SetFinish(true);

	DramaScene* scene = new DramaScene;
	scene->Init(m_kParam.u1.nMapId);

	//pop上一个场景
	if(NDDirector::DefaultDirector()->GetScene(RUNTIME_CLASS(DramaScene)) != NULL )
	{
		NDDirector::DefaultDirector()->PopScene();
	} 

	NDDirector::DefaultDirector()->PushScene(scene);
}
Ejemplo n.º 9
0
void DramaCommandSprite::ExcuteSpriteReverse()
{
	NDAsssert(DCT_SPRITE_REVERSE == m_kParam.type);
	SetFinish(true);
	DramaScene* dramaScene	= GetDramaScene();

	if (!dramaScene)
	{
		return;
	}

	NDSprite* sprite = dramaScene->GetSprite(m_kParam.nKey);
	if (!sprite)
	{
		return;
	}
	sprite->SetCurrentAnimation(0, m_kParam.u1.bReverse);
}
Ejemplo n.º 10
0
void DramaCommandWait::ExcuteWaitTime()
{
	NDAsssert(DCT_WAITTIME == m_kParam.type);

	DramaScene* dramaScene = GetDramaScene();

	if (!dramaScene || m_kParam.u3.bTimeout)
	{
		SetFinish(true);
		SetCanExcuteNextCommand(true);
		return;
	}

	if (!m_kParam.u2.bTimeStart)
	{
		m_timer.SetTimer(this, TAG_TIME_WAIT, m_kParam.u1.fTime);

		m_kParam.u2.bTimeStart = true;
	}
}
Ejemplo n.º 11
0
void DramaCommandSprite::ExcuteSetPostion()
{
	NDAsssert(DCT_SETSPRITEPOS == m_kParam.type);

	SetFinish(true);

	DramaScene* dramaScene = GetDramaScene();

	if (!dramaScene)
	{
		return;
	}

	NDSprite* sprite = dramaScene->GetSprite(m_kParam.u3.nTargetKey);
	if (!sprite)
	{
		return;
	}

	sprite->SetPosition(ccp(m_kParam.u1.nPosX, m_kParam.u2.nPoxY));
}
Ejemplo n.º 12
0
void DramaCommandScene::ExcuteFinishDrama()
{
	NDAsssert(DCT_OVER == m_kParam.type);

	SetFinish(true);

	NDDirector* director = NDDirector::DefaultDirector();
	if (!director)
	{
		return;
	}

	DramaScene* dramaScene = GetDramaScene();

	if (!dramaScene)
	{
		return;
	}

	NDScene* pkRunScene = NULL;
	while ((pkRunScene = director->GetRunningScene()))
	{
		bool bfind = pkRunScene->IsKindOfClass(RUNTIME_CLASS(DramaScene));
		if (!director->PopScene(true) || bfind)
		{
			break;
		}
	}

#if 0
	//继续战斗
	if (BattleMgrObj.GetBattle() != NULL){
		ScriptMgrObj.excuteLuaFunc("DramaEnd", "Drama");
		BattleMgrObj.BattleContinue();
	}
#endif

	DramaCommandBase::ResetKeyAlloc();
}
Ejemplo n.º 13
0
void DramaCommandSprite::ExcuteSetAnimation()
{
	NDAsssert(DCT_SETSPRITEANI == m_kParam.type);

	SetFinish(true);

	DramaScene* dramaScene = GetDramaScene();

	if (!dramaScene)
	{
		return;
	}

	NDSprite* sprite = dramaScene->GetSprite(m_kParam.u3.nTargetKey);

	if (!sprite)
	{
		return;
	}

	sprite->SetCurrentAnimation(m_kParam.u1.nAniIndex, sprite->IsReverse());
}
Ejemplo n.º 14
0
void DramaCommandScene::ExcuteLoadEraseScene()
{
	NDAsssert(DCT_LOADERASESCENE == m_kParam.type);

	SetFinish(true);

	DramaScene* dramaScene = GetDramaScene();

	if (!dramaScene)
	{
		return;
	}

	DramaTransitionScene* scene = new DramaTransitionScene;
	scene->Init();
	scene->SetText(m_kParam.str, m_kParam.u2.nFontSize, m_kParam.u1.nFontColor);

	if (!dramaScene->PushScene(m_kParam.nKey, scene))
	{
		delete scene;
	}
}
Ejemplo n.º 15
0
void DramaCommandSprite::ExcuteAddSprite()
{
	NDAsssert(DCT_ADDSPRITE == m_kParam.type);

	SetFinish(true);

	DramaScene* pkDramaScene = GetDramaScene();

	if (!pkDramaScene)
	{
		return;
	}

	switch (m_kParam.u2.nSpriteType) {
		case ST_PLAYER:
			pkDramaScene->AddManuRole(m_kParam.nKey, m_kParam.u1.nLookFace, m_kParam.u3.bFaceRight);
			break;
		case ST_NPC:
			pkDramaScene->AddNpc(m_kParam.nKey, m_kParam.u1.nLookFace, m_kParam.u3.bFaceRight);
			break;
		case ST_MONSTER:
			pkDramaScene->AddMonster(m_kParam.nKey, m_kParam.u1.nLookFace, m_kParam.u3.bFaceRight);
			break;
		default:
			break;
	}

	NDSprite* sprite = pkDramaScene->GetSprite(m_kParam.nKey);

	if (sprite && sprite->IsKindOfClass(RUNTIME_CLASS(NDBaseRole)))
	{
		((NDBaseRole*) sprite)->SetName( m_kParam.str );
	}
	if (sprite && sprite->IsKindOfClass(RUNTIME_CLASS(NDMonster)))
	{
		//((NDMonster*)sprite)->SetNameColor(ccc4(0, 255, 0, 255));
	}
}
Ejemplo n.º 16
0
void DramaCommandSprite::ExcuteAddSpriteByFile()
{
	NDAsssert(DCT_ADDSPRITEBYFILE == m_kParam.type);
	
	SetFinish(true);

	DramaScene* pkDramaScene = GetDramaScene();

	if (!pkDramaScene)
	{
		return;
	}

	char sprFile[256] = { 0 };
	sprintf(sprFile, "%s", NDPath::GetAniPath(m_kParam.str.c_str()).c_str());
	pkDramaScene->AddSprite(m_kParam.nKey, sprFile);

	NDSprite* sprite = pkDramaScene->GetSprite(m_kParam.nKey);

	if (sprite && sprite->IsKindOfClass(RUNTIME_CLASS(NDBaseRole)))
	{
		sprite->SetCurrentAnimation(0, false);
	}
}
Ejemplo n.º 17
0
  void LocalMapping::RunClient() {

    mbFinished = false;

    while(1) {
      // Tracking will see that Local Mapping is busy
      SetAcceptKeyFrames(false);

      // Check if there are keyframes in the queue
      if(CheckNewKeyFrames()) {
        // Get Communicator Mutex -> Comm cannot publish. Assure no publishing whilst changing data
        //            if(mpComm->mbStrictLock) unique_lock<mutex> lockComm(mpComm->mMutexForMapping);
        if(mVerboseMode == -9) {
          cout << "xxx Mapping --> Lock Mapping xxx" << endl;
        }

        if(mVerboseMode == -9) {
          cout << "LockSleep: " << mpCC->mLockSleep << endl;
        }

        if(mpComm->mbStrictLock) while(!mpCC->LockMapping()) {
            usleep(mpCC->mLockSleep);
          }

        if(mVerboseMode == -9) {
          cout << "xxx Mapping --> Mapping Locked xxx" << endl;
        }

        // BoW conversion and insertion in Map
        ProcessNewKeyFrame();

        // Check recent MapPoints
        MapPointCulling();

        // Triangulate new MapPoints
        CreateNewMapPoints();

        if(!CheckNewKeyFrames()) {
          // Find more matches in neighbor keyframes and fuse point duplications
          SearchInNeighbors();
        }

        mbAbortBA = false;

        if(!CheckNewKeyFrames() && !stopRequested()) {
          // Local BA
          if(mpMap->KeyFramesInMap() > 2) {
            Optimizer::LocalBundleAdjustmentClient(mpCurrentKeyFrame, &mbAbortBA, mpMap, mpComm, mClientId);
          }

          //                // Check redundant local Keyframes
          //                KeyFrameCulling();
        }

        if(mpComm->mbStrictLock) {
          mpCC->UnLockMapping();
        }

      } else if(Stop()) {
        // Safe area to stop
        while(isStopped() && !CheckFinish()) {
          usleep(mMappingRate);
        }

        if(CheckFinish()) {
          break;
        }
      }

      ResetIfRequested();

      // Tracking will see that Local Mapping is busy
      SetAcceptKeyFrames(true);

      if(CheckFinish()) {
        break;
      }

      usleep(mMappingRate);
    }

    SetFinish();
  }
Ejemplo n.º 18
0
CAnimationItem& CAnimationItem::SetPoint( CPoint pt )
{
	SetStart( pt );
	return SetFinish( pt );
}
Ejemplo n.º 19
0
void DramaCommandSoundEffect::excute()
{
	ScriptMgrObj.excuteLuaFunc("PlayEffectSound", "Music", m_kParam.nKey);
	SetFinish(true);
	SetCanExcuteNextCommand(true);
}
Ejemplo n.º 20
0
void DramaCommandSprite::ExcuteMoveSprite()
{
	NDAsssert(DCT_MOVESPRITE == m_kParam.type);

	DramaScene* dramaScene = GetDramaScene();

	if (!dramaScene)
	{
		SetFinish(true);
		return;
	}

	NDSprite* sprite = dramaScene->GetSprite(m_kParam.nKey);
	if (!sprite)
	{
		SetFinish(true);
		return;
	}
	
	bool bRight   = false;
	bool bXArrive = false;
	bool bYArrive = false;
	CCPoint curPos = sprite->GetPosition();
	if (abs(int(curPos.x) - m_kParam.u1.nToPosX) <= m_kParam.u3.nMoveStep)
	{
		curPos.x = m_kParam.u1.nToPosX;
		bXArrive = true;
	}
	else if (int(curPos.x) > m_kParam.u1.nToPosX)
	{
		curPos.x -= m_kParam.u3.nMoveStep;
	}
	else if (int(curPos.x) < m_kParam.u1.nToPosX)
	{
		curPos.x += m_kParam.u3.nMoveStep;
		bRight = true;
	}

	if (abs(int(curPos.y) - m_kParam.u2.nToPosY) <= m_kParam.u3.nMoveStep)
	{
		curPos.y = m_kParam.u2.nToPosY;
		bYArrive = true;
	}
	else if (int(curPos.y) > m_kParam.u2.nToPosY)
	{
		curPos.y -= m_kParam.u3.nMoveStep;
	}
	else if (int(curPos.y) < m_kParam.u2.nToPosY)
	{
		curPos.y += m_kParam.u3.nMoveStep;
	}

	sprite->SetSpriteDir(bRight ? 0 : 2);
	sprite->SetCurrentAnimation(MANUELROLE_WALK, sprite->IsReverse());
	sprite->SetPosition(curPos);

	if (bXArrive && bYArrive)
	{
		sprite->SetCurrentAnimation(0, m_kParam.bRightTmp ? 2 : 0);
		SetFinish(true);
		return;
	}
	m_kParam.bRightTmp = bRight;
}