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


C++ Sim::GetPlayerShip方法代码示例

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


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

示例1: if

GroundAI::GroundAI(SimObject* s)
: ship((Ship*) s), target(0), subtarget(0), exec_time(0), carrier_ai(0)
{
    Sim*  sim         = Sim::GetSim();
    Ship* pship       = sim->GetPlayerShip();
    int   player_team = 1;
    int   ai_level    = 1;

    if (pship)
    player_team = pship->GetIFF();

    Player* player = Player::GetCurrentPlayer();
    if (player) {
        if (ship && ship->GetIFF() && ship->GetIFF() != player_team) {
            ai_level = player->AILevel();
        }
        else if (player->AILevel() == 0) {
            ai_level = 1;
        }
    }

    // evil alien ships are *always* smart:
    if (ship && ship->GetIFF() > 1 && ship->Design()->auto_roll > 1) {
        ai_level = 2;
    }

    if (ship && ship->GetHangar() && ship->GetCommandAILevel() > 0)
    carrier_ai = new(__FILE__,__LINE__) CarrierAI(ship, ai_level);
}
开发者ID:Banbury,项目名称:starshatter-open,代码行数:29,代码来源:GroundAI.cpp

示例2: ship

TacticalAI::TacticalAI(ShipAI* ai)
: ship(0), ship_ai(0), carrier_ai(0), navpt(0), orders(0),
action(0), threat_level(0), support_level(1),
directed_tgtid(0)
{
    if (ai) {
        ship_ai     = ai;
        ship        = ai->GetShip();

        Sim* sim    = Sim::GetSim();

        if (ship && ship->GetHangar() && ship->GetCommandAILevel() > 0 &&
                ship != sim->GetPlayerShip())
        carrier_ai = new(__FILE__,__LINE__) CarrierAI(ship, ship_ai->GetAILevel());
    }

    agression      = 0;
    roe            = FLEXIBLE;
    element_index  = 1;
    exec_time      = exec_time_seed;
    exec_time_seed += 17;
}
开发者ID:Banbury,项目名称:starshatter-open,代码行数:22,代码来源:TacticalAI.cpp

示例3: if

void
RadioTraffic::SendMessage(RadioMessage* msg)
{
	if (!msg) return;

	Sim*  sim    = Sim::GetSim();
	Ship* player = sim->GetPlayerShip();
	int   iff    = 0;

	if (player)
	iff = player->GetIFF();

	if (msg->DestinationShip()) {
		traffic.append(msg);

		if (msg->Channel() == 0 || msg->Channel() == iff)
		DisplayMessage(msg);

		if (!NetGame::IsNetGameClient())
		msg->DestinationShip()->HandleRadioMessage(msg);
	}

	else if (msg->DestinationElem()) {
		traffic.append(msg);

		if (msg->Channel() == 0 || msg->Channel() == iff)
		DisplayMessage(msg);

		if (!NetGame::IsNetGameClient())
		msg->DestinationElem()->HandleRadioMessage(msg);
	}

	else {
		if (msg->Channel() == 0 || msg->Channel() == iff)
		DisplayMessage(msg);

		delete msg;
	}
}
开发者ID:The-E,项目名称:Starshatter-Experimental,代码行数:39,代码来源:RadioTraffic.cpp

示例4: 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

示例5: if

void
MissionEvent::Execute(bool silent)
{
	Starshatter*   stars    = Starshatter::GetInstance();
	HUDView*       hud      = HUDView::GetInstance();
	Sim*           sim      = Sim::GetSim();
	Ship*          player   = sim->GetPlayerShip();
	Ship*          ship     = 0;
	Ship*          src      = 0;
	Ship*          tgt      = 0;
	Element*       elem     = 0;
	int            pan      = 0;
	bool           end_mission = false;

	if (event_ship.length())
	ship = sim->FindShip(event_ship);
	else
	ship = player;

	if (event_source.length())
	src = sim->FindShip(event_source);

	if (event_target.length())
	tgt = sim->FindShip(event_target);

	if (ship)
	elem = ship->GetElement();

	else if (event_ship.length()) {
		elem = sim->FindElement(event_ship);

		if (elem)
		ship = elem->GetShip(1);
	}

	// expire the delay, if any remains
	delay = 0;

	// fire the event action
	switch (event) {
	case MESSAGE:
		if (event_message.length() > 0) {
			if (ship) {
				RadioMessage* msg = new(__FILE__,__LINE__) RadioMessage(ship, src, event_param[0]);
				msg->SetInfo(event_message);
				msg->SetChannel(ship->GetIFF());
				if (tgt)
				msg->AddTarget(tgt);
				RadioTraffic::Transmit(msg);
			}

			else if (elem) {
				RadioMessage* msg = new(__FILE__,__LINE__) RadioMessage(elem, src, event_param[0]);
				msg->SetInfo(event_message);
				msg->SetChannel(elem->GetIFF());
				if (tgt)
				msg->AddTarget(tgt);
				RadioTraffic::Transmit(msg);
			}
		}

		if (event_sound.length() > 0) {
			pan = event_param[0];
		}
		break;

	case OBJECTIVE: 
		if (elem) {
			if (event_param[0]) {
				elem->ClearInstructions();
				elem->ClearObjectives();
			}

			Instruction* obj = new(__FILE__,__LINE__) Instruction(event_param[0], 0);
			obj->SetTarget(event_target);
			elem->AddObjective(obj);

			if (elem->Contains(player)) {
				HUDView* hud = HUDView::GetInstance();

				if (hud)
				hud->ShowHUDInst();
			}
		}
		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();
			}
		}
//.........这里部分代码省略.........
开发者ID:The-E,项目名称:Starshatter-Experimental,代码行数:101,代码来源:MissionEvent.cpp


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