本文整理汇总了C++中Hero::getHp方法的典型用法代码示例。如果您正苦于以下问题:C++ Hero::getHp方法的具体用法?C++ Hero::getHp怎么用?C++ Hero::getHp使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Hero
的用法示例。
在下文中一共展示了Hero::getHp方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BeginContact
/*
void Slime::BeginContact(GameObject* other, b2Contact* contact)
{
if (other->getType() == TYPE_HERO)
{
Hero* hero = GameManager::getInstance()->hero;
if (hero->isDie())
return;
hero->setHp(hero->getHp() - SD_INT("slime_int_atk"));
//Ó¢ÐÛÎÞµÐ0.5Ãë
hero->setUnbeatable(0.5);
//»ñÈ¡Åöײºó²úÉúµÄºÏÁ¦·½Ïò
float y = contact->GetManifold()->localNormal.y;
if (y > 0)
{
b2Vec2 vec = hero->getBody()->GetLinearVelocity();
vec.y = SD_FLOAT("slime_float_atk_jump");
//ʹӢÐÛÌøÔ¾
hero->getBody()->SetLinearVelocity(vec);
//É˺¦Ê·À³Ä·
this->setHp(getHp()-1);
}
}
}
*/
void Slime::PreSolve(GameObject* other, b2Contact* contact, const b2Manifold* oldManifold)
{
if (other->getType() == TYPE_HERO)
{
Hero* hero = GameManager::getInstance()->hero;
if (hero->isDie())
return;
hero->setHp(hero->getHp() - SD_INT("slime_int_atk"));
//Ó¢ÐÛÎÞµÐ0.5Ãë
hero->setUnbeatable(SD_FLOAT("slime_float_unbeatable"));
//»ñÈ¡Åöײºó²úÉúµÄºÏÁ¦·½Ïò
float y = contact->GetManifold()->localNormal.y;
if (y > 0)
{
b2Vec2 vec = hero->getBody()->GetLinearVelocity();
vec.y = SD_FLOAT("slime_float_atk_jump");
//ʹӢÐÛÌøÔ¾
hero->getBody()->SetLinearVelocity(vec);
//É˺¦Ê·À³Ä·
this->setHp(getHp()-1);
}
}
}
示例2: getBaseHero
// 自己打自己的实现
BaseHero* ClientTestProvider::getBaseHero(unsigned int _heroId,ScriptBuilderUserData user_data)
{
short cdTime;
getHeroCDTime(cdTime,_heroId,user_data);
// 直接取本地的英雄的数据
vector<BaseActor*> actors = MyselfManager::getManager()->getTeamActors_ZhenShen(Actor_ShangZheng);
int actorNum = actors.size();
BaseActor* actor = actors[(_heroId-1)%actorNum];
Hero* ret = new Hero();
ret->init(actor->getCurrentProperty());
// 不用装备
ret->equipVec.clear();
ret->skilVec.clear();
switch (actor->getActorType())
{
case Profession_Yemanren:
ret->skilVec.push_back(SkillDataForFight(SkillType_BaoLieZhan));
break;
case Profession_Chike:
ret->skilVec.push_back(SkillDataForFight(SkillType_ShaLu));
break;
case Profession_Fashi:
ret->skilVec.push_back(SkillDataForFight(SkillType_ShanDian));
break;
case Profession_Qishi:
ret->skilVec.push_back(SkillDataForFight(SkillType_JianShou));
break;
case Profession_ShenJianShou:
ret->skilVec.push_back(SkillDataForFight(SkillType_LieGong));
break;
case Profession_MiShu:
ret->skilVec.push_back(SkillDataForFight(SkillType_HuoQiuShu));
break;
case Profession_WuSeng:
ret->skilVec.push_back(SkillDataForFight(SkillType_ShenZhiXingNian));
break;
case Profession_YouXia:
ret->skilVec.push_back(SkillDataForFight(SkillType_ShunYinTuXi));
break;
case Profession_LieShou:
ret->skilVec.push_back(SkillDataForFight(SkillType_JianYu));
break;
case Profession_WuShi:
ret->skilVec.push_back(SkillDataForFight(SkillType_WenYi));
break;
default:
break;
}
vector<Equipment*> equips = actor->getEquipments();
int equipsNum = equips.size();
for (int i=0;i<equipsNum;i++)
{
ret->equipVec.push_back(equips[i]->getEquipData());
}
if (user_data.teamTag > 0)
{
// 回血
if (((FightSUD*)user_data.data)->fightIndex > 0)
{
for (int i=0;i<FormationHeroAcountMax;i++)
{
if (((FightSUD*)user_data.data)->heroHpAfterLastFight.A_teamHeroId[i] == _heroId)
{
ret->zhuangbeiOpEnd();
//修改血
float hp = ret->getHp();
hp *= 0.15f;
hp += ((FightSUD*)user_data.data)->heroHpAfterLastFight.currentHp_A[i];
if(hp > ret->getHp())
{
hp = ret->getHp();
}
ret->subHp(ret->getHp() - hp);
}
}
}
else
{
ret->zhuangbeiOpEnd();
}
}
return ret;
}
示例3: potionShop
void PotionShop::potionShop(Hero& hero)
{
/*this->potion_items = {//name, health, price, value
{1, Potion("Mommy's Tea", 4, 150, 1)},
{2, Potion("Antidote of Life", 10, 230, 2)},
{3, Potion("Red Potion'", 16, 300, 3)},
{4, Potion("Imperial Regeneration", 24, 550, 4)},
{5, Potion("Oil of Health", 32, 610, 5)},
{6, Potion("Holy Light", 40, 690, 6)},
{7, Potion("Serum of Rejuvination", 52, 750, 7)},
{8, Potion("Elixir", 60, 900, 8)}
};*/
this->init_map_values();//Inherits init_map_values from mainshop
this->potion_items = {//name, health, price, value
{1, Potion("Mommy's Tea", map_effect_array[0], map_price_array[0],map_sellValue_array[0], 1)},
{2, Potion("Antidote of Life", map_effect_array[1], map_price_array[1],map_sellValue_array[1], 2)},
{3, Potion("Red Potion'", map_effect_array[2], map_price_array[2],map_sellValue_array[2], 3)},
{4, Potion("Imperial Regeneration", map_effect_array[3], map_price_array[3],map_sellValue_array[3], 4)},
{5, Potion("Oil of Health", map_effect_array[4], map_price_array[4],map_sellValue_array[4], 5)},
{6, Potion("Holy Light", map_effect_array[5], map_price_array[5],map_sellValue_array[5], 6)},
{7, Potion("Serum of Rejuvination", map_effect_array[6], map_price_array[6],map_sellValue_array[6], 7)},
{8, Potion("Elixir", map_effect_array[7], map_price_array[7],map_sellValue_array[7], 8)}
};
//Make a random function that gets potions from inventories and puts thhem into treasure chests which are also called randomly
//Make the potions you take, not pass the hp-For example: If i am lvl 2 and my max hp is 200, and i have 190hp and i get a potion of 50 hp
//make sure it will fill me to max hp which is 200, not passed it
//Create an inventory for weapons, potions and armor instead of just one inventory
//Change The gold and Health numbers for potions
this->getPotionShop();//Display potions
//int choice;
cout << "Select what you would like to buy, or enter 9 to quit!\n";
cin >> choice;
switch (choice)
{
case 1:
for (map <int, Potion>::iterator iter = potion_items.begin(); iter != potion_items.end(); iter++)
{
if(iter->first == 1)
{
if (hero.getMoney() >= iter->second._price)
{//Add a function-if you already have a weapon, you cannot buy it again
add_potion(iter->second);
hero.setMoney(hero.getMoney() - iter->second._price);
hero.setHp(hero.getHp() + iter->second._health);
cout << "\nYou have Successfully Bought " << iter->second._name << "\nIt has been added to your inventory\n";
cout << "your total items are: "<< potion_inventory.size() << endl;
break;//break for loop
}
else
{
cout << "You do not have enough money to buy this weapon\nPlease try again\n" << endl;
//system("CLS");//cout << string(50, '\n');
this->potionShop(hero);
break;//break for loop
}
}
}
break;//break switch
case 2:
for (map <int, Potion>::iterator iter = potion_items.begin(); iter != potion_items.end(); iter++)
{
if(iter->first == 2)
{
if (hero.getMoney() >= iter->second._price)
{
add_potion(iter->second);
hero.setMoney(hero.getMoney() - iter->second._price);
hero.setHp(hero.getHp() + iter->second._health);
cout << "\nYou have Successfully Bought " << iter->second._name << "\nIt has been added to your inventory\n";
cout << "your total items are: "<< potion_inventory.size() << endl;
break;//break for loop
}
else
{
cout << "You do not have enough money to buy this weapon\nPlease try again\n" << endl;
//system("CLS");//cout << string(50, '\n');
this->potionShop(hero);
break;//break for loop
}
}
}
break;//break switch
case 3:
for (map <int, Potion>::iterator iter = potion_items.begin(); iter != potion_items.end(); iter++)
{
if(iter->first == 3)
{
if (hero.getMoney() >= iter->second._price)
{
add_potion(iter->second);
//.........这里部分代码省略.........