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


C++ Ship::RespawnCount方法代码示例

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


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

示例1: Update

bool
Element::Update(SimObject* obj)
{
	// false alarm, keep watching:
	if (obj->Life() != 0) {
		::Print("Element (%s) false update on (%s) life = %f\n", Name().data(), obj->Name(), obj->Life());
		return false;
	}

	Ship* s = (Ship*) obj;
	ships.remove(s);

	if (ships.isEmpty())
	respawns = s->RespawnCount();

	return SimObserver::Update(obj);
}
开发者ID:The-E,项目名称:Starshatter-Experimental,代码行数:17,代码来源:Element.cpp

示例2:

bool
Element::IsFinished() const
{
	bool finished = false;

	if (launch_time > 0 && respawns < 1) {
		finished = true;

		if (ships.size() > 0) {
			for (int i = 0; i < ships.size() && finished; i++) {
				Ship* s = ships[i];
				if (s->RespawnCount() >  0 ||
						s->MissionClock() == 0 ||
						s->Life() && !s->GetInbound())
				finished = false;
			}
		}
	}

	return finished;
}
开发者ID:The-E,项目名称:Starshatter-Experimental,代码行数:21,代码来源:Element.cpp

示例3: if

bool
MissionEvent::CheckTrigger()
{
	Sim* sim = Sim::GetSim();

	if (time > 0 && time > sim->MissionClock())
	return false;

	switch (trigger) {
	case TRIGGER_TIME: {
			if (time <= sim->MissionClock())
			Activate();
		}
		break;

	case TRIGGER_DAMAGE: {
			Ship* ship = sim->FindShip(trigger_ship);
			if (ship) {
				double damage = 100.0 * (ship->Design()->integrity - ship->Integrity()) /
				(ship->Design()->integrity);
				
				if (damage >= trigger_param[0])
				Activate();
			}
		}
		break;

	case TRIGGER_DETECT: {
			Ship* ship = sim->FindShip(trigger_ship);
			Ship* tgt  = sim->FindShip(trigger_target);
			
			if (ship && tgt) {
				if (ship->FindContact(tgt))
				Activate();
			}
			else {
				Skip();
			}
		}
		break;

	case TRIGGER_RANGE: {
			Ship* ship = sim->FindShip(trigger_ship);
			Ship* tgt  = sim->FindShip(trigger_target);
			
			if (ship && tgt) {
				double range     = (ship->Location() - tgt->Location()).length();
				double min_range = 0;
				double max_range = 1e12;

				if (trigger_param[0] > 0)
				min_range = trigger_param[0];
				else
				max_range = -trigger_param[0];

				if (range < min_range || range > max_range)
				Activate();
			}
			else {
				Skip();
			}
		}
		break;

	case TRIGGER_SHIPS_LEFT: {
			int alive   = 0;
			int count   = 0;
			int iff     = -1;
			int nparams = NumTriggerParams();

			if (nparams > 0) count = TriggerParam(0);
			if (nparams > 1) iff   = TriggerParam(1);

			ListIter<SimRegion> iter = sim->GetRegions();
			while (++iter) {
				SimRegion* rgn = iter.value();

				ListIter<Ship> s_iter = rgn->Ships();
				while (++s_iter) {
					Ship* ship = s_iter.value();

					if (ship->Type() >= Ship::STATION)
					continue;

					if (ship->Life() == 0 && ship->RespawnCount() < 1)
					continue;

					if (iff < 0 || ship->GetIFF() == iff)
					alive++;
				}
			}

			if (alive <= count)
			Activate();
		}
		break;

	case TRIGGER_EVENT_ALL: {
			bool  all     = true;
			int   nparams = NumTriggerParams();
//.........这里部分代码省略.........
开发者ID:The-E,项目名称:Starshatter-Experimental,代码行数:101,代码来源:MissionEvent.cpp


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