Пример #1
0
    public ShipDesign(string name, TechHull hull) : base()
    {
        this.name     = name;
        this.hull     = hull;
        this.hullName = hull.getName();

        setupSlots();
    }
Пример #2
0
 public void setHull(TechHull hull)
 {
     this.hull = hull;
     if (hull == null)
     {
         this.hullName = null;
     }
     else
     {
         this.hullName = hull.getName();
     }
 }
Пример #3
0
    /**
     * Initialize the Player techs with the tech store
     */
    public void init(Player player, TechStore techStore)
    {
        engines           = new List <TechEngine>();
        scanners          = new List <TechHullComponent>();
        shields           = new List <TechHullComponent>();
        armor             = new List <TechHullComponent>();
        torpedos          = new List <TechHullComponent>();
        beamWeapons       = new List <TechHullComponent>();
        hulls             = new List <TechHull>();
        starbases         = new List <TechHull>();
        planetaryScanners = new List <TechPlanetaryScanner>();
        defenses          = new List <TechDefence>();
        techsForCategory  = new Dictionary <TechCategory, List <Tech> >();
        hullComponents    = new List <TechHullComponent>();

        bestEngine           = addPlayerTechs(player, techStore.getAllEngines(), engines);
        bestScanner          = addPlayerTechs(player, techStore.getAllScanners(), scanners);
        bestShield           = addPlayerTechs(player, techStore.getAllShields(), shields);
        bestArmor            = addPlayerTechs(player, techStore.getAllArmor(), armor);
        bestTorpedo          = addPlayerTechs(player, techStore.getAllTorpedos(), torpedos);
        bestBeamWeapon       = addPlayerTechs(player, techStore.getAllBeamWeapons(), beamWeapons);
        bestHull             = addPlayerTechs(player, techStore.getAllHulls(), hulls);
        bestStarbase         = addPlayerTechs(player, techStore.getAllStarbases(), starbases);
        bestPlanetaryScanner = addPlayerTechs(player, techStore.getAllPlanetaryScanners(), planetaryScanners);
        bestDefense          = addPlayerTechs(player, techStore.getAllDefenses(), defenses);

        foreach (TechCategory category in Enum.GetValues(typeof(TechCategory)))
        {
            techsForCategory.Add(category, new List <Tech>());
        }

        foreach (Tech tech in techStore.getAll())
        {
            if (player.hasTech(tech))
            {
                List <Tech> t = techsForCategory[tech.getCategory()];
                t.Add(tech);
                if (tech is TechHullComponent)
                {
                    hullComponents.Add((TechHullComponent)tech);
                }
            }
        }

        foreach (TechCategory category in Enum.GetValues(typeof(TechCategory)))
        {
            techsForCategory[category] = techsForCategory[category].OrderBy(t => t.getRanking()).ToList <Tech>();
        }

        hullComponents = hullComponents.OrderBy(t => t.getRanking()).ToList <TechHullComponent>();
    }
Пример #4
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);
    }
Пример #5
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()));
    }
Пример #6
0
 public void setBestStarbase(TechHull bestStarbase)
 {
     this.bestStarbase = bestStarbase;
 }
Пример #7
0
 public void setBestHull(TechHull bestHull)
 {
     this.bestHull = bestHull;
 }