//------------------------------- Activate ------------------------------------
//-----------------------------------------------------------------------------
void GoalAttackTarget::activate()
{
	_status = ACTIVE;

	//if this goal is reactivated then there may be some existing subgoals that
	//must be removed
	removeAllSubgoals();

	//it is possible for a bot's target to die whilst this goal is active so we
	//must test to make sure the bot always has an active target
	if (!_owner->getTargetSys()->isTargetPresent())
	{
		_status = COMPLETED;

		return;
	}

	//if the bot is able to shoot the target (there is LOS between bot and target),
	//then select a tactic to follow while shooting
	if (_owner->getTargetSys()->isTargetAttackable())
	{
		addSubgoal(new GoalMainAttack(_owner));
	}

	//if the target is not visible, go hunt it.
	else
	{
		if (_owner->getType() != BaseGameEntity::TOWER_CHARACTER)
			addSubgoal(new GoalHuntTarget(_owner));
		//addSubgoal(new GoalHuntTarget(_owner));
	}
}
//------------------------------ activate -------------------------------------
//-----------------------------------------------------------------------------
void GoalPersistanceAttack::activate()
{
	_status = ACTIVE;

	if (_owner->getTargetSys()->isTargetPresent())
	{
		if (_owner->getTargetSys()->getTarget()->isAlive())
		{
			if (_owner->getTargetSys()->isTargetAttackable())
			{
				addSubgoal(new GoalMainAttack(_owner));
			}
			else
			{
				addSubgoal(new GoalHuntTarget(_owner));
			}
		}
		else
		{
			_status = COMPLETED;
		}
	}
	else
	{
		_status = COMPLETED;
	}
}
Beispiel #3
0
/**
* 我发现队员的大脑已经变成了接受队伍消息的地方了,然后根据队伍消息来调整自己的目标 
*/
bool GoalCharacterThink::handleMessage( Telegram& msg )
{
    // 首先交给子目标处理
    if (forwardMessageToFrontMostSubgoal(msg)) return true;

    switch (msg.type)
    {
    case TELEGRAM_ENUM_TEAM_COLLECTIVE_FORWARD:                 // 队伍通知手下跟随队伍前进
        {
            m_pOwner->getSteeringBehaviros()->keepFormationOn();
            return true;
        }

    case TELEGRAM_ENUM_TEAM_CANCEL_COLLECTIVE_FORWARD:          // 队伍通知手下不用跟随队伍了
        {
            m_pOwner->getSteeringBehaviros()->keepFormationOff();
            return true;
        }

    case TELEGRAM_ENUM_TEAM_ATTACK_SPECIFIED_TARGET:            // 队伍命令手下攻击指定目标
        {
            // 删除所有的当前任务,然后设定新的任务
            removeAllSubgoals();
            int tmpTargetId =   (int)msg.extraInfo;
            addSubgoal(new GoalAttackSpecifiedTarget(m_pOwner, tmpTargetId));
            return true;
        }

    default:
        break;
    }

    return false;
}
Beispiel #4
0
void GoalThink::addGoal_HoldPosition(const cocos2d::Vec2& destination)
{
	if (notPresent(GOAL_HOLD_POSITION))
	{
		removeAllSubgoals();
		addSubgoal(new GoalHoldPosition(_owner, destination));
	}
}
Beispiel #5
0
void GoalThink::addGoal_AttackTarget()
{
	if (notPresent(GOAL_ATTACK_TARGET))
	{
		removeAllSubgoals();
		addSubgoal(new GoalAttackTarget(_owner));
	}
}
Beispiel #6
0
void GoalThink::addGoal_Explore()
{
	if (notPresent(GOAL_EXPLORE))
	{
		removeAllSubgoals();
		addSubgoal(new GoalExplore(_owner));
	}
}
Beispiel #7
0
void GoalThink::addGoal_PersistanceAttack()
{
	if (_owner->getTargetSys()->isTargetPresent())
	{
		if (notPresent(GOAL_PERSISTANCE_ATTACK))
		{
			removeAllSubgoals();
			addSubgoal(new GoalPersistanceAttack(_owner));
		}
	}
	else
	{
		CCLOG("no target!");
	}
}
Beispiel #8
0
void GoalThink::addGoal_Death()
{
	addSubgoal(new GoalDeath(_owner));
}
Beispiel #9
0
void GoalThink::addGoal_BasicCasting(cocos2d::Vec2 pos, CastingType type)
{
	addSubgoal(new GoalSpecialCasting(_owner, pos, type));
}
Beispiel #10
0
void GoalThink::addGoal_MoveToPosition(cocos2d::Vec2 pos)
{
	addSubgoal(new GoalMoveToPosition(_owner, pos));
}