private void SetupData() { var game = Object.FindObjectOfType <GameManager>(); config = InspectorUtil.GetPrivateValue <GameConfig, GameManager>("config", game); var cells = Object.FindObjectOfType <Cells>(); var cellTypes = (Cells.CellTypes[])Enum.GetValues(typeof(Cells.CellTypes)); foreach (var cellType in cellTypes) { if (cellType == Cells.CellTypes.None) { continue; } var cell = cells.GetPrefab(cellType); if (cell != null) { data.techTreeData.GetNode(cell); } } foreach (var buildAction in config.techConfig.buildActions) { data.techTreeData.GetNode(buildAction); } foreach (var upgradeAction in config.techConfig.upgrades) { data.techTreeData.GetNode(upgradeAction); } }
public TurnCalculator() { var game = Object.FindObjectOfType <GameManager>(); config = InspectorUtil.GetPrivateValue <GameConfig, GameManager>("config", game); cells = Object.FindObjectOfType <Cells>(); config.Init(cells); }
private VisualElement GetUpgradeDetails(HexCell cell) { if (!(cell is BuildingCell buildingCell)) { return(null); } var upgradeDetails = InspectorUtil.GetPrivateValue <List <BuildingCell.UpgradeDetail>, BuildingCell>("upgradeDetails", buildingCell); var element = new VisualElement(); for (int i = 0; i < upgradeDetails.Count; i++) { var index = i; var detail = upgradeDetails[index]; var detailElement = new VisualElement(); var currency = NodeUtil.CreateCostField(detail.currencyBonus, newCurrency => UpdateUpgradeBonus(buildingCell, index, newCurrency)); detailElement.Add(new Label(detail.tech.ToString())); detailElement.Add(currency); element.Add(detailElement); } return(element); }
private void SetupData() { var game = Object.FindObjectOfType <GameManager>(); var config = InspectorUtil.GetPrivateValue <GameConfig, GameManager>("config", game); var cells = Object.FindObjectOfType <Cells>(); config.Init(cells); playerData = new PlayerData(null); playerData.Init(config); var homeCell = (BuildingCell)cells.GetPrefab(Cells.CellTypes.Home); buildings.Add(homeCell); playerData.TurnNumber = 1; playerData.TechnologyData.AddTechnology(homeCell.Technology); playerData.CurrencyData.Supplies = config.startingSupply; playerData.CurrencyData.Production.maximum = homeCell.GetCurrencyBonus().production; playerData.CurrencyData.Population.maximum = homeCell.GetCurrencyBonus().population; DisplayCurrency(); turnLabel.text = $"Turn {playerData.TurnNumber}"; }