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


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

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


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

示例1: while

void
CameraDirector::SetViewObjectGroup(ListIter<Ship> group, bool quick)
{
    if (!ship) return;

    Starshatter* stars = Starshatter::GetInstance();

    if (!stars->InCutscene()) {
        // only view solid contacts:
        while (++group) {
            Ship* s = group.value();

            if (s->GetIFF() != ship->GetIFF()) {
                Contact* c = ship->FindContact(s);
                if (!c || !c->ActLock())
                return;
            }

            if (s->Life() == 0 || s->IsDying() || s->IsDead())
            return;
        }
    }

    group.reset();

    if (external_group.size() > 1 &&
            external_group.size() == group.size()) {

        bool same = true;

        for (int i = 0; same && i < external_group.size(); i++) {
            if (external_group[i] != group.container()[i])
            same = false;
        }

        if (same) {
            SetMode(MODE_ZOOM);
            return;
        }
    }

    ClearGroup();

    if (quick) {
        mode = MODE_ORBIT;
        transition = 0;
    }
    else {
        SetMode(MODE_TRANSLATE);
    }

    external_group.append(group.container());

    ListIter<Ship> iter = external_group;
    while (++iter) {
        Ship* s = iter.value();
        region = s->GetRegion();
        Observe(s);
    }
}
开发者ID:Banbury,项目名称:starshatter-open,代码行数:60,代码来源:CameraDirector.cpp

示例2:

bool
Element::IsActive() const
{
	bool active = false;

	for (int i = 0; i < ships.size() && !active; i++) {
		Ship* s = ships[i];
		if (s->Life() && s->MissionClock())
		active = true;
	}

	return active;
}
开发者ID:The-E,项目名称:Starshatter-Experimental,代码行数:13,代码来源: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::Life方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。