/*
* Initialises the class instance
*
* @author				Cameron MacIntosh
* @param _pOwner		the owning AIPlayer
* @param _pMove			an address of an instance of the Move substate
* @param _pFlee			an address of an instance of the Flee substate
* @param Attack			an address of an instance of the Attack substate
* @return				if it succeded. Don't use the instance if it returns false.
*/
bool CAIStateGetFlag::Initialise(CAIPlayer* _pOwner, CAISubstateMove* _pMove, CAISubstateFlee* _pFlee,
		CAISubstateAttack* _pAttack)
{
	if(_pOwner!=0)
	{
		m_pOwner = _pOwner;
		m_pTank = m_pOwner->GetTank();

		m_pMove = _pMove;
		m_pFlee = _pFlee;
		m_pAttack = _pAttack;

		InitGeneral();

		m_pAllyFlag = s_pCube->GetFlag(m_eAllyTeam);
		m_pEnemyFlag = s_pCube->GetFlag(m_eEnemyTeam);
		
		//set the path to the flag (regardless of position)
		D3DXVECTOR2 _vec2Target(0,0);
		mFlagPos3Last = m_pEnemyFlag->GetPosition();

		CPathfinder::ConvertUnit3DtoTile2D(m_pEnemyFlag->GetFace(), mFlagPos3Last, _vec2Target);
		m_pMove->SetTarget(static_cast<int16>(_vec2Target.x),static_cast<int16>(_vec2Target.y),m_pEnemyFlag->GetFace());

		return(true);
	}
	return(false);
}
示例#2
0
CBBBase::CBBBase(MdlNode* pObj)
  {
  m_pNd = pObj;

  m_pMethod = NULL;

  InitGeneral();
  }
/*
* Initialises the class instance
*
* @author				Cameron MacIntosh
* @param _pOwner		the owning AIPlayer
* @param _pMove			an address of an instance of the Move substate
* @param _pFlee			an address of an instance of the Flee substate
* @param Attack			an address of an instance of the Attack substate
* @return				if it succeded. Don't use the instance if it returns false.
*/
bool CAIStateProtectPlayer::Initialise(CAIPlayer* _pOwner, CAISubstateMove* _pMove, CAISubstateFlee* _pFlee,
		CAISubstateAttack* _pAttack)
{
	if(_pOwner!=0)
	{
		m_pOwner = _pOwner;
		m_pTank = m_pOwner->GetTank();

		m_pMove = _pMove;
		m_pFlee = _pFlee;
		m_pAttack = _pAttack;

		InitGeneral();

		for(uint32 i=0; i<8; ++i)
		{
			CTank* pTank = CPlayerManager::GetPlayerManagerInstance().GetPlayer(i)->GetTank();
			if((m_eEnemyTeam!=pTank->GetTeam())&&(pTank!=m_pTank))
			{
				if(pTank->HasFlag())
				{
					//carrier has flag
					m_pFlagCarrier = pTank;
					D3DXVECTOR2 vec2 = pTank->GetPosition2D();
					m_TTargetLastPos2.x = static_cast<int32>(vec2.x);
					m_TTargetLastPos2.y = static_cast<int32>(vec2.y);
					m_pMove->SetTarget(m_TTargetLastPos2.x, m_TTargetLastPos2.y, pTank->GetFacePosition());
				}
			}
		}
		if(m_pFlagCarrier==0)
		{
			m_pOwner->RequestState(AI_STATE_IDLE);
			return(false);
		}
		return(true);
	}
	return(false);
}
void CImageDividerNumbers::InitFromSingle(int iLeftOffset, int iTopOffset, int iRightOffset, int iBottomOffset)
{
	InitGeneral(-1, -1, 1, 1, iLeftOffset, iTopOffset, iRightOffset, iBottomOffset);
}
void CImageDividerNumbers::InitFromRowsColumns(int iColumnCount, int iRowCount, int iLeftOffset, int iTopOffset, int iWidthSpacing, int iHeightSpacing)
{
	InitGeneral(-1, -1, iColumnCount, iRowCount, iLeftOffset, iTopOffset, iWidthSpacing, iHeightSpacing);
}
void CImageDividerNumbers::InitFromCelSize(int iCelWidth, int iCelHeight, int iLeftOffset, int iTopOffset, int iWidthSpacing, int iHeightSpacing)
{
	InitGeneral(iCelWidth, iCelHeight, -1, -1, iLeftOffset, iTopOffset, iWidthSpacing, iHeightSpacing);
}