当前位置: 首页>>代码示例>>C++>>正文


C++ CUnit::Move方法代码示例

本文整理汇总了C++中CUnit::Move方法的典型用法代码示例。如果您正苦于以下问题:C++ CUnit::Move方法的具体用法?C++ CUnit::Move怎么用?C++ CUnit::Move使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CUnit的用法示例。


在下文中一共展示了CUnit::Move方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Update

void CBasicMapDamage::Update()
{
	SCOPED_TIMER("BasicMapDamage::Update");

	std::deque<Explo*>::iterator ei;

	for (ei = explosions.begin(); ei != explosions.end(); ++ei) {
		Explo* e = *ei;
		if (e->ttl <= 0) {
			continue;
		}
		--e->ttl;

		const int x1 = e->x1;
		const int x2 = e->x2;
		const int y1 = e->y1;
		const int y2 = e->y2;
		std::vector<float>::const_iterator si = e->squares.begin();

		for (int y = y1; y <= y2; ++y) {
			for (int x = x1; x<= x2; ++x) {
				const float dif = *(si++);
				readMap->AddHeight(y * gs->mapxp1 + x, dif);
			}
		}
		std::vector<ExploBuilding>::const_iterator bi;
		for (bi = e->buildings.begin(); bi != e->buildings.end(); ++bi) {
			const float dif = bi->dif;
			const int tx1 = bi->tx1;
			const int tx2 = bi->tx2;
			const int tz1 = bi->tz1;
			const int tz2 = bi->tz2;

			for (int z = tz1; z < tz2; z++) {
				for (int x = tx1; x < tx2; x++) {
					readMap->AddHeight(z * gs->mapxp1 + x, dif);
				}
			}

			CUnit* unit = unitHandler->GetUnit(bi->id);

			if (unit != NULL) {
				unit->Move(UpVector * dif, true);
			}
		}
		if (e->ttl == 0) {
			RecalcArea(x1 - 2, x2 + 2, y1 - 2, y2 + 2);
		}
	}

	while (!explosions.empty() && explosions.front()->ttl == 0) {
		delete explosions.front();
		explosions.pop_front();
	}

	UpdateLos();
}
开发者ID:9heart,项目名称:spring,代码行数:57,代码来源:BasicMapDamage.cpp

示例2: MouseEvent

//------------------------------------------------------------------------
// 
// [2011/1/14 jjuiddong]
//------------------------------------------------------------------------
void CEvosGame::MouseEvent( int windowEvent, POINT pos)
{
	switch (windowEvent)
	{
	case WM_RBUTTONDOWN:
		{
			CUnit *punit = m_pUnitControl->GetUnit(0);
			if (punit)
			{
				punit->Move(Vector2D(pos.x, pos.y));
			}
		}
		break;
	}

}
开发者ID:jjuiddong,项目名称:Dx3D-Study,代码行数:20,代码来源:evosgame.cpp

示例3: Update

void CBasicMapDamage::Update()
{
	SCOPED_TIMER("BasicMapDamage::Update");

	for (Explo* e: explosions) {
		if (e->ttl <= 0) {
			continue;
		}
		--e->ttl;

		std::vector<float>::const_iterator si = e->squares.begin();
		for (int y = e->y1; y <= e->y2; ++y) {
			for (int x = e->x1; x <= e->x2; ++x) {
				const float dif = *(si++);
				readMap->AddHeight(y * mapDims.mapxp1 + x, dif);
			}
		}

		for (ExploBuilding& b: e->buildings) {
			for (int z = b.tz1; z < b.tz2; z++) {
				for (int x = b.tx1; x < b.tx2; x++) {
					readMap->AddHeight(z * mapDims.mapxp1 + x, b.dif);
				}
			}

			CUnit* unit = unitHandler->GetUnit(b.id);
			if (unit != NULL) {
				unit->Move(UpVector * b.dif, true);
			}
		}

		if (e->ttl == 0) {
			RecalcArea(e->x1 - 1, e->x2 + 1, e->y1 - 1, e->y2 + 1);
		}
	}

	while (!explosions.empty() && explosions.front()->ttl == 0) {
		delete explosions.front();
		explosions.pop_front();
	}

	UpdateLos();
}
开发者ID:amitamitamitamit,项目名称:spring,代码行数:43,代码来源:BasicMapDamage.cpp

示例4: HandleCollisions

bool CHoverAirMoveType::HandleCollisions(bool checkCollisions)
{
	const float3& pos = owner->pos;

	if (pos != oldPos) {
		oldPos = pos;

		bool hitBuilding = false;

		// check for collisions if not on a pad, not being built, or not taking off
		// includes an extra condition for transports, which are exempt while loading
		if (!forceHeading && checkCollisions) {
			const vector<CUnit*>& nearUnits = quadField->GetUnitsExact(pos, owner->radius + 6);

			for (vector<CUnit*>::const_iterator ui = nearUnits.begin(); ui != nearUnits.end(); ++ui) {
				CUnit* unit = *ui;

				if (unit->transporter != NULL)
					continue;

				const float sqDist = (pos - unit->pos).SqLength();
				const float totRad = owner->radius + unit->radius;

				if (sqDist <= 0.1f || sqDist >= (totRad * totRad))
					continue;

				const float dist = math::sqrt(sqDist);
				const float3 dif = (pos - unit->pos).Normalize();

				if (unit->mass >= CSolidObject::DEFAULT_MASS || unit->immobile) {
					owner->Move(-dif * (dist - totRad), true);
					owner->SetVelocity(owner->speed * 0.99f);

					hitBuilding = true;
				} else {
					const float part = owner->mass / (owner->mass + unit->mass);
					const float colSpeed = -owner->speed.dot(dif) + unit->speed.dot(dif);

					owner->Move(-dif * (dist - totRad) * (1.0f - part), true);
					owner->SetVelocity(owner->speed + (dif * colSpeed * (1.0f - part)));

					if (!unit->UsingScriptMoveType()) {
						unit->SetVelocityAndSpeed(unit->speed - (dif * colSpeed * (part)));
						unit->Move(dif * (dist - totRad) * (part), true);
					}
				}
			}

			// update speed.w
			owner->SetSpeed(owner->speed);
		}

		if (hitBuilding && owner->IsCrashing()) {
			owner->KillUnit(NULL, true, false);
			return true;
		}

		if (pos.x < 0.0f) {
			owner->Move( RgtVector * 0.6f, true);
		} else if (pos.x > float3::maxxpos) {
			owner->Move(-RgtVector * 0.6f, true);
		}

		if (pos.z < 0.0f) {
			owner->Move( FwdVector * 0.6f, true);
		} else if (pos.z > float3::maxzpos) {
			owner->Move(-FwdVector * 0.6f, true);
		}

		return true;
	}

	return false;
}
开发者ID:9heart,项目名称:spring,代码行数:74,代码来源:HoverAirMoveType.cpp


注:本文中的CUnit::Move方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。