private void Start() { doctrineTab.SetActive(false); openDoctrineTabButton.onClick.AddListener(delegate { openDoctrineTab(); }); App app = UnityEngine.Object.FindObjectOfType <App>(); int playerIndex = app.GetHumanIndex(); Nation player = State.getNations()[playerIndex]; int rowIndex = 0; LandForces landForces = player.landForces; foreach (MyEnum.ArmyDoctrines doctrine in Enum.GetValues(typeof(MyEnum.ArmyDoctrines))) { TableRow row = doctrineTable.Rows[rowIndex]; Button addButton = row.GetComponentInChildren <Button>(); addButton.onClick.AddListener(delegate { addDoctrine(); }); if (landForces.hasDoctrine(doctrine)) { Toggle toggle = row.GetComponentInChildren <Toggle>(); toggle.isOn = true; } rowIndex++; } }
private void openDoctrineTab() { App app = UnityEngine.Object.FindObjectOfType <App>(); int playerIndex = app.GetHumanIndex(); Nation player = State.getNations()[playerIndex]; LandForces landForces = player.landForces; int rowIndex = 0; foreach (MyEnum.ArmyDoctrines doctrine in Enum.GetValues(typeof(MyEnum.ArmyDoctrines))) { TableRow row = doctrineTable.Rows[rowIndex]; Button addButton = row.GetComponentInChildren <Button>(); if (landForces.hasDoctrine(doctrine)) { Toggle toggle = row.GetComponentInChildren <Toggle>(); toggle.isOn = true; addButton.interactable = false; } rowIndex++; } doctrineTab.SetActive(true); }
private void updateDoctrinePanel(Nation player) { int rowIndex = 0; LandForces landForces = player.landForces; foreach (MyEnum.ArmyDoctrines doctrine in Enum.GetValues(typeof(MyEnum.ArmyDoctrines))) { TableRow row = doctrineTable.Rows[rowIndex]; Button addButton = row.Cells[3].GetComponentInChildren <Button>(); if (landForces.hasDoctrine(doctrine)) { Toggle toggle = row.GetComponentInChildren <Toggle>(); toggle.isOn = true; addButton.interactable = false; } if (PlayerCalculator.canMakeDevelopmentAction(player) == false) { addButton.interactable = false; } rowIndex++; } }