Пример #1
0
size_t EffRect::GetAroundShapes( const Graph::PosPair &poss, std::vector<CShape*> &shapes )
{
    CServerRegion *rgn = (CServerRegion*)(m_pParam->pUser->GetFather());
    long offset = (long) m_width;
    long sx = (long) poss.first.x;
    long sy = (long) poss.first.y;
    long dx = (long) poss.second.x;
    long dy = (long) poss.second.y;

    if( dx == sx && dy == sy ) // the same tile
    {
        rgn->GetShape( dx, dy, shapes ); 
    }
    else
    {
        long minx = min( sx, dx );
        long maxx = max( sx, dx );
        long miny = min( sy, dy );
        long maxy = max( sy, dy );
        minx -= offset;
        maxx += offset;
        miny -= offset;
        maxy += offset;
        long xOffset = maxx - minx + 1;
        for( ; miny <= maxy; ++ miny )
        {
            for( ; minx <= maxx; ++ minx )
            {
                rgn->GetShape( minx, miny, shapes );
            }
            minx -= xOffset;
        }
    }

    return shapes.size();    
}
Пример #2
0
//得到所用的作用对象
unsigned int CEffPoint::GetEffectObjs(list<CMoveShape*>& listObjs)
{
    listObjs.clear();
    CMoveShape* pShape = NULL;
    if(m_ePos==ePos_Self)
    {
        pShape= m_pParam->pUser;
    }
    else if(m_ePos==ePos_Dest )
    {
        CServerRegion* pServerRegion = (CServerRegion*)(m_pParam->pUser->GetFather());
        if(pServerRegion)
        {
            CBaseObject *pObj = pServerRegion->FindChildObject(m_pParam->nMouseShapeType,m_pParam->MouseShapeID);
            m_pParam->pMouseShape = dynamic_cast<CMoveShape*>(pObj);
            pShape = m_pParam->pMouseShape;
        }
    }
    else if(m_ePos == ePos_Mouse)
    {
        CServerRegion* pServerRegion = (CServerRegion*)(m_pParam->pUser->GetFather());
        if(pServerRegion)
        {
            pShape = dynamic_cast<CMoveShape*>(pServerRegion->GetShape(m_pParam->nMouseX,m_pParam->nMouseY));
            m_pParam->pMouseShape = pShape;
        }
    }
    else if (m_ePos == ePos_Firer)
    {
        if (m_pParam->pFirer)
        {
            pShape = m_pParam->pFirer;
        }
        else
        {
            CServerRegion* pServerRegion = (CServerRegion*)(m_pParam->pUser->GetFather());
            if(pServerRegion)
            {
                CBaseObject *pObj = pServerRegion->FindChildObject(m_pParam->nFirerType,m_pParam->FirerID);
                pShape = dynamic_cast<CMoveShape*>(pObj);
            }
        }
    }
    else if (m_ePos == ePos_Attacker)
    {
        CServerRegion* pServerRegion = (CServerRegion*)(m_pParam->pUser->GetFather());
        if(pServerRegion)
        {
            CBaseObject *pObj = pServerRegion->FindChildObject(m_pParam->pUser->GetAttackerType(),m_pParam->pUser->GetAttackerGuid());
            if (pObj)
            {
                pShape = dynamic_cast<CMoveShape*>(pObj);
            }
        }
    }
    else if (m_ePos == ePos_Target)
    {
        CServerRegion* pServerRegion = (CServerRegion*)(m_pParam->pUser->GetFather());
        if(pServerRegion)
        {
            CGUID TargetGuid =NULL_GUID;
            long  lTargetType = 0;
            m_pParam->pUser->GetTarget(TargetGuid,lTargetType);
            CBaseObject *pObj = pServerRegion->FindChildObject(lTargetType,TargetGuid);
            if (pObj)
            {
                pShape = dynamic_cast<CMoveShape*>(pObj);
            }
        }
    }
    else if (m_ePos==ePos_AttackTarget)
    {
        CServerRegion* pServerRegion = (CServerRegion*)(m_pParam->pUser->GetFather());
        if(pServerRegion)
        {
            CGUID AttackTargetGuid =NULL_GUID;
            long  lAttackTargetType = 0;
            m_pParam->pUser->GetAttacktarget(AttackTargetGuid,lAttackTargetType);
            CBaseObject *pObj = pServerRegion->FindChildObject(lAttackTargetType,AttackTargetGuid);
            if (pObj)
            {
                pShape = dynamic_cast<CMoveShape*>(pObj);
            }
        }

    }
    else if (m_ePos == ePos_Host)
    {
        pShape = m_pParam->pUser->GetHost();
    }


    //加入shape
    if(pShape)
    {
        if(m_pCondiGroup )
        {   //有条件且为真
            if( m_pCondiGroup->Result(pShape,m_pParam) )
                listObjs.push_back(pShape);
        }
        else
        {
            //没有条件对象
            listObjs.push_back(pShape);
        }
    }
    return listObjs.size();
}
Пример #3
0
//得到所用的作用对象
unsigned int CEffLine::GetEffectObjs(list<CMoveShape*>& listObjs)
{
	listObjs.clear();
	int nNum = 0;

    if ( m_strNum!="" )
    {
        /// by:expter 2010/08/31 技能增加一个参数
        m_nNum = m_pParam->pFirer->GetSkillValue(m_pParam->nID,m_pParam->nLvl,m_strNum);
    }
    if( m_nNum < 0 )
        m_nNum = 0;

	list<POINT> listPos;
	CServerRegion* pServerRegion = (CServerRegion*)(m_pParam->pUser->GetFather());
	if(NULL == pServerRegion)	return 0;

	CBaseObject *pObj = pServerRegion->FindChildObject(m_pParam->nMouseShapeType,m_pParam->MouseShapeID);
	m_pParam->pMouseShape = dynamic_cast<CMoveShape*>(pObj);

    CMoveShape *pExcept = NULL;

	if(m_ePos == ePos_Self)
		return 0;
	//目标
	else if(m_ePos == ePos_Dest && m_pParam->pMouseShape)
	{
		GetLinePointToDest(listPos,
			m_pParam->pUser->GetTileX(),m_pParam->pUser->GetTileY(),
			m_pParam->pMouseShape->GetTileX(),m_pParam->pMouseShape->GetTileY(),m_nDistance);
        if( m_IsWithinObj)
            pExcept = m_pParam->pMouseShape;
	}
	//目标坐标点位置
	else if(m_ePos == ePos_Coord)
	{
		GetLinePointToDest(listPos,
			m_pParam->pUser->GetTileX(),m_pParam->pUser->GetTileY(),
			m_pParam->nMouseX,m_pParam->nMouseY,m_nDistance);
	}	
	//鼠标位置
	else if(m_ePos == ePos_Mouse)
	{		
		long lDir = m_pParam->pUser->GetDestDir(m_pParam->pUser->GetTileX(),
							m_pParam->pUser->GetTileY(),
							m_pParam->nMouseX,m_pParam->nMouseY);
		//得到与目标之间的格子
		//得到与目标之间的格子
		GetLinePointByDir(listPos,m_pParam->pUser->GetTileX(),
									m_pParam->pUser->GetTileY(),lDir,m_nDistance);
	}

    if ( pExcept )
    {
#ifdef _SKILL_INFO_D_      
        Log4c::Trace(SKILL_MODULE, "CEffLine:作用于对象外的玩家");    
#endif
    }

	//计算出moveshape
	list<POINT>::iterator it = listPos.begin();
	for(;it != listPos.end();it++)
	{
		POINT& pos = (*it);		
		CMoveShape* pMoveShape = dynamic_cast<CMoveShape*>(pServerRegion->GetShape(pos.x,pos.y));
		if(pMoveShape &&(NULL==m_pCondiGroup || m_pCondiGroup->Result(pMoveShape,m_pParam)))
		{
			nNum++;
            if (m_nNum>0)
            {      
                if (m_nNum<nNum)
                {
                    break;
                }
            }
            /// 除去范围内对象
            if( pExcept && pExcept == pMoveShape )
            {
#ifdef _SKILL_INFO_D_       
               Log4c::Trace(SKILL_MODULE, "CEffLine:作用于对象外的玩家");    
#endif
                continue;                       
            }
			listObjs.push_back(pMoveShape);
		}

	}
	return nNum;
}