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


C++ Hero::getPetBox方法代码示例

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


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

示例1: attactWagonComm


//.........这里部分代码省略.........
		cout<<"This wagon has no owner, but you can attack it"<<endl;
		goto LG;	//没有主人的马车也能被打
		// return;
	}
	//马车主人不能打自己的马车
	owerId = owner->getIdentity();
	if (!strcmp(owerId, hero->getIdentity()))
	{
		return;
	}
LG: ;	
	//全用像素点
	Point wagonLocation = wagon->getPt();
	int range;			//攻击者的攻击范围
	//bool isLive;		//马车是否还活着
	int distance = 0;	//攻击者离马车距离
	
	Skill *skill; 
	//int skillNeedMagic = 0;						//技能的魔法消耗
	int attackLife = 100;						//攻击者当前血量……置为宠物的属性值
	int attackMagic = 100;						//攻击者魔法……置为宠物的属性值
	//int attackHurt = wagon->getHurt();			//马车每次被攻击掉血固定
	//index = 0 为人攻击马车
	if (index == 0)
	{
		map<string,Skill*> attack_skill_list;				//玩家角色的技能列表	
		map<string,Skill*>::iterator skill_iter;
		attack_skill_list = hero->getSkill_list();	
		skill_iter = attack_skill_list.find(skillId);
		if(skill_iter == attack_skill_list.end())
		{
			cout<<"BisonTest: hero does not has this skill to use when attack wagon"<<endl;
			return;
		}                   
		skill = skill_iter->second;							//玩家所使用的技能
		
		if (skill->gettype() != 1 || skill->geteffect() != 1)
		{
			//管你是群攻还是医疗,只要不是主动技能都别用来搞马车
			cout<<"skill type can't attack wagon"<<endl;
			return;
		}
		
		if(!isFightStatusOfHero(hero, skill))					//判断玩家的真气,和技能的时间是否符合条件
		{
			cout<<"BisonTest: magical or time is not ok to use this skill"<<endl;
			return;
		}
		
		cout<<"BisonTest: Hero attacks the wagon "<<wagonId<<endl;
		//判断距离是否够
		Point heroLocation = hero->getLocation();
		int deltaX = wagonLocation._x - heroLocation._x;
		int deltaY = wagonLocation._y - heroLocation._y;
		int distance = sqrt(deltaX * deltaX + deltaY * deltaY);
		range = hero->getAtk_range();
		cout<<"BisonTest: distance is "<<distance<<" hero attack range is "<<range<<endl; 
		if (distance > range)
		{
			cout<<"BisonTest: The wagon is out attack range"<<endl;
			return;
			
		} else {
			//攻击者者扣蓝
			//hero->setMagicVal(hero->getMagicVal() - skillNeedMagic);
			PropertyOfAttackerChange(hero, skill);
			//玩家的当前血蓝
			attackLife = hero->getLifeVal();		//难道还有攻击者自身会掉血的情况?不懂,随着他们用
			attackMagic = hero->getMagicVal();
		}
	} else if (index == 1) {
		//index = 1,为宠物打马车
		Pet *pet = hero->getPetBox()->getActivePet();
		if (pet == NULL)
		{
			cout<<"BisonTest: hero have no active Pet "<<endl;
			return;
		} else {
			//宠物位置
			Point petLocation = pet->getLogicNow();
			petLocation = LogicalExchangeMap(petLocation);
			int deltaX = wagonLocation._x - petLocation._x;
			int deltaY = wagonLocation._y - petLocation._y;
			int distance = sqrt(deltaX * deltaX + deltaY * deltaY);
			range = pet->getAttackRange();
			cout<<"BisonTest: distance is "<<distance<<" pet attack range is "<<range<<endl; 
			if (distance > range)
			{
				cout<<"BisonTest: The wagon is out attack range"<<endl;
				return;
				
			} 
		}
	} else {
		return;
	}
	
	attackWagon(hero->getIdentity(), attackLife, attackMagic, skillId, wagonId);
#endif
}
开发者ID:cirosantilli,项目名称:netWork-fork,代码行数:101,代码来源:attack_wagon.cpp


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