示例#1
0
//---------------------------------------------------------------------------
void TTestControlTank::Send()
{
	lockQtSend();
	//----------------------------
	UpdateAngle();
	TBreakPacket bp;
	bp.PushFront((char*)mDesc.get(), sizeof(TDesc));

	TDevTool_Share::TComponent* pComponent = TDevTool_Share::Singleton()->GetComponent();
	PrototypeMMOBaseServer* pBS = (PrototypeMMOBaseServer*)pComponent->mNet.Base;

	std::list<unsigned int> listKey;
	//###
	// рассылка всем клиентам
	PrototypeMMOSlave::TDescDownSlave descDown;
	int sizeDesc = sizeof(descDown);
	int countClient = pComponent->mNet.Slave->GetCountDown();
	for( int iClient = 0 ; iClient < countClient ; iClient++)
	{
		//if(pComponent->mNet.Slave->GetDescDown(iClient, (void*)&descDown, sizeDesc))
			//pBS->SendDown( descDown.id_session, bp);
		if(pComponent->mNet.Slave->GetDescDown(iClient, (void*)&descDown, sizeDesc))
		{
			unsigned int id_client;
			if(pComponent->mNet.Slave->FindClientKeyBySession(descDown.id_session,id_client))
				listKey.push_back(id_client);
		}
	}
	pBS->SendByClientKey( listKey, bp);
	//###
  //----------------------------
	unlockQtSend();
}
			void Fire()
			{
				mHasFired = true;
				mGuidanceOn = true;

				UpdateAngle();
				SetRotation(mDesiredAngle);
			}
示例#3
0
文件: game.cpp 项目: sig-vip/Pacman
void Ghost::Update()
{
	UpdateCoord();

	if (objType != GOT_PLAYER)
	{
		UpdateAngle();
		UpdateAI(1, true);   // in order to ghosts don't stop

		// updating AI after moving to the next cell
		if (!(i == mi && j == mj))
		{
			if (pGame->IsDifficultyHard() && pGame->GetMode() == "rl")
			{
				if (Velocity == pGame->cGhostList().cbegin()->Velocity)
					UpdateAI(0.4, false);   //0.3
				else
					UpdateAI(0.8, false);   //0.2
			}
			else if (pGame->GetCell(i, j) == 4 || pGame->GetCell(i, j) == 5)
			{
				if (pGame->GetMode() == "s")
					UpdateAI(0.8, false);
				else
				{
					double call_prob = 0.8;             //0.5   0.8
					if (pGame->GetMode() == "rl")
						call_prob = 0.3;                //0.4   0.8   0.2

					if (pGame->IsDifficultyHard())
						// for labyrinth mode
						UpdateAI(call_prob, false);
					else
					{
						if (RANDOM < 0.7)
							UpdateAI(call_prob, false);
						else
							UpdateAI(call_prob);
					}
				}
			}
		}
	}

	Update_mij();   // isn't used if (objType == GOT_PLAYER) -> for future needs
}
			void Update(sf::Time& deltaTime)
			{
				mTimeSinceLast = deltaTime.asMilliseconds() - mTimeSinceLast;

				sf::IntRect screen(0, 0, 1280, 720);
				if (!screen.contains((int)this->GetPosition().x, (int)this->GetPosition().y))
					SetAlive(false);

				if (mHasFired)
				{
					if (mElapsed > mAimpointUpdateDelayMs)
					{
						mCurrentAimpoint = mFinalAimpoint;
						mElapsed = 0;
						mAimpointUpdated = true;

						UpdateAngle();
					}
					else
					{
						mElapsed += mTimeSinceLast;
					}

					if ((GetRotation() > mDesiredAngle + 1) || (GetRotation() < mDesiredAngle - 1))
					{
						if (mGuidanceOn)
						{
							if (mDesiredAngle > GetRotation())
								SetRotation(GetRotation() + 0.25f);
							else
								SetRotation(GetRotation() - 0.25f);
						}
					}
					else
					{
						if (mAimpointUpdated)
							mGuidanceOn = false;
					}

					float velx = (float)(cos(Math::ToRadians(GetRotation() - 90.0f)) * mSpeed);
					float vely = (float)(sin(Math::ToRadians(GetRotation() - 90.0f)) * mSpeed);
					SetVelocity(sf::Vector2f(velx, vely));
				}

				Sprite::Update(deltaTime);
			}
示例#5
0
文件: TiltSensor.cpp 项目: hot67/2016
double TiltSensor::GetAngle()
{
	m_angle = UpdateAngle();
	return (m_angle*180.0/3.14159);
}