Esempio n. 1
0
    void Start()
    {
        pc = new PlanetControllerImpl(fc, mapObject, game, baseFleet);
        if (!load)
        {
            UniverseGenerator gen = GetComponent <UniverseGenerator>();

            if (NewGameInit.instance != null)
            {
                game.getGame().setSize(NewGameInit.instance.size);
                game.getGame().setDensity(NewGameInit.instance.density);

                game.getGame().setName(NewGameInit.instance.gameName);

                game.getGame().getPlayers()[0].setRace(NewGameInit.instance.races[0]);
                game.getGame().getPlayers()[1].setRace(NewGameInit.instance.races[1]);
            }
            gen.setUniverseGenerator(game.getGame(), fc, pc, new ShipDesignerImpl(), StaticTechStore.getInstance());

            gen.generate();
        }
        else
        {
            LoadUniverseGenerator loadGen = GetComponent <LoadUniverseGenerator>();

            if (NewGameInit.instance != null)
            {
                game.getGame().setSize(NewGameInit.instance.size);
                game.getGame().setDensity(NewGameInit.instance.density);

                game.getGame().getPlayers()[0].setRace(NewGameInit.instance.races[0]);
                game.getGame().getPlayers()[1].setRace(NewGameInit.instance.races[1]);

                loadGen.setUniverseGenerator(Application.persistentDataPath + "/Game/" + NewGameInit.instance.gameName, game.getGame(), fc, pc, new ShipDesignerImpl(), StaticTechStore.getInstance());
            }
            else
            {
                loadGen.setUniverseGenerator(Application.persistentDataPath + "/Game/Game1/", game.getGame(), fc, pc, new ShipDesignerImpl(), StaticTechStore.getInstance());
            }

            loadGen.generate();
        }
        Settings.instance.playerID = game.getGame().getPlayers()[0].getID();

        layoutManager.LoadLayout();
    }
Esempio n. 2
0
    public ShipDesign designShip(TechHull hull, Player player)
    {
        ShipDesign design = new ShipDesign(hull.getName(), hull);

        foreach (ShipDesignSlot slot in design.getSlots())
        {
            HullSlotType[] types = slot.getHullSlot().getTypes();

            if (types.Contains(HullSlotType.Engine))
            {
                design.assignSlot(slot, player.getTechs().getBestEngine(), slot.getQuantity());
            }
            else if (types.Contains(HullSlotType.Scanner))
            {
                design.assignSlot(slot, player.getTechs().getBestScanner(), slot.getQuantity());
            }
            else if (types.Contains(HullSlotType.Shield))
            {
                design.assignSlot(slot, player.getTechs().getBestShield(), slot.getQuantity());
            }
            else if (types.Contains(HullSlotType.Armor))
            {
                design.assignSlot(slot, player.getTechs().getBestArmor(), slot.getQuantity());
            }
            else if (types.Contains(HullSlotType.Weapon))
            {
                design.assignSlot(slot, player.getTechs().getBestTorpedo(), slot.getQuantity());
            }
            else if (types.Contains(HullSlotType.Mechanical))
            {
                // if this is a colony ship, put the colonization module in the mechanical slot
                if (hull.getName().Equals("Colony Ship"))
                {
                    design.assignSlot(slot, StaticTechStore.getInstance().getHullComponent("Colonization Module"), slot.getQuantity());
                }
                else
                {
                    design.assignSlot(slot, StaticTechStore.getInstance().getHullComponent("Fuel Tank"), slot.getQuantity());
                }
            }
        }
        design.computeAggregate(player);
        initShipDesign(design);

        return(design);
    }
Esempio n. 3
0
    public void initShipDesign(ShipDesign design)
    {
        TechHull hull = StaticTechStore.getInstance().getHull(design.getHullName());

        design.setHull(hull);
        for (int slotIndex = 0; slotIndex < hull.getSlots().Count; slotIndex++)
        {
            ShipDesignSlot designSlot = design.getSlots()[slotIndex];
            if (designSlot.getHullComponentName() == null)
            {
                break;
            }
            designSlot.setHullSlot(hull.getSlots()[slotIndex]);
            designSlot.setHullComponent(StaticTechStore.getInstance().getHullComponent(designSlot.getHullComponentName()));
        }

        design.getAggregate().setEngine(
            StaticTechStore.getInstance().
            getEngine(
                design.
                getAggregate().
                getEngineName()));
    }
Esempio n. 4
0
    void Start()
    {
        pc = new PlanetControllerImpl(fc, mapObject, game, baseFleet);
        if (!load)
        {
            UniverseGenerator gen = GetComponent <UniverseGenerator>();

            if (NewGameInit.instance != null)
            {
                game.getGame().setSize(NewGameInit.instance.size);
                game.getGame().setDensity(NewGameInit.instance.density);

                game.getGame().setName(NewGameInit.instance.gameName);

                game.getGame().getPlayers()[0].setName(NewGameInit.instance.playerNames[0]);
                game.getGame().getPlayers()[0].getUser().setName(NewGameInit.instance.playerNames[0]);
                game.getGame().getPlayers()[0].setRace(NewGameInit.instance.races[0]);
                game.getGame().getPlayers()[1].setRace(NewGameInit.instance.races[1]);
                game.getGame().getPlayers()[1].setName(NewGameInit.instance.playerNames[1]);
                game.getGame().getPlayers()[1].getUser().setName(NewGameInit.instance.playerNames[1]);

                game.getGame().getPlayers()[0].getUser().setAi(false);
                game.getGame().getPlayers()[1].getUser().setAi(false);
            }
            gen.setUniverseGenerator(game.getGame(), fc, pc, new ShipDesignerImpl(), StaticTechStore.getInstance());

            gen.generate();
        }
        else
        {
            LoadUniverseGenerator loadGen = GetComponent <LoadUniverseGenerator>();

            if (NewGameInit.instance != null)
            {
                game.getGame().setSize(NewGameInit.instance.size);
                game.getGame().setDensity(NewGameInit.instance.density);

                game.getGame().setName(NewGameInit.instance.gameName);

                game.getGame().getPlayers()[0].setName(NewGameInit.instance.playerNames[0]);
                game.getGame().getPlayers()[0].getUser().setName(NewGameInit.instance.playerNames[0]);
                game.getGame().getPlayers()[0].setRace(NewGameInit.instance.races[0]);
                game.getGame().getPlayers()[1].setRace(NewGameInit.instance.races[1]);
                game.getGame().getPlayers()[1].setName(NewGameInit.instance.playerNames[1]);
                game.getGame().getPlayers()[1].getUser().setName(NewGameInit.instance.playerNames[1]);

                game.getGame().getPlayers()[0].getUser().setAi(false);
                game.getGame().getPlayers()[1].getUser().setAi(false);

                loadGen.setUniverseGenerator(Application.persistentDataPath + "/Online/serverFile/", game.getGame(), fc, pc, new ShipDesignerImpl(), StaticTechStore.getInstance());
            }
            else
            {
                loadGen.setUniverseGenerator(Application.persistentDataPath + "/Online/serverFile/", game.getGame(), fc, pc, new ShipDesignerImpl(), StaticTechStore.getInstance());
            }

            loadGen.generate();

            new FileInfo(Application.persistentDataPath + "/Online/serverFile.zip").Delete();
            new DirectoryInfo(Application.persistentDataPath + "/Online/serverFile/").Delete(true);
        }

        messagePanel.playerIndex = researchPanel.playerIndex = planetReport.playerIndex = fleetReport.playerIndex = GameSparksManager.getInstance().getPlayerName() == game.getGame().getPlayers()[0].getName() ? 0 : 1;

        Settings.instance.playerID = GameSparksManager.getInstance().getPlayerName() == game.getGame().getPlayers()[0].getName() ? game.getGame().getPlayers()[0].getID() : game.getGame().getPlayers()[1].getID();

        layoutManager.LoadLayout();
    }