コード例 #1
0
        /// <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();
        }
コード例 #2
0
        /// <summary>
        /// This routine processes the chagne in the toggle displaying the German supply range
        /// </summary>
        public void DisplayGermanSupplyRange()
        {
            GlobalDefinitions.WriteToCommandFile(GlobalDefinitions.DISPLAYGERMANSUPPLYRANGETOGGLEWORD);

            if (gameObject.GetComponent <Toggle>().isOn)
            {
                // Check if the German supply range is being displayed, it must be turned off first otherwise we will get confused
                if (GlobalDefinitions.displayAlliedSupplyStatus)
                {
                    GameObject.Find("AlliedSupplyToggle").GetComponent <Toggle>().isOn = false;
                }

                // Set the global variable so the other unhighlighing can be processed properly
                GlobalDefinitions.displayGermanSupplyStatus = true;
                // Highlight all hexes that have supply available
                foreach (GameObject hex in HexDefinitions.allHexesOnBoard)
                {
                    if (hex.GetComponent <HexDatabaseFields>().germanInSupply)
                    {
                        GlobalDefinitions.HighlightHexInSupply(hex);
                    }
                }
            }
            else
            {
                // Set the global variable so the other unhighlighing can be processed properly
                GlobalDefinitions.displayGermanSupplyStatus = false;
                // Turn off supply highlighting
                foreach (GameObject hex in HexDefinitions.allHexesOnBoard)
                {
                    GlobalDefinitions.UnhighlightHexSupplyRange(hex);
                }
            }
        }
コード例 #3
0
        /// <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);
        }
コード例 #4
0
        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);
            }
        }
コード例 #5
0
 public void ExecutePostCombatMovement()
 {
     GlobalDefinitions.WriteToCommandFile(GlobalDefinitions.POSTCOMBATOKKEYWORD + " " + name);
     GUIRoutines.RemoveGUI(transform.parent.gameObject);
     GlobalDefinitions.hexesAvailableForPostCombatMovement.Clear();
     GlobalDefinitions.combatResolutionGUIInstance.SetActive(true);
 }
コード例 #6
0
        public void MultiUnitSelection()
        {
            GlobalDefinitions.WriteToCommandFile(GlobalDefinitions.TACAIRMULTIUNITSELECTIONKEYWORD + " " + name);

            GUIRoutines.RemoveGUI(GlobalDefinitions.tacticalAirGUIInstance);
            CombatResolutionRoutines.AddInterdictedUnitToList(unit);
        }
コード例 #7
0
        /// <summary>
        /// Executes when the user wants to display the current combats
        /// </summary>
        public void ExecuteCombatResolution()
        {
            if (GUIRoutines.guiList.Count == 0)
            {
                if (GlobalDefinitions.allCombats.Count > 0)
                {
                    // Turn off the button
                    GameObject.Find("ResolveCombatButton").GetComponent <Button>().interactable = false;

                    CombatResolutionRoutines.CombatResolutionDisplay();

                    // When this is called by the AI then the line below end up calling two guis when the command file is being read
                    if (!GlobalDefinitions.AICombat)
                    {
                        GlobalDefinitions.WriteToCommandFile(GlobalDefinitions.DISPLAYCOMBATRESOLUTIONKEYWORD);
                    }
                }
                else
                {
                    GlobalDefinitions.GuiUpdateStatusMessage("No combats have been assigned therefore there is nothing to resolve");
                }
            }
            else
            {
                GlobalDefinitions.GuiUpdateStatusMessage("Resolve the currently displayed menu before trying to bring up combat display");
            }
        }
コード例 #8
0
        /// <summary>
        /// This routine sends a command for a mouse click to the opponent's computer
        /// </summary>
        /// <param name="unit"></param>
        /// <param name="hex"></param>
        public static void RecordMouseClick(GameObject unit, GameObject hex)
        {
            GlobalDefinitions.WriteToCommandFile(GlobalDefinitions.SETCAMERAPOSITIONKEYWORD + " " + Camera.main.transform.position.x + " " + Camera.main.transform.position.y + " " + Camera.main.transform.position.z + " " + Camera.main.GetComponent <Camera>().orthographicSize);

            string hexName;
            string unitName;

            if (hex != null)
            {
                hexName = hex.name;
            }
            else
            {
                hexName = "null";
            }

            if (unit != null)
            {
                unitName = unit.name;
            }
            else
            {
                unitName = "null";
            }

            GlobalDefinitions.WriteToCommandFile(GlobalDefinitions.MOUSESELECTIONKEYWORD + " " + hexName + " " + unitName);
        }
コード例 #9
0
        /// <summary>
        /// Toggle that displays all units that must be attacked
        /// </summary>
        public void DisplayMustAttackUnits()
        {
            GlobalDefinitions.WriteToCommandFile(GlobalDefinitions.DISPLAYMUSTATTACKTOGGLEWORD);

            if (gameObject.GetComponent <Toggle>().isOn)
            {
                CombatRoutines.CheckIfRequiredUnitsAreUncommitted(GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.currentNationality, true);
            }
            else
            {
                foreach (GameObject unit in GlobalDefinitions.alliedUnitsOnBoard)
                {
                    GlobalDefinitions.UnhighlightUnit(unit);
                }
                foreach (GameObject unit in GlobalDefinitions.germanUnitsOnBoard)
                {
                    GlobalDefinitions.UnhighlightUnit(unit);
                }
            }

            //else
            //{
            //    foreach (GameObject unit in GlobalDefinitions.mustAttackUnits)
            //        GlobalDefinitions.unhighlightUnit(unit);
            //    foreach (GameObject unit in GlobalDefinitions.mustBeAttackedUnits)
            //        GlobalDefinitions.unhighlightUnit(unit);
            //    GlobalDefinitions.mustAttackUnits.Clear();
            //    GlobalDefinitions.mustBeAttackedUnits.Clear();
            //}
        }
コード例 #10
0
        /// <summary>
        /// Executes when the user selects Assign Combat from the static gui
        /// </summary>
        public void LoadCombat()
        {
            if (GUIRoutines.guiList.Count == 0)
            {
                GlobalDefinitions.WriteToCommandFile(GlobalDefinitions.LOADCOMBATKEYWORD);

                GlobalDefinitions.GuiUpdateStatusMessage("Select a hex to attack; hex must contain enemy units that are adjacent to friendly units");
                if (GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.name == "alliedInvasionStateInstance")
                {
                    GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.executeMethod =
                        GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.GetComponent <AlliedInvasionState>().LoadCombat;
                }
                if (GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.name == "alliedAirborneStateInstance")
                {
                    GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.executeMethod =
                        GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.GetComponent <AlliedAirborneState>().LoadCombat;
                }
                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>().LoadCombat;
                }
                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
            {
                GlobalDefinitions.GuiUpdateStatusMessage("Resolve the currently displayed menu before assigning combat");
            }
        }
コード例 #11
0
        /// <summary>
        /// Used to toggle the air support option on the combat gui in network games
        /// </summary>
        public void ToggleAirSupport()
        {
            GlobalDefinitions.WriteToCommandFile(GlobalDefinitions.TOGGLEAIRSUPPORTCOMBATTOGGLE + " " + name);

            if (this.GetComponent <Toggle>().isOn)
            {
                if (GlobalDefinitions.tacticalAirMissionsThisTurn < GlobalDefinitions.maxNumberOfTacticalAirMissions)
                {
                    currentCombat.GetComponent <Combat>().attackAirSupport = true;
                    GlobalDefinitions.WriteToLogFile("toggleAirSupport: incrementing GlobalDefinitions.tacticalAirMissionsThisTurn");
                    GlobalDefinitions.tacticalAirMissionsThisTurn++;
                }
                else
                {
                    GlobalDefinitions.WriteToLogFile("No more air missions available");
                    this.GetComponent <Toggle>().isOn = false;
                }
            }
            else
            {
                currentCombat.GetComponent <Combat>().attackAirSupport = false;
                GlobalDefinitions.tacticalAirMissionsThisTurn--;
            }
            UpdateOddsText();
        }
コード例 #12
0
        public static void TacticalAirOK()
        {
            GlobalDefinitions.WriteToCommandFile(GlobalDefinitions.EXECUTETACTICALAIROKKEYWORD);

            GUIRoutines.RemoveGUI(GlobalDefinitions.tacticalAirGUIInstance);

            GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.ExecuteQuit();
        }
コード例 #13
0
        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);
        }
コード例 #14
0
        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);
        }
コード例 #15
0
        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);
            }
        }
コード例 #16
0
        /// <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);
        }
コード例 #17
0
        /// <summary>
        /// Called when the ok button is selected
        /// </summary>
        public void OkSelected()
        {
            GlobalDefinitions.aggressiveSetting = (int)GameObject.Find("AgressivenessSlider").GetComponent <Slider>().value;
            GlobalDefinitions.difficultySetting = (int)GameObject.Find("DifficultySlider").GetComponent <Slider>().value;
            GlobalDefinitions.WriteToCommandFile(GlobalDefinitions.AGGRESSIVESETTINGKEYWORD + " " + (int)GameObject.Find("AgressivenessSlider").GetComponent <Slider>().value);
            GlobalDefinitions.WriteToCommandFile(GlobalDefinitions.DIFFICULTYSETTINGKEYWORD + " " + (int)GameObject.Find("DifficultySlider").GetComponent <Slider>().value);
            // Write out the values of the sliders to the settings file
            GameControl.readWriteRoutinesInstance.GetComponent <ReadWriteRoutines>().WriteSettingsFile(GlobalDefinitions.difficultySetting, GlobalDefinitions.aggressiveSetting);
            CombatResolutionRoutines.AdjustAggressiveness();

            CancelSelected();
        }
コード例 #18
0
        public void ToggleCarpetBombing()
        {
            GlobalDefinitions.WriteToCommandFile(GlobalDefinitions.TOGGLECARPETBOMBINGCOMBATTOGGLE + " " + name);

            if (this.GetComponent <Toggle>().isOn)
            {
                currentCombat.GetComponent <Combat>().carpetBombing = true;
            }
            else
            {
                currentCombat.GetComponent <Combat>().carpetBombing = false;
            }
        }
コード例 #19
0
        public void LocateInterdictedUnit()
        {
            GlobalDefinitions.WriteToCommandFile(GlobalDefinitions.LOCATEUNITINTERDICTIONKEYWORD + " " + name);

            Camera mainCamera = GameObject.Find("Main Camera").GetComponent <Camera>();

            // This centers the camera on the unit
            mainCamera.transform.position = new Vector3(unit.transform.position.x, unit.transform.position.y, mainCamera.transform.position.z);
            // This then moves the camera over to the left so that the gui doesn't cover the unit
            mainCamera.transform.position = new Vector3(
                mainCamera.ViewportToWorldPoint(new Vector2(0.25f, 0.5f)).x,
                unit.transform.position.y,
                mainCamera.transform.position.z);
        }
コード例 #20
0
        public void LocateCloseDefense()
        {
            GlobalDefinitions.WriteToCommandFile(GlobalDefinitions.LOCATECLOSEDEFENSEKEYWORD + " " + name);

            Camera mainCamera = GameObject.Find("Main Camera").GetComponent <Camera>();

            // This centers the camera on the hex
            mainCamera.transform.position = new Vector3(hex.transform.position.x, hex.transform.position.y, mainCamera.transform.position.z);
            // This then moves the camera over to the left so that the gui doesn't cover the unit
            mainCamera.transform.position = new Vector3(
                mainCamera.ViewportToWorldPoint(new Vector2(0.25f, 0.5f)).x,
                hex.transform.position.y,
                mainCamera.transform.position.z);
        }
コード例 #21
0
        // 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;
            }
        }
コード例 #22
0
        public void LocateCarpetBombingHex()
        {
            GlobalDefinitions.WriteToCommandFile(GlobalDefinitions.CARPETBOMBINGLOCATIONKEYWORD + " " + name);

            Camera mainCamera = GameObject.Find("Main Camera").GetComponent <Camera>();

            // This centers the camera on the unit
            mainCamera.transform.position = new Vector3(hex.transform.position.x, hex.transform.position.y, mainCamera.transform.position.z);
            // This then moves the camera over to the left so that the gui doesn't cover the unit
            mainCamera.transform.position = new Vector3(
                mainCamera.ViewportToWorldPoint(new Vector2(0.25f, 0.5f)).x,
                hex.transform.position.y,
                mainCamera.transform.position.z);
        }
コード例 #23
0
        /// <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();
            }
        }
コード例 #24
0
        /// <summary>
        /// Button the ends the current phase on the static gui
        /// </summary>
        public void GoToNextPhase()
        {
            // Check if there is a gui up before we move to the next phase since it could result in unknown state
            if (GUIRoutines.guiList.Count == 0)
            {
                // Need to do this first since during changes in control the next phase routine passes control so this would never be sent
                GlobalDefinitions.WriteToCommandFile(GlobalDefinitions.NEXTPHASEKEYWORD);

                // Quit the current game state
                GameControl.gameStateControlInstance.GetComponent <GameStateControl>().currentState.ExecuteQuit();
            }
            else
            {
                GlobalDefinitions.GuiUpdateStatusMessage("Resolve displayed menu before trying advancing to the next phase");
            }
        }
コード例 #25
0
        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();
        }
コード例 #26
0
        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();
        }
コード例 #27
0
        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();
        }
コード例 #28
0
        public void LocateAttack()
        {
            GlobalDefinitions.WriteToCommandFile(GlobalDefinitions.COMBATLOCATIONSELECTEDKEYWORD + " " + name);

            Camera mainCamera = GameObject.Find("Main Camera").GetComponent <Camera>();

            // This centers the camera on the defending hex
            mainCamera.transform.position = new Vector3(
                curentCombat.GetComponent <Combat>().defendingUnits[0].transform.position.x,
                curentCombat.GetComponent <Combat>().defendingUnits[0].transform.position.y,
                mainCamera.transform.position.z);
            // This then moves the camera over to the left so that the gui doesn't cover the unit
            mainCamera.transform.position = new Vector3(
                mainCamera.ViewportToWorldPoint(new Vector2(0.25f, 0.5f)).x,
                curentCombat.GetComponent <Combat>().defendingUnits[0].transform.position.y,
                mainCamera.transform.position.z);
        }
コード例 #29
0
        // Called when the user select to change the status of air support on the combat resolution gui
        public void AddAttackAirSupport()
        {
            if (GetComponent <Toggle>().isOn)
            {
                GlobalDefinitions.WriteToCommandFile(GlobalDefinitions.ADDCOMBATAIRSUPPORTKEYWORD + " " + name);

                if (GlobalDefinitions.tacticalAirMissionsThisTurn < GlobalDefinitions.maxNumberOfTacticalAirMissions)
                {
                    curentCombat.GetComponent <Combat>().attackAirSupport = true;
                    GlobalDefinitions.WriteToLogFile("addAttackAirSupport: incrementing GlobalDefinitions.tacticalAirMissionsThisTurn");
                    GlobalDefinitions.tacticalAirMissionsThisTurn++;
                    attackFactorTextGameObject.GetComponent <TextMeshProUGUI>().text =
                        CalculateBattleOddsRoutines.CalculateAttackFactor(
                            curentCombat.GetComponent <Combat>().attackingUnits,
                            curentCombat.GetComponent <Combat>().attackAirSupport).ToString();
                    oddsTextGameObject.GetComponent <TextMeshProUGUI>().text =
                        GlobalDefinitions.ConvertOddsToString(
                            CalculateBattleOddsRoutines.ReturnCombatOdds(curentCombat.GetComponent <Combat>().defendingUnits,
                                                                         curentCombat.GetComponent <Combat>().attackingUnits,
                                                                         curentCombat.GetComponent <Combat>().attackAirSupport));
                }
                else
                {
                    GlobalDefinitions.GuiUpdateStatusMessage("No more air support missions left to assign");
                    GetComponent <Toggle>().isOn = false;
                }
            }
            else
            {
                GlobalDefinitions.WriteToCommandFile(GlobalDefinitions.REMOVECOMBATAIRSUPPORTKEYWORD + " " + name);

                curentCombat.GetComponent <Combat>().attackAirSupport = false;
                GlobalDefinitions.tacticalAirMissionsThisTurn--;
                attackFactorTextGameObject.GetComponent <TextMeshProUGUI>().text =
                    CalculateBattleOddsRoutines.CalculateAttackFactor(
                        curentCombat.GetComponent <Combat>().attackingUnits,
                        curentCombat.GetComponent <Combat>().attackAirSupport).ToString();
                oddsTextGameObject.GetComponent <TextMeshProUGUI>().text =
                    GlobalDefinitions.ConvertOddsToString(
                        CalculateBattleOddsRoutines.ReturnCombatOdds(
                            curentCombat.GetComponent <Combat>().defendingUnits,
                            curentCombat.GetComponent <Combat>().attackingUnits,
                            curentCombat.GetComponent <Combat>().attackAirSupport));
            }
        }
コード例 #30
0
 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;
 }