本文整理汇总了C++中CUnit::GetType方法的典型用法代码示例。如果您正苦于以下问题:C++ CUnit::GetType方法的具体用法?C++ CUnit::GetType怎么用?C++ CUnit::GetType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CUnit
的用法示例。
在下文中一共展示了CUnit::GetType方法的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: 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)");
}
示例3: SaveGame
//.........这里部分代码省略.........
CHero* pHero = dynamic_cast<CHero*>(GetChampion(m_vPlayers[i]->GetPlayerID()));
if (pHero == nullptr)
{
// Why are you here?
MessageBoxA(0, "How did you get here? Why are you saving when hero is dead? Go away. Don't save after you won",
"ERROR:", MB_OK);
continue;
}
if (pHero->GetNumWaypoints() > 0)
{
pChampion->SetAttribute("posX", pHero->GetLastWaypoint().nPosX);
pChampion->SetAttribute("posY", pHero->GetLastWaypoint().nPosY);
}
else
{
pChampion->SetAttribute("posX", pHero->GetPos().nPosX);
pChampion->SetAttribute("posY", pHero->GetPos().nPosY);
}
pChampion->SetAttribute("health", pHero->GetHP());
pChampion->SetAttribute("xp", m_vPlayers[i]->GetExp());
pChampion->SetAttribute("facing", pHero->GetFacing());
pChampion->SetAttribute("tilesMoved", pHero->GetTilesMoved());
pChampion->SetAttribute("hasAttacked", (int)pHero->GetHasAttacked());
// TODO: setup spell saving here
TiXmlElement* pSpells = new TiXmlElement("Spells");
pSpells->SetAttribute("numSpells", pHero->GetNumSpells());
pChampion->LinkEndChild(pSpells);
for (unsigned int n = 0; n < pHero->GetNumSpells(); ++n)
{
TiXmlElement* pSpell = new TiXmlElement("Spell");
pSpell->SetAttribute("sType", pHero->GetSpell(n)->GetType());
pSpell->SetAttribute("Cooldown", pHero->GetCooldown(n));
pSpells->LinkEndChild(pSpell);
}
TiXmlElement* pBoughtSpells = new TiXmlElement("BoughtSpells");
pBoughtSpells->SetAttribute("numBought", pHero->GetNumBought());
pChampion->LinkEndChild(pBoughtSpells);
for( int n = 0; n < pHero->GetNumBought(); n++ )
{
TiXmlElement* pBought = new TiXmlElement("Bought");
pBought->SetAttribute("Type", pHero->GetBought(n)->GetType());
pBoughtSpells->LinkEndChild(pBought);
}
TiXmlElement* pEffects = new TiXmlElement("Effects");
pChampion->LinkEndChild(pEffects);
pEffects->SetAttribute("numEffects", pHero->GetNumEffects());
for (int x = 0; x < pHero->GetNumEffects(); ++x)
{
TiXmlElement* pEffect = new TiXmlElement("Effect");
pEffect->SetAttribute("ability", pHero->GetEffect(x)->GetType());
pEffects->LinkEndChild(pEffect);
}
pPlayer->LinkEndChild(pChampion);
// Lets save the units!
TiXmlElement* pUnits = new TiXmlElement("Units");
pPlayer->LinkEndChild(pUnits);
int nNumUnits = 0;