Exemplo n.º 1
0
void CHostageImprov::__MAKE_VHOOK(TrackPath)(const Vector &pathGoal, float deltaT)
{
	FaceTowards(pathGoal, deltaT);
	MoveTowards(pathGoal, deltaT);

	m_jumpTarget = pathGoal;
	DrawAxes(pathGoal, 255, 0, 255);
}
Exemplo n.º 2
0
  void PlayScene::LandingIntroUpdate()
  {

    if (!_landingFinished)
    {
      _landingTimer += GTime.deltaTime;

      _spacecraft->SetAlpha(Clamp(_landingTimer, 0.0f, kLandingAppearDuration)
        / kLandingAppearDuration);

      int32_t y = 0;
      if (_landingTimer <= kLandingFastDuration)
      {
        y = MoveTowards(_spacecraft->GetCenterY(), _landingDestination.second, 2);
      }
      else
      {
        y = MoveTowards(_spacecraft->GetCenterY(), _landingDestination.second, 1);
      }


      _spacecraft->SetCenterPosition(_spacecraft->GetCenterX(), y);

      if (_landingTimer >= kLandingBaseDelay)
      {
        auto t = Clamp(_landingTimer, kLandingBaseDelay, kLandingDuration);
        t = (t - kLandingBaseDelay) / (kLandingDuration - kLandingBaseDelay);
        _landingPlatform->SetAlpha(t);
      }


      if (_landingTimer > kLandingDuration)
      {
        _landingFinished = true;
      }
    }
  }
Exemplo n.º 3
0
void Level00::UpdateRobots()
{
	if (!mExplorer[0]->mTransform) return;
	auto player = mExplorer[0]->mTransform;

	for (int i = 0; i < mRobotCount; i++)
	{
		auto robot = &mRobots[i];
		auto follower = mFollowers[i];

		auto n = mGrid.GetNodeAt(robot->Transform.GetPosition());

		if (n->weight == -2)
		{
			auto list = mGrid.graph.GetNodeConnections(n);
			Node* minNode = n;
			float minWeight = FLT_MAX;

			for (auto conn : *list) {
				float w = conn.to->weight;
				if (w < 0) continue;
				if (w < minWeight)
				{
					minNode = conn.to;
					minWeight = w;
				}
			}
			n = minNode;

			delete list;
		}

		SearchResult<Node> searchResult;
		searchResult.path.push_back(n);

		TRACE_DIAMOND(n->worldPos, Colors::green);

		if (n->weight > 100 || n->weight < 0) continue;

		while (n->weight > 0) {
			auto list = mGrid.graph.GetNodeConnections(n);
			Node* minNode = n;
			float connCost = 0;

			for (auto conn : *list) {
				float w = conn.to->weight;
				if (w < 0) continue;
				if (w < minNode->weight)
				{
					minNode = conn.to;
					connCost = conn.cost;
				}
			}
			TRACE_LINE(n->worldPos, minNode->worldPos, Colors::yellow);
			n = minNode;

			searchResult.path.push_back(n);

			delete list;
		}

		if (searchResult.path.size() <= 1)
		{
			continue;
		}

		follower.MoveTowards(*player, searchResult);

		//mRobotTransforms[i] = robot->Transform.GetWorldMatrix();
	}
}