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


C++ CombatGroup类代码示例

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


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

示例1: while

int
CombatGroup::CountUnits() const
{
	int n = 0;

	CombatGroup* g = (CombatGroup*) this;

	ListIter<CombatUnit> unit = g->units;
	while (++unit)
	n += unit->Count() - unit->DeadCount();

	CombatGroup* pThis = ((CombatGroup*) this);
	pThis->live_comp.clear();
	ListIter<CombatGroup> iter = g->components;
	while (++iter) {
		CombatGroup* comp = iter.value();

		if (!comp->IsReserve()) {
			int unit_count = comp->CountUnits();
			if (unit_count > 0)
			pThis->live_comp.append(comp);

			n += unit_count;
		}
	}

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

示例2: RandomIndex

CampaignMissionRequest*
CampaignPlanMission::PlanRandomStarshipMission()
{
    int type    = Mission::PATROL;
    int r       = RandomIndex();
    int ownside = player_group->GetIFF();

    if (mission_type_index < 0)
    mission_type_index = r;

    else if (mission_type_index >= 16)
    mission_type_index = 0;

    type = mission_types[mission_type_index++];

    if (type == Mission::ESCORT_FREIGHT) {
        CombatGroup*  freight  = campaign->FindGroup(ownside, CombatGroup::FREIGHT);
        if (!freight || freight->CountUnits() < 1)
        type = Mission::PATROL;
    }

    CampaignMissionRequest* request = 0;
    request = new(__FILE__,__LINE__)
    CampaignMissionRequest(campaign, type, start, player_group);

    return request;
}
开发者ID:Banbury,项目名称:starshatter-open,代码行数:27,代码来源:CampaignPlanMission.cpp

示例3: while

void
CampaignPlanStrategic::ExecFrame()
{
    if (campaign && campaign->IsActive()) {
        if (Campaign::Stardate() - exec_time < 300)
        return;

        ListIter<CombatZone> zone = campaign->GetZones();
        while (++zone)
        zone->Clear();

        ListIter<Combatant>  iter = campaign->GetCombatants();
        while (++iter) {
            Combatant*     c     = iter.value();
            CombatGroup*   force = c->GetForce();

            force->CalcValue();

            PlaceGroup(force);
            ScoreCombatant(c);
            ScoreNeeds(c);

            force->ClearUnlockedZones();
            AssignZones(c);
            ResolveZoneMovement(force);
        }

        exec_time = Campaign::Stardate();
    }
}
开发者ID:Banbury,项目名称:starshatter-open,代码行数:30,代码来源:CampaignPlanStrategic.cpp

示例4: GetParent

CombatGroup*
CombatGroup::FindCarrier()
{
	CombatGroup* p = GetParent();

	while (p         != 0                           && 
	p->Type() != CombatGroup::CARRIER_GROUP  &&
	p->Type() != CombatGroup::STATION        &&
	p->Type() != CombatGroup::STARBASE)
	p = p->GetParent();

	if (p && p->GetUnits().size())
	return p;

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

示例5: Text

void
CombatGroup::SetZoneLock(bool lock)
{
	if (!assigned_zone)
	zone_lock = false;
	else
	zone_lock = lock;

	if (zone_lock)
	assigned_system = Text();

	ListIter<CombatGroup> iter = components;
	while (++iter) {
		CombatGroup* g = iter.value();
		g->SetZoneLock(lock);
	}
}
开发者ID:The-E,项目名称:Starshatter-Experimental,代码行数:17,代码来源:CombatGroup.cpp

示例6: while

CampaignMissionRequest*
CampaignPlanMission::PlanCampaignMission()
{
    CampaignMissionRequest* request = 0;

    ListIter<CombatAction> iter = campaign->GetActions();
    while (++iter && !request) {
        CombatAction* action = iter.value();

        if (action->Type() != CombatAction::MISSION_TEMPLATE)
        continue;

        if (action->IsAvailable()) {

            // only fire each action once every two hours:
            if (action->ExecTime() > 0 && campaign->GetTime() - action->ExecTime() < 7200)
            continue;

            CombatGroup* g = campaign->FindGroup(action->GetIFF(),
            action->AssetType(),
            action->AssetId());

            if (g && (g == player_group || 
                        (player_group->Type() == CombatGroup::WING &&
                            player_group->FindGroup(g->Type(), g->GetID())))) {

                request = new(__FILE__,__LINE__)
                CampaignMissionRequest(campaign, 
                action->Subtype(),
                start, 
                g);

                if (request) {
                    request->SetOpposingType(action->OpposingType());
                    request->SetScript(action->GetText());
                }

                action->FireAction();
            }
        }
    }

    return request;
}
开发者ID:Banbury,项目名称:starshatter-open,代码行数:44,代码来源:CampaignPlanMission.cpp

示例7: new

CombatGroup*
CombatGroup::Clone(bool deep)
{
	CombatGroup* clone = new(__FILE__,__LINE__)
	CombatGroup(type, id, name, iff, enemy_intel);

	clone->combatant  = combatant;
	clone->region     = region;
	clone->location   = location;
	clone->value      = value;
	clone->expanded   = expanded;

	for (int i = 0; i < units.size(); i++) {
		CombatUnit* u = new(__FILE__,__LINE__) CombatUnit(*units[i]);
		u->SetCombatGroup(clone);
		clone->units.append(u);
	}

	if (deep) {
		for (int i = 0; i < components.size(); i++) {
			CombatGroup* g = components[i]->Clone(deep);
			clone->AddComponent(g);

			if (g->Type() == FIGHTER_SQUADRON   ||
					g->Type() == INTERCEPT_SQUADRON ||
					g->Type() == ATTACK_SQUADRON    ||
					g->Type() == LCA_SQUADRON) {

				if (units.size() > 0) {
					CombatUnit* carrier = units[0];

					for (int u = 0; u < g->GetUnits().size(); u++) {
						CombatUnit* unit = g->GetUnits()[u];

						if (unit->Type() >= Ship::FIGHTER ||
								unit->Type() <= Ship::LCA) {
							unit->SetCarrier(carrier);
							unit->SetRegion(carrier->GetRegion());
						}
					}
				}
			}
		}
	}

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

示例8: while

void
FltDlg::OnMissionType(AWEvent* event)
{
	mission_type = -1;

	for (int i = 0; i < 6; i++) {
		if (mission_btn[i]) {
			if (mission_btn[i] == event->window) {
				mission_btn[i]->SetButtonState(1);
				mission_type = i;
			}
			else {
				mission_btn[i]->SetButtonState(0);
			}
		}
	}

	if (objective_list && mission_type > -1) {
		objective_list->ClearItems();

		char txt[32];
		Sim* sim = Sim::GetSim();
		ListIter<Element> iter = sim->GetElements();

		while (++iter) {
			Element* elem = iter.value();

			if (!elem->IsActive() || elem->IsFinished() || elem->IsSquadron())
			continue;

			CombatGroup*   group = elem->GetCombatGroup();
			int            iff   = elem->GetIFF();
			Ship*          s     = elem->GetShip(1);
			double         r     = 0;
			bool           con   = false;

			if (iff != ship->GetIFF()) {
				if (elem->IntelLevel() < Intel::LOCATED)
				continue;

				if (group && group->IntelLevel() < Intel::LOCATED)
				continue;
			}

			if (s) {
				Point s_loc = s->Location()    + s->GetRegion()->Location();
				Point h_loc = ship->Location() + ship->GetRegion()->Location();

				r = (s_loc - h_loc).length();

				con = ship->FindContact(s) != 0;

				if (con) {
					FormatNumber(txt, r);
				}
				else {
					strcpy_s(txt, Game::GetText("FltDlg.Unknown").data());
					r = 2e9;
				}
			}

			switch (mission_type) {
			case 1:  // INTERCEPT
				if (iff && iff != ship->GetIFF() && s && s->IsDropship()) {
					int item = objective_list->AddItem(elem->Name()) - 1;
					objective_list->SetItemText(item, 1, s->GetRegion()->Name());

					objective_list->SetItemText(item, 2, txt);
					objective_list->SetItemData(item, 2, (DWORD) r);
				}
				break;

			case 2:  // ASSAULT
				if (iff && iff != ship->GetIFF() && s && (s->IsStarship() || s->IsStatic())) {
					int item = objective_list->AddItem(elem->Name()) - 1;
					objective_list->SetItemText(item, 1, s->GetRegion()->Name());

					objective_list->SetItemText(item, 2, txt);
					objective_list->SetItemData(item, 2, (DWORD) r);
				}
				break;

			case 3:  // STRIKE
				if (iff && iff != ship->GetIFF() && s && s->IsGroundUnit()) {
					int item = objective_list->AddItem(elem->Name()) - 1;
					objective_list->SetItemText(item, 1, s->GetRegion()->Name());

					objective_list->SetItemText(item, 2, txt);
					objective_list->SetItemData(item, 2, (DWORD) r);
				}
				break;

			case 4:  // ESCORT
				if ((iff == 0 || iff == ship->GetIFF()) && (!s || !s->IsStatic())) {
					int item = objective_list->AddItem(elem->Name()) - 1;

					if (s) {
						objective_list->SetItemText(item, 1, s->GetRegion()->Name());
						objective_list->SetItemText(item, 2, txt);
						objective_list->SetItemData(item, 2, (DWORD) r);
//.........这里部分代码省略.........
开发者ID:lightgemini78,项目名称:Starshatter-Rearmed,代码行数:101,代码来源:FltDlg.cpp

示例9: BuildGroupList

void
CampaignPlanStrategic::AssignZones(Combatant* c)
{
    // find the list of assignable groups, in priority order:
    List<CombatGroup> groups;
    BuildGroupList(c->GetForce(), groups);
    groups.sort();

    // for each group, assign a zone:
    ListIter<CombatGroup> g_iter = groups;

    // first pass: fighter and attack squadrons assigned to star bases
    while (++g_iter) {
        CombatGroup* g     = g_iter.value();
        int          gtype = g->Type();

        if (gtype == CombatGroup::ATTACK_SQUADRON    ||
                gtype == CombatGroup::FIGHTER_SQUADRON   ||
                gtype == CombatGroup::INTERCEPT_SQUADRON) {
            CombatGroup* parent = g->GetParent();

            if (parent && parent->Type() == CombatGroup::WING)
            parent = parent->GetParent();

            if (!parent || parent->Type() == CombatGroup::CARRIER_GROUP)
            continue;

            // these groups are attached to fixed resources,
            // so they must be assigned to the parent's zone:
            CombatZone* parent_zone = campaign->GetZone(parent->GetRegion());

            if (parent_zone) {
                ZoneForce*  parent_force = parent_zone->FindForce(g->GetIFF());

                if (parent_force) {
                    g->SetAssignedZone(parent_zone);
                    parent_force->AddNeed(g->Type(), -(g->Value()));
                }
            }
        }
    }

    // second pass: carrier groups
    g_iter.reset();
    while (++g_iter) {
        CombatGroup* g     = g_iter.value();
        int          gtype = g->Type();

        if (gtype == CombatGroup::CARRIER_GROUP) {
            int         current_zone_need = 0;
            int         highest_zone_need = 0;
            CombatZone* highest_zone      = 0;
            ZoneForce*  highest_force     = 0;
            CombatZone* current_zone      = 0;
            ZoneForce*  current_force     = 0;

            List<CombatZone> possible_zones;

            if (g->IsZoneLocked()) {
                current_zone  = g->GetAssignedZone();
                current_force = current_zone->FindForce(g->GetIFF());
            }

            else {
                ListIter<CombatZone> z_iter = campaign->GetZones();
                while (++z_iter) {
                    CombatZone* zone  = z_iter.value();
                    ZoneForce*  force = zone->FindForce(g->GetIFF());
                    int         need  = force->GetNeed(CombatGroup::CARRIER_GROUP)     +
                    force->GetNeed(CombatGroup::ATTACK_SQUADRON)   +
                    force->GetNeed(CombatGroup::FIGHTER_SQUADRON)  +
                    force->GetNeed(CombatGroup::INTERCEPT_SQUADRON);

                    if (g->IsSystemLocked() && zone->System() != g->GetAssignedSystem())
                    continue;

                    possible_zones.append(zone);

                    if (zone->HasRegion(g->GetRegion())) {
                        current_zone_need = need;
                        current_zone      = zone;
                        current_force     = force;
                    }

                    if (need > highest_zone_need) {
                        highest_zone_need = need;
                        highest_zone      = zone;
                        highest_force     = force;
                    }
                }
            }

            CombatZone* assigned_zone  = current_zone;
            ZoneForce*  assigned_force = current_force;

            if (highest_zone_need > current_zone_need) {
                assigned_zone  = highest_zone;
                assigned_force = highest_force;
            }

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

示例10: if


//.........这里部分代码省略.........

			if (event_param[0] == 3) {
				cam_dir->SetOrbitPoint(event_point.x, event_point.y, event_point.z);
			}

			else if (event_param[0] == 5) {
				cam_dir->SetOrbitRates(event_point.x, event_point.y, event_point.z);
			}
		}
		break;

	case VOLUME:
		if (stars->InCutscene()) {
			AudioConfig* audio_cfg = AudioConfig::GetInstance();

			audio_cfg->SetEfxVolume(event_param[0]);
			audio_cfg->SetWrnVolume(event_param[0]);
		}
		break;

	case DISPLAY:
		if (stars->InCutscene()) {
			DisplayView* disp_view = DisplayView::GetInstance();

			if (disp_view) {
				Color color;
				color.Set(event_param[0]);

				if (event_message.length() && event_source.length()) {

					if (event_message.contains('$')) {
						Campaign*      campaign = Campaign::GetCampaign();
						Player*        user     = Player::GetCurrentPlayer();
						CombatGroup*   group    = campaign->GetPlayerGroup();

						if (user) {
							event_message = FormatTextReplace(event_message, "$NAME",  user->Name().data());
							event_message = FormatTextReplace(event_message, "$RANK",  Player::RankName(user->Rank()));
						}

						if (group) {
							event_message = FormatTextReplace(event_message, "$GROUP", group->GetDescription());
						}

						if (event_message.contains("$TIME")) {
							char timestr[32];
							FormatDayTime(timestr, campaign->GetTime(), true);
							event_message = FormatTextReplace(event_message, "$TIME", timestr);
						}
					}

					disp_view->AddText(  event_message,
					FontMgr::Find(event_source),
					color,
					event_rect,
					event_point.y,
					event_point.x,
					event_point.z);

				}

				else if (event_target.length()) {
					DataLoader* loader = DataLoader::GetLoader();

					if (loader) {
						loader->SetDataPath(0);
开发者ID:The-E,项目名称:Starshatter-Experimental,代码行数:67,代码来源:MissionEvent.cpp

示例11: if

CampaignMissionRequest*
CampaignPlanMission::PlanRandomFighterMission()
{
    CampaignMissionRequest* request  = 0;
    int                     type     = fighter_mission_types[fighter_mission_index++];
    int                     ownside  = player_group->GetIFF();
    CombatGroup*            primary  = player_group;
    CombatGroup*            obj      = 0;

    if (fighter_mission_index > 15)
    fighter_mission_index = 0;

    if (type == Mission::ESCORT_FREIGHT) {
        CombatGroup*  freight  = campaign->FindGroup(ownside, CombatGroup::FREIGHT);
        if (!freight || freight->CalcValue() < 1)
        type = Mission::PATROL;
        else
        obj  = freight;
    }

    else if (type == Mission::ESCORT_SHUTTLE) {
        CombatGroup*  shuttle = campaign->FindGroup(ownside, CombatGroup::LCA_SQUADRON);
        if (!shuttle || shuttle->CalcValue() < 1)
        type = Mission::PATROL;
        else
        obj  = shuttle;
    }

    else if (primary->Type() == CombatGroup::WING) {
        if (RandomChance())
        primary = primary->FindGroup(CombatGroup::INTERCEPT_SQUADRON);
        else
        primary = primary->FindGroup(CombatGroup::FIGHTER_SQUADRON);
    }

    if (type >= Mission::AIR_PATROL && type <= Mission::AIR_INTERCEPT) {
        CombatZone* zone     = 0;
        bool        airborne = false;

        if (primary)
        zone = primary->GetAssignedZone();

        if (zone && zone->GetRegions().size() > 1) {
            Text        air_region = *zone->GetRegions().at(1);
            StarSystem* system     = campaign->GetSystem(zone->System());

            if (system) {
                OrbitalRegion* rgn = system->FindRegion(air_region);

                if (rgn && rgn->Type() == Orbital::TERRAIN)
                airborne = true;
            }
        }

        if (!airborne) {
            if (type == Mission::AIR_INTERCEPT)
            type = Mission::INTERCEPT;

            else if (type == Mission::AIR_SWEEP)
            type = Mission::SWEEP;

            else
            type = Mission::PATROL;
        }
    }

    request = new(__FILE__,__LINE__)
    CampaignMissionRequest(campaign, type, start, primary);

    if (request)
    request->SetObjective(obj);

    return request;
}
开发者ID:Banbury,项目名称:starshatter-open,代码行数:74,代码来源:CampaignPlanMission.cpp

示例12: Random

bool
CombatAction::IsAvailable() const
{
	CombatAction* pThis = (CombatAction*) this;

	if (rval < 0) {
		pThis->rval = (int) Random(0, 100);

		if (rval > probability)
		pThis->status = SKIPPED;
	}

	if (status != PENDING)
	return false;

	if (min_rank > 0 || max_rank < 100) {
		Player* player = Player::GetCurrentPlayer();

		if (player->Rank() < min_rank || player->Rank() > max_rank)
		return false;
	}

	Campaign* campaign = Campaign::GetCampaign();
	if (campaign) {
		if (campaign->GetTime() < start_after) {
			return false;
		}

		if (campaign->GetTime() > start_before) {
			pThis->status = FAILED; // too late!
			return false;
		}

		// check requirements against actions in current campaign:
		ListIter<CombatActionReq> iter = pThis->requirements;
		while (++iter) {
			CombatActionReq* r  = iter.value();
			bool             ok = false;

			if (r->action > 0) {
				ListIter<CombatAction> action = campaign->GetActions();
				while (++action) {
					CombatAction* a = action.value();

					if (a->Identity() == r->action) {
						if (r->not) {
							if (a->Status() == r->stat)
							return false;
						}
						else {
							if (a->Status() != r->stat)
							return false;
						}
					}
				}
			}

			// group-based requirement
			else if (r->group_type > 0) {
				if (r->c1) {
					CombatGroup* group = r->c1->FindGroup(r->group_type, r->group_id);

					if (group) {
						int test = 0;
						int comp = 0;

						if (r->intel) {
							test = group->IntelLevel();
							comp = r->intel;
						}

						else {
							test = group->CalcValue();
							comp = r->score;
						}

						switch (r->comp) {
						case CombatActionReq::LT:  ok = (test <  comp); break;
						case CombatActionReq::LE:  ok = (test <= comp); break;
						case CombatActionReq::GT:  ok = (test >  comp); break;
						case CombatActionReq::GE:  ok = (test >= comp); break;
						case CombatActionReq::EQ:  ok = (test == comp); break;
						}
					}

					if (!ok)
					return false;
				}
			}

			// score-based requirement
			else {
				int test = 0;

				if (r->comp <= CombatActionReq::EQ) {  // absolute
					if (r->c1) {
						int test = r->c1->Score();

						switch (r->comp) {
						case CombatActionReq::LT:  ok = (test <  r->score); break;
//.........这里部分代码省略.........
开发者ID:The-E,项目名称:Starshatter-Experimental,代码行数:101,代码来源:CombatAction.cpp

示例13: parser

CombatGroup*
CombatGroup::LoadOrderOfBattle(const char* filename, int team, Combatant* combatant)
{
	CombatGroup* force = 0;
	DataLoader* loader = DataLoader::GetLoader();
	BYTE* block;
	loader->LoadBuffer(filename, block, true);

	Parser parser(new(__FILE__,__LINE__) BlockReader((const char*) block));
	Term*  term = parser.ParseTerm();

	if (!term) {
		Print("ERROR: could not parse order of battle '%s'\n", filename);
		return 0;
	}
	else {
		TermText* file_type = term->isText();
		if (!file_type || file_type->value() != "ORDER_OF_BATTLE") {
			Print("ERROR: invalid Order of Battle file '%s'\n", filename);
			term->print(10);
			return 0;
		}
	}


	do {
		delete term; term = 0;
		term = parser.ParseTerm();
		
		if (term) {
			TermDef* def = term->isDef();
			if (def) {
				if (def->name()->value() == "group") {
					if (!def->term() || !def->term()->isStruct()) {
						Print("WARNING: group struct missing in '%s'\n", filename);
					}
					else {
						TermStruct* val = def->term()->isStruct();

						char  name[256];
						char  type[64];
						char  intel[64];
						char  region[64];
						char  system[64];
						char  parent_type[64];
						int   parent_id = 0;
						int   id  = 0;
						int   iff = -1;
						Vec3  loc = Vec3(1.0e9f,0.0f,0.0f);

						List<CombatUnit>  unit_list;
						char              unit_name[64];
						char              unit_regnum[16];
						char              unit_design[64];
						char              unit_skin[64];
						int               unit_class  = 0;
						int               unit_count  = 1;
						int               unit_dead   = 0;
						int               unit_damage = 0;
						int               unit_heading= 0;
						int               unit_index  = 0;
						
						*name          = 0;
						*type          = 0;
						*intel         = 0;
						*region        = 0;
						*system        = 0;
						*parent_type   = 0;
						*unit_name     = 0;
						*unit_regnum   = 0;
						*unit_design   = 0;
						*unit_skin     = 0;

						strcpy_s(intel, "KNOWN");

						// all groups in this OOB default to the IFF of the main force
						if (force)
						iff = force->GetIFF();
						
						for (int i = 0; i < val->elements()->size(); i++) {
							TermDef* pdef = val->elements()->at(i)->isDef();
							if (pdef && (iff < 0 || team < 0 || iff == team)) {
								GET_DEF_TEXT(name);
								else GET_DEF_TEXT(type);
								else GET_DEF_TEXT(intel);
								else GET_DEF_TEXT(region);
								else GET_DEF_TEXT(system);
								else GET_DEF_VEC(loc);
								else GET_DEF_TEXT(parent_type);
								else GET_DEF_NUM(parent_id);
开发者ID:The-E,项目名称:Starshatter-Experimental,代码行数:90,代码来源:CombatGroup.cpp

示例14: RandomDirection

void
CampaignPlanMovement::MoveUnit(CombatUnit* u)
{
	if (u) {
		// starship repair:
		double damage  = u->GetSustainedDamage();

		if (damage > 0 && u->GetDesign()) {
			int    percent = (int) (100 * damage / u->GetDesign()->integrity);

			if (percent > 50) {
				u->SetSustainedDamage(0.90 * damage);
			}
		}

		Point  loc  = u->Location();
		Point  dir  = loc;
		double dist = dir.Normalize();

		const double MAX_RAD  = 320e3;
		const double MIN_DIST = 150e3;

		if (dist < MAX_RAD) {
			double scale = 1 - dist/MAX_RAD;

			loc += dir * (Random(30e3, 90e3) * scale) + RandomDirection() * 10e3;

			if (fabs(loc.z) > 20e3)
			loc.z *= 0.1;

			u->MoveTo(loc);

			CombatGroup* g = u->GetCombatGroup();
			if (g && g->Type() > CombatGroup::FLEET && g->GetFirstUnit() == u) {
				g->MoveTo(loc);

				if (g->IntelLevel() > Intel::KNOWN)
				g->SetIntelLevel(Intel::KNOWN);
			}
		}

		else if (dist > 1.25 * MAX_RAD) {
			double scale = 1 - dist/MAX_RAD;

			loc += dir * (Random(80e3, 120e3) * scale) + RandomDirection() * 3e3;

			if (fabs(loc.z) > 20e3)
			loc.z *= 0.1;

			u->MoveTo(loc);

			CombatGroup* g = u->GetCombatGroup();
			if (g && g->Type() > CombatGroup::FLEET && g->GetFirstUnit() == u) {
				g->MoveTo(loc);

				if (g->IntelLevel() > Intel::KNOWN)
				g->SetIntelLevel(Intel::KNOWN);
			}
		}

		else {
			loc += RandomDirection() * 30e3;

			if (fabs(loc.z) > 20e3)
			loc.z *= 0.1;

			u->MoveTo(loc);

			CombatGroup* g = u->GetCombatGroup();
			if (g && g->Type() > CombatGroup::FLEET && g->GetFirstUnit() == u) {
				g->MoveTo(loc);

				if (g->IntelLevel() > Intel::KNOWN)
				g->SetIntelLevel(Intel::KNOWN);
			}
		}

		CombatUnit* closest_unit = 0;
		double      closest_dist = 1e6;

		ListIter<CombatUnit> iter = all_units;
		while (++iter) {
			CombatUnit* unit = iter.value();

			if (unit->GetCombatGroup() != u->GetCombatGroup() && unit->GetRegion() == u->GetRegion() && !unit->IsDropship()) {
				Point  delta = loc - unit->Location();
				dist  = delta.Normalize();

				if (dist < closest_dist) {
					closest_unit = unit;
					closest_dist = dist;
				}
			}
		}

		if (closest_unit && closest_dist < MIN_DIST) {
			Point  delta = loc - closest_unit->Location();
			dist  = delta.Normalize();

			loc += delta * 1.1 * (MIN_DIST - closest_dist);
//.........这里部分代码省略.........
开发者ID:The-E,项目名称:Starshatter-Experimental,代码行数:101,代码来源:CampaignPlanMovement.cpp


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