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


C++ CUnit::GetType方法代码示例

本文整理汇总了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)");

}
开发者ID:slewicki,项目名称:khanquest,代码行数:32,代码来源:CFactory.cpp

示例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)");


}
开发者ID:slewicki,项目名称:khanquest,代码行数:76,代码来源:CFactory.cpp

示例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;
开发者ID:Jon-Stumpfel,项目名称:league-of-champion-craft,代码行数:66,代码来源:GameManager.cpp


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