-
-
Save todorok1/330c7ca306fcb929e50d7f310be5cb5f to your computer and use it in GitHub Desktop.
シンプルRPGチュートリアル第116回 戦闘機能を呼び出すイベントを処理するクラス
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /// <summary> | |
| /// イベントの処理を実行します。 | |
| /// </summary> | |
| public override void Execute() | |
| { | |
| StartCoroutine(StartBattleProcess()); | |
| } | |
| /// <summary> | |
| /// 戦闘の開始処理を行います。 | |
| /// </summary> | |
| IEnumerator StartBattleProcess() | |
| { | |
| // 現在のBGMを停止します。 | |
| float fadeTime = 0.1f; | |
| AudioManager.Instance.StopAllBgm(fadeTime); | |
| var battleManager = FindAnyObjectByType<BattleManager>(); | |
| if (battleManager == null) | |
| { | |
| SimpleLogger.Instance.LogError("シーン内のBattleManagerが見つかりませんでした。"); | |
| CallNextProcess(); | |
| yield break; | |
| } | |
| // 戦闘開始の効果音を再生します。 | |
| AudioManager.Instance.PlaySe(SeNames.BattleStart); | |
| yield return new WaitForSeconds(fadeTime); | |
| battleManager.SetUpEnemyStatus(_enemyId); | |
| battleManager.SetCanRunaway(_canRunaway); | |
| battleManager.RegisterCallback(this); | |
| battleManager.StartBattle(); | |
| // 戦闘BGMを再生します。 | |
| AudioManager.Instance.PlayBgm(_battleBgmName, false, true); | |
| } | |
| /// <summary> | |
| /// 戦闘終了時のコールバックです。 | |
| /// </summary> | |
| public void OnFinishedBattle() | |
| { | |
| // 現在のマップIDを取得します。 | |
| var mapManager = FindAnyObjectByType<MapManager>(); | |
| if (mapManager != null) | |
| { | |
| // BGMを続きから再生します。 | |
| int mapId = mapManager.GetCurrentMapController().MapId; | |
| string bgmName = MapDataManager.GetMapBgmName(mapId); | |
| AudioManager.Instance.PlayBgm(bgmName, true, true); | |
| } | |
| CallNextProcess(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment