Example #1
0
    public Ship SpawnShip(ShipCategory catagory, ShipType type, int portIndex)
    {
        GameObject spawned  = m_spawners[portIndex].SpawnShip(m_shipPrefabs[(int)type]);
        Ship       shipComp = spawned.GetComponent <Ship>();

        if (shipComp == null)
        {
            Debug.LogError("Prefab doesn't have Ship script attached :(");
        }
        else
        {
            m_ships[(int)catagory].Add(shipComp);
        }
        return(shipComp);
    }
Example #2
0
 public static float __GetMass(ShipCategory hull) {
     switch (hull) {
         case ShipCategory.Fighter:
             return 10F;
         case ShipCategory.Frigate:
             return 50F;
         case ShipCategory.Destroyer:
             return 100F;
         case ShipCategory.Cruiser:
             return 200F;
         case ShipCategory.Dreadnaught:
             return 400F;
         case ShipCategory.Carrier:
             return 500F;
         case ShipCategory.Colonizer:
         case ShipCategory.Science:
         case ShipCategory.Scout:
         case ShipCategory.Troop:
         case ShipCategory.None:
         default:
             throw new NotImplementedException(ErrorMessages.UnanticipatedSwitchValue.Inject(hull));
     }
 }
Example #3
0
 public bool Update(ShipCategory model)
 {
     return(_shippingCategoryDAL.Update(model) > 0);
 }
Example #4
0
        public bool Delete(int modelID)
        {
            ShipCategory shipCategory = _shippingCategoryDAL.Get(a => a.ID == modelID);

            return(_shippingCategoryDAL.Delete(shipCategory) > 0);
        }
Example #5
0
 public bool Delete(ShipCategory model)
 {
     return(_shippingCategoryDAL.Delete(model) > 0);
 }
Example #6
0
 public bool Add(ShipCategory model)
 {
     return(_shippingCategoryDAL.Add(model) > 0);
 }
Example #7
0
    private void CreateRandomComposition() {
        IPlayer owner;
        if (!__isHumanOwnedCreated) {
            owner = GameManager.Instance.HumanPlayer;
            __isHumanOwnedCreated = true;
        }
        else {
            owner = new Player(new Race(Enums<Races>.GetRandom(excludeDefault: true)), IQ.Normal);
        }
        _composition = new FleetComposition();

        ShipCategory[] __elementCategoriesToPickFrom = new ShipCategory[] { ShipCategory.Carrier, ShipCategory.Cruiser, ShipCategory.Destroyer, ShipCategory.Dreadnaught, ShipCategory.Frigate };

        //determine how many ships of what hull for the fleet, then build shipdata and add to composition
        int elementCount = RandomExtended<int>.Range(1, maxElements);
        for (int i = 0; i < elementCount; i++) {
            ShipCategory elementCategory = RandomExtended<ShipCategory>.Choice(__elementCategoriesToPickFrom);
            int nextIndex = GetExistingCount(elementCategory) + 1;
            string uniqueElementName = elementCategory.GetName() + Constants.Underscore + nextIndex;
            ShipData elementData = CreateElementData(elementCategory, uniqueElementName, owner);
            _composition.Add(elementData);
        }
    }
Example #8
0
 protected abstract GameObject GetElementPrefab(ShipCategory elementCategory);
Example #9
0
 private int GetExistingCount(ShipCategory elementCategory) {
     if (!_composition.ElementCategories.Contains(elementCategory)) {
         return 0;
     }
     return _composition.GetData(elementCategory).Count;
 }
Example #10
0
 protected virtual ShipData CreateElementData(ShipCategory elementCategory, string elementInstanceName, IPlayer owner) {
     float mass = TempGameValues.__GetMass(elementCategory);
     float drag = 0.1F;
     ShipData elementData = new ShipData(elementCategory, elementInstanceName, 50F, mass, drag) {
         // Ship's optionalParentName gets set when it gets attached to a fleet
         Strength = new CombatStrength(),
         CurrentHitPoints = UnityEngine.Random.Range(25F, 50F),
         MaxTurnRate = UnityEngine.Random.Range(45F, 315F),
         Owner = owner,
         MaxThrust = mass * drag * UnityEngine.Random.Range(2F, 5F)  // MaxThrust = Mass * Drag * MaxSpeed;
     };
     return elementData;
 }
Example #11
0
    private void CreateRandomComposition() {
        IPlayer owner;
        if (!__isHumanFleetCreated) {
            owner = GameManager.Instance.HumanPlayer;
            __isHumanFleetCreated = true;
        }
        else {
            owner = new Player(new Race(Enums<Races>.GetRandom(excludeDefault: true)), IQ.Normal);
        }
        _composition = new FleetComposition();

        ShipCategory[] __hullsToConsider = new ShipCategory[] { ShipCategory.Carrier, ShipCategory.Cruiser, ShipCategory.Destroyer, ShipCategory.Dreadnaught, ShipCategory.Frigate };

        //determine how many ships of what hull for the fleet, then build shipdata and add to composition
        int shipCount = RandomExtended<int>.Range(1, maxShips);
        for (int i = 0; i < shipCount; i++) {
            ShipCategory hull = RandomExtended<ShipCategory>.Choice(__hullsToConsider);
            int shipHullIndex = GetShipHullIndex(hull);
            string shipName = hull.GetName() + Constants.Underscore + shipHullIndex;
            ShipData shipData = CreateShipData(hull, shipName, owner);
            _composition.Add(shipData);
        }
    }
Example #12
0
 private int GetShipHullIndex(ShipCategory hull) {
     if (!_composition.ElementCategories.Contains(hull)) {
         return 1;
     }
     return _composition.GetData(hull).Count + 1;
 }
Example #13
0
 private ShipData CreateShipData(ShipCategory hull, string shipName, IPlayer owner) {
     float mass = TempGameValues.__GetMass(hull);
     float drag = 0.1F;
     ShipData shipData = new ShipData(hull, shipName, 50F, mass, drag) {
         // Ship's optionalParentName gets set when it gets attached to a fleet
         Strength = new CombatStrength(),
         CurrentHitPoints = UnityEngine.Random.Range(25F, 50F),
         MaxTurnRate = UnityEngine.Random.Range(45F, 315F),
         Owner = owner,
         MaxThrust = mass * drag * UnityEngine.Random.Range(2F, 5F)  // MaxThrust = Mass * Drag * MaxSpeed;
     };
     return shipData;
 }
Example #14
0
 private ShipTypeGroup(int id, string name) : base(id, name)
 {
     this.ships        = new List <ShipType>();
     this.shipCategory = ShipCategory.SmallFighter;
 }