public static IEventActor SubscribeToEvent <TEvent>(this IActorRefFactory actor, IActorRef target, Action <TEvent> handler, bool killOnFirstResponse = false)
        {
            var eventActor = EventActor.Create(actor, handler, killOnFirstResponse);

            eventActor.Send(target, new EventSubscribe(typeof(TEvent)));
            return(eventActor);
        }
예제 #2
0
        public void Request(string name, Action <Option <object> > valueResponse, CultureInfo?info = null)
        {
            var hook = EventActor.Create(_system, null, true);

            hook.Register(HookEvent.Create <LocCoordinator.ResponseLocValue>(res => valueResponse(res.Result)));
            hook.Send(_extension.LocCoordinator,
                      new LocCoordinator.RequestLocValue(name, info ?? CultureInfo.CurrentUICulture));
        }
        public void Request(string name, Action <object?> valueResponse, Maybe <CultureInfo> info = default)
        {
            var hook = EventActor.Create(_system, Maybe <string> .Nothing, true);

            hook.Do(h =>
            {
                h.Register(HookEvent.Create <LocCoordinator.ResponseLocValue>(res => valueResponse(res.Result)));
                h.Send(_extension.LocCoordinator, new LocCoordinator.RequestLocValue(name, info.Or(CultureInfo.CurrentUICulture)));
            });
        }
예제 #4
0
    /// <summary>生成事件Actor</summary>
    public EventActor createActor(EventManager manager, int index)
    {
        string[] action = m_actions[index];
        string   kind   = action[0];

        string[] parameters = new string[action.Length - 1];
        Array.Copy(action, 1, parameters, 0, parameters.Length);

        m_actorName  = "";
        m_actorIndex = index;
        EventActor actor = null;

        switch (kind.ToLower())
        {
        // [evaluate-event]
        // 事件结束时继续执行指定的事件
        case "evaluate-event":
            actor = EventActorEvaluateEvent.CreateInstance(parameters, manager.gameObject);
            break;

        // [set]
        // 将字符串代入游戏内变量
        case "set":
            actor = EventActorSet.CreateInstance(parameters, manager.gameObject);
            break;

        // [move]
        // 移动对象
        case "move":
            actor = EventActorMove.CreateInstance(parameters, manager.gameObject);
            break;

        // [hide]
        // 不显示指定的对象
        case "hide":
            actor = EventActorVisibility.CreateInstance(parameters, false, manager.gameObject);
            break;

        // [show]
        // 显示指定的对象
        case "show":
            actor = EventActorVisibility.CreateInstance(parameters, true, manager.gameObject);
            break;

        // [text]
        // 显示文本
        case "text":
            actor = EventActorText.CreateInstance(parameters, manager.gameObject);
            break;

        // [dialog]
        // 显示对话内容
        case "dialog":
            actor = EventActorDialog.CreateInstance(parameters, manager.gameObject, this);
            break;

        // [choice]
        // 显示选项并根据选择内容将值代入游戏内变量
        case "choice":
            actor = EventActorChoice.CreateInstance(parameters, manager.gameObject);
            break;

        // [play]
        // 播放声音
        case "play":
            actor = EventActorPlay.CreateInstance(parameters, manager.gameObject, this);
            break;

        // [fadeout]
        // 执行淡出
        case "fadeout":
            actor = EventActorFading.CreateInstance(parameters, false, manager.gameObject);
            break;

        // [fadein]
        // 执行淡入
        case "fadein":
            actor = EventActorFading.CreateInstance(parameters, true, manager.gameObject);
            break;

        // [load]
        // 读取脚本替换事件
        case "load":
            // ToDo: load 指令存在时是否中断后续的评价?(现在不中断)
            actor = EventActorLoad.CreateInstance(parameters, manager.gameObject);
            break;

        // [call-event]
        // 执行指令时强行执行其他事件
        case "call-event":
            actor = EventActorCallEvent.CreateInstance(parameters, manager.gameObject);
            break;

        // [message]
        // 发送消息给对象执行特定的处理
        case "message":
            actor = EventActorMessage.CreateInstance(parameters, manager.gameObject);
            break;

        default:
            Debug.LogError("Invalid command \"" + kind + "\"");
            break;
        }

        return(actor);
    }
예제 #5
0
    /// <summary>イベントアクターを生成する</summary>
    public EventActor createActor(EventManager manager, int index)
    {
        string[] action = m_actions[index];
        string   kind   = action[0];

        string[] parameters = new string[action.Length - 1];
        Array.Copy(action, 1, parameters, 0, parameters.Length);

        m_actorName  = "";
        m_actorIndex = index;
        EventActor actor = null;

        switch (kind.ToLower())
        {
        // [evaluate-event]
        // イベントの終了時に指定したイベントを連続して実行する.
        case "evaluate-event":
            actor = EventActorEvaluateEvent.CreateInstance(parameters, manager.gameObject);
            break;

        // [set]
        // ゲーム内変数に文字列を代入する.
        case "set":
            actor = EventActorSet.CreateInstance(parameters, manager.gameObject);
            break;

        // [move]
        // オブジェクトを移動する.
        case "move":
            actor = EventActorMove.CreateInstance(parameters, manager.gameObject);
            break;

        // [hide]
        // 指定されたオブジェクトを非表示にする.
        case "hide":
            actor = EventActorVisibility.CreateInstance(parameters, false, manager.gameObject);
            break;

        // [show]
        // 指定されたオブジェクトを表示する.
        case "show":
            actor = EventActorVisibility.CreateInstance(parameters, true, manager.gameObject);
            break;

        // [text]
        // 地の文を表示する.
        case "text":
            actor = EventActorText.CreateInstance(parameters, manager.gameObject);
            break;

        // [dialog]
        // 会話文を表示する.
        case "dialog":
            actor = EventActorDialog.CreateInstance(parameters, manager.gameObject, this);
            break;

        // [choice]
        // 選択肢を表示して選んだものに応じてゲーム内変数に値を代入する.
        case "choice":
            actor = EventActorChoice.CreateInstance(parameters, manager.gameObject);
            break;

        // [play]
        // サウンドを再生する.
        case "play":
            actor = EventActorPlay.CreateInstance(parameters, manager.gameObject, this);
            break;

        // [fadeout]
        // フェードアウトを行う.
        case "fadeout":
            actor = EventActorFading.CreateInstance(parameters, false, manager.gameObject);
            break;

        // [fadein]
        // フェードインを行う.
        case "fadein":
            actor = EventActorFading.CreateInstance(parameters, true, manager.gameObject);
            break;

        // [load]
        // スクリプトを読み込んでイベントを入れ替える.
        case "load":
            // ToDo: load コマンドがあったときは継続評価を打ち切る? (現在は打ち切っていない).
            actor = EventActorLoad.CreateInstance(parameters, manager.gameObject);
            break;

        // [call-event]
        // コマンドが実行されるタイミングで強引に別のイベントを実行する.
        case "call-event":
            actor = EventActorCallEvent.CreateInstance(parameters, manager.gameObject);
            break;

        // [message]
        // オブジェクトにメッセージを送信して固有の処理を行わせる.
        case "message":
            actor = EventActorMessage.CreateInstance(parameters, manager.gameObject);
            break;

        default:
            Debug.LogError("Invalid command \"" + kind + "\"");
            break;
        }

        return(actor);
    }
예제 #6
0
 public static EventActor[] Remove(int index, EventActor[] list)
 {
     ArrayList tmp = new ArrayList();
     foreach(EventActor str in list) tmp.Add(str);
     tmp.RemoveAt(index);
     return tmp.ToArray(typeof(EventActor)) as EventActor[];
 }
예제 #7
0
 public static EventActor[] Add(EventActor n, EventActor[] list)
 {
     ArrayList tmp = new ArrayList();
     foreach(EventActor str in list) tmp.Add(str);
     tmp.Add(n);
     return tmp.ToArray(typeof(EventActor)) as EventActor[];
 }