コード例 #1
0
        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;
            }
        }
コード例 #2
0
        /// <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);
            }
        }
コード例 #3
0
        public void ExchangeOKSelected()
        {
            List <GameObject> unitsToDelete = new List <GameObject>();

            // Determine if the user has selected enough factors
            if (GlobalDefinitions.exchangeFactorsSelected >= GlobalDefinitions.exchangeFactorsToLose)
            {
                GlobalDefinitions.WriteToCommandFile(GlobalDefinitions.OKEXCHANGEKEYWORD + " " + name);

                GlobalDefinitions.WriteToLogFile("exchangeOKSelected: attackerHadMostFactors = " + attackerHadMostFactors + " Units selected for exchange:");
                foreach (GameObject unit in GlobalDefinitions.unitsToExchange)
                {
                    GlobalDefinitions.WriteToLogFile("    unit " + unit.name);
                    unitsToDelete.Add(unit);
                }

                if (attackerHadMostFactors)
                {
                    foreach (GameObject unit in defendingUnits)
                    {
                        GlobalDefinitions.UnhighlightUnit(unit);
                        GlobalDefinitions.MoveUnitToDeadPile(unit);
                    }
                    defendingUnits.Clear();

                    foreach (GameObject unit in unitsToDelete)
                    {
                        attackingUnits.Remove(unit); // This is needed to see if there are any attackers left at the end for post-combat movement
                        GlobalDefinitions.UnhighlightUnit(unit);
                        GlobalDefinitions.MoveUnitToDeadPile(unit);
                    }
                }
                else
                {
                    foreach (GameObject unit in attackingUnits)
                    {
                        GlobalDefinitions.UnhighlightUnit(unit);
                        GlobalDefinitions.MoveUnitToDeadPile(unit);
                    }
                    attackingUnits.Clear();

                    foreach (GameObject unit in unitsToDelete)
                    {
                        GlobalDefinitions.UnhighlightUnit(unit);
                        GlobalDefinitions.MoveUnitToDeadPile(unit);
                    }
                }

                GUIRoutines.RemoveGUI(GlobalDefinitions.ExchangeGUIInstance);

                if (attackerHadMostFactors && (GlobalDefinitions.hexesAvailableForPostCombatMovement.Count > 0) && (attackingUnits.Count > 0))
                {
                    CombatResolutionRoutines.SelectUnitsForPostCombatMovement(attackingUnits);
                }
                else
                {
                    // The CombatResolution table will be activated after the post movement combat units are selected which is why this check is needed.
                    GlobalDefinitions.combatResolutionGUIInstance.SetActive(true);
                }

                GlobalDefinitions.unitsToExchange.Clear();
            }
            else
            {
                GlobalDefinitions.WriteToLogFile("exchangeOKSelected: ERROR - Not enough factors selected");
            }
        }