Exemplo n.º 1
0
    //-----------------------------------------------------------------------
    void CCSEntityLineMoveAcion::onEnter()
    {
        //calculateRealMoveSpeed();

		if(!mEntity)
		{
			return;
		}

        mIsPrepareMoveEndPos = false;
        mIsAlreadyMoveEndPos = false;
        mAnimPlaying = false;

		mPathRadius = mEntity->getEntity()->getModelObject()->getPatherRadius();

		ISceneNode* sceneNode = mEntity->getEntity()->getSceneNode();
		if(!sceneNode)
		{
			return;
		}
 
		mEntity->playAnimation(mAnimName.c_str(), true, true, false, false );
		
		mBlockManager = sceneNode->getScene()->getBlockManager();

		//calculateRealMoveSpeed();

        /////////////////////////////////////////////////////////////////////////////////////////////

        setMoveAcionState( MAS_MOVING );

        /////////////////////////////////////////////////////////////////////////////////////////////

        if ( isNeedMoveToStartPos() )
        {
            moveToStartPos();
        }else
        {
            moveToEndPos();
        }
    }
Exemplo n.º 2
0
	//-----------------------------------------------------------------------
	void CItemEntity::parabolaDrop( Vec3 dropStartPos )
	{
		Flt height = 0;
		ClientMain::getInstance().getScene()->getCollisionSystem()->getStickHeight(dropStartPos, height);
		dropStartPos.y = height;

		Vec3 dir(1,0,0);
		Int angle = MGRandom::getInstance().rand_ab_One(0, 360);
		dir = MGMath::rotateVector(dir, angle * (MG_PI / 180));
		Int dis = MGRandom::getInstance().rand_ab_One(1, 3);
		Vec3 dropEndPos = dropStartPos + dir * dis;

		ISceneNode* sceneNode = mEntity->getSceneNode();

		ISceneNodeLineMoveToAction* lineMoveToAction = sceneNode->getScene()->getActionManager()->createSceneNodeParabolaMoveToAction(sceneNode);
		lineMoveToAction->setMoveSpeed(1);
		lineMoveToAction->setIgnoreHeight(false);
		lineMoveToAction->setStickTerrain(false);
		lineMoveToAction->setMoveToDestination(dropEndPos);
		sceneNode->getLinedStateManager()->push(lineMoveToAction);
	}
Exemplo n.º 3
0
    //-----------------------------------------------------------------------
    void CCSEntityLineMoveAcion::moveToEndPos()
    {
        mIsAlreadyMoveEndPos = true;

        if ( !mEntity )
            return;

        if ( !mEntity->getEntity() )
            return;

        ISceneNode* sceneNode = mEntity->getEntity()->getSceneNode();
        if( !sceneNode )
        {
            return;
        }

		IDynamicBlockObject* dynamicBlockObject = mEntity->getEntity()->getDynamicBlockObject();
	
        mSceneNodeLineMoveToEndPosAction = sceneNode->getScene()->getActionManager()->createSceneNodeGridLineMoveToAction(sceneNode, dynamicBlockObject);

        mSceneNodeLineMoveToActionName = mSceneNodeLineMoveToEndPosAction->getName();
        mSceneNodeLineMoveToEndPosAction->addListener( this );
        mSceneNodeLineMoveToEndPosAction->setMoveSpeed(mMoveSpeed);
        mSceneNodeLineMoveToEndPosAction->setMoveToDestination(mEndPos);
        mSceneNodeLineMoveToEndPosAction->setBlockCheck( mIsBlockCheck );
		mSceneNodeLineMoveToEndPosAction->setMoveToPathFindType(mMoveToPathFindType);

		if (dynamicBlockObject != NULL)
		{
			Flt perturbRadiu = dynamicBlockObject->getObjectRadius()*2;
			mSceneNodeLineMoveToEndPosAction->setPerturbRadiu(perturbRadiu);

			//mSceneNodeLineMoveToEndPosAction->setPerturbEnable(true);
		}

		CCSEntityLineMoveAcion* entityLineMoveAcion = NULL;
		ISceneNodeGridLineMoveToAction* sceneNodeGridLineMoveToAction = NULL;
		for(UInt i = 0; i < mMoveAcionListenerList.size(); ++i)
		{
			entityLineMoveAcion = mMoveAcionListenerList[i];
			sceneNodeGridLineMoveToAction = entityLineMoveAcion->getCurrSceneNodeGridLineMoveToAction();
			if(!sceneNodeGridLineMoveToAction)
			{
				continue;
			}

			mSceneNodeLineMoveToEndPosAction->addListener(sceneNodeGridLineMoveToAction);
		}

        sceneNode->getLinedStateManager()->push(mSceneNodeLineMoveToEndPosAction, false);

        /////////////////////////////////////////////////////////////////////////////////////////////

        ISceneNodeYawToAction* yawToAction = sceneNode->getScene()->getActionManager()->createSceneNodeYawToAction(sceneNode);
        yawToAction->setYawSpeed(mYawSpeed);

        //Vec3 currPos;
        //sceneNode->getPosition(currPos);

        yawToAction->setYawToPosition(mEndPos);
        yawToAction->setIsImmediately(false);
        sceneNode->getLinedStateManager()->push(yawToAction, false);

        /////////////////////////////////////////////////////////////////////////////////////////////

        sceneNode->stickTerrain();
    }