//-----------------------------------------------------------------------------
// Purpose: Builds the spline points between this keyframe and the previous
//			keyframe.
// Input  : pPrev - 
//-----------------------------------------------------------------------------
void CMapKeyFrame::BuildPathSegment( CMapKeyFrame *pPrev )
{
	RecalculateTimeFromSpeed();

	CMapAnimator *pAnim = GetAnimator();

	Quaternion qAngles;
	for ( int i = 0; i < MAX_LINE_POINTS; i++ )
	{
		if (pAnim != NULL)
		{
			CMapAnimator::GetAnimationAtTime( this, pPrev, MoveTime() * ( float )( i + 1 ) / (float)MAX_LINE_POINTS, m_LinePoints[i], qAngles, pAnim->m_iPositionInterpolator, pAnim->m_iRotationInterpolator );
		}
		else
		{
			// FIXME: If we aren't connected to an animator yet, just draw straight lines. This code is never hit, because
			//		 BuildPathSegment is only called from CMapAnimator. To make matters worse, we can only reliably find
			//		 pPrev through an animator.
			CMapAnimator::GetAnimationAtTime( this, pPrev, MoveTime() * (float)( i + 1) / (float)MAX_LINE_POINTS, m_LinePoints[i], qAngles, 0, 0 );
		}
	}

	// HACK: we shouldn't need to do this. CalcBounds alone should work (but it doesn't because of where we
	// call RebuildPath from). Make this work more like other objects.
	if ( m_pParent )
	{
		GetParent()->CalcBounds( true );
	}
	else
	{
		CalcBounds();
	}

	m_bRebuildPath = false;
}
示例#2
0
void Red1Fail1(void)
{
	IntakePower(0);
	MoveTime(2000,-100)
	KillALL();
	while(1);
}
示例#3
0
void SlimeKingMiddle::MoodMove(float dt)
{
	if (timer == kTimerUp)
	{
		timer = MoveTime();
		dir = rand() % 4;
		cocos2d::JumpBy * jump;
		switch (dir)
		{
		case myEnum::kDir::kDirEast:
			jump = JumpBy::create(0.5f, Vec2(50, 0), this->getContentSize().height*0.5f, 1);
			break;
		case myEnum::kDir::kDirWest:
			jump = JumpBy::create(0.5f, Vec2(-50, 0), this->getContentSize().height*0.5f, 1);
			break;
		case myEnum::kDir::kDirSouth:
			jump = JumpBy::create(0.5f, Vec2(0, -50), this->getContentSize().height*0.5f, 1);
			break;
		case myEnum::kDir::kDirNorth:
			jump = JumpBy::create(0.5f, Vec2(0, +50), this->getContentSize().height*0.5f, 1);
			break;
		}
		auto seq = Sequence::create(jump, jump->clone(), NULL);
		this->runAction(seq);
	}
	else if (timer <= 0.0f)
	{
		ChooseMood();
	}
}
示例#4
0
文件: Guard.cpp 项目: ilhaeYe/MB
void Guard::MoodStay(float dt)
{
	if (timer == kTimerUp)
	{
		timer = MoveTime();
	}
	else if (timer <= 0.0f)
	{
		ChooseMood();
	}
}
示例#5
0
/*----------------------------------------------------------------------------*/
void BlueAuto2(void)
{
	///4 PRELOADS 3 PILE
	/// STARTING TYLE IS FURTHERST TYLE
	int YouAreGoodToCount = 0;
	Transmission(1);
	BallCounter = 4;
	ShootingMode = 1;
	IntakeShoot(6000);//SHOOT 4 PRELOADS // * FAILSAFE POINT
	ShootingMode = 4;
	DistanceCalculatorTurn(1);
	while(DistanceCalculatorTurn(0) < 15) //*FAILSE WHAT IF WE GET OFF THE LINE ( WHAT IF ROBOT BLOCKS PATH AND WE ARE STILL ON THE LINE)
	{
		Move(-1, 50);
	}
	Break2(100,-10);
	delay(200);
	stage = 1;
	SetRPM(2200);
	DistanceCalculator(1);
	while(DistanceCalculator(0) < 12) //*FAILSE WHAT IF WE GET OFF THE LINE ( WHAT IF ROBOT BLOCKS PATH AND WE ARE STILL ON THE LINE)
	{
		Move(2, 127);
	}
	clearTimer(T3);
	while(SensorValue[IR1] == 1 ) //*FAILSE WHAT IF WE GET OFF THE LINE ( WHAT IF ROBOT BLOCKS PATH AND WE ARE STILL ON THE LINE)
	{
		IntakeOnAuto();
		Move(2, 20);
		if(time1[T3] > 6000)
		{
			FailSafeEngaged = 1;
			break;
		}
	}
	if(FailSafeEngaged == 1)Blue1Fail1();/////////////////////RED1FAIL1
		IntakePower(0);
	Break(100,10);
	while(MoveDist(-1, 20,0) == 1) // DO WE NEED FAILSAFE HERE?
	{
		IntakeOnAuto();
	}
	while(MoveDist(35, 40,3000) == 1)//17 // DO WE NEED FAILSAFE HERE?
	{
		IntakeOnAuto();
		if(FailSafeEngaged == 1)Blue1FailInfinite();/////////////////////RED1FAIL1
	}
	IntakePower(0);
	while(LineStatus() == 0)
	{
		Move(-2, 100);
	}
	Break(100,-10);
	while(MoveDist(3, 30,0) == 1);
	delay(200);
	SetRPM(2200);
	while(LineStatus() == 0) //TURN UNTIL YOU SEE THE LINE
	{
		Move(1, 20);
	}
	DistanceCalculator(1);
	while(LineStatus() == 1) //*FAILSE WHAT IF WE GET OFF THE LINE ( WHAT IF ROBOT BLOCKS PATH AND WE ARE STILL ON THE LINE)
	{
		FollowLine(40);
		if(LineStatusOffset() == 1)
		{
			DistanceCalculator(1);
			YouAreGoodToCount = 1;
		}
		if(DistanceCalculator(0) > 18 && YouAreGoodToCount == 1)
		{
			DistanceCalculator(1);
			break;

		}
	}
	if(DistanceCalculator(0) < 50 && YouAreGoodToCount == 0)Blue1FailInfinite();//**FAIL GOOD
		Break(100,20);
	delay(500);
	IntakePower(127);///SHOT FIRST PILE
	delay(3000);
	ShootingMode = 3;
	StopDrive();
	stage = 1;
	DistanceCalculator(1);
	while(SensorValue[IR1] == 1 && LineStatus() == 1) //*FAILSE WHAT IF WE GET OFF THE LINE ( WHAT IF ROBOT BLOCKS PATH AND WE ARE STILL ON THE LINE)
	{
		FollowLine(35);
		IntakeOnAuto();
	}
	Break(100,20);
	StopDrive();
	clearTimer(T3);
	while(stage == 1) // WHAT IF TWO BALLS ARE STUCK FOREVER? TIMER?
	{
		if(time1[T3] > 10000)
		{
			break;
		}
		IntakeOnAuto();
	}
	clearTimer(T3);
	while(LineStatus() == 1 && DistanceCalculator(0) < 37 )//*FAILSE WHAT IF WE GET OFF THE LINE ( WHAT IF ROBOT BLOCKS PATH AND WE ARE STILL ON THE LINE)
	{
		FollowLine(35);
		IntakeOnAuto();
		if(time1[T3] > 10000)
		{
			break;
		}
	}
	MoveTime(500,127);
	StopDrive();
	delay(500);
	IntakePower(127);///SHOT BAR SHOTS
	delay(3500);
	IntakePower(0);
	SetRPM(2200);
	stage = 1;
	//////////////////////////////////////////////////////SHOT 8 COMPLETE
	DistanceCalculator(1);
	while(DistanceCalculator(0) < 50) //*FAILSE WHAT IF WE GET OFF THE LINE ( WHAT IF ROBOT BLOCKS PATH AND WE ARE STILL ON THE LINE)
	{
		Move(-2, 127);
	}
	Break(200,-15);
	delay(200);
	DistanceCalculatorTurn(1);
	clearTimer(T3);
	while(DistanceCalculatorTurn(0) < 62) //*FAILSE WHAT IF WE GET OFF THE LINE ( WHAT IF ROBOT BLOCKS PATH AND WE ARE STILL ON THE LINE)
	{
		Move(-1, 100);
		if(time1[T3] > 5000)
		{
			FailSafeEngaged = 1;
			break;
		}
	}
	if(FailSafeEngaged == 1)Blue1FailInfinite();
	Break2(100,10);
	delay(300);
	DistanceCalculator(1);
	clearTimer(T3);
	while(DistanceCalculator(0) < 24) //*FAILSE WHAT IF WE GET OFF THE LINE ( WHAT IF ROBOT BLOCKS PATH AND WE ARE STILL ON THE LINE)
	{
		Move(2, 127);
		if(time1[T3] > 5000)
		{
			FailSafeEngaged = 1;
			break;
		}
	}
	if(FailSafeEngaged == 1)Blue1FailInfinite();
	clearTimer(T3);
	while(SensorValue[IR1] == 1 )//PILE BY THE WALL
	{
		IntakeOnAuto();
		Move(2, 20);
		if(time1[T3] > 5000)
		{
			FailSafeEngaged = 1;
			break;
		}
	}
	if(FailSafeEngaged == 1)Blue1FailInfinite();
	IntakePower(0);
	Break(100,10);
	while(MoveDist(-1, 20,0) == 1) // DO WE NEED FAILSAFE HERE?
	{
		IntakeOnAuto();
	}
	while(MoveDist(19, 35,2000) == 1) // DO WE NEED FAILSAFE HERE?
	{
		IntakeOnAuto();
	}
	IntakePower(0);
	///////////////////////////////////////////////////////////////////////////////////PICK UP 3RD
	SetRPM(2200);
	clearTimer(T3);
	while(LineStatus() == 0 )
	{
		Move(-2, 127);
		if(time1[T3] > 5000)
		{
			FailSafeEngaged = 1;
			break;
		}
	}
	if(FailSafeEngaged == 1)Blue1FailInfinite(); //**FAIL GOOD
		Break(200,-15);
	while(MoveDist(3, 40,0) == 1);
	clearTimer(T3);
	while(LineStatus() == 0) // TURN UNTILL IT SEES LINE (WHAT IF WE NEVER SEE LINE)
	{
		Move(1,22);
		if(time1[T3] > 5000)
		{
			FailSafeEngaged = 1;
			break;
		}
	}
	if(FailSafeEngaged == 1)Blue1FailInfinite(); //**FAIL GOOD
		DistanceCalculator(1);
	clearTimer(T3);
	while(LineStatus() == 1 && DistanceCalculator(0) < 12)//*FAILSE WHAT IF WE GET OFF THE LINE ( WHAT IF ROBOT BLOCKS PATH AND WE ARE STILL ON THE LINE)
	{
		FollowLine(35);
		if(time1[T3] > 5000)
		{
			FailSafeEngaged = 1;
			break;
		}
	}
	if(FailSafeEngaged == 1)Blue1FailInfinite(); //**FAIL GOOD
		Break(100,20);
	StopDrive();
	delay(500);
	IntakePower(127);///SHOT LAST BALLS BAR SHOTS
	delay(3000);
	TurnDegree(-45,100,2000);
	while(MoveDist(24, 40,0) == 1);
	ShootingMode = 4;
	KillALL();
	while(1);
}
示例#6
0
void RedAuto1(void)
{
	int Launch = 0;
	Transmission(1);
	BallCounter = 4;
	ShootingMode = 1;
	IntakeShoot(6000);//SHOOT 4 PRELOADS // * FAILSAFE POINT
	ShootingMode = 4;
	stage = 1;
	TurnDegree(-10,40,0); // DO WE NEED FAILSAFE HERE?
	delay(200);
	Move(2,127);
	delay(500);
	clearTimer(T3);
	while(SensorValue[IR1] == 1) //*FAILSAFE ?WHAT IF WE DONT SEE ANY BALLS
	{
		IntakeOnAuto();
		Move(2,20);
		if(time1[T3] > 8000)
		{
			FailSafeEngaged = 1;
			break;
		}
	}
	if(FailSafeEngaged == 1)Red1Fail1();/////////////////////RED1FAIL1
		IntakePower(0);
	Break(100,10);
	while(MoveDist(-1, 20,0) == 1) // DO WE NEED FAILSAFE HERE?
	{
		IntakeOnAuto();
	}
	while(MoveDist(40, 50,0) == 1) //*FAILSAFE ?WHAT IF WE ARE BLOCKED (ROBOT FINISHED ABOUT MID COURT)
	{
		if(FailSafeEngaged == 1)Red1Fail1();/////////////////////RED1FAIL1
			IntakeOnAuto();
	}
	IntakePower(0);
	TurnDegree(-45,127,2000); //*FAILSAFE ?WHAT IF WE ARE BLOCKED
	if(FailSafeEngaged == 1)Red1FailInfinite();
	delay(200);
	SetRPM(2250);//LAUNCHER ON (NEXT SHOOTING RPM)
	clearTimer(T3);
	while(LineStatus() == 0) //*FAILSAFE AT WHAT POINT DO WE STOP MOVING? WHAT IF WE ARE OF COURSE?
	{
		Move(-2,30);
		if(time1[T3] > 3500)
		{
			FailSafeEngaged = 1;
			break;
		}
	}
	if(FailSafeEngaged == 1)Red1FailInfinite();
	Break(100,-20);
	delay(200);
	while(MoveDist(7, 30,0) == 1){} // DO WE NEED FAILSAFE HERE?
	clearTimer(T3);
	while(LineStatus() == 0) // TURN UNTILL IT SEES LINE (WHAT IF WE NEVER SEE LINE)
	{
		Move(1,22);
		if(time1[T3] > 3000)
		{
			FailSafeEngaged = 1;
			break;
		}
	}
	if(FailSafeEngaged == 1)Red1FailInfinite();
	while(LineStatus() == 1 && LineStatusOffset() == 0) //*FAILSE WHAT IF WE GET OFF THE LINE ( WHAT IF ROBOT BLOCKS PATH AND WE ARE STILL ON THE LINE)
	{
		FollowLine(40);
		if(LineStatus() == 1 && LineStatusOffset() == 1) Launch = 1;//WE REACHED THE CROSS(MIDDLE OF FIELD SET FLAG
	}
	if(LineStatus() == 1 && LineStatusOffset() == 1) Launch = 1;
	Break(100,20);
	StopDrive();
	delay(300);
	if(Launch) //IF LAUNCH FLAG WAS SATISFIED EARLIER THEN WE CAN LAUNCH BALLS
	{
		IntakePower(127); // SHOOT MID COURT
		delay(3000);
	}
	stage = 1;
	ShootingMode = 3;
	DistanceCalculator(1);
	while(SensorValue[IR1] == 1 && LineStatus() == 1 && DistanceCalculator(0) < 55) //*FAILSE WHAT IF WE GET OFF THE LINE ( WHAT IF ROBOT BLOCKS PATH AND WE ARE STILL ON THE LINE)
	{
		FollowLine(35);
		IntakeOnAuto();
	}
	Break(100,20);
	StopDrive();
	while(stage == 1) // WHAT IF TWO BALLS ARE STUCK FOREVER? TIMER?
	{
		IntakeOnAuto();
	}
	while(LineStatus() == 1 && DistanceCalculator(0) < 55)//*FAILSE WHAT IF WE GET OFF THE LINE ( WHAT IF ROBOT BLOCKS PATH AND WE ARE STILL ON THE LINE)
	{
		FollowLine(35);
		IntakeOnAuto();
	}
	MoveTime(300,127);
	StopDrive();
	IntakePower(127);///SHOT LAST BALLS BAR SHOTS
	delay(4000);
	stage = 1;
	///////////
	KillALL();
	while(1);
}