-
-
Save todorok1/7736109a1dfe106286bc61a09c137e83 to your computer and use it in GitHub Desktop.
シンプルRPGチュートリアル第53回 行動処理の全体を管理するクラス
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 void SetPriorities() | |
| { | |
| // アクションコマンドの素早さの値に20%の乱数を乗じます。 | |
| foreach (var action in _actions) | |
| { | |
| action.actorSpeed = (int)(action.actorSpeed * (1 + Random.Range(-0.2f, 0.2f))); | |
| } | |
| // 遅い順に並べ替え、優先度を1から順に設定します。 | |
| // 優先度が大きい方を先に処理します。 | |
| var query = _actions.OrderBy(a => a.actorSpeed); | |
| int priority = 1; | |
| int runPriority = 100; | |
| foreach (var action in query) | |
| { | |
| if (action.battleCommand == BattleCommand.Run) | |
| { | |
| action.priority = runPriority; | |
| continue; | |
| } | |
| action.priority = priority; | |
| priority++; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment