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); } }
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); } }
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); } }
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); } }