コード例 #1
0
void ComponentSkill::onMessage(const Message& message)
{
	Message newMessage;
	switch (message.type)
	{
	case Message::TRY_BUY:
		canBuy(message.value, message.gameObject);
		break;
	case Message::ADD_EXPERIENCE:
		jade += message.value*2/3;
		newMessage.type = Message::JADE_CHANGED;
		newMessage.value = jade;
		parent->broadcastMessage(newMessage);
		break;
	case Message::USE_SKILL:
		useSkill(message.value);
		break;
	case Message::LEVEL_CHANGED:
		addLevel(message.value);
		break;
	case Message::DEATH:
		down = true;
		for(size_t i = 0;i < skills.size();i++)
		{
			skills[i]->deselect();
		}
		break;
	case Message::REPAIRED:
		down = false;
		break;
	}

}
コード例 #2
0
ファイル: Enemy.cpp プロジェクト: SubwayRocketTeam/game
void Enemy::update(float dt){

	followTimer -= dt;
	if (followTimer <= 0) {
		updateMovement();
		// TODO: Targt update하는 주기 상수
		followTimer = 0.2f;
	}

	auto target = getTarget();

	enemyAttackData.position = position;
	stage->ally[_OPPOSITE(ally)]->processAttack(enemyAttackData);

	if (skill)
	{
		if (target && cooltime <= 0.f)
		{
			useSkill(skill->id, target->position);
			// skill->use(this, target->position);
			cooltime = skill->cooltime;
		}
		else
			cooltime -= dt;
	}

	Unit::update(dt);
}
コード例 #3
0
ファイル: skilldialog.cpp プロジェクト: Rawng/ManaPlus
void SkillDialog::action(const ActionEvent &event)
{
    const std::string &eventId = event.getId();
    if (eventId == "inc")
    {
        const SkillTab *const tab = static_cast<const SkillTab *const>(
                                        mTabs->getSelectedTab());
        if (tab)
        {
            if (const SkillInfo *const info = tab->getSelectedInfo())
                playerHandler->increaseSkill(static_cast<uint16_t>(info->id));
        }
    }
    else if (eventId == "sel")
    {
        const SkillTab *const tab = static_cast<const SkillTab *const>(
                                        mTabs->getSelectedTab());
        if (tab)
        {
            if (const SkillInfo *const info = tab->getSelectedInfo())
            {
                mUseButton->setEnabled(info->isUsable());
                mUseButton->setCaption(info->useButton);
                mIncreaseButton->setEnabled(info->id < SKILL_VAR_MIN_ID);
                const int num = itemShortcutWindow->getTabIndex();
                if (num >= 0 && num < static_cast<int>(SHORTCUT_TABS)
                        && itemShortcut[num])
                {
                    itemShortcut[num]->setItemSelected(
                        info->id + SKILL_MIN_ID);
                }
            }
            else
            {
                mUseButton->setEnabled(false);
                mIncreaseButton->setEnabled(false);
                mUseButton->setCaption(_("Use"));
            }
        }
    }
    else if (eventId == "use")
    {
        const SkillTab *const tab = static_cast<const SkillTab *const>(
                                        mTabs->getSelectedTab());
        if (tab)
        {
            const SkillInfo *const info = tab->getSelectedInfo();
            useSkill(info);
        }
    }
    else if (eventId == "close")
    {
        setVisible(Visible_false);
    }
}
コード例 #4
0
bool EnemyExplode::onDeath(){
	if (!Enemy::onDeath())
		return false;
	useSkill(skillExplosion, position);
	return true;
}
コード例 #5
0
void MonsterActive::response(void)
{		
	
	StyObj obj(identity,MONSTER_STYLE_TYPE);
	vector<string> herId;		
	Point heroPt;
	Hero *perHero;		
	Nbox *box;
	
	if(map_now == NULL)
	{
		return;
	}
	
	box = map_now->getBox();	
	if(box == NULL || !isAlive)
	{
		return;
	}
	
	/*判断任务是否还在*/
	if(judgeTask())
	{
		cout<<"the task mon of the task is illeay:"<<endl;
		return;
	}
	
	if(!isPlayOver())
	{
		// cout<<"it is playCd time:"<<endl;
		return;
	}	
	
	memset(otherMsg,'\0',MONSTER_MSG_LENGTH + 1);
	
	box->getStaInSrcVec(obj);
	
	/*处理延时性技能*/
	hitedSkiFun();
	
	/*地图没人,判断是否已眩晕*/
	if(!dizz)     
	{
		stopMove();
		return;
	}	
	
	/*回血功能*/
	recoverBloodSelf();
	
	/*boss逃跑*/
	if(flgRun)    
	{
		/*判断是否已定身*/
		if(!skiBody)
		{
			stopMove();
			return;
		}		
	}
	else
	{			
		/*仇恨范围搜寻*/
		schRge();
		
		/*如果仇恨列表不为空*/
		if(!enmityValues.empty())   
		{						
			/*这个是从仇恨列表里面得到的最高值,至于怎么得到的,则要看仇恨计算*/
			perHero = getHero(perHerId);
			
			if(perHero == NULL || !perHero->getLifeStation())
			{
				return;	
			}
			
			heroPt = perHero->getLogPt();
			
			/*攻击距离判断*/
			int fight_state = attackRangePoint(pt,perHero->getLocation(),attack_range);	
			
			
			if(fight_state != 1)
			{				
				/*判断是否已定身*/
				if(!skiBody)
				{
					stopMove();					
					return;
				}
         
                /*如果人物没动,则这次就不必要再寻一次路*/
                if(jdgSmePt(heroPt))
                {					
                    findAttWay(heroPt);						
					isPersuitHero = true;
                }
			}
			
			else
			{			
				stopMove();	
				exchageHat(herId);
				if(attackPoint && useSkill(herId))
				{					
					return;
				}
				attPerHero(otherMsg,sizeof(otherMsg),perHero);					
				box->sentBoxMsg(otherMsg);
			}			
		}
		else
		{
			/*如果上次正在追人,而这次仇恨没人,则立即停下来*/
			if(isPersuitHero)
			{
				stopMove();
				
				isPersuitHero = false;
			}
		
			/*归位*/
            if(Rec)
            { 			
				/*判断是否已定身*/
				if(!skiBody)
				{
					stopMove();	
					return;
				}
				
				if(perLstPt == logic_pt)
				{
					Rec = false;
					return;
				}
				
				/*避免多次寻路*/
				if(keyPath.empty())
				{
					findSlfWay(perLstPt);		
				}			
            }		
			
		}
		
	}
	
	if(perLstPt == logic_pt)
	{
		Rec = false;
	}
	else
	{
		Rec = true;
	}		
	
}	
コード例 #6
0
ファイル: pc.C プロジェクト: Methuselas/btbuilder
void BTPc::useAutoCombatSkill(bool melee, BitField &special)
{
 BTGame *game = BTGame::getGame();
 BTSkillList &skillList = game->getSkillList();
 for (int i = 0; i < skillList.size(); ++i)
 {
  if ((skillList[i]->use == BTSKILLUSE_AUTOCOMBAT) ||
   ((melee) && (skillList[i]->use == BTSKILLUSE_AUTOCOMBATMELEE)) ||
   ((!melee) && (skillList[i]->use == BTSKILLUSE_AUTOCOMBATRANGED)))
  {
   if (((-1 == skillList[i]->after) || (combat.skillUsed == skillList[i]->after)) && (useSkill(i)))
   {
    special.set(skillList[i]->effect);
   }
  }
 }
}
コード例 #7
0
void MonsterAttRed::response(void)
{
	StyObj obj(identity,MONSTER_STYLE_TYPE);	
	vector<string> herId;	
	Point heroPt;
	Hero *perHero;		
	Nbox *box;
	
	if(map_now == NULL)
	{
		return;
	}
	
	box = map_now->getBox();
	
	if(box == NULL || !isAlive)
	{
		return;
	}	
	
	/*判断任务是否还在*/
	if(judgeTask())
	{
		cout<<"the task mon of the task is illeay:"<<endl;
		return;
	}
	
	if(!isPlayOver())
	{
	//	cout<<"it is playCd time:"<<endl;
		return;
	}
	
	memset(otherMsg,'\0',MONSTER_MSG_LENGTH + 1);	
	
	box->getStaInSrcVec(obj);	
	
	/*处理延时性技能*/
	hitedSkiFun();	
	
	/*判断地图是否有人,怪物是否已眩晕*/
	if(!dizz)     
	{
		stopMove();
		return;
	}

	/*回血功能*/
	recoverBloodSelf();
	
    /*这个是从仇恨列表里面得到的最高值,至于怎么得到的,则要看仇恨计算*/	
	if(flgRun)    
	{
		/*判断是否已定身*/
		if(!skiBody)
		{
			stopMove();
			return;
		}		
	}
	else
	{		
		
		/*终究还是专打红名了 add by chenzhen 201301300950*/
		redSchRge();
		
		if(!enmityValues.empty())
		{
			chageEny(((*(enmityValues.begin())).id)); 

			/*这个是从仇恨列表里面得到的最高值,至于怎么得到的,则要看仇恨计算*/
			perHero = getHero(perHerId); 
			if(perHero == NULL || !perHero->getLifeStation())
			{
				return;
			}
			
			heroPt = perHero->getLogPt();
			int fight_state = attackRangePoint(pt,perHero->getLocation(),attack_range);     
				
			if(fight_state != 1)
			{
				/*判断是否已定身*/
				if(!skiBody)
				{
					stopMove();					
					return;
				}
				
				 /*如果人物没动,则这次就不必要再寻一次路*/
                if(jdgSmePt(heroPt))
                {					
					findAttWay(heroPt);					
					isPersuitHero = true;
                }	
				
				isInPatrol = false;
			}
			
			else
			{
				stopMove();					
				exchageHat(herId);
				if(attackPoint && useSkill(herId))
				{					
					return;
				}
				attPerHero(otherMsg,sizeof(otherMsg),perHero);					
				box->sentBoxMsg(otherMsg);
			}			
		}
		else
		{	
			/*如果上次正在追人,而这次仇恨没人,则立即停下来*/
			if(isPersuitHero)
			{
				stopMove();
				
				isPersuitHero = false;
			}
			
			/*回血功能*/
	//		recoverBloodSelf();	
		
			if(Rec && !isInPatrol)
			{					
				/*判断是否已定身*/
				if(!skiBody)
				{
					stopMove();	
					return;
				}
				if(logic_pt == perLstPt)
				{
					Rec = false;
					return;	
				}
				
				/*避免多次寻路*/
				if(keyPath.empty())
				{
					findAttWay(perLstPt,false);			
				}			
				
			}
			else
			{					
				if(!isInPatrol)
				{
					/*模糊反应*/
					if(!judgeGoFor())
					{
						stopMove();	
						return;
					}	
				}
				
				/*判断是否已定身*/
				if(!skiBody)
				{
					stopMove();	
					return;
				}
				
				/*生成寻路终点*/
				getEnd();  
				
				if(logic_pt == endFinPt)
				{
					Rec = true;
					isInPatrol = false;
					return;
				}
				
				/*避免多次寻路*/
				if(keyPath.empty())
				{
					findSlfWay(endFinPt);		
				}			
			}
		}
	}
	if(perLstPt == logic_pt)
	{
		Rec = false;
	}
	else
	{
		Rec = true;
	}
}