本文整理汇总了C++中CCharacter::GetPos方法的典型用法代码示例。如果您正苦于以下问题:C++ CCharacter::GetPos方法的具体用法?C++ CCharacter::GetPos怎么用?C++ CCharacter::GetPos使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCharacter
的用法示例。
在下文中一共展示了CCharacter::GetPos方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Collision
//-----------------------------------------------------------------------------//
// 충돌이 일어나면 이 함수가 호출된다.
// TestNum : 1 = 주인공이 공격한후 충돌체크
// 2 = 적이 공격한후 충돌체크
// ICollisionable : 충돌한 객체 포인터
//-----------------------------------------------------------------------------//
void CCharacter::Collision( int TestNum, ICollisionable *pObj )
{
if( CHAR_HERO == m_Group )
{
switch( TestNum )
{
case 1:
break;
case 2:
{
int damage = 0;
ATTACK_TYPE type = NONE;
Vector3 dir(0,0,0);
CCharacter *p = (CCharacter*)pObj;
if( p->m_pCurAct )
{
damage = p->m_pCurAct->damage;
type = (ATTACK_TYPE)p->m_pCurAct->attack_type;
dir = GetPos() - p->GetPos();
dir.Normalize();
}
Damage( type, damage, &dir );
}
break;
}
}
else if( CHAR_ENEMY == m_Group )
{
switch( TestNum )
{
case 1:
{
int damage = 0;
ATTACK_TYPE type = NONE;
Vector3 dir(0,0,0);
CCharacter *p = (CCharacter*)pObj;
if( p->m_pCurAct )
{
damage = p->m_pCurAct->damage;
type = (ATTACK_TYPE)p->m_pCurAct->attack_type;
dir = GetPos() - p->GetPos();
dir.Normalize();
}
Damage( type, damage, &dir );
}
break;
case 2:
break;
}
}
}
示例2: EvaluateSpawnPos
float IGameController::EvaluateSpawnPos(int WorldID, CSpawnEval *pEval, vec2 Pos) const
{
float Score = 0.0f;
CCharacter *pC = static_cast<CCharacter *>(GameServer()->m_World[WorldID].FindFirst(MOD_ENTTYPE_CHARACTER));
for(; pC; pC = (CCharacter *)pC->TypeNext())
{
// team mates are not as dangerous as enemies
float Scoremod = 1.0f;
if(pEval->m_FriendlyTeam != -1 && pC->GetPlayer()->GetTeam() == pEval->m_FriendlyTeam)
Scoremod = 0.5f;
float d = distance(Pos, pC->GetPos());
Score += Scoremod * (d == 0 ? 1000000000.0f : 1.0f/d);
}
return Score;
}
示例3: ChatCmds
//.........这里部分代码省略.........
if(!GetPlayerChar(ClientID))
{
SendChatTarget(ClientID, "Wait to respawn to do this");
return;
}
for(int i = 0; i < NUM_WEAPONS; i++)
{
if(i == WEAPON_NINJA)
continue;
GetPlayerChar(ClientID)->GiveWeapon(i, 10);//On peut mettre -1 aussi pour munitions illimités, mais si on met -1 ça va ramasser les armes.
}
SendChatTarget(ClientID, "You now have all weapons");
return;
}
if(!str_comp_nocase(pMsg, "immu"))
{
if(!IsAdmin)
{
SendChatTarget(ClientID, "You are not an admin");
return;
}
pPlayer->m_Immunity ^= true;
SendChatTarget(ClientID, pPlayer->m_Immunity ? "Immunity enabled !" : "Immunity disabled.");
CCharacter *pChar = GetPlayerChar(ClientID);
if(!pChar)
return;
CreateDeath(pChar->GetPos(), ClientID);
return;
}
/*if(!str_comp_nocase(pMsg, "fullinvisible"))
{
if(!IsAdmin)
{
SendChatTarget(ClientID, "You are not an admin");
return;
}
pPlayer->m_FullInvisible ^= true;
SendChatTarget(ClientID, pPlayer->m_Immunity ? "Fullinvisible enabled !" : "Fullinvisible disabled.");
char aBuf[256];
if(pPlayer->m_FullInvisible)
{
str_format(aBuf, sizeof(aBuf), "'%s' has left the game", Server()->ClientName(ClientID));
SendChatTarget(-1, aBuf);
}
else
{
//faudra changer ça si tu veux faire plus réaliste, quand tu auras des comptes
//pck tu vas entrer en spec avant, si y a pas le message de spec ça va paraitre (je l'ai mal écrit mais osef) chelou
str_format(aBuf, sizeof(aBuf), "'%s' entered and joined the game", Server()->ClientName(ClientID));
SendChatTarget(-1, aBuf);
m_SendMsgTick = Server()->TickSpeed() * 2;
m_SendMsgID = ClientID;
}
return;
}*/
示例4: OnDirectInput
void CPlayer::OnDirectInput(CNetObj_PlayerInput *NewInput)
{
if(GameServer()->m_World.m_Paused)
{
m_PlayerFlags = NewInput->m_PlayerFlags;
return;
}
if(NewInput->m_PlayerFlags&PLAYERFLAG_CHATTING)
{
// skip the input if chat is active
if(m_PlayerFlags&PLAYERFLAG_CHATTING)
return;
// reset input
if(m_pCharacter)
m_pCharacter->ResetInput();
m_PlayerFlags = NewInput->m_PlayerFlags;
return;
}
m_PlayerFlags = NewInput->m_PlayerFlags;
if(m_pCharacter)
m_pCharacter->OnDirectInput(NewInput);
if(!m_pCharacter && m_Team != TEAM_SPECTATORS && (NewInput->m_Fire&1))
Respawn();
if(!m_pCharacter && m_Team == TEAM_SPECTATORS && (NewInput->m_Fire&1))
{
if(!m_ActiveSpecSwitch)
{
m_ActiveSpecSwitch = true;
if(m_SpecMode == SPEC_FREEVIEW)
{
CCharacter *pChar = (CCharacter *)GameServer()->m_World.ClosestEntity(m_ViewPos, 6.0f*32, CGameWorld::ENTTYPE_CHARACTER, 0);
CFlag *pFlag = (CFlag *)GameServer()->m_World.ClosestEntity(m_ViewPos, 6.0f*32, CGameWorld::ENTTYPE_FLAG, 0);
if(pChar || pFlag)
{
if(!pChar || (pFlag && pChar && distance(m_ViewPos, pFlag->GetPos()) < distance(m_ViewPos, pChar->GetPos())))
{
m_SpecMode = pFlag->GetTeam() == TEAM_RED ? SPEC_FLAGRED : SPEC_FLAGBLUE;
m_pSpecFlag = pFlag;
m_SpectatorID = -1;
}
else
{
m_SpecMode = SPEC_PLAYER;
m_pSpecFlag = 0;
m_SpectatorID = pChar->GetPlayer()->GetCID();
}
}
}
else
{
m_SpecMode = SPEC_FREEVIEW;
m_pSpecFlag = 0;
m_SpectatorID = -1;
}
}
}
else if(m_ActiveSpecSwitch)
m_ActiveSpecSwitch = false;
// check for activity
if(NewInput->m_Direction || m_LatestActivity.m_TargetX != NewInput->m_TargetX ||
m_LatestActivity.m_TargetY != NewInput->m_TargetY || NewInput->m_Jump ||
NewInput->m_Fire&1 || NewInput->m_Hook)
{
m_LatestActivity.m_TargetX = NewInput->m_TargetX;
m_LatestActivity.m_TargetY = NewInput->m_TargetY;
m_LastActionTick = Server()->Tick();
m_InactivityTickCounter = 0;
}
}