Coder Social home page Coder Social logo

unimoondialogue's Introduction

UniMoonDialogue

  • Unityで動作するノベル風シナリオ進行ダイアログのフレームワーク

  • C# と Lua でシナリオを記述できます。

  • 開発中のプロジェクトなので、大幅な変更が入る可能性があります

How to Use

C#による記述

  • 初期状態ではC#によるシナリオ記述にのみ対応しています。
  • サンプルの実行は Assets/UniMoonDialogue/Example/HelloUniMoonDialogue.scene をPlayして、右端の CshparのCubeをクリックしてください。
  • C# によるシナリオ記述方法は、以下、Example > Csharpによる記述例を参考にしてください。

Lua による記述

  • Luaスクリプトの読み込みはデフォルト状態では、利用できません。
  • LuaスクリプトのパースはMoonSharpを利用しています。
  • 以下の手順で Luaの実行を有効にしてください。
  1. moonsharp_release_2.0.0.0.zip をダウンロード

  2. MoonSharp_2.0.0.0.unitypackage をProjectにインポートしてください。/Plugins/MoonSharp/に配置されます。

  3. ProjectSettings > Other Settings > Scripting Define Symbols に 'ENABLE_MoonSharp' を追加してください。

  4. Assets/UniMoonDialogue/Example/HelloUniMoonDialogue.scene をPlayして、**のLua Sample1 のCubeをクリックしてください。

Example

private int index = 0;

Scenario scenario = new Scenario(
    dialogs: new Dictionary<int, Dialogue>
    {
        {1,  new Dialogue("こんにちは。私はC#で書かれています。")},
        {2,  new Dialogue("次のメッセージ")},
        {3,  new Dialogue("質問です!",
            choices: new List<Choice>
            {
                new Choice("はい",4),
                new Choice("いいえ",5),
            }
        )},
        {4,  new Dialogue("「はい」を選びましたね",6)},
        {5,  new Dialogue("「いいえ」を選びましたね",6)},
        {6,  new Dialogue("おしまい")}
    }
);

public void StartScenario()
{
    var data = new EventData(gameObject);
    if (ScenarioEngine.Instance.StartScenario(data))
    {
        ScenarioEngine.Instance.OnMessageStart += OnMessageStart;
        ScenarioEngine.Instance.OnMessageEnd += OnMessageEnd;
        ScenarioEngine.Instance.OnUserInput += OnUserInput;
        index = scenario.dialogs.Keys.Min();
        ShowDialogue(data, index);
    }
}
return function()
scene.msg( 'Hello。私は、<color=red>赤ちゃんX</color>です。\r\n<size=30>バブバブ。</size>' )
coroutine.yield()

scene.msg( '今日はどこから来たの?' )
coroutine.yield()
 
scene.choice( 'どこから?' , 'Tokyo', 'Hakata', 'Nagoya' )
local selected = coroutine.yield()

if selected == 0 then
    scene.msg( 'へえ。教えてくれないの、、、' )
    coroutine.yield()

elseif selected == 1 then
    scene.msg( 'へぇ。東京なんだ' )
    coroutine.yield()

elseif selected == 2 then
    scene.msg( '博多から来てくれてありがとう' )
    coroutine.yield()
elseif selected == 3 then
    scene.msg( '愛知県だよね。' )
    coroutine.yield()
end
scene.msg( 'さっきも言ったけど、私は、赤ちゃんです。バブバブ。' )
coroutine.yield()
scene.msg( 'もうおわり' )
end

License

  • MIT License
  • Copyright (c) 2020 Tomoki Hayashi

unimoondialogue's People

Contributors

the6th avatar

Stargazers

 avatar

Watchers

 avatar  avatar

unimoondialogue's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.