まず、別のクラスの変数にアクセスするにはどうすればよいですか?
あなたは両方とも同じように優れている、あなたはクラスのインスタンスまたは静的クラスのいずれかを使用することができます値のためのリファとして役立つ一般的なクラスを持っていると思います-if。
私も、このクラスのインスタンスを必要としないので、私はそのちょうどデータベース以来 、クラス権利、およびない インスタンス変数の変数を取得したいと思います。
- あなたがC++のようにポインタを取得する場合、そのことを心配する必要はありません。新しいキーワードを使用しない限り、別のオブジェクトに均等化されたオブジェクトはすべてポインタになります。
scene_battleはプレイヤーと敵を呼び出します。プレイヤーと敵は私の データベースからデータを取得します。基本的に、私はプレーヤークラスのインスタンスを繰り返すだけです。 ゲームパーティーに基づいたIDを持ちます。
- 私はこれまでにターンベースのゲームプレイを実装しました。ここで私はそれをやったのですが、それは最善の実装ではないことを覚えておいてください。
BattleManager
Members:
-BattleScenario (this contains all the meta data for your battle scenario, teams, map location, any modifiers that are related to a battle)
-Teams (this is a list of Team classes wich have players)
-TeamSequence(this is a list of team wich will be populated from Teams and will control the flow of the battle)
Functions:
-StartBattle
-EndBattle
-GiveTeamTurn (this function gets the TeamSequence and calls ActTurn on the Class Team and removes the team from the TeamSequence list)
-RepopulateTeamSequence(when the TeamSequence is empty this is called to repopulate the TeamSequence)
Team
Members:
-Players (this is a list of players)
Functions:
-ActTurn (this function calls a player that is still able to act during the turn, and tells him to act, this is where you prompt the user for actions or use your AI)
これは大きな線であり、実装しなければならないことを示していないものです。また、多くのコールバックがトリビュートされることに注意してください。プレイヤーが演技を終了し、そのターンに完了し、そのチームが他のメンバーのためにActTurnをコールする必要があり、チームのすべてのプレイヤーがこのターンのために完了すると、battlemanagerへのコールバックを引き起こすチームにも同じことが起こります。
これが役に立ったら、GL!