Ejemplo n.º 1
0
  public SolGame(
      SolApplication cmp,
      boolean usePrevShip,
      TextureManager textureManager,
      boolean tut,
      CommonDrawer commonDrawer) {
    myCmp = cmp;
    GameDrawer drawer = new GameDrawer(textureManager, commonDrawer);
    gameColors = new GameColors();
    mySoundManager = new SoundManager();
    mySpecialSounds = new SpecialSounds(mySoundManager);
    myDraMan = new DraMan(drawer);
    myCam = new SolCam(drawer.r);
    myScreens = new GameScreens(drawer.r, cmp);
    myTutorialManager =
        tut
            ? new TutorialManager(commonDrawer.r, myScreens, cmp.isMobile(), cmp.getOptions())
            : null;
    myTextureManager = textureManager;
    myFarBackgroundManagerOld = new FarBackgroundManagerOld(myTextureManager);
    myShipBuilder = new ShipBuilder();
    myEffectTypes = new EffectTypes();
    mySpecialEffects = new SpecialEffects(myEffectTypes, myTextureManager, gameColors);
    myItemManager = new ItemManager(myTextureManager, mySoundManager, myEffectTypes, gameColors);
    myAbilityCommonConfigs =
        new AbilityCommonConfigs(myEffectTypes, myTextureManager, gameColors, mySoundManager);
    hullConfigManager =
        new HullConfigManager(
            myShipBuilder,
            FileManager.getInstance(),
            textureManager,
            myItemManager,
            myAbilityCommonConfigs,
            mySoundManager);
    myNames = new SolNames();
    myPlanetManager =
        new PlanetManager(myTextureManager, hullConfigManager, gameColors, myItemManager);
    SolContactListener contactListener = new SolContactListener(this);
    myFractionMan = new FractionMan(myTextureManager);
    myObjectManager = new ObjectManager(contactListener, myFractionMan);
    myGridDrawer = new GridDrawer(textureManager);
    myChunkManager = new ChunkManager(myTextureManager);
    myPartMan = new PartMan();
    myAsteroidBuilder = new AsteroidBuilder(myTextureManager);
    myLootBuilder = new LootBuilder();
    myFarBgMan = new FarBgMan();
    myMapDrawer = new MapDrawer(myTextureManager, commonDrawer.h);
    myShardBuilder = new ShardBuilder(myTextureManager);
    myGalaxyFiller = new GalaxyFiller();
    myStarPortBuilder = new StarPort.Builder();
    myPlayerSpawnConfig = PlayerSpawnConfig.load(hullConfigManager, myItemManager);
    myDraDebugger = new DraDebugger();
    myBeaconHandler = new BeaconHandler(textureManager);
    myMountDetectDrawer = new MountDetectDrawer(textureManager);
    myRespawnItems = new ArrayList<SolItem>();
    myTimeFactor = 1;

    // from this point we're ready!
    myPlanetManager.fill(myNames);
    myGalaxyFiller.fill(this);
    ShipConfig startingShip =
        usePrevShip ? SaveManager.readShip(hullConfigManager, myItemManager) : null;
    createPlayer(startingShip);
    SolMath.checkVectorsTaken(null);
  }
Ejemplo n.º 2
0
  // 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();
  }