Exemplo n.º 1
0
 private void CreateCompositionFromChildren() {
     _elements = gameObject.GetSafeMonoBehaviourComponentsInChildren<ShipItem>();
     IPlayer owner = GameManager.Instance.HumanPlayer;
     __isHumanOwnedCreated = true;
     _composition = new FleetComposition();
     foreach (var element in _elements) {
         ShipCategory elementCategory = DeriveCategory(element);
         string elementName = element.gameObject.name;
         ShipData data = CreateElementData(elementCategory, elementName, owner);
         _composition.Add(data);
     }
 }
Exemplo n.º 2
0
 private void CreateCompositionFromChildren() {
     _ships = gameObject.GetSafeMonoBehaviourComponentsInChildren<ShipItem>();
     IPlayer owner = GameManager.Instance.HumanPlayer;
     __isHumanFleetCreated = true;
     _composition = new FleetComposition();
     foreach (var ship in _ships) {
         ShipCategory hull = GetShipHull(ship);
         string shipName = ship.gameObject.name;
         ShipData data = CreateShipData(hull, shipName, owner);
         _composition.Add(data);
     }
 }
Exemplo n.º 3
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);
        }
    }
Exemplo n.º 4
0
 public FleetCategory GenerateCmdCategory(FleetComposition unitComposition) {
     int elementCount = UnitComposition.GetTotalElementsCount();
     D.Log("{0}'s known elements count = {1}.", FullName, elementCount);
     if (elementCount >= 22) {
         return FleetCategory.Armada;
     }
     if (elementCount >= 15) {
         return FleetCategory.BattleGroup;
     }
     if (elementCount >= 9) {
         return FleetCategory.TaskForce;
     }
     if (elementCount >= 4) {
         return FleetCategory.Squadron;
     }
     if (elementCount >= 1) {
         return FleetCategory.Flotilla;
     }
     return FleetCategory.None;
 }
Exemplo n.º 5
0
 protected override void UpdateComposition() {
     var elementCategories = ElementsData.Cast<ShipData>().Select(sd => sd.Category);
     UnitComposition = new FleetComposition(elementCategories);
 }
Exemplo n.º 6
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);
        }
    }
Exemplo n.º 7
0
 protected override void RefreshComposition() {
     var elementCategories = _elementsData.Cast<ShipData>().Select(sd => sd.HullCategory);
     UnitComposition = new FleetComposition(elementCategories);
 }