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


C++ Tower::GetElement方法代码示例

本文整理汇总了C++中Tower::GetElement方法的典型用法代码示例。如果您正苦于以下问题:C++ Tower::GetElement方法的具体用法?C++ Tower::GetElement怎么用?C++ Tower::GetElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Tower的用法示例。


在下文中一共展示了Tower::GetElement方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: GetStrength

//shows the strength of a tower
int TowerRules::GetStrength(Ref & t)
{
    Tower * to = (Tower*) &t;
    
    int a;
    
    // 1 second / inbetweenAttacksPeriod 
    if(to->GetElement() == ElementalAffinity::Fire)
    {
        //return ((to->attackPoints + this->addFireDamage) * (1/to->inbetweenAttacksPeriod)) / 50;
        a = ((this->elementsAmplifier * to->attackPoints) + this->addFireDamage) + (1/to->inbetweenAttacksPeriod) / 1000;
        //std::cout << "\n\n test strength test: " << a << "\n\n";
        return a;
    }
    else if(to->GetElement() == ElementalAffinity::Earth)
    {
        a = ((this->elementsAmplifier * to->attackPoints) + this->addEarthDamage) + (1/to->inbetweenAttacksPeriod) / 1000;
        //std::cout << "\n\n test strength test: " << a << "\n\n";
        return a;
    }
    else if(to->GetElement() == ElementalAffinity::Water)
    {
        a = ((this->elementsAmplifier * to->attackPoints) + this->addWaterDamage) + (1/to->inbetweenAttacksPeriod) / 1000;
        //std::cout << "\n\n test strength test: " << a << "\n\n";
        return a;
    }
    else if(to->GetElement() == ElementalAffinity::Shock)
    {
        a = ((this->elementsAmplifier * to->attackPoints) + this->addShockDamage) + (1/to->inbetweenAttacksPeriod) / 1000;
        //std::cout << "\n\n test strength test: " << a << "\n\n";
        return a;
    }
    else // element == none
    {
        //return ((to->attackPoints) * (1/to->inbetweenAttacksPeriod)) /50 ;
        a = ((this->elementsAmplifier * to->attackPoints) ) + (1/to->inbetweenAttacksPeriod) / 1000;
        //std::cout << "\n\n test strength test: " << a << "\n\n";
        return a;
    }
}
开发者ID:geofl,项目名称:tdai,代码行数:41,代码来源:TowerRules.cpp

示例2: UpgradeToEarth

bool TowerRules::UpgradeToEarth(Ref* p, Ref & u)
{
    Tower *t = (Tower*)&u;
    if( t->GetElement() == ElementalAffinity::None && ((Player*)p)->GetCurrency() >= this->earthUpgradeCost )
    {
        t->SetElement(ElementalAffinity::Earth);
        ((Player*)p)->RemoveCoins(this->earthUpgradeCost);
        return true;
    }
    else
    {
        return false;
    }
}
开发者ID:geofl,项目名称:tdai,代码行数:14,代码来源:TowerRules.cpp

示例3: if

void GeneticAlgorithmProfile1::SimulationForward(ThreadData* td, AdditionalTowers& at)
{
    GameScene* gs = ((GameScene*)td->_sc);
    
    std::cout << "\[email protected]@@@@@@@@@@@@@@@@@@@@@@";
    std::cout << "\nADDITIONAL TOWERS DBG";
    
    td->bkCurrency = gs->playerHandler->GetCurrency();
    
    std::cout << "\nplayerMoney : " << gs->playerHandler->GetCurrency();
    
    //AI -> forward
    for ( int i = 0; i < 20; i++ )
    {
        //FIRST CASE : enough money for placing tower and upgrading it to an element
        if(gs->playerHandler->GetCurrency() >= (50 + 500))
        {
            Tower* n1 = new Tower(*gs, Settings::towerTexture, ((GameScene*)td->_sc)->playerHandler->tw);
            n1->setPosition(gs->getMapInfo()->GetRandomPointMidByType(MapInfoType::SimTowerPlace));
            
            n1->SetHitPositions(gs->getMapInfo());
            n1->SetStartingStats(Settings::towerAttackRange, Settings::towerAttackPoints, Settings::towerInbetweenAttacksPeriod, Settings::towerCost);
            
            at.additionalTowers.push_back(n1);
            
            gs->playerHandler->RemoveCoins(Settings::towerCost);
            
            
            if(gs->playerHandler->GetCurrency() >= 500) //element can be upgraded
            {
                int numOfFire, numOfWater, numOfEarth, numOfShock = 0;
                for(int a = 0; a < at.additionalTowers.size(); a++ )
                {
                    if(at.additionalTowers[a]->GetElement() == ElementalAffinity::Fire)
                    {
                        numOfFire++;
                    }
                    else if(at.additionalTowers[a]->GetElement() == ElementalAffinity::Water)
                    {
                        numOfWater++;
                    }
                    else if(at.additionalTowers[a]->GetElement() == ElementalAffinity::Earth)
                    {
                        numOfEarth++;
                    }
                    else if(at.additionalTowers[a]->GetElement() == ElementalAffinity::Shock)
                    {
                        numOfShock++;
                    }
                }
                for ( std::list<Tower*>::iterator tower = gs->towerslist.begin(); tower != gs->towerslist.end(); ++tower )
                {
                    Tower* t = *tower;
                    if(t->GetElement() == ElementalAffinity::Fire)
                    {
                        numOfFire++;
                    }
                    else if(t->GetElement() == ElementalAffinity::Water)
                    {
                        numOfWater++;
                    }
                    else if(t->GetElement() == ElementalAffinity::Earth)
                    {
                        numOfEarth++;
                    }
                    else if(t->GetElement() == ElementalAffinity::Shock)
                    {
                        numOfShock++;
                    }
                }
                
                
                if(numOfEarth < numOfFire && numOfEarth < numOfWater && numOfEarth < numOfShock)
                {
                    if(n1->UpgradeToEarth(gs->playerHandler))
                    {
                        gs->playerHandler->RemoveCoins(n1->toweRules->GetEarthUpgradeCost());
                        //now upgrade atk spd
                        while ( gs->playerHandler->GetCurrency() >= n1->toweRules->GetAttackUpgradeCost(*n1) ||
                               gs->playerHandler->GetCurrency() >= n1->toweRules->GetSpeedUpgradeCost(*n1) )
                        {
                            
                            if(n1->UpgradeAttackPower(gs->playerHandler))
                            {
                                gs->playerHandler->RemoveCoins(n1->toweRules->GetAttackUpgradeCost(*n1));
                            }
                            
                            if(n1->UpgradeAttackSpeed(gs->playerHandler))
                            {
                                gs->playerHandler->RemoveCoins(n1->toweRules->GetSpeedUpgradeCost(*n1));
                            }
                        }
                        
                    }
                    
                }
                else if(numOfFire < numOfEarth && numOfFire < numOfWater && numOfFire < numOfShock)
                {
                    if(n1->UpgradeToFire(gs->playerHandler))
                    {
//.........这里部分代码省略.........
开发者ID:geofl,项目名称:tdai,代码行数:101,代码来源:GeneticAlgorithmProfile1.cpp


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