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


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

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


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

示例1:

bool
FighterTacticalAI::IsStrikeComplete(Instruction* instr)
{
	// wingmen can not call a halt to a strike:
	if (!ship || element_index > 1)
	return false;

	// if there's nothing to shoot at, we must be done:
	if (!instr || !instr->GetTarget() || instr->GetTarget()->Life() == 0 ||
			instr->GetTarget()->Type() != SimObject::SIM_SHIP)
	return true;

	// break off strike only when ALL weapons are expended:
	// (remember to check all relevant wingmen)
	Element*    element = ship->GetElement();
	Ship*       target  = (Ship*) instr->GetTarget();

	if (!element)
	return true;

	for (int i = 0; i < element->NumShips(); i++) {
		Ship* s = element->GetShip(i+1);

		if (!s || s->Integrity() < 25) // || (s->Location() - target->Location()).length() > 250e3)
		continue;

		ListIter<WeaponGroup> g_iter = s->Weapons();
		while (++g_iter) {
			WeaponGroup* w = g_iter.value();

			if (w->Ammo() && w->CanTarget(target->Class())) {
				ListIter<Weapon> w_iter = w->GetWeapons();

				while (++w_iter) {
					Weapon* weapon = w_iter.value();

					if (weapon->Status() > System::CRITICAL)
					return false;
				}
			}
		}
	}

	// still here?  we must be done!
	return true;
}
开发者ID:The-E,项目名称:Starshatter-Experimental,代码行数:46,代码来源:FighterTacticalAI.cpp

示例2: if

void
Instruction::Evaluate(Ship* ship)
{
    Sim* sim = Sim::GetSim();

    switch (action) {
    case VECTOR:
        break;

    case LAUNCH:
        if (ship->GetFlightPhase() == Ship::ACTIVE)
        SetStatus(COMPLETE);
        break;

    case DOCK:
    case RTB:
        if (sim->GetPlayerShip() == ship &&
                (ship->GetFlightPhase() == Ship::DOCKING ||
                    ship->GetFlightPhase() == Ship::DOCKED))
        SetStatus(COMPLETE);
        else if (ship->Integrity() < 1)
        SetStatus(FAILED);
        break;

    case DEFEND:
    case ESCORT:
        {
            bool found = false;
            bool safe  = true;

            ListIter<Element> iter = sim->GetElements();
            while (++iter && !found) {
                Element* e = iter.value();

                if (e->IsFinished() || e->IsSquadron())
                continue;

                if (e->Name() == tgt_name || 
                        (e->GetCommander() && e->GetCommander()->Name() == tgt_name)) {

                    found = true;

                    for (int i = 0; i < e->NumShips(); i++) {
                        Ship* s = e->GetShip(i+1);

                        if (s && s->Integrity() < 1)
                        SetStatus(FAILED);
                    }

                    if (status == PENDING) {
                        // if the element had a flight plan, and all nav points
                        // have been addressed, then the element is safe
                        if (e->FlightPlanLength() > 0) {
                            if (e->GetNextNavPoint() == 0)
                            SetStatus(COMPLETE);
                            else
                            safe = false;
                        }
                    }
                }
            }

            if (status == PENDING && safe &&
                    sim->GetPlayerShip() == ship &&
                    (ship->GetFlightPhase() == Ship::DOCKING ||
                        ship->GetFlightPhase() == Ship::DOCKED)) {
                SetStatus(COMPLETE);
            }
        }
        break;

    case PATROL:
    case SWEEP:
        {
            Sim* sim   = Sim::GetSim();
            bool alive = false;

            ListIter<Element> iter = sim->GetElements();
            while (++iter) {
                Element* e = iter.value();

                if (e->IsFinished() || e->IsSquadron())
                continue;

                if (e->GetIFF() && e->GetIFF() != ship->GetIFF()) {
                    for (int i = 0; i < e->NumShips(); i++) {
                        Ship* s = e->GetShip(i+1);

                        if (s && s->Integrity() >= 1)
                        alive = true;
                    }
                }
            }

            if (status == PENDING && !alive) {
                SetStatus(COMPLETE);
            }
        }
        break;

//.........这里部分代码省略.........
开发者ID:Banbury,项目名称:starshatter-open,代码行数:101,代码来源:Instruction.cpp

示例3: if


//.........这里部分代码省略.........
		}
		break;

	case INSTRUCTION:
		if (elem) {
			if (event_param[0])
			elem->ClearInstructions();

			elem->AddInstruction(event_message);

			if (elem->Contains(player) && event_message.length() > 0) {
				HUDView* hud = HUDView::GetInstance();

				if (hud)
				hud->ShowHUDInst();
			}
		}
		break;

	case IFF:
		if (elem) {
			elem->SetIFF(event_param[0]);
		}

		else if (ship) {
			ship->SetIFF(event_param[0]);
		}
		break;

	case DAMAGE:
		if (ship) {
			ship->InflictDamage(event_param[0]);

			if (ship->Integrity() < 1) {
				NetUtil::SendObjKill(ship, 0, NetObjKill::KILL_MISC);
				ship->DeathSpiral();
				Print("    %s Killed By Scripted Event %d (%s)\n", (const char*) ship->Name(), id, FormatGameTime());
			}
		}
		else {
			Print("   EVENT %d: Could not apply damage to ship '%s' (not found).\n", id, (const char*) event_ship);
		}
		break;

	case JUMP:
		if (ship) {
			SimRegion* rgn = sim->FindRegion(event_target);

			if (rgn && ship->GetRegion() != rgn) {
				if (rgn->IsOrbital()) {
					QuantumDrive* quantum_drive = ship->GetQuantumDrive();
					if (quantum_drive) {
						quantum_drive->SetDestination(rgn, Point(0,0,0));
						quantum_drive->Engage(true); // request immediate jump
					}

					else if (ship->IsAirborne()) {
						ship->MakeOrbit();
					}
				}

				else {
					ship->DropOrbit();
				}
			}
开发者ID:The-E,项目名称:Starshatter-Experimental,代码行数:66,代码来源:MissionEvent.cpp

示例4: if

void
NetGameClient::DoObjKill(NetMsg* msg)
{
	if (!msg) return;

	NetObjKill obj_kill;
	obj_kill.Unpack(msg->Data());

	Ship* ship = FindShipByObjID(obj_kill.GetObjID());
	if (ship) {
		Ship* killer = FindShipByObjID(obj_kill.GetKillerID());
		Text  killer_name = Game::GetText("NetGameClient.unknown");

		if (killer)
		killer_name = killer->Name();

		// log the kill:
		switch (obj_kill.GetKillType()) {
		default:
		case NetObjKill::KILL_MISC:
			Print("Ship '%s' destroyed (misc) (%s)\n", ship->Name(), FormatGameTime());
			break;

		case NetObjKill::KILL_PRIMARY:
		case NetObjKill::KILL_SECONDARY:
			Print("Ship '%s' killed by '%s' (%s)\n", ship->Name(), killer_name.data(), FormatGameTime());
			break;

		case NetObjKill::KILL_COLLISION:
			Print("Ship '%s' killed in collision with '%s' (%s)\n", ship->Name(), killer_name.data(), FormatGameTime());
			break;

		case NetObjKill::KILL_CRASH:
			Print("Ship '%s' destroyed (crash) (%s)\n", ship->Name(), FormatGameTime());

		case NetObjKill::KILL_DOCK:
			Print("Ship '%s' docked (%s)\n", ship->Name(), FormatGameTime());
		}

		// record the kill in the stats:
		if (killer && obj_kill.GetKillType() != NetObjKill::KILL_DOCK) {
			ShipStats* kstats = ShipStats::Find(killer->Name());
			if (kstats) {
				if (obj_kill.GetKillType() == NetObjKill::KILL_PRIMARY)
				kstats->AddEvent(SimEvent::GUNS_KILL, ship->Name());
				
				else if (obj_kill.GetKillType() == NetObjKill::KILL_SECONDARY)
				kstats->AddEvent(SimEvent::MISSILE_KILL, ship->Name());
			}

			if (killer && killer->GetIFF() != ship->GetIFF()) {
				if (ship->GetIFF() > 0 || killer->GetIFF() > 1)
				kstats->AddPoints(ship->Value());
			}
		}

		ShipStats* killee = ShipStats::Find(ship->Name());
		if (killee) {
			if (obj_kill.GetKillType() == NetObjKill::KILL_DOCK)
			killee->AddEvent(SimEvent::DOCK, killer_name);
			else 
			killee->AddEvent(SimEvent::DESTROYED, killer_name);
		}

		if (obj_kill.GetKillType() == NetObjKill::KILL_DOCK) {
			FlightDeck* deck = killer->GetFlightDeck(obj_kill.GetFlightDeck());
			sim->NetDockShip(ship, killer, deck);
		}
		else {
			ship->InflictNetDamage(ship->Integrity());
			ship->DeathSpiral();

			if (!obj_kill.GetRespawn())
			ship->SetRespawnCount(0);
			else
			ship->SetRespawnLoc(obj_kill.GetRespawnLoc());
		}
	}

	// this shouldn't happen in practice, 
	// but if it does, this is what should be done:
	else {
		Shot* shot = FindShotByObjID(obj_kill.GetObjID());

		if (shot) {
			::Print("NetGameClient::DoObjKill destroying shot '%s'\n", shot->Name());
			shot->Destroy();
		}
	}
}
开发者ID:The-E,项目名称:Starshatter-Experimental,代码行数:90,代码来源:NetGameClient.cpp


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