本文整理汇总了C++中Ship::GetShipType方法的典型用法代码示例。如果您正苦于以下问题:C++ Ship::GetShipType方法的具体用法?C++ Ship::GetShipType怎么用?C++ Ship::GetShipType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ship
的用法示例。
在下文中一共展示了Ship::GetShipType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: l_ship_attr_ship_id
/*
* Attribute: shipId
*
* The internal id of the ship type. This value can be passed to
* <ShipType.GetShipType> to retrieve information about this ship type.
*
* Availability:
*
* alpha 28
*
* Status:
*
* stable
*/
static int l_ship_attr_ship_id(lua_State *l)
{
Ship *s = LuaObject<Ship>::CheckFromLua(1);
const ShipType &st = s->GetShipType();
lua_pushstring(l, st.id.c_str());
return 1;
}
示例2: Start
//.........这里部分代码省略.........
for (Space::bodiesIter_t i = Space::bodies.begin(); i!=Space::bodies.end(); i++) {
if ((*i)->IsType(Object::SPACESTATION)) {
station = (SpaceStation*)*i;
if (!station->IsGroundStation()) break;
}
}
assert(station);
player->SetPosition(vector3d(0,0,0));
player->SetFrame(station->GetFrame());
player->SetDockedWith(station, 0);
MainLoop();
} else if (choice == 3) {
/* debug start point */
SBodyPath path(1,0,2);
path.sbodyId = 6;
Space::DoHyperspaceTo(&path);
player->SetPosition(vector3d(2*EARTH_RADIUS,0,0));
player->SetVelocity(vector3d(0,0,0));
player->m_equipment.Add(Equip::HYPERCLOUD_ANALYZER);
Ship *enemy = new Ship(ShipType::EAGLE_LRF);
enemy->SetFrame(player->GetFrame());
enemy->SetPosition(player->GetPosition()+vector3d(0,0,-9000.0));
enemy->SetVelocity(vector3d(0,0,0));
enemy->m_equipment.Add(Equip::PULSECANNON_1MW);
enemy->AIKill(player);
Space::AddBody(enemy);
player->SetCombatTarget(enemy);
const ShipType *shipdef;
double mass, acc1, acc2, acc3;
printf("Player ship mass = %.0fkg, Enemy ship mass = %.0fkg\n",
player->GetMass(), enemy->GetMass());
shipdef = &player->GetShipType();
mass = player->GetMass();
acc1 = shipdef->linThrust[ShipType::THRUSTER_FORWARD] / (9.81*mass);
acc2 = shipdef->linThrust[ShipType::THRUSTER_REVERSE] / (9.81*mass);
acc3 = shipdef->linThrust[ShipType::THRUSTER_UP] / (9.81*mass);
printf("Player ship thrust = %.1fg, %.1fg, %.1fg\n", acc1, acc2, acc3);
shipdef = &enemy->GetShipType();
mass = enemy->GetMass();
acc1 = shipdef->linThrust[ShipType::THRUSTER_FORWARD] / (9.81*mass);
acc2 = shipdef->linThrust[ShipType::THRUSTER_REVERSE] / (9.81*mass);
acc3 = shipdef->linThrust[ShipType::THRUSTER_UP] / (9.81*mass);
printf("Enemy ship thrust = %.1fg, %.1fg, %.1fg\n", acc1, acc2, acc3);
/* Frame *stationFrame = new Frame(pframe, "Station frame...");
stationFrame->SetRadius(5000);
stationFrame->m_sbody = 0;
stationFrame->SetPosition(vector3d(0,0,zpos));
stationFrame->SetAngVelocity(vector3d(0,0,0.5));
for (int i=0; i<4; i++) {
Ship *body = new Ship(ShipType::LADYBIRD);
char buf[64];
snprintf(buf,sizeof(buf),"X%c-0%02d", 'A'+i, i);
body->SetLabel(buf);
body->SetFrame(stationFrame);
body->SetPosition(vector3d(200*(i+1), 0, 2000));
Space::AddBody(body);
}
SpaceStation *station = new SpaceStation(SpaceStation::JJHOOP);
station->SetLabel("Poemi-chan's Folly");
station->SetFrame(stationFrame);
station->SetPosition(vector3d(0,0,0));
Space::AddBody(station);
SpaceStation *station2 = new SpaceStation(SpaceStation::GROUND_FLAVOURED);
station2->SetLabel("Conor's End");
station2->SetFrame(*pframe->m_children.begin()); // rotating frame of planet
station2->OrientOnSurface(EARTH_RADIUS, M_PI/4, M_PI/4);
Space::AddBody(station2);
*/
// player->SetDockedWith(station2, 0);
MainLoop();
} else if (choice == 4) {
if (Pi::player) {
Pi::player->MarkDead();
Space::bodies.remove(Pi::player);
delete Pi::player;
Pi::player = 0;
}
Pi::gameMenuView->OpenLoadDialog();
do {
Gui::MainLoopIteration();
} while (Pi::currentView != Pi::worldView);
if (Pi::isGameStarted) MainLoop();
} else {
Pi::Quit();
}
UninitGame();
}
示例3: UpdateAlertState
void Ship::UpdateAlertState()
{
// no alerts if no scanner
if (m_equipment.Get(Equip::SLOT_SCANNER) == Equip::NONE) {
// clear existing alert state if there was one
if (GetAlertState() != ALERT_NONE) {
SetAlertState(ALERT_NONE);
LuaEvent::Queue("onShipAlertChanged", this, LuaConstants::GetConstantString(Lua::manager->GetLuaState(), "ShipAlertStatus", ALERT_NONE));
}
return;
}
bool ship_is_near = false, ship_is_firing = false;
for (Space::BodyIterator i = Pi::game->GetSpace()->BodiesBegin(); i != Pi::game->GetSpace()->BodiesEnd(); ++i)
{
if ((*i) == this) continue;
if (!(*i)->IsType(Object::SHIP) || (*i)->IsType(Object::MISSILE)) continue;
Ship *ship = static_cast<Ship*>(*i);
if (ship->GetShipType().tag == ShipType::TAG_STATIC_SHIP) continue;
if (ship->GetFlightState() == LANDED || ship->GetFlightState() == DOCKED) continue;
if (GetPositionRelTo(ship).LengthSqr() < 100000.0*100000.0) {
ship_is_near = true;
Uint32 gunstate = 0;
for (int j = 0; j < ShipType::GUNMOUNT_MAX; j++)
gunstate |= ship->m_gunState[j];
if (gunstate) {
ship_is_firing = true;
break;
}
}
}
bool changed = false;
switch (m_alertState) {
case ALERT_NONE:
if (ship_is_near) {
SetAlertState(ALERT_SHIP_NEARBY);
changed = true;
}
if (ship_is_firing) {
m_lastFiringAlert = Pi::game->GetTime();
SetAlertState(ALERT_SHIP_FIRING);
changed = true;
}
break;
case ALERT_SHIP_NEARBY:
if (!ship_is_near) {
SetAlertState(ALERT_NONE);
changed = true;
}
else if (ship_is_firing) {
m_lastFiringAlert = Pi::game->GetTime();
SetAlertState(ALERT_SHIP_FIRING);
changed = true;
}
break;
case ALERT_SHIP_FIRING:
if (!ship_is_near) {
SetAlertState(ALERT_NONE);
changed = true;
}
else if (ship_is_firing) {
m_lastFiringAlert = Pi::game->GetTime();
}
else if (m_lastFiringAlert + 60.0 <= Pi::game->GetTime()) {
SetAlertState(ALERT_SHIP_NEARBY);
changed = true;
}
break;
}
if (changed)
LuaEvent::Queue("onShipAlertChanged", this, LuaConstants::GetConstantString(Lua::manager->GetLuaState(), "ShipAlertStatus", GetAlertState()));
}