Ejemplo n.º 1
0
    public Hull(HullData hd)
    {
        _name        = hd.name;
        _description = hd.description;

        _weaponSlots  = hd.weaponSlots;
        _utilitySlots = hd.utilitySlots;

        _hullpoints        = hd.hitpoints;
        _baseMovementSpeed = hd.movementSpeed;
        _baseRotationSpeed = hd.rotationSpeed;

        _gasStorage   = hd.gasStorage;
        _oreStorage   = hd.oreStorage;
        _fuelStorage  = hd.fuelStorage;
        _goodsStorage = hd.goodsStorage;

        _maintenanceCosts = hd.maintenanceCosts;

        _size = hd.size;

        _model        = hd.model;
        _destroyedVFX = hd.destroyedVFX;
        _icon         = hd.icon;
    }
Ejemplo n.º 2
0
    public ShipComponent(ShipComponentData scd, ShipComponentRarity rarity)
    {
        _name        = scd.name;
        _description = scd.description;

        _cooldown = scd.cooldown;

        _modifiers = scd.modifiers;

        _rarity      = rarity;
        _minimumSize = scd.minimumSize;
        _icon        = scd.icon;

        _autoActivate = scd.autoActivateEnabledByDefault;
    }
Ejemplo n.º 3
0
    /**
     * load Fleet ship prefabs
     */
    void LoadFleetShips()
    {
        fleetShipPrefabs = new Dictionary <Tuple <Race, HullClass>, FleetShip>();
        var objects = Resources.LoadAll("Fleet", typeof(GameObject));

        foreach (GameObject obj in objects)
        {
            FleetShip ship = obj.GetComponent <FleetShip>();
            if (ship != null)
            {
                Race      race      = (Race)ship.GetType().GetField("race").GetRawConstantValue();
                HullClass hullClass = (HullClass)ship.GetType().GetField("hullClass").GetRawConstantValue();
                fleetShipPrefabs.Add(new Tuple <Race, HullClass>(race, hullClass), ship);
                continue;
            }
        }
    }
Ejemplo n.º 4
0
    public Ship(ShipData sd)
    {
        _name = sd.name.Length == 0 ? NameGenerator.GetShipName() : sd.name;
        _hull = sd.hull.CreateInstance() as Hull;
        _size = _hull.size;

        _weapons    = new Weapon[_hull.weaponSlots];
        _utilities  = new Utility[_hull.utilitySlots];
        _components = new ShipComponent[_hull.weaponSlots + _hull.utilitySlots];

        _modifiers.AddRange(_hull.maintenanceCosts);

        _model        = _hull.model;
        _destroyedVFX = _hull.destroyedVFX;

        //add preconfigured utilities
        if (sd.weapons != null)
        {
            for (int i = 0; i < sd.weapons.Length; i++)
            {
                if (sd.weapons[i] != null)
                {
                    _weapons[i] = sd.weapons[i].Instantiate() as Weapon;
                }
            }
        }

        if (sd.utilities != null)
        {
            for (int i = 0; i < sd.utilities.Length; i++)
            {
                if (sd.utilities[i] != null)
                {
                    _utilities[i] = sd.utilities[i].Instantiate() as Utility;
                }
            }
        }

        //autofill component slots with components for debug purposes
        var weapons =
            Resources.LoadAll <WeaponData>("Data/Parts/Weapons")
            .Where(w => (int)w.minimumSize <= (int)_hull.size)
            .ToArray();
        var utilities =
            Resources.LoadAll <UtilityData>("Data/Parts/Utilities")
            .Where(u => (int)u.minimumSize <= (int)_hull.size)
            .ToArray();

        for (int i = 0; i < _weapons.Length; i++)
        {
            if (_weapons[i] == null)
            {
                _weapons[i] = weapons.RandomItem().Instantiate() as Weapon;
            }

            _components[i] = _weapons[i];
        }
        for (int i = 0; i < _utilities.Length; i++)
        {
            if (_utilities[i] == null)
            {
                _utilities[i] = utilities.RandomItem().Instantiate() as Utility;
            }

            _components[_weapons.Length + i] = _utilities[i];
        }

        UpdateStats();
        UpdateResourceScanner();
    }
Ejemplo n.º 5
0
        /// <summary>
        /// Decrements the class count for a given class
        /// </summary>
        /// <param name="c">Class to decrement</param>
        public void remove(HullClass.CLASS c, GridEnforcer ge)
        {
            int classID = (int)c;
            if (m_Counts[classID] > 0) {
                m_Counts[classID] -= 1;
                m_TotalCount--;
            } else {
                log("Error: Decrementing class " + classID + " count, but already 0",
                    "removeClass", Logger.severity.ERROR);
            }

            updateSupportRemoved(classID, ge);
            //debugPrint("remove");
        }
Ejemplo n.º 6
0
 public uint maxClass(HullClass.CLASS c)
 {
     return m_Maximums[(int)c];
 }
Ejemplo n.º 7
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="c">Class to check</param>
 /// <returns>Count of c</returns>
 public uint countClass(HullClass.CLASS c)
 {
     return m_Counts[(int)c];
 }
Ejemplo n.º 8
0
 public bool canSupportAnother(HullClass.CLASS c)
 {
     return (countClass(c) < maxClass(c)) || (maxClass(c) < 0);
 }
Ejemplo n.º 9
0
        /// <summary>
        /// Increments the class count for a given class
        /// </summary>
        /// <param name="c">Class to increment</param>
        public void add(HullClass.CLASS c, GridEnforcer ge)
        {
            log("adding class " + ge.Class, "add", Logger.severity.TRACE);

            int classID = (int)ge.Class;
            //log("m_Counts[classID] is " + m_Counts[classID], "add", Logger.severity.TRACE);

            updateSupportAdded(ge);
            m_Counts[classID] += 1;
            m_TotalCount++;
            //log("m_Counts[classID] is " + m_Counts[classID], "add", Logger.severity.TRACE);

            //debugPrint("add");
        }
Ejemplo n.º 10
0
 public FleetShip GetFleetShipPrefab(Race race, HullClass hullClass)
 {
     return(fleetShipPrefabs[new Tuple <Race, HullClass>(race, hullClass)]);
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Check if the owner can have any more of this class.
 /// </summary>
 /// <param name="c">Class to check</param>
 /// <returns>True if the class is allowed</returns>
 private bool checkClassAllowed(HullClass.CLASS c)
 {
     log("checking if fleet can support more of " + c, "checkClassAllowed");
     return m_Owner.Fleet.canSupportAnother(c);
 }
Ejemplo n.º 12
0
 private void setReservedTo(HullClass.CLASS newClass)
 {
     if (m_ReservedClass == newClass) {
         log("No change, ReservedClass remains " + m_ReservedClass, "setReservedTo");
     }
     else {
         log("Changing ReservedClass from " + m_ReservedClass + " to " + newClass,
             "setReservedTo");
         m_ReservedClass = newClass;
         m_ReservedRules = s_Settings.HullRules[(int)newClass];
     }
 }
Ejemplo n.º 13
0
 private void setEffectiveTo(HullClass.CLASS newClass)
 {
     if (m_EffectiveClass == newClass) {
         log("No changed, EffectiveClass remains " + m_EffectiveClass, "setEffectiveTo");
     }
     else {
         log("Changing EffectiveClass from " + m_EffectiveClass + " to " + newClass,
             "setEffectiveTo");
         m_EffectiveClass = newClass;
         m_EffectiveRules = s_Settings.HullRules[(int)newClass];
         reserveEffectiveClassFromOwner();
         m_CheckCleanupNextUpdate = true;
     }
 }
Ejemplo n.º 14
0
        /// <summary>
        /// If the class has changed, update class the fleet stored it as
        /// </summary>
        /// <param name="c">New Hull Class</param>
        public void setClassification(HullClass.CLASS c)
        {
            if (m_Class == c)
                return;

            log("changing owner class to " + c, "setClassification");
            m_Fleet.remove(m_Class, m_Enforcer);
            m_Class = c;
            m_Fleet.add(m_Class, m_Enforcer);
            log("Owner class changed to " + m_Class, "setClassification");
        }
Ejemplo n.º 15
0
 public FleetShip GetFleetShipPrefab(Race race, HullClass hullClass)
 {
     return fleetShipPrefabs[new Tuple<Race, HullClass>(race, hullClass)];
 }