1

ここ数週間、プレイヤーのアクションだけを中心に展開する一種のテキスト ベースのアドベンチャー ゲームを作成してきました。一般的な考え方は、ワールドの状態を維持する Simulation クラスが存在し、SimulationController (つまりプレイヤー) がアクションを継続する責任を負うというものです。ほとんどの場合、シミュレーションに何をすべきか (すなわち、1 タイムステップ前にシミュレートする) を指示しているのはコントローラーと言われますが、シミュレーションがコントローラーに何かを尋ねる必要がある場合もあります。したがって、次のようなインターフェイスを作成しました。

/**
 * An interface to a GUI, command line, etc;
 * a way to interact with the Simulation class
 * @author dduckworth
 *
 */
public interface SimulationController {

    /**
     * Returns the index of a choice from a list
     * 
     * @param message: prompt for the player
     * @param choices: options, in order
     * @return: the index of the choice chosen
     */
    public int chooseItem(String message, List<String> choices);

    /**
     * Returns some text the player must type in manually.
     * 
     * @param message
     * @return
     */
    public String enterChoice(String message);

    /**
     * Give the user a message.  This could be notification
     * of a failed action, some response to some random event,
     * anything.
     * 
     * @param message
     */
    public void giveMessage(String message);

    /**
     * The simulation this controller is controlling
     * @return
     */
    public Simulation getSimulation();

    /**
     * The primary loop for this controller.  General flow
     * should be something like this:
     * 1)   Prompt the player to choose a tool and target
     *      from getAvailableTools() and getAvailableTargets()
     * 2)   Prompt the player to choose an action from
     *      getAvailableActions()
     * 3)   call Simuluation.simulate() with the tool, target,
     *      action chosen, the time taken to make that decision,
     *      and this
     * 4)   while Simulation.isFinished() == false, continue onward
     */
    public void run();
}

これらすべてのメイン制御ループは に実装する必要がありますSimulationController.run()が、シミュレーションは他のメソッドを呼び出してプレーヤーからの情報を要求することもできます。

私は現在、BlazeDS で Adob​​e Flex を使用して、インターフェイスを実装するものを実装または保持することでシミュレーションと通信する非常に単純なユーザー インターフェイスを作成していSimulationControllerます。「ロング ポーリング」という概念がありますが、このようなリモート オブジェクトでそれを使用する方法をよく知っているとは言えません。

Simulation私の質問は、すべてのリクエストが Flash クライアントに直接送信され、すべての制御ループ ロジックが Java 側にとどまることができるように、プレーヤーに情報をプッシュするための適切な設計パターンは何ですか?

ありがとう!

4

1 に答える 1

0

主な概念を理解するには、Push テクノロジに関する wiki を参照してください。その後、BlazeDS 開発者ガイドのメッセージ部分を読んでください。

BlazeDS の使用経験があることを前提としています (少なくとも、アプリケーション サーバーにインストールしたことはあります)。サンプル フォルダーを調べると、2 つの興味深い例 (チャット アプリケーションと、datapush と呼ばれる別のアプリケーション) が見つかります。それらは理解するのが非常に簡単です。

于 2010-07-23T14:59:29.083 に答える