本文整理汇总了C++中CvPlot::setBonusType方法的典型用法代码示例。如果您正苦于以下问题:C++ CvPlot::setBonusType方法的具体用法?C++ CvPlot::setBonusType怎么用?C++ CvPlot::setBonusType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CvPlot
的用法示例。
在下文中一共展示了CvPlot::setBonusType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addNonUniqueBonusType
void CvMapGenerator::addNonUniqueBonusType(BonusTypes eBonusType)
{
int iBonusCount = calculateNumBonusesToAdd(eBonusType);
if (iBonusCount == 0)
{
return;
}
std::vector<int> aiShuffle(GC.getMapINLINE().numPlotsINLINE());
GC.getGameINLINE().getMapRand().shuffleSequence(aiShuffle, "addNonUniqueBonusType shuffle");
CvBonusInfo& pBonusInfo = GC.getBonusInfo(eBonusType);
bool bIgnoreLatitude = false;
gDLL->getPythonIFace()->pythonIsBonusIgnoreLatitudes(&bIgnoreLatitude);
CvPlot* pPlot = NULL;
for (int iI = 0; iI < GC.getMapINLINE().numPlotsINLINE(); iI++)
{
pPlot = GC.getMapINLINE().plotByIndexINLINE(aiShuffle[iI]);
if (canPlaceBonusAt(eBonusType, pPlot->getX_INLINE(), pPlot->getY_INLINE(), bIgnoreLatitude))
{
pPlot->setBonusType(eBonusType);
iBonusCount--;
for (int iDX = -(pBonusInfo.getGroupRange()); iDX <= pBonusInfo.getGroupRange(); iDX++)
{
for (int iDY = -(pBonusInfo.getGroupRange()); iDY <= pBonusInfo.getGroupRange(); iDY++)
{
if (iBonusCount > 0)
{
CvPlot* pLoopPlot = plotXY(pPlot->getX_INLINE(), pPlot->getY_INLINE(), iDX, iDY);
if (pLoopPlot != NULL)
{
if (canPlaceBonusAt(eBonusType, pLoopPlot->getX_INLINE(), pLoopPlot->getY_INLINE(), bIgnoreLatitude))
{
if (GC.getGameINLINE().getMapRandNum(100, "addNonUniqueBonusType") < pBonusInfo.getGroupRand())
{
pLoopPlot->setBonusType(eBonusType);
iBonusCount--;
}
}
}
}
}
}
FAssertMsg(iBonusCount >= 0, "iBonusCount must be >= 0");
if (iBonusCount == 0)
{
break;
}
}
}
}
示例2: eraseBonuses
void CvMapGenerator::eraseBonuses()
{
for (int i = 0; i < GC.getMapINLINE().numPlotsINLINE(); i++)
{
CvPlot* pPlot = GC.getMapINLINE().plotByIndexINLINE(i);
pPlot->setBonusType(NO_BONUS);
}
}
示例3: addUniqueBonusType
void CvMapGenerator::addUniqueBonusType(BonusTypes eBonusType)
{
int* piAreaTried = new int[GC.getMapINLINE().getNumAreas()];
for (int iI = 0; iI < GC.getMapINLINE().getNumAreas(); iI++)
{
piAreaTried[iI] = FFreeList::INVALID_INDEX;
}
CvBonusInfo& pBonusInfo = GC.getBonusInfo(eBonusType);
int iBonusCount = calculateNumBonusesToAdd(eBonusType);
bool bIgnoreLatitude = false;
gDLL->getPythonIFace()->pythonIsBonusIgnoreLatitudes(&bIgnoreLatitude);
FAssertMsg(pBonusInfo.isOneArea(), "addUniqueBonusType called with non-unique bonus type");
while (true)
{
int iBestValue = 0;
int iLoop = 0;
CvArea *pBestArea = NULL;
CvArea *pLoopArea = NULL;
for(pLoopArea = GC.getMapINLINE().firstArea(&iLoop); pLoopArea != NULL; pLoopArea = GC.getMapINLINE().nextArea(&iLoop))
{
bool bTried = false;
for (int iI = 0; iI < GC.getMapINLINE().getNumAreas(); iI++)
{
if (pLoopArea->getID() == piAreaTried[iI])
{
bTried = true;
break;
}
}
if (!bTried)
{
int iNumUniqueBonusesOnArea = pLoopArea->countNumUniqueBonusTypes() + 1; // number of unique bonuses starting on the area, plus this one
int iNumTiles = pLoopArea->getNumTiles();
int iValue = iNumTiles / iNumUniqueBonusesOnArea;
if (iValue > iBestValue)
{
iBestValue = iValue;
pBestArea = pLoopArea;
}
}
}
if (pBestArea == NULL)
{
break; // can't place bonus on any area
}
for (int iI = 0; iI < GC.getMapINLINE().getNumAreas(); iI++)
{
if (piAreaTried[iI] == FFreeList::INVALID_INDEX)
{
piAreaTried[iI] = pBestArea->getID();
break;
}
}
// Place the bonuses:
std::vector<int> aiShuffle(GC.getMapINLINE().numPlotsINLINE());
GC.getGameINLINE().getMapRand().shuffleSequence(aiShuffle, "addUniqueBonusType shuffle");
for (int iI = 0; iI < GC.getMapINLINE().numPlotsINLINE(); iI++)
{
CvPlot* pPlot = GC.getMapINLINE().plotByIndexINLINE(aiShuffle[iI]);
FAssertMsg(pPlot != NULL, "addUniqueBonusType(): pPlot is null");
if (GC.getMapINLINE().getNumBonuses(eBonusType) >= iBonusCount)
{
break; // We already have enough
}
if (pBestArea == pPlot->area())
{
if (canPlaceBonusAt(eBonusType, pPlot->getX_INLINE(), pPlot->getY_INLINE(), bIgnoreLatitude))
{
pPlot->setBonusType(eBonusType);
for (int iDX = -(pBonusInfo.getGroupRange()); iDX <= pBonusInfo.getGroupRange(); iDX++)
{
for (int iDY = -(pBonusInfo.getGroupRange()); iDY <= pBonusInfo.getGroupRange(); iDY++)
{
if (GC.getMapINLINE().getNumBonuses(eBonusType) < iBonusCount)
{
CvPlot* pLoopPlot = plotXY(pPlot->getX_INLINE(), pPlot->getY_INLINE(), iDX, iDY);
if (pLoopPlot != NULL && (pLoopPlot->area() == pBestArea))
{
if (canPlaceBonusAt(eBonusType, pLoopPlot->getX_INLINE(), pLoopPlot->getY_INLINE(), bIgnoreLatitude))
{
if (GC.getGameINLINE().getMapRandNum(100, "addUniqueBonusType") < pBonusInfo.getGroupRand())
//.........这里部分代码省略.........