本文整理汇总了C++中Character::GetNum方法的典型用法代码示例。如果您正苦于以下问题:C++ Character::GetNum方法的具体用法?C++ Character::GetNum怎么用?C++ Character::GetNum使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Character
的用法示例。
在下文中一共展示了Character::GetNum方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Strategy
void CreatureManager::Strategy()
{
//当前有单位行动中,等待其行动完成
if(m_nActionCreatureNum != -1)
return;
ResetAllCreature();
if (m_eCampTurn == eCampTurn_Enemy)
{
Character* enemy = GetNextEnemy();
if(enemy == NULL)
return;
if(enemy->GetActionStage() == eActionStage_WaitStage)
{
enemy->SetActionStage(eActionStage_MoveStage);
m_nActionCreatureNum = enemy->GetNum();
//m_nSelectNum = m_nActionCreatureNum;
int xMove = g_RandomInt(0,enemy->GetMoveAbility());
int yMove = enemy->GetMoveAbility() - xMove;
int xDir = (g_RandomInt(0,1)==0)?-1:1;
int yDir = (g_RandomInt(0,1)==0)?-1:1;
eErrorCode errorCode = enemy->Move(enemy->GetBlock().xpos+xMove*xDir,enemy->GetBlock().ypos+yMove*yDir);
//测试
if (errorCode != eErrorCode_Success)
{
enemy->SetFinish(true);
}
}
}
// enemy->Move((Direction)(App::sInstance().GetHGE()->Random_Int(0,4)));
}
示例2: SelectCreature
void CreatureManager::SelectCreature()
{
//友方回合才可以进行选择操作,包括查看敌方行动范围
if (m_eCampTurn == eCampTurn_Friend)
{
Block mouseBlock = App::sInstance().GetMouseBlock();
Character* selectChar = NULL;
if (mouseBlock.xpos!=-1 && mouseBlock.ypos!=-1)
{
selectChar = GetCreature(mouseBlock.xpos,mouseBlock.ypos);
//选中单位
if(selectChar!=NULL)
{
//需要拦截点击操作界面的消息
if (g_getLButtonState(App::sInstance().GetHGE()) == eLButtonState_Up && !(UISystem::sInstance().GetWindow(eWindowID_Command)->IsOnControl()))
{
int nLastSelect = m_nSelectNum;
if (selectChar->GetCamp() == eCamp_Friend )
{
//上次没有选择单位
if(nLastSelect == -1)
{
//选中的未行动友方进入移动阶段
if(!selectChar->GetFinish())
{
m_nSelectNum = selectChar->GetNum();
selectChar->SetActionStage(eActionStage_MoveStage);
}
}
//连续两次点击同一友方单位
else if(nLastSelect == selectChar->GetNum())
{
if(!selectChar->GetFinish())
{
//跳过移动阶段,进入操作阶段
selectChar->SetActionStage(eActionStage_HandleStage);
//打开操作界面
UIWindow* commandWindow = UISystem::sInstance().GetWindow(eWindowID_Command);
if(commandWindow)
{
commandWindow->SetShow(true);
commandWindow->SetBindChar(selectChar);
}
}
}
//其他情况
else
{
Character* lastChar = GetCreature(nLastSelect);
if(lastChar != NULL)
{
//上次点的是别的友方
if(lastChar->GetCamp() == eCamp_Friend)
{
if(lastChar->GetFinish() && !selectChar->GetFinish())
{
m_nSelectNum = selectChar->GetNum();
selectChar->SetActionStage(eActionStage_MoveStage);
}
// //上次的友方返回至待命阶段
// lastChar->SetActionStage(eActionStage_WaitStage);
// selectChar->SetActionStage(eActionStage_MoveStage);
}
else if(lastChar->GetCamp() == eCamp_Enemy)
{
if(!selectChar->GetFinish())
{
m_nSelectNum = selectChar->GetNum();
selectChar->SetActionStage(eActionStage_MoveStage);
}
}
}
else
//这里是错误分支,不可以运行到这里
return;
}
}
else if (selectChar->GetCamp() == eCamp_Enemy)
{
Character* lastChar = GetCreature(nLastSelect);
if(lastChar!=NULL)
{
if(lastChar->GetCamp()==eCamp_Friend)
{
if(lastChar->GetActionStage() == eActionStage_AttackStage)
{
//判断是否可以攻击到选中单位
if(lastChar->CanHitTarget(selectChar))
{
lastChar->SetTarget(selectChar->GetNum());
lastChar->GeginHit();
m_nSelectNum = -1;
return;
}
}
}
else if (lastChar->GetCamp() == eCamp_Enemy)
{
m_nSelectNum = selectChar->GetNum();
}
//.........这里部分代码省略.........
示例3: SelectCreature
void CreatureManager::SelectCreature()
{
//友方回合才可以进行选择操作,包括查看敌方行动范围
if (m_eCampTurn == eCampTurn_Friend)
{
Block mouseBlock = App::sInstance().GetMouseBlock();
Character* selectChar = NULL;
if (mouseBlock.xpos!=-1 && mouseBlock.ypos!=-1)
{
selectChar = GetCreature(mouseBlock.xpos,mouseBlock.ypos);
//选中单位
if(selectChar!=NULL)
{
if (g_getLButtonState(App::sInstance().GetHGE()) == eLButtonState_Up)
{
int nLastSelect = m_nSelectNum;
if (selectChar->GetCamp() == eCamp_Friend )
{
//上次没有选择单位
if(nLastSelect == -1)
{
//选中的未行动友方进入移动阶段
if(!selectChar->GetFinish())
{
m_nSelectNum = selectChar->GetNum();
selectChar->SetActionStage(eActionStage_MoveStage);
}
}
//连续两次点击同一友方单位
else if(nLastSelect == m_nSelectNum)
{
//过滤移动阶段,进入攻击阶段
selectChar->SetActionStage(eActionStage_AttackStage);
}
//其他情况
else
{
Character* lastChar = GetCreature(nLastSelect);
if(lastChar != NULL)
{
//上次点的是别的友方
if(lastChar->GetCamp() == eCamp_Friend)
{
// //上次的友方返回至待命阶段
// lastChar->SetActionStage(eActionStage_WaitStage);
// selectChar->SetActionStage(eActionStage_MoveStage);
}
else if(lastChar->GetCamp() == eCamp_Enemy)
{
if(!selectChar->GetFinish())
{
m_nSelectNum = selectChar->GetNum();
selectChar->SetActionStage(eActionStage_MoveStage);
}
}
}
else
//这里是错误分支,不可以运行到这里
return;
}
}
else if (selectChar->GetCamp() == eCamp_Enemy)
{
Character* lastChar = GetCreature(nLastSelect);
if(lastChar!=NULL)
{
if(lastChar->GetCamp()==eCamp_Friend)
{
if(lastChar->GetActionStage() == eActionStage_AttackStage)
{
//判断是否可以攻击到选中单位
eAttackRange attackRange = lastChar->GetAttackRange();
int tarX = 0,tarY = 0;
for (MAttackRange::iterator mit=m_mAttackRange.begin();mit!=m_mAttackRange.end();mit++)
{
if(mit->first == attackRange)
{
for (vector<Pair>::iterator it=mit->second.begin();it!=mit->second.end();it++)
{
tarX = it->x + lastChar->GetBlock().xpos;
tarY = it->y + lastChar->GetBlock().ypos;
if(selectChar->GetBlock().xpos == tarX && selectChar->GetBlock().ypos == tarY)
{
//在攻击范围内
lastChar->SetTarget(selectChar->GetNum());
lastChar->GeginHit();
m_nSelectNum = -1;
return;
}
}
}
}
}
}
else if (lastChar->GetCamp() == eCamp_Enemy)
{
m_nSelectNum = selectChar->GetNum();
}
}
else
//.........这里部分代码省略.........