public void MultiUnitSelection() { GlobalDefinitions.WriteToCommandFile(GlobalDefinitions.TACAIRMULTIUNITSELECTIONKEYWORD + " " + name); GUIRoutines.RemoveGUI(GlobalDefinitions.tacticalAirGUIInstance); CombatResolutionRoutines.AddInterdictedUnitToList(unit); }
private void YesContinue() { for (int index = 0; index < singleCombat.GetComponent <Combat>().attackingUnits.Count; index++) { GlobalDefinitions.MoveUnitToDeadPile(singleCombat.GetComponent <Combat>().attackingUnits[index]); } foreach (GameObject unit in singleCombat.GetComponent <Combat>().defendingUnits) { if (unit.GetComponent <UnitDatabaseFields>().isCommittedToAnAttack) { unit.GetComponent <UnitDatabaseFields>().isCommittedToAnAttack = false; GlobalDefinitions.HighlightUnit(unit); } } Destroy(singleCombat); GUIRoutines.RemoveGUI(GlobalDefinitions.combatGUIInstance); if ((GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.name == "alliedCombatStateInstance") || (GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.name == "germanCombatStateInstance")) { GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.executeMethod = GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.GetComponent <CombatState>().ExecuteSelectUnit; } else { GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.executeMethod = GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.GetComponent <MovementState>().ExecuteSelectUnit; } }
public void ExecutePostCombatMovement() { GlobalDefinitions.WriteToCommandFile(GlobalDefinitions.POSTCOMBATOKKEYWORD + " " + name); GUIRoutines.RemoveGUI(transform.parent.gameObject); GlobalDefinitions.hexesAvailableForPostCombatMovement.Clear(); GlobalDefinitions.combatResolutionGUIInstance.SetActive(true); }
private void NoAbort() { foreach (GameObject unit in singleCombat.GetComponent <Combat>().defendingUnits) { if (unit.GetComponent <UnitDatabaseFields>().isCommittedToAnAttack) { unit.GetComponent <UnitDatabaseFields>().isCommittedToAnAttack = false; } } foreach (GameObject unit in singleCombat.GetComponent <Combat>().attackingUnits) { if (unit.GetComponent <UnitDatabaseFields>().isCommittedToAnAttack) { unit.GetComponent <UnitDatabaseFields>().isCommittedToAnAttack = false; } } Destroy(singleCombat); GUIRoutines.RemoveGUI(GlobalDefinitions.combatGUIInstance); if ((GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.name == "alliedCombatStateInstance") || (GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.name == "germanCombatStateInstance")) { GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.executeMethod = GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.GetComponent <CombatState>().ExecuteSelectUnit; CombatRoutines.CheckIfRequiredUnitsAreUncommitted(GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.currentNationality, true); } else { GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.executeMethod = GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.GetComponent <MovementState>().ExecuteSelectUnit; CombatRoutines.CheckIfRequiredUnitsAreUncommitted(GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.currentNationality, false); } }
public void InvadedAreaSelected() { if (GetComponent <Toggle>().isOn) { GlobalDefinitions.WriteToCommandFile(GlobalDefinitions.INVASIONAREASELECTIONKEYWORD + " " + name); GameControl.invasionRoutinesInstance.GetComponent <InvasionRoutines>().SetInvasionArea(index); // Turn on the gui buttons GlobalDefinitions.nextPhaseButton.GetComponent <Button>().interactable = true; GlobalDefinitions.undoButton.GetComponent <Button>().interactable = true; GlobalDefinitions.MustAttackToggle.GetComponent <Toggle>().interactable = true; GlobalDefinitions.AssignCombatButton.GetComponent <Button>().interactable = true; GlobalDefinitions.DisplayAllCombatsButton.GetComponent <Button>().interactable = true; GlobalDefinitions.AlliedSupplyRangeToggle.GetComponent <Toggle>().interactable = true; GlobalDefinitions.GermanSupplyRangeToggle.GetComponent <Toggle>().interactable = true; GlobalDefinitions.AlliedSupplySourcesButton.GetComponent <Button>().interactable = true; if (!GlobalDefinitions.localControl) { GlobalDefinitions.SetGUIForNonLocalControl(); } GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.executeMethod = GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.GetComponent <AlliedInvasionState>().ExecuteSelectUnit; GUIRoutines.RemoveGUI(transform.parent.gameObject); } }
public void NewSavedGameOK() { if (GlobalDefinitions.newGameToggle.GetComponent <Toggle>().isOn) { GlobalDefinitions.WriteToLogFile("newSavedGameOK: Starting new game"); GUIRoutines.RemoveGUI(transform.parent.gameObject); GameControl.setUpStateInstance.GetComponent <SetUpState>().ExecuteNewGame(); } else if (GlobalDefinitions.savedGameToggle.GetComponent <Toggle>().isOn) { GlobalDefinitions.WriteToLogFile("newSavedGameOK: Starting saved game"); // Since at this point we know we are starting a new game and not running the command file, remove the command file if (!GlobalDefinitions.commandFileBeingRead) { GlobalDefinitions.DeleteCommandFile(); } GUIRoutines.RemoveGUI(transform.parent.gameObject); GameControl.setUpStateInstance.GetComponent <SetUpState>().ExecuteSavedGame(); } else if (GlobalDefinitions.commandFileToggle.GetComponent <Toggle>().isOn) { GlobalDefinitions.WriteToLogFile("newSavedGameOK: Executing command file"); GUIRoutines.RemoveGUI(transform.parent.gameObject); GameControl.setUpStateInstance.GetComponent <SetUpState>().ReadCommandFile(); } }
/// <summary> /// Executed when the ok button is selected on the supply sources gui for supply assignment. At the end of a phase. /// </summary> public void OkSupplyWithEndPhase() { GlobalDefinitions.WriteToCommandFile(GlobalDefinitions.OKSUPPLYWITHENDPHASEKEYWORD + " " + name); // Reset all highlighting foreach (GameObject unit in GlobalDefinitions.alliedUnitsOnBoard) { GlobalDefinitions.UnhighlightUnit(unit); if (unit.GetComponent <UnitDatabaseFields>().inSupply) { unit.GetComponent <UnitDatabaseFields>().supplyIncrementsOutOfSupply = 0; } } GameControl.supplyRoutinesInstance.GetComponent <SupplyRoutines>().CheckIfAlliedUnsuppliedUnitsShouldBeEliminated(false); GUIRoutines.RemoveGUI(GlobalDefinitions.supplySourceGUIInstance); // Got rid of the GUI, now get rid of the global copies of the supply gui's //int count = GlobalDefinitions.supplyGUI.Count; //for (int i = 0; i < count; i++) // DestroyImmediate(GlobalDefinitions.supplyGUI[i]); //GlobalDefinitions.supplyGUI.Clear(); // Turn the button back on GameObject.Find("SupplySourcesButton").GetComponent <Button>().interactable = true; GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.ExecuteQuit(); }
/// <summary> /// Called to exit the supply gui when used for display /// </summary> public void OkSupply() { GlobalDefinitions.WriteToCommandFile(GlobalDefinitions.OKSUPPLYKEYWORD + " " + name); // Reset all highlighting foreach (GameObject unit in GlobalDefinitions.alliedUnitsOnBoard) { GlobalDefinitions.UnhighlightUnit(unit); if (unit.GetComponent <UnitDatabaseFields>().inSupply) { unit.GetComponent <UnitDatabaseFields>().supplyIncrementsOutOfSupply = 0; } } // I need to know whether this is the beginning or end of a turn since unsupplied units are only eliminated at the end of a turn // With the implementation of the AI there is no Allied supply state but I think that the check at the end of combat doesn't come through this path... which might not be right //if (GameControl.gameStateControlInstance.GetComponent<gameStateControl>().currentState == GameControl.alliedSupplyStateInstance.GetComponent<SupplyState>()) GameControl.supplyRoutinesInstance.GetComponent <SupplyRoutines>().CheckIfAlliedUnsuppliedUnitsShouldBeEliminated(false); //else //GameControl.supplyRoutinesInstance.GetComponent<SupplyRoutines>().checkIfAlliedUnsuppliedUnitsShouldBeEliminated(true); // Turn the button back on GameObject.Find("SupplySourcesButton").GetComponent <Button>().interactable = true; GUIRoutines.RemoveGUI(GlobalDefinitions.supplySourceGUIInstance); }
/// <summary> /// Display a GUI that shows all of the available carpet bombing hexes available /// </summary> public static void DisplayCarpetBombingHexesAvailable() { Canvas bombingCanvas = new Canvas(); Button tempOKButton; int widthSeed = 6; // Just to make the development easier since position is based on width int heightSeed = GlobalDefinitions.hexesAttackedLastTurn.Count + 2; float panelWidth = widthSeed * 1.25f * GlobalDefinitions.GUIUNITIMAGESIZE; float panelHeight = heightSeed * 1.25f * GlobalDefinitions.GUIUNITIMAGESIZE; // The avaialble carpet bombing hexes are stored in the hexesAttackedLastTurn list. All non valid // hexes were removed already (i.e. hexes attacked last turn but do not have Germans on them this turn) GUIRoutines.CreateGUICanvas("CarpetBombingGUI", panelWidth, panelHeight, ref bombingCanvas); for (int index = 0; index < GlobalDefinitions.hexesAttackedLastTurn.Count; index++) { Toggle tempToggle; Button tempLocateButton; GUIRoutines.CreateUIText("Carpet bombing available - you may select a hex", "CarpetBombingAvailableText", widthSeed * 1.25f * GlobalDefinitions.GUIUNITIMAGESIZE, GlobalDefinitions.GUIUNITIMAGESIZE, (widthSeed * 1.25f * GlobalDefinitions.GUIUNITIMAGESIZE) / 2 - 0.5f * panelWidth, heightSeed * 1.25f * GlobalDefinitions.GUIUNITIMAGESIZE - 0.5f * GlobalDefinitions.GUIUNITIMAGESIZE - 0.5f * panelHeight, Color.white, bombingCanvas); for (int index2 = 0; index2 < GlobalDefinitions.hexesAttackedLastTurn[index].GetComponent <HexDatabaseFields>().occupyingUnit.Count; index2++) { GUIRoutines.CreateUnitImage(GlobalDefinitions.hexesAttackedLastTurn[index].GetComponent <HexDatabaseFields>().occupyingUnit[index2], "UnitImage", index2 * 1.25f * GlobalDefinitions.GUIUNITIMAGESIZE + GlobalDefinitions.GUIUNITIMAGESIZE - 0.5f * panelWidth, (index + 1) * 1.25f * GlobalDefinitions.GUIUNITIMAGESIZE + 0.5f * GlobalDefinitions.GUIUNITIMAGESIZE - 0.5f * panelHeight, bombingCanvas); } tempLocateButton = GUIRoutines.CreateButton("BombingLocateButton" + index, "Locate", 3 * 1.25f * GlobalDefinitions.GUIUNITIMAGESIZE + GlobalDefinitions.GUIUNITIMAGESIZE - 0.5f * panelWidth, (index + 1) * 1.25f * GlobalDefinitions.GUIUNITIMAGESIZE + 0.5f * GlobalDefinitions.GUIUNITIMAGESIZE - 0.5f * panelHeight, bombingCanvas); tempLocateButton.gameObject.AddComponent <CarpetBombingToggleRoutines>(); tempLocateButton.GetComponent <CarpetBombingToggleRoutines>().hex = GlobalDefinitions.hexesAttackedLastTurn[index]; tempLocateButton.onClick.AddListener(tempLocateButton.GetComponent <CarpetBombingToggleRoutines>().LocateCarpetBombingHex); tempToggle = GUIRoutines.CreateToggle("BombingToggle" + index, 4 * 1.25f * GlobalDefinitions.GUIUNITIMAGESIZE + GlobalDefinitions.GUIUNITIMAGESIZE - 0.5f * panelWidth, (index + 1) * 1.25f * GlobalDefinitions.GUIUNITIMAGESIZE + 0.5f * GlobalDefinitions.GUIUNITIMAGESIZE - 0.5f * panelHeight, bombingCanvas).GetComponent <Toggle>(); tempToggle.gameObject.AddComponent <CarpetBombingToggleRoutines>(); tempToggle.GetComponent <CarpetBombingToggleRoutines>().hex = GlobalDefinitions.hexesAttackedLastTurn[index]; tempToggle.GetComponent <Toggle>().onValueChanged.AddListener((bool value) => tempToggle.GetComponent <CarpetBombingToggleRoutines>().SelectHex()); } tempOKButton = GUIRoutines.CreateButton("BombingOKButton", "OK", widthSeed * 1.25f * GlobalDefinitions.GUIUNITIMAGESIZE / 2 - 0.5f * panelWidth, 0.5f * GlobalDefinitions.GUIUNITIMAGESIZE - 0.5f * panelHeight, bombingCanvas); tempOKButton.gameObject.AddComponent <CarpetBombingOKRoutines>(); tempOKButton.onClick.AddListener(tempOKButton.GetComponent <CarpetBombingOKRoutines>().CarpetBombingOK); }
public void AddCloseDefenseHex() { GlobalDefinitions.WriteToCommandFile(GlobalDefinitions.ADDCLOSEDEFENSEKEYWORD); GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.executeMethod = GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.GetComponent <AlliedTacticalAirState>().ExecuteCloseDefenseSelection; GUIRoutines.RemoveGUI(GlobalDefinitions.tacticalAirGUIInstance); }
public void AddRiverInterdiction() { GlobalDefinitions.WriteToCommandFile(GlobalDefinitions.ADDRIVERINTERDICTIONKEYWORD); GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.executeMethod = GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.GetComponent <AlliedTacticalAirState>().ExecuteRiverInterdictionSelection; GUIRoutines.RemoveGUI(GlobalDefinitions.tacticalAirGUIInstance); }
public static void TacticalAirOK() { GlobalDefinitions.WriteToCommandFile(GlobalDefinitions.EXECUTETACTICALAIROKKEYWORD); GUIRoutines.RemoveGUI(GlobalDefinitions.tacticalAirGUIInstance); GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.ExecuteQuit(); }
public void SelectUnitToMove() { GlobalDefinitions.WriteToCommandFile(GlobalDefinitions.MULTIUNITSELECTIONKEYWORD + " " + name); List <GameObject> movementHexes = new List <GameObject>(); if (GetComponent <Toggle>().isOn) { if (unit.GetComponent <UnitDatabaseFields>().isCommittedToAnAttack) { GlobalDefinitions.GuiUpdateStatusMessage("Unit selected is committed to an attack\nCancel attack if you want to move this unit"); GetComponent <Toggle>().isOn = false; } else { GlobalDefinitions.HighlightUnit(unit); GlobalDefinitions.selectedUnit = unit; GlobalDefinitions.startHex = unit.GetComponent <UnitDatabaseFields>().occupiedHex; // We don't want to highlight the movement hexes if we're in setup mode if (GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.name != "setUpStateInstance") { movementHexes = GameControl.movementRoutinesInstance.GetComponent <MovementRoutines>().ReturnAvailableMovementHexes(GlobalDefinitions.startHex, GlobalDefinitions.selectedUnit); foreach (GameObject hex in movementHexes) { GlobalDefinitions.HighlightHexForMovement(hex); } } GUIRoutines.RemoveGUI(transform.parent.gameObject); if ((GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.name == "alliedMovementStateInstance") || (GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.name == "germanMovementStateInstance")) { GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.executeMethod = GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.GetComponent <MovementState>().ExecuteSelectUnitDestination; } else if (GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.name == "setUpStateInstance") { GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.executeMethod = GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.GetComponent <SetUpState>().ExecuteSelectUnitDestination; } //if (GlobalDefinitions.localControl && (GlobalDefinitions.gameMode == GlobalDefinitions.GameModeValues.Network)) // GameControl.sendMouseClickToNetwork(GlobalDefinitions.selectedUnit, GlobalDefinitions.startHex); } } else { // This actually should never happen since when the toggle is selected the gui is removed so there is never a chance to unselect the toggle GUIRoutines.RemoveGUI(transform.parent.gameObject); } }
/// <summary> /// This routine switches the supply status of the unit selected from the multi-unit gui /// </summary> public void SelectFromMultiUnits() { if (GetComponent <Toggle>().isOn) { GlobalDefinitions.WriteToCommandFile(GlobalDefinitions.CHANGESUPPLYSTATUSKEYWORD + " " + name); GameControl.supplyRoutinesInstance.GetComponent <SupplyRoutines>().SwapSupplyStatus(unit); } GUIRoutines.RemoveGUI(transform.parent.gameObject); GlobalDefinitions.supplySourceGUIInstance.SetActive(true); }
/// <summary> /// This routine executes when the player hits the button to indicate that they will be playing the German side /// </summary> public void GermanButtonSelected() { GlobalDefinitions.nationalityUserIsPlaying = GlobalDefinitions.Nationality.German; GlobalDefinitions.commandFileHeader += " German"; GameControl.CreateStatesForAI(GlobalDefinitions.Nationality.German); GlobalDefinitions.gameMode = GlobalDefinitions.GameModeValues.AI; GlobalDefinitions.gameStarted = true; // Set true here since there is no network setup GlobalDefinitions.SwitchLocalControl(true); GUIRoutines.RemoveGUI(transform.parent.gameObject); GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState = GameControl.setUpStateInstance.GetComponent <SetUpState>(); GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.Initialize(); GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.executeMethod(GameControl.inputMessage.GetComponent <InputMessage>()); }
/// <summary> /// Called when the cancel button is selected /// </summary> public void CancelSelected() { // Get rid of the gui GUIRoutines.RemoveGUI(transform.parent.gameObject); // Bring back any gui's that were active before this was called foreach (GameObject gui in GUIRoutines.guiList) { gui.SetActive(true); } // Turn the button back on GameObject.Find("SettingsButton").GetComponent <Button>().interactable = true; }
// Cancels the combat assignment public void CancelCombatGUISelection() { GlobalDefinitions.WriteToCommandFile(GlobalDefinitions.COMBATGUICANCELKEYWORD + " " + name); foreach (GameObject unit in singleCombat.GetComponent <Combat>().defendingUnits) { GlobalDefinitions.UnhighlightUnit(unit); unit.GetComponent <UnitDatabaseFields>().isCommittedToAnAttack = false; } foreach (GameObject unit in singleCombat.GetComponent <Combat>().attackingUnits) { GlobalDefinitions.UnhighlightUnit(unit); unit.GetComponent <UnitDatabaseFields>().isCommittedToAnAttack = false; } Destroy(singleCombat); GUIRoutines.RemoveGUI(GlobalDefinitions.combatGUIInstance); if ((GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.name == "alliedCombatStateInstance") || (GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.name == "germanCombatStateInstance") || GlobalDefinitions.MustAttackToggle.GetComponent <Toggle>().isOn) { CombatRoutines.CheckIfRequiredUnitsAreUncommitted(GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.currentNationality, true); } // Determine what state we are in and set the next executeMethod if ((GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.name == "alliedMovementStateInstance") || (GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.name == "germanMovementStateInstance")) { GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.executeMethod = GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.GetComponent <MovementState>().ExecuteSelectUnit; } if ((GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.name == "alliedCombatStateInstance") || (GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.name == "germanCombatStateInstance")) { GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.executeMethod = GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.GetComponent <CombatState>().ExecuteSelectUnit; } if (GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.name == "alliedInvasionStateInstance") { GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.executeMethod = GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.GetComponent <AlliedInvasionState>().ExecuteSelectUnit; } if (GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.name == "alliedAirborneStateInstance") { GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.executeMethod = GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.GetComponent <AlliedAirborneState>().ExecuteSelectUnit; } }
/// <summary> /// This routine executes when the player hits the button to indicate that they will be playing the Allied side /// </summary> public void AllyButtonSelected() { GlobalDefinitions.nationalityUserIsPlaying = GlobalDefinitions.Nationality.Allied; GlobalDefinitions.commandFileHeader += " Allied"; GameControl.CreateStatesForAI(GlobalDefinitions.Nationality.Allied); GlobalDefinitions.gameMode = GlobalDefinitions.GameModeValues.AI; GlobalDefinitions.gameStarted = true; // Set true here since there is no network setup GlobalDefinitions.SwitchLocalControl(true); GUIRoutines.RemoveGUI(transform.parent.gameObject); // Call the setup routine. The user will indicate whether they are playing a saved or new game there. GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState = GameControl.germanAISetupStateInstance.GetComponent <GermanAISetupState>(); GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.Initialize(); // Note there is no execute method for the German AI state }
/// <summary> /// Executes when the OK button on the combat resolution screen is clicked /// </summary> public void Ok() { // If network game notify the remote system to execute OK GlobalDefinitions.WriteToCommandFile(GlobalDefinitions.COMBATOKKEYWORD + " " + name); if (GetComponentInChildren <Text>().text == "Continue") { GUIRoutines.RemoveGUI(GlobalDefinitions.combatResolutionGUIInstance); // Turn the button back on GameObject.Find("ResolveCombatButton").GetComponent <Button>().interactable = true; // Determine what state we are in and set the next executeMethod if ((GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.name == "alliedMovementStateInstance") || (GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.name == "germanMovementStateInstance")) { GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.executeMethod = GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.GetComponent <MovementState>().ExecuteSelectUnit; } if ((GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.name == "alliedCombatStateInstance") || (GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.name == "germanCombatStateInstance")) { GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.executeMethod = GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.GetComponent <CombatState>().ExecuteSelectUnit; } if (GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.name == "alliedInvasionStateInstance") { GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.executeMethod = GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.GetComponent <AlliedInvasionState>().ExecuteSelectUnit; } if (GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.name == "alliedAirborneStateInstance") { GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.executeMethod = GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.GetComponent <AlliedAirborneState>().ExecuteSelectUnit; } } else { // Turn the button back on GameObject.Find("ResolveCombatButton").GetComponent <Button>().interactable = true; GUIRoutines.RemoveGUI(GlobalDefinitions.combatResolutionGUIInstance); GlobalDefinitions.allCombats.Clear(); GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.GetComponent <CombatState>().ExecuteQuit(); } }
public void CancelInterdictedUnit() { GlobalDefinitions.WriteToCommandFile(GlobalDefinitions.CANCELUNITINTERDICTIONKEYWORD + " " + name); for (int index = 0; index < GlobalDefinitions.interdictedUnits.Count; index++) { if (GlobalDefinitions.interdictedUnits[index] == unit) { GlobalDefinitions.interdictedUnits[index].GetComponent <UnitDatabaseFields>().unitInterdiction = false; GlobalDefinitions.interdictedUnits.Remove(unit); } } GlobalDefinitions.tacticalAirMissionsThisTurn--; GUIRoutines.RemoveGUI(GlobalDefinitions.tacticalAirGUIInstance); CombatResolutionRoutines.CreateTacticalAirGUI(); }
public void CancelCloseDefense() { GlobalDefinitions.WriteToCommandFile(GlobalDefinitions.CANCELCLOSEDEFENSEKEYWORD + " " + name); for (int index = 0; index < GlobalDefinitions.closeDefenseHexes.Count; index++) { if (GlobalDefinitions.closeDefenseHexes[index] == hex) { GlobalDefinitions.closeDefenseHexes[index].GetComponent <HexDatabaseFields>().closeDefenseSupport = false; GlobalDefinitions.UnhighlightHex(GlobalDefinitions.closeDefenseHexes[index]); GlobalDefinitions.closeDefenseHexes.Remove(hex); } } GlobalDefinitions.tacticalAirMissionsThisTurn--; GUIRoutines.RemoveGUI(GlobalDefinitions.tacticalAirGUIInstance); CombatResolutionRoutines.CreateTacticalAirGUI(); }
public void CancelRiverInterdiction() { GlobalDefinitions.WriteToCommandFile(GlobalDefinitions.CANCELRIVERINTERDICTIONKEYWORD + " " + name); for (int index = 0; index < GlobalDefinitions.riverInderdictedHexes.Count; index++) { if (GlobalDefinitions.riverInderdictedHexes[index] == hex) { GlobalDefinitions.riverInderdictedHexes[index].GetComponent <HexDatabaseFields>().riverInterdiction = false; GlobalDefinitions.UnhighlightHex(GlobalDefinitions.riverInderdictedHexes[index]); GlobalDefinitions.riverInderdictedHexes.Remove(hex); } } GlobalDefinitions.tacticalAirMissionsThisTurn--; GUIRoutines.RemoveGUI(GlobalDefinitions.tacticalAirGUIInstance); CombatResolutionRoutines.CreateTacticalAirGUI(); }
public void CarpetBombingOK() { GlobalDefinitions.WriteToCommandFile(GlobalDefinitions.CARPETBOMBINGOKKEYWORD + " " + name); foreach (Transform childTransform in transform.parent.transform) { if (childTransform.gameObject.GetComponent <Toggle>() != null) { if (childTransform.gameObject.GetComponent <Toggle>().isOn) { childTransform.gameObject.GetComponent <CarpetBombingToggleRoutines>().hex.GetComponent <HexDatabaseFields>().carpetBombingActive = true; GlobalDefinitions.numberOfCarpetBombingsUsed++; GlobalDefinitions.carpetBombingUsedThisTurn = true; } } } GUIRoutines.RemoveGUI(transform.parent.gameObject); GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.executeMethod = GameControl.alliedCombatStateInstance.GetComponent <CombatState>().ExecuteSelectUnit; }
public void CarpetBombingResultsSelected() { if (gameObject.GetComponent <Toggle>().isOn) { if ((GlobalDefinitions.gameMode == GlobalDefinitions.GameModeValues.Peer2PeerNetwork) && (!GlobalDefinitions.localControl)) { GUIRoutines.RemoveGUI(transform.parent.gameObject); CombatResolutionRoutines.ExecuteCombatResults(defendingUnits, attackingUnits, combatOdds, dieRollResult, combatResults, buttonLocation); } else { GlobalDefinitions.WriteToCommandFile(GlobalDefinitions.COMBATRESOLUTIONSELECTEDKEYWORD + " " + GlobalDefinitions.CombatResultToggleName); GlobalDefinitions.WriteToCommandFile(GlobalDefinitions.CARPETBOMBINGRESULTSSELECTEDKEYWORD + " " + name + " " + dieRollResult); GUIRoutines.RemoveGUI(transform.parent.gameObject); CombatResolutionRoutines.ExecuteCombatResults(defendingUnits, attackingUnits, combatOdds, dieRollResult, combatResults, buttonLocation); } } }
/// <summary> /// Executes when the cancel button is pressed /// </summary> public void CancelGui() { GlobalDefinitions.WriteToCommandFile(GlobalDefinitions.MULTIUNITSELECTIONCANCELKEYWORD + " " + name); if ((GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.name == "alliedMovementStateInstance") || (GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.name == "germanMovementStateInstance")) { GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.executeMethod = GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.GetComponent <MovementState>().ExecuteSelectUnit; } else if (GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.name == "setUpStateInstance") { GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.executeMethod = GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.GetComponent <SetUpState>().ExecuteSelectUnit; } GUIRoutines.RemoveGUI(transform.parent.gameObject); }
/// <summary> /// Routine pulls up a list of the invasion areas for the user to select from. /// </summary> /// <returns></returns> public void SelectInvasionArea() { GlobalDefinitions.WriteToLogFile("selectInvasionArea: executing"); Canvas invasionAreaSelectionCanvasInstance = new Canvas(); float panelWidth = 3 * 1.25f * GlobalDefinitions.GUIUNITIMAGESIZE; float panelHeight = 9 * GlobalDefinitions.GUIUNITIMAGESIZE; GlobalDefinitions.invasionAreaSelectionGUIInstance = GUIRoutines.CreateGUICanvas("InvasionAreaSelectionGUIInstance", panelWidth, panelHeight, ref invasionAreaSelectionCanvasInstance, 0.16f, 0.16f); GlobalDefinitions.invasionAreaSelectionGUIInstance.GetComponent <RectTransform>().anchorMin = new Vector2(0.16f, 0.5f); GUIRoutines.CreateUIText("Select invasion area", "InvasionAreaSelectionText", (3) * 1.25f * GlobalDefinitions.GUIUNITIMAGESIZE, 1 * GlobalDefinitions.GUIUNITIMAGESIZE, 1.5f * GlobalDefinitions.GUIUNITIMAGESIZE - 0.5f * panelWidth, (8) * GlobalDefinitions.GUIUNITIMAGESIZE - 0.5f * panelHeight, Color.white, invasionAreaSelectionCanvasInstance, 0.16f, 0.16f, 0.5f, 0.5f); for (int index = 0; index < 7; index++) { Toggle tempToggle; GUIRoutines.CreateUIText(GlobalDefinitions.invasionAreas[index].name, "InvasionAreaSelectionText", 2 * GlobalDefinitions.GUIUNITIMAGESIZE, GlobalDefinitions.GUIUNITIMAGESIZE, GlobalDefinitions.GUIUNITIMAGESIZE * 1.25f - 0.5f * panelWidth, (index + 1) * GlobalDefinitions.GUIUNITIMAGESIZE - 0.5f * panelHeight, Color.white, invasionAreaSelectionCanvasInstance, 0.16f, 0.16f, 0.5f, 0.5f); tempToggle = GUIRoutines.CreateToggle("InvasionAreaSelectionToggle" + index, 2 * 1.25f * GlobalDefinitions.GUIUNITIMAGESIZE - 0.5f * panelWidth, (index + 1) * GlobalDefinitions.GUIUNITIMAGESIZE - 0.5f * panelHeight, invasionAreaSelectionCanvasInstance, 0.16f, 0.16f, 0.5f, 0.5f).GetComponent <Toggle>(); tempToggle.gameObject.AddComponent <InvasionSelectionToggleRoutines>(); tempToggle.GetComponent <InvasionSelectionToggleRoutines>().index = index; tempToggle.onValueChanged.AddListener((bool value) => tempToggle.GetComponent <InvasionSelectionToggleRoutines>().InvadedAreaSelected()); } }
/// <summary> /// Called when a unit is selected from the gui to retreat when there are multiple units avaialble /// </summary> public void SelectUnitsToMove() { if (GetComponent <Toggle>().isOn) { GlobalDefinitions.WriteToCommandFile(GlobalDefinitions.RETREATSELECTIONKEYWORD + " " + name); // The unit has been selected so move it to the zero position in the list since that is what will be moved GlobalDefinitions.retreatingUnits.Remove(GetComponent <RetreatToggleRoutines>().unit); GlobalDefinitions.retreatingUnits.Insert(0, GetComponent <RetreatToggleRoutines>().unit); List <GameObject> retreatHexes = CombatResolutionRoutines.ReturnRetreatHexes(GetComponent <RetreatToggleRoutines>().unit); if (retreatHexes.Count > 0) { GlobalDefinitions.HighlightUnit(unit); foreach (GameObject hex in retreatHexes) { GlobalDefinitions.HighlightHexForMovement(hex); } GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.executeMethod = GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.GetComponent <CombatState>().ExecuteRetreatMovement; } // This executes when there is no retreat available for the unit. While the units without retreat available is checked early on, // this is a case where there was more than one unit that needed to retreat but there wasn't room for all of them else { GlobalDefinitions.GuiUpdateStatusMessage("No retreat available - eliminating unit" + unit.name); GlobalDefinitions.MoveUnitToDeadPile(unit); GlobalDefinitions.retreatingUnits.RemoveAt(0); // Need to call selection routines in case there are more units that cannot retreat CombatResolutionRoutines.SelectUnitsForRetreat(); } GUIRoutines.RemoveGUI(transform.parent.gameObject); } }
/// <summary> /// Executes when the OK button is selected /// </summary> public void OkGameMode() { if (MainMenuRoutines.hotseatToggle.GetComponent <Toggle>().isOn) { GlobalDefinitions.WriteToLogFile("okGameMode: Setting up hotseat mode"); GlobalDefinitions.gameMode = GlobalDefinitions.GameModeValues.Hotseat; GlobalDefinitions.commandFileHeader = "Hotseat"; GameControl.CreateStatesForHotSeatOrNetwork(); GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState = GameControl.setUpStateInstance.GetComponent <SetUpState>(); GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.Initialize(); GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.executeMethod(GameControl.inputMessage.GetComponent <InputMessage>()); GlobalDefinitions.gameStarted = true; GlobalDefinitions.SwitchLocalControl(true); GUIRoutines.RemoveGUI(transform.parent.gameObject); } else if (MainMenuRoutines.AIToggle.GetComponent <Toggle>().isOn) { // Note: unlike hotseat or network the state transitions in AI are determined by the side being played so the state creation is called in the button routines // that are invoked by the user selecting the side to play GlobalDefinitions.WriteToLogFile("okGameMode: Setting up AI mode"); GlobalDefinitions.commandFileHeader = "AI"; GlobalDefinitions.AskUserWhichSideToPlay(); GUIRoutines.RemoveGUI(transform.parent.gameObject); } //else if (MainMenuRoutines.peerToPeerNetworkToggle.GetComponent<Toggle>().isOn) //{ // GlobalDefinitions.WriteToLogFile("okGameMode: Setting up Peer to Peer Network mode"); // GlobalDefinitions.gameMode = GlobalDefinitions.GameModeValues.Peer2PeerNetwork; // GlobalDefinitions.commandFileHeader = "Peer2PeerNetwork"; // GameControl.CreateStatesForHotSeatOrNetwork(); // //GameControl.fileTransferServerInstance.GetComponent<FileTransferServer>().initiateFileTransferServer(); // MainMenuRoutines.NetworkSettingsUI(); // GUIRoutines.RemoveGUI(transform.parent.gameObject); //} }
/// <summary> /// Executes when the user indicates he wants to go to main menu /// </summary> public void YesMain() { List <GameObject> removeUnitList = new List <GameObject>(); // If this is a network game I've already checked that the player is in control //if (GlobalDefinitions.gameMode == GlobalDefinitions.GameModeValues.Peer2PeerNetwork) //{ // GlobalDefinitions.WriteToLogFile("YesMain: Calling ResetConnection()"); // //byte error; // //NetworkTransport.Disconnect(TransportScript.receivedHostId, TransportScript.gameConnectionId, out error); // //Network.Disconnect(); // TransportScript.ResetConnection(TransportScript.computerId); //} // Copy list so the guis can be removed List <GameObject> removeList = new List <GameObject>(); foreach (GameObject gui in GUIRoutines.guiList) { removeList.Add(gui); } // Get rid of all active guis foreach (GameObject gui in removeList) { GUIRoutines.RemoveGUI(gui); } // Put all the units back on the OOB sheet foreach (Transform unit in GlobalDefinitions.allUnitsOnBoard.transform) { unit.GetComponent <UnitDatabaseFields>().unitInterdiction = false; unit.GetComponent <UnitDatabaseFields>().isCommittedToAnAttack = false; unit.GetComponent <UnitDatabaseFields>().hasMoved = false; unit.GetComponent <UnitDatabaseFields>().unitEliminated = false; unit.GetComponent <UnitDatabaseFields>().occupiedHex = null; unit.GetComponent <UnitDatabaseFields>().beginningTurnHex = null; unit.GetComponent <UnitDatabaseFields>().invasionAreaIndex = -1; unit.GetComponent <UnitDatabaseFields>().inSupply = true; unit.GetComponent <UnitDatabaseFields>().supplySource = null; unit.GetComponent <UnitDatabaseFields>().supplyIncrementsOutOfSupply = 0; unit.GetComponent <UnitDatabaseFields>().remainingMovement = unit.GetComponent <UnitDatabaseFields>().movementFactor; if (unit.GetComponent <UnitDatabaseFields>().occupiedHex != null) { GlobalDefinitions.UnhighlightUnit(unit.gameObject); GeneralHexRoutines.RemoveUnitFromHex(unit.gameObject, unit.GetComponent <UnitDatabaseFields>().occupiedHex); unit.GetComponent <UnitDatabaseFields>().occupiedHex = null; } removeUnitList.Add(unit.gameObject); } foreach (GameObject unit in removeUnitList) { GlobalDefinitions.ReturnUnitToOOBShet(unit); } // Clear out the lists keeping track of both side's units on board GlobalDefinitions.alliedUnitsOnBoard.Clear(); GlobalDefinitions.germanUnitsOnBoard.Clear(); // Go through the hexes and reset all highlighting foreach (GameObject hex in HexDefinitions.allHexesOnBoard) { hex.GetComponent <HexDatabaseFields>().riverInterdiction = false; hex.GetComponent <HexDatabaseFields>().closeDefenseSupport = false; hex.GetComponent <HexDatabaseFields>().successfullyInvaded = false; hex.GetComponent <HexDatabaseFields>().alliedControl = false; hex.GetComponent <HexDatabaseFields>().inAlliedZOC = false; hex.GetComponent <HexDatabaseFields>().inGermanZOC = false; hex.GetComponent <HexDatabaseFields>().occupyingUnit.Clear(); hex.GetComponent <HexDatabaseFields>().unitsExertingZOC.Clear(); hex.GetComponent <HexDatabaseFields>().availableForMovement = false; hex.GetComponent <HexDatabaseFields>().strategicRemainingMovement = 0; hex.GetComponent <HexDatabaseFields>().remainingMovement = 0; hex.GetComponent <HexDatabaseFields>().supplySources.Clear(); hex.GetComponent <HexDatabaseFields>().unitsThatCanBeSupplied.Clear(); hex.GetComponent <HexDatabaseFields>().closeDefenseSupport = false; hex.GetComponent <HexDatabaseFields>().riverInterdiction = false; hex.GetComponent <HexDatabaseFields>().carpetBombingActive = false; GlobalDefinitions.UnhighlightHex(hex.gameObject); } GlobalDefinitions.WriteToLogFile("Putting Allied units in Britain"); // When restarting a game the units won't have their Britain location loaded so this needs to be done before a restart file is read GameControl.createBoardInstance.GetComponent <CreateBoard>().ReadBritainPlacement(GlobalGameFields.britainUnitLocationFile); GlobalDefinitions.ResetAllGlobalDefinitions(); // Turn the button back on GlobalDefinitions.mainMenuButton.GetComponent <Button>().interactable = true; MainMenuRoutines.GetGameModeUI(); }
/// <summary> /// Executes when the user hits OK on the victory screen /// </summary> public void VictoryOK() { GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState = GameControl.victoryState.GetComponent <VictoryState>(); GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.Initialize(); GUIRoutines.RemoveAllGUIs(); }