当前位置: 首页>>代码示例>>C++>>正文


C++ CMonster::DoWalkAround方法代码示例

本文整理汇总了C++中CMonster::DoWalkAround方法的典型用法代码示例。如果您正苦于以下问题:C++ CMonster::DoWalkAround方法的具体用法?C++ CMonster::DoWalkAround怎么用?C++ CMonster::DoWalkAround使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CMonster的用法示例。


在下文中一共展示了CMonster::DoWalkAround方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: DoWalkAround

void CStateMachinen::DoWalkAround(CMonster& monster, eStateEvent evt)
{	
	const BASE_MONSTER_LIST& baseMonsterList = monster.GetSMonsterList();
	StateParameter& stateParamter = monster.mStateParamter;	
	
	if( monster.GetAbnormalStatus()->IsStun ||
		monster.GetAbnormalStatus()->IsFreezing ||
		monster.GetAbnormalStatus()->IsStone ||
		monster.GetAbnormalStatus()->IsSlip ||
		monster.GetAbnormalStatus()->IsMoveStop ||
		monster.GetAbnormalStatus()->IsParalysis )

	{
		SetState(
			&monster,
			eMA_STAND);
		return;
	}

	switch(evt)
	{
	case eSEVENT_Enter:
		{
			// 소유주가 있을 경우 그 중심으로 행동한다
			if(CObject* const ownerObject = g_pUserTable->FindUser(monster.GetOwnerIndex()))
			{
				if(ownerObject->GetObjectBattleState())
				{
					SetState(
						&monster,
						eMA_STAND);
					break;
				}

				VECTOR3 ownerPosition = {0};
				ownerObject->GetPosition(
					&ownerPosition);

				const float distance = ownerObject->GetRadius() * 3;
				VECTOR3 monsterPosition = {0};
				monster.GetPosition(
					&monsterPosition);

				if(distance > CalcDistanceXZ(&ownerPosition, &monsterPosition))
				{
					SetState(
						&monster,
						eMA_STAND);
					break;
				}

				const float randomRateX = float(rand()) / RAND_MAX;
				const float randomRateZ = float(rand()) / RAND_MAX;
				const float randomAxisX = (randomRateX < 0.5f ? -1.0f : 1.0f) * (ownerObject->GetRadius() * (1.0f + randomRateX));
				const float randomAxisZ = (randomRateZ < 0.5f ? -1.0f : 1.0f) * (ownerObject->GetRadius() * (1.0f + randomRateZ));

				monster.GetFiniteStateMachine().GetMemory().SetVariable(
					"__move_x__",
					int(ownerPosition.x + randomAxisX));
				monster.GetFiniteStateMachine().GetMemory().SetVariable(
					"__move_z__",
					int(ownerPosition.z + randomAxisZ));
				SetState(
					&monster,
					eMA_SCRIPT_RUN);

				// 이렇게 하지 않으면 eSEVENT_Process 루틴으로 들어가서 상태를 바꿔버린다
				stateParamter.nextTime = gCurTime + 500;
				break;
			}

            monster.SetTObject(0);
			monster.DoWalkAround();
			
			stateParamter.nextTime	= gCurTime + CCharMove::GetMoveEstimateTime(&monster);
			break;
		}

	case eSEVENT_Process:
		{
			if( stateParamter.nextTime > gCurTime )
			{
				break;
			}

			Mon_SpeechState speechState = eMon_Speech_MAX;
			const int rate = rand() % 100;

			if(0 <= rate && rate < baseMonsterList.StandRate )
			{
				SetState(
					&monster,
					eMA_STAND);
				speechState = eMon_Speech_Stand;
			}
			else
			{
				SetState(
					&monster,
					eMA_WALKAROUND);
//.........这里部分代码省略.........
开发者ID:xianyinchen,项目名称:LUNAPlus,代码行数:101,代码来源:StateMachinen.cpp


注:本文中的CMonster::DoWalkAround方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。