Esempio n. 1
0
        /// <summary>
        ///     Starts a turn-based battle in this instance
        /// </summary>
        /// <param name="leaderPlayer">The leading player driver</param>
        /// <param name="leaderEnemy">The leading enemy driver</param>
        public void StartBattleMode(PlayerBattleDriver leaderPlayer, EnemyBattleDriver leaderEnemy)
        {
            if (this.Initialized)
            {
                throw new RPGException(RPGException.Cause.BattleManagerCantStartInitialized);
            }

            this.battleStatus = new BattleStatus(leaderPlayer, leaderEnemy);
            this.battleFlow   = new BattleFlow(this, this.battleStatus);

            // Disable activity handling
            ActivityHandler.Enabled = false;

            // Deactivate unneeded GameObjects
            foreach (GameObject gameObject in this.battleStatus.DeactivatableGameObjects)
            {
                gameObject.SetActive(false);
            }

            this.SetupEntities(battleStarts: true);

            BaseBattleDriver.HighestTurnSpeed = this.battleStatus.HighestTurnSpeed;

            this.hudParent = MonoBehaviour.Instantiate(GenericPrefab.Panel, HudManager.BattleHud.transform).transform;

            // Create the status bars (HUD)
            leaderPlayer.CreateStatusBars(this.hudParent, GenericPrefab.StatusDisplayPlayer);
            leaderEnemy.CreateStatusBars(this.hudParent, GenericPrefab.StatusDisplayEnemy);

            // Deduplicate names to make them easier to tell apart
            leaderPlayer.DeduplicateBattleNamesInAllies();
            leaderEnemy.DeduplicateBattleNamesInAllies();

            // Start the battle on all entities
            foreach (BaseBattleDriver battleDriver in this.battleStatus.AllFightingEntities)
            {
                battleDriver.OnBattleStart();
            }

            this.Initialized = true;
        }
 /// <summary>
 ///     Initializes a new instance of the <see cref="BattleFlow"/> class.
 /// </summary>
 /// <param name="battleManager">The <seealso cref="BattleManager"/> depending on this instance</param>
 /// <param name="battleStatus">The <seealso cref="BattleStatus"/> object</param>
 public BattleFlow(BattleManager battleManager, BattleStatus battleStatus)
 {
     this.battleManager = battleManager;
     this.BattleStatus  = battleStatus;
 }