Beispiel #1
0
 private void CreateCompositionFromChildren() {
     _ships = gameObject.GetSafeMonoBehaviourComponentsInChildren<FacilityItem>();
     IPlayer owner = GameManager.Instance.HumanPlayer;
     __isHumanFleetCreated = true;
     _composition = new StarbaseComposition();
     foreach (var ship in _ships) {
         FacilityCategory hull = GetShipHull(ship);
         string shipName = ship.gameObject.name;
         FacilityData data = CreateShipData(hull, shipName, owner);
         _composition.Add(data);
     }
 }
Beispiel #2
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 StarbaseComposition();

        FacilityCategory[] __hullsToConsider = new FacilityCategory[] { FacilityCategory.CentralHub, FacilityCategory.Construction, FacilityCategory.Economic, FacilityCategory.Science, FacilityCategory.Defense };

        //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++) {
            FacilityCategory hull = RandomExtended<FacilityCategory>.Choice(__hullsToConsider);
            int shipHullIndex = GetShipHullIndex(hull);
            string shipName = hull.GetName() + Constants.Underscore + shipHullIndex;
            FacilityData shipData = CreateShipData(hull, shipName, owner);
            _composition.Add(shipData);
        }
    }