本文整理汇总了C++中CUnit::GetSpeed方法的典型用法代码示例。如果您正苦于以下问题:C++ CUnit::GetSpeed方法的具体用法?C++ CUnit::GetSpeed怎么用?C++ CUnit::GetSpeed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CUnit
的用法示例。
在下文中一共展示了CUnit::GetSpeed方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreatePlayerUnit
void CFactory::CreatePlayerUnit(int nType)
{
PROFILE("CFactory::CreatePlayerUnit(int)");
//static float xPos = 100;
//static float yPos = 50;
CUnit* unit = new CUnit(nType);
// Use default shallow copy since no dynamic info in creation
CUnit temp = CGame::GetInstance()->GetUnitInfo(nType);
unit->SetAttackPower(temp.GetAttackPower());
unit->SetAttackSpeed(temp.GetAttackSpeed());
unit->SetMaxHP(temp.GetMaxHP());
unit->SetCurrentHP(temp.GetMaxHP());
unit->SetRange(temp.GetRange());
unit->SetSpeed(temp.GetSpeed());
unit->SetState(IDLE);
unit->SetDirection(SOUTH_WEST);
unit->SetIsPlayerUnit(true);
unit->SetAttackSoundID(CGame::GetInstance()->GetAttackSound(unit->GetType()));
// Register Events
unit->SetDeathSoundID(CGame::GetInstance()->GetDeathSound(unit->GetType()));
// Add to manager
ObjectManager::GetInstance()->AddObject(unit);
// Let it know we aren't hanging on to it
unit->Release();
STOP("CFactory::CreatePlayerUnit(int)");
}
示例2: Execute
void CScriptManager::Execute( CAbility* pAbility, CTile* pTile, CUnit* pCaster, CTile* TileCharged )
{
// Finds the facing for the specified unit
int face = pCaster->GetFacing();
std::vector< Vec2D > TilePos;
std::vector< Vec2D > pat;
if( pAbility->GetIfFacing() )
pat = CAbilityManager::GetInstance()->GetProperFacing(pCaster->GetFacing(), pAbility, pTile);
else
pat = pAbility->GetPattern();
for( unsigned int i = 0; i < pAbility->GetPattern().size(); i++ )
{
pat[i].nPosX += pTile->GetPosition().nPosX;
pat[i].nPosY += pTile->GetPosition().nPosY;
TilePos.push_back(pat[i]);
}
lua_getglobal(L, "OnUse");
lua_newtable(L);
CGameManager* pGM = CGameManager::GetInstance();
vector< CUnit* > affected;
int nCount = 0;
int z = (int)TilePos.size()-1;
for( int i = 0; i <= z; i++ )
{
CUnit* tmp = pGM->FindUnit(TilePos[i].nPosX, TilePos[i].nPosY);
if( pAbility->GetType() == SP_CHARGE || pAbility->GetType() == SP_RUSH )
{
if( TilePos[i] == TileCharged->GetPosition() )
break;
}
if( tmp == nullptr )
continue;
affected.push_back( tmp );
lua_newtable(L);
lua_pushstring(L, "posX");
lua_pushnumber(L, tmp->GetPos().nPosX);
lua_settable(L, -3);
lua_pushstring(L, "posY");
lua_pushnumber(L, tmp->GetPos().nPosY);
lua_settable(L, -3);
lua_pushstring(L, "health");
lua_pushnumber(L, tmp->GetHP());
lua_settable(L, -3);
lua_pushstring(L, "speed");
lua_pushnumber(L, tmp->GetSpeed());
lua_settable(L, -3);
lua_pushstring(L, "shielded");
lua_pushnumber(L, tmp->GetShielded());
lua_settable(L, -3);
lua_pushstring(L, "uniqueID");
lua_pushnumber(L, tmp->GetUniqueID());
lua_settable(L, -3);
lua_pushnumber(L, nCount+1);
nCount++;
lua_insert(L, -2);
lua_settable(L, -3);
}
lua_setglobal(L, "tUnitData");
std::string path = "Assets/Ability/" + pAbility->GetLua();
luaL_dofile(L, path.c_str());
lua_getglobal(L, "OnUse");
lua_pcall(L, 0, 0, 0);
lua_getglobal(L, "tUnitData");
lua_pushnil(L);
vector<std::pair<std::string, int>> tData;
// std::pair<std::string, int> tmp;
tData.clear();
while(lua_next(L, -2) != 0)
{
if( lua_istable(L, -1) )
{
lua_pushnil(L);
while( lua_next(L, -2) )
{
if(lua_isnumber(L, -1))
{
std::pair<std::string, int> tmp;
tmp.first = lua_tostring(L, -2);
tmp.second = (int)lua_tonumber(L, -1);
tData.push_back(tmp);
}
lua_pop(L, 1);
}
}
//.........这里部分代码省略.........
示例3: CreateComputerUnit
void CFactory::CreateComputerUnit(int nType)
{
PROFILE("CFactory::CreateComputerUnit(int)");
//static float xPos = 100;
//static float yPos = 50;
CUnit* unit = new CUnit(nType);
// Use default shallow copy since no dynamic info in creation
CUnit temp = CGame::GetInstance()->GetCPUUnitInfo(nType);
unit->SetAttackPower(temp.GetAttackPower());
unit->SetAttackSpeed(temp.GetAttackSpeed());
unit->SetMaxHP(temp.GetMaxHP());
unit->SetCurrentHP(temp.GetMaxHP());
unit->SetRange(temp.GetRange());
unit->SetSpeed(temp.GetSpeed());
unit->SetState(IDLE);
unit->SetDirection(NORTH_WEST);
unit->SetIsPlayerUnit(false);
// Register Events
unit->SetAttackSoundID(CGame::GetInstance()->GetAttackSound(unit->GetType()));
unit->SetDeathSoundID(CGame::GetInstance()->GetDeathSound(unit->GetType()));
switch(CGame::GetInstance()->GetSelectedCity()->GetID())
{
case KCITY1:
break;
case KCITY2:
unit->SetAttackPower(unit->GetAttackPower()+2);
break;
case KCITY3:
unit->SetAttackPower(unit->GetAttackPower()+2);
unit->SetAttackSpeed(unit->GetAttackSpeed()-(unit->GetAttackSpeed()*.2f));
unit->SetSpeed(unit->GetSpeed()-(unit->GetSpeed()*.5f));
break;
case XCITY1:
break;
case XCITY2:
unit->SetAttackPower(unit->GetAttackPower()+2);
break;
case XCITY3:
unit->SetAttackPower(unit->GetAttackPower()+2);
unit->SetAttackSpeed(unit->GetAttackSpeed()-(unit->GetAttackSpeed()*.2f));
unit->SetSpeed(unit->GetSpeed()-(unit->GetSpeed()*.5f));
break;
case JCITY1:
break;
case JCITY2:
unit->SetAttackPower(unit->GetAttackPower()+2);
break;
case JCITY3:
unit->SetAttackPower(unit->GetAttackPower()+2);
unit->SetAttackSpeed(unit->GetAttackSpeed()-(unit->GetAttackSpeed()*.2f));
unit->SetSpeed(unit->GetSpeed()-(unit->GetSpeed()*.5f));
break;
}
// Add to manager
ObjectManager::GetInstance()->AddObject(unit);
// Let it know we aren't hanging on to it
unit->Release();
STOP("CFactory::CreateComputerUnit(int)");
}