本文整理汇总了C++中CShipClass::IsPlayerShip方法的典型用法代码示例。如果您正苦于以下问题:C++ CShipClass::IsPlayerShip方法的具体用法?C++ CShipClass::IsPlayerShip怎么用?C++ CShipClass::IsPlayerShip使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CShipClass
的用法示例。
在下文中一共展示了CShipClass::IsPlayerShip方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateRandomShip
ALERROR CTranscendenceWnd::CreateRandomShip (CSystem *pSystem, CSovereign *pSovereign, CShip **retpShip)
// CreateRandomShip
//
// Creates a random ship
{
ALERROR error;
int i;
// Figure out the class
CShipClass *pShipClass;
if (m_dwIntroShipClass == 0)
{
do
pShipClass = m_Universe.GetShipClass(mathRandom(0, m_Universe.GetShipClassCount()-1));
while (pShipClass->GetScore() > 1000 || pShipClass->IsPlayerShip());
}
else
{
int i;
int iIndex = -1;
for (i = 0; i < m_Universe.GetShipClassCount(); i++)
if (m_Universe.GetShipClass(i)->GetUNID() == m_dwIntroShipClass)
{
iIndex = i;
break;
}
if (iIndex == -1 || (iIndex + 1) == m_Universe.GetShipClassCount())
pShipClass = m_Universe.GetShipClass(0);
else
pShipClass = m_Universe.GetShipClass(iIndex + 1);
m_dwIntroShipClass = 0;
}
// Normally we create a single ship, but sometimes we create lots
int iCount;
int iRoll = mathRandom(1, 100);
// Adjust the roll for capital ships
if (pShipClass->GetHullMass() >= 10000)
iRoll -= 9;
else if (pShipClass->GetHullMass() >= 1000)
iRoll -= 6;
if (iRoll == 100)
iCount = mathRandom(30, 60);
else if (iRoll >= 98)
iCount = mathRandom(10, 20);
else if (iRoll >= 95)
iCount = mathRandom(5, 10);
else if (iRoll >= 90)
iCount = mathRandom(2, 5);
else
iCount = 1;
// Create the ships
for (i = 0; i < iCount; i++)
{
CShip *pShip;
if ((error = pSystem->CreateShip(pShipClass->GetUNID(),
NULL,
pSovereign,
PolarToVector(mathRandom(0, 359), mathRandom(250, 2500) * g_KlicksPerPixel),
NullVector,
mathRandom(0, 359),
NULL,
&pShip)))
return error;
// Override the controller
CIntroShipController *pNewController = new CIntroShipController(this, pShip->GetController());
pShip->SetController(pNewController, false);
pNewController->SetShip(pShip);
pShip->SetData(CONSTLIT("IntroController"), CONSTLIT("True"));
*retpShip = pShip;
}
return NOERROR;
}