public boolean isPlaceEmpty(Vector2 pos, boolean considerPlanets) { Planet np = myPlanetManager.getNearestPlanet(pos); if (considerPlanets) { boolean inPlanet = np.getPos().dst(pos) < np.getFullHeight(); if (inPlanet) return false; } SolSystem ns = myPlanetManager.getNearestSystem(pos); if (ns.getPos().dst(pos) < SunSingleton.SUN_HOT_RAD) return false; List<SolObject> objs = myObjectManager.getObjs(); for (int i = 0, objsSize = objs.size(); i < objsSize; i++) { SolObject o = objs.get(i); if (!o.hasBody()) continue; if (pos.dst(o.getPos()) < myObjectManager.getRadius(o)) { return false; } } List<FarObjData> farObjs = myObjectManager.getFarObjs(); for (int i = 0, farObjsSize = farObjs.size(); i < farObjsSize; i++) { FarObjData fod = farObjs.get(i); FarObj o = fod.fo; if (!o.hasBody()) continue; if (pos.dst(o.getPos()) < o.getRadius()) { return false; } } return true; }
public void respawn() { if (myHero != null) { beforeHeroDeath(); myObjectManager.removeObjDelayed(myHero); } else if (myTranscendentHero != null) { FarShip farH = myTranscendentHero.getShip(); setRespawnState(farH.getMoney(), farH.getIc(), farH.getHullConfig()); myObjectManager.removeObjDelayed(myTranscendentHero); } createPlayer(null); }
public void update() { myDraDebugger.update(this); if (myPaused) return; myTimeFactor = DebugOptions.GAME_SPEED_MULTIPLIER; if (myHero != null) { ShipAbility ability = myHero.getAbility(); if (ability instanceof SloMo) { float factor = ((SloMo) ability).getFactor(); myTimeFactor *= factor; } } myTimeStep = Const.REAL_TIME_STEP * myTimeFactor; myTime += myTimeStep; myPlanetManager.update(this); myCam.update(this); myChunkManager.update(this); myMountDetectDrawer.update(this); myObjectManager.update(this); myDraMan.update(this); myMapDrawer.update(this); mySoundManager.update(this); myBeaconHandler.update(this); myHero = null; myTranscendentHero = null; List<SolObject> objs = myObjectManager.getObjs(); for (int i = 0, objsSize = objs.size(); i < objsSize; i++) { SolObject obj = objs.get(i); if ((obj instanceof SolShip)) { SolShip ship = (SolShip) obj; Pilot prov = ship.getPilot(); if (prov.isPlayer()) { myHero = ship; break; } } if (obj instanceof StarPort.Transcendent) { StarPort.Transcendent trans = (StarPort.Transcendent) obj; FarShip ship = trans.getShip(); if (ship.getPilot().isPlayer()) { myTranscendentHero = trans; break; } } } if (myTutorialManager != null) myTutorialManager.update(); }
public void drawDebug(GameDrawer drawer) { if (DebugOptions.GRID_SZ > 0) myGridDrawer.draw(drawer, this, DebugOptions.GRID_SZ, drawer.debugWhiteTex); myPlanetManager.drawDebug(drawer, this); myObjectManager.drawDebug(drawer, this); if (DebugOptions.ZOOM_OVERRIDE != 0) myCam.drawDebug(drawer); drawDebugPoint(drawer, DebugOptions.DEBUG_POINT, DebugCol.POINT); drawDebugPoint(drawer, DebugOptions.DEBUG_POINT2, DebugCol.POINT2); drawDebugPoint(drawer, DebugOptions.DEBUG_POINT3, DebugCol.POINT3); }
public void onGameEnd() { saveShip(); myObjectManager.dispose(); mySoundManager.dispose(); }
// uh, this needs refactoring private void createPlayer(ShipConfig prevShip) { Vector2 pos = myGalaxyFiller.getPlayerSpawnPos(this); myCam.setPos(pos); Pilot pilot; if (myCmp.getOptions().controlType == GameOptions.CONTROL_MOUSE) { myBeaconHandler.init(this, pos); pilot = new AiPilot( new BeaconDestProvider(), true, Fraction.LAANI, false, "you", Const.AI_DET_DIST); } else { pilot = new UiControlledPilot(myScreens.mainScreen); } ShipConfig shipConfig; if (DebugOptions.GOD_MODE) { shipConfig = myPlayerSpawnConfig.godShipConfig; } else if (prevShip != null) { shipConfig = prevShip; } else { shipConfig = myPlayerSpawnConfig.shipConfig; } float money = myRespawnMoney != 0 ? myRespawnMoney : myTutorialManager != null ? 200 : shipConfig.money; HullConfig hull = myRespawnHull != null ? myRespawnHull : shipConfig.hull; String itemsStr = !myRespawnItems.isEmpty() ? "" : shipConfig.items; boolean giveAmmo = prevShip == null && myRespawnItems.isEmpty(); myHero = myShipBuilder .buildNewFar( this, new Vector2(pos), null, 0, 0, pilot, itemsStr, hull, null, true, money, null, giveAmmo) .toObj(this); ItemContainer ic = myHero.getItemContainer(); if (!myRespawnItems.isEmpty()) { for (int i1 = 0, sz = myRespawnItems.size(); i1 < sz; i1++) { SolItem item = myRespawnItems.get(i1); ic.add(item); } } else if (DebugOptions.GOD_MODE) { myItemManager.addAllGuns(ic); } else if (myTutorialManager != null) { for (int i = 0; i < 50; i++) { if (ic.groupCount() > 1.5f * Const.ITEM_GROUPS_PER_PAGE) break; SolItem it = myItemManager.random(); if (!(it instanceof GunItem) && it.getIcon(this) != null && ic.canAdd(it)) { ic.add(it.copy()); } } } ic.seenAll(); AiPilot.reEquip(this, myHero); myObjectManager.addObjDelayed(myHero); myObjectManager.resetDelays(); }