Inheritance: global::ProtoBuf.IExtensible
示例#1
0
        private void HandleStoryMessage(NodeMessage msg, int handle, uint seq)
        {
            GameFrameworkMessage.NodeMessageWithGuid storyMsg = msg.m_NodeHeader as GameFrameworkMessage.NodeMessageWithGuid;
            if (null != storyMsg)
            {
                GameFrameworkMessage.Msg_CLC_StoryMessage protoData = msg.m_ProtoData as GameFrameworkMessage.Msg_CLC_StoryMessage;
                if (null != protoData)
                {
                    ulong      guid       = storyMsg.m_Guid;
                    UserThread userThread = m_UserProcessScheduler.GetUserThread(guid);
                    if (null != userThread)
                    {
                        //客户端发来的消息都加上前缀client,防止直接调用服务器端逻辑(服务器消息不能用client前缀!)
                        string    msgId = string.Format("client:{0}", protoData.m_MsgId);
                        ArrayList args  = new ArrayList();
                        args.Add(guid);
                        for (int i = 0; i < protoData.m_Args.Count; i++)
                        {
                            switch (protoData.m_Args[i].val_type)
                            {
                            case LobbyArgType.NULL:    //null
                                args.Add(null);
                                break;

                            case LobbyArgType.INT:    //int
                                args.Add(int.Parse(protoData.m_Args[i].str_val));
                                break;

                            case LobbyArgType.FLOAT:    //float
                                args.Add(float.Parse(protoData.m_Args[i].str_val));
                                break;

                            default:    //string
                                args.Add(protoData.m_Args[i].str_val);
                                break;
                            }
                        }
                        object[] objArgs = args.ToArray();
                        userThread.QueueAction(userThread.SendStoryMessage, msgId, objArgs);
                    }
                }
            }
        }
        internal void HighlightPrompt(UserInfo user, int dictId, params object[] args)
        {
            //0--null 1--int 2--float 3--string
            GameFrameworkMessage.Msg_CLC_StoryMessage protoData = new GameFrameworkMessage.Msg_CLC_StoryMessage();
            protoData.m_MsgId = string.Format("highlightprompt{0}", args.Length);
            GameFrameworkMessage.Msg_CLC_StoryMessage.MessageArg item0 = new GameFrameworkMessage.Msg_CLC_StoryMessage.MessageArg();
            item0.val_type = LobbyArgType.INT;
            item0.str_val  = dictId.ToString();
            protoData.m_Args.Add(item0);
            for (int i = 0; i < args.Length; ++i)
            {
                GameFrameworkMessage.Msg_CLC_StoryMessage.MessageArg item = new GameFrameworkMessage.Msg_CLC_StoryMessage.MessageArg();
                item.val_type = LobbyArgType.STRING;
                item.str_val  = args[i].ToString();
                protoData.m_Args.Add(item);
            }
            NodeMessage msg = new NodeMessage(LobbyMessageDefine.Msg_CLC_StoryMessage, user.Guid);

            msg.m_ProtoData = protoData;
            NodeMessageDispatcher.SendNodeMessage(user.NodeName, msg);
        }
        internal void SendStoryMessage(UserInfo user, string msgId, params object[] args)
        {
            //0--null 1--int 2--float 3--string
            GameFrameworkMessage.Msg_CLC_StoryMessage protoData = new GameFrameworkMessage.Msg_CLC_StoryMessage();
            protoData.m_MsgId = msgId;
            for (int i = 0; i < args.Length; ++i)
            {
                object arg = args[i];
                GameFrameworkMessage.Msg_CLC_StoryMessage.MessageArg item = new GameFrameworkMessage.Msg_CLC_StoryMessage.MessageArg();
                if (null != arg)
                {
                    if (arg is int)
                    {
                        item.val_type = LobbyArgType.INT;
                    }
                    else if (arg is float)
                    {
                        item.val_type = LobbyArgType.FLOAT;
                    }
                    else
                    {
                        item.val_type = LobbyArgType.STRING;
                    }
                    item.str_val = arg.ToString();
                }
                else
                {
                    item.val_type = LobbyArgType.NULL;
                    item.str_val  = "";
                }
                protoData.m_Args.Add(item);
            }
            NodeMessage msg = new NodeMessage(LobbyMessageDefine.Msg_CLC_StoryMessage, user.Guid);

            msg.m_ProtoData = protoData;
            NodeMessageDispatcher.SendNodeMessage(user.NodeName, msg);
        }
示例#4
0
        private void HandleStoryMessage(NodeMessage lobbyMsg)
        {
            GameFrameworkMessage.Msg_CLC_StoryMessage protoMsg = lobbyMsg.m_ProtoData as GameFrameworkMessage.Msg_CLC_StoryMessage;
            if (null != protoMsg)
            {
                try {
                    string    msgId = protoMsg.m_MsgId;
                    ArrayList args  = new ArrayList();
                    for (int i = 0; i < protoMsg.m_Args.Count; i++)
                    {
                        switch (protoMsg.m_Args[i].val_type)
                        {
                        case LobbyArgType.NULL:    //null
                            args.Add(null);
                            break;

                        case LobbyArgType.INT:    //int
                            args.Add(int.Parse(protoMsg.m_Args[i].str_val));
                            break;

                        case LobbyArgType.FLOAT:    //float
                            args.Add(float.Parse(protoMsg.m_Args[i].str_val));
                            break;

                        default:    //string
                            args.Add(protoMsg.m_Args[i].str_val);
                            break;
                        }
                    }
                    object[] objArgs = args.ToArray();
                    GfxStorySystem.Instance.SendMessage(msgId, objArgs);
                } catch (Exception ex) {
                    LogSystem.Error("HandleStoryMessage throw exception:{0}\n{1}", ex.Message, ex.StackTrace);
                }
            }
        }
示例#5
0
 internal void SendStoryMessage(UserInfo user, string msgId, params object[] args)
 {
     //0--null 1--int 2--float 3--string
     GameFrameworkMessage.Msg_CLC_StoryMessage protoData = new GameFrameworkMessage.Msg_CLC_StoryMessage();
     protoData.m_MsgId = msgId;
     for (int i = 0; i < args.Length; ++i) {
         object arg = args[i];
         GameFrameworkMessage.Msg_CLC_StoryMessage.MessageArg item = new GameFrameworkMessage.Msg_CLC_StoryMessage.MessageArg();
         if (null != arg) {
             if (arg is int) {
                 item.val_type = LobbyArgType.INT;
             } else if (arg is float) {
                 item.val_type = LobbyArgType.FLOAT;
             } else {
                 item.val_type = LobbyArgType.STRING;
             }
             item.str_val = arg.ToString();
         } else {
             item.val_type = LobbyArgType.NULL;
             item.str_val = "";
         }
         protoData.m_Args.Add(item);
     }
     NodeMessage msg = new NodeMessage(LobbyMessageDefine.Msg_CLC_StoryMessage, user.Guid);
     msg.m_ProtoData = protoData;
     TransmitToWorld(user, msg);
 }
示例#6
0
 internal void HighlightPrompt(UserInfo user, int dictId, params object[] args)
 {
     //0--null 1--int 2--float 3--string
     GameFrameworkMessage.Msg_CLC_StoryMessage protoData = new GameFrameworkMessage.Msg_CLC_StoryMessage();
     protoData.m_MsgId = string.Format("highlightprompt{0}", args.Length);
     GameFrameworkMessage.Msg_CLC_StoryMessage.MessageArg item0 = new GameFrameworkMessage.Msg_CLC_StoryMessage.MessageArg();
     item0.val_type = LobbyArgType.INT;
     item0.str_val = dictId.ToString();
     protoData.m_Args.Add(item0);
     for (int i = 0; i < args.Length; ++i) {
         GameFrameworkMessage.Msg_CLC_StoryMessage.MessageArg item = new GameFrameworkMessage.Msg_CLC_StoryMessage.MessageArg();
         item.val_type = LobbyArgType.STRING;
         item.str_val = args[i].ToString();
         protoData.m_Args.Add(item);
     }
     NodeMessage msg = new NodeMessage(LobbyMessageDefine.Msg_CLC_StoryMessage, user.Guid);
     msg.m_ProtoData = protoData;
     TransmitToWorld(user, msg);
 }
        protected override bool ExecCommand(StoryInstance instance, long delta)
        {
            string _msg = m_Msg.Value;

            Msg_CLC_StoryMessage protoData = new Msg_CLC_StoryMessage();
            protoData.m_MsgId = _msg;

            for (int i = 0; i < m_Args.Count; ++i) {
                IStoryValue<object> val = m_Args[i];
                object v = val.Value;
                if (null == v) {
                    Msg_CLC_StoryMessage.MessageArg arg = new Msg_CLC_StoryMessage.MessageArg();
                    arg.val_type = LobbyArgType.NULL;
                    arg.str_val = "";
                    protoData.m_Args.Add(arg);
                } else if (v is int) {
                    Msg_CLC_StoryMessage.MessageArg arg = new Msg_CLC_StoryMessage.MessageArg();
                    arg.val_type = LobbyArgType.INT;
                    arg.str_val = ((int)v).ToString();
                    protoData.m_Args.Add(arg);
                } else if (v is float) {
                    Msg_CLC_StoryMessage.MessageArg arg = new Msg_CLC_StoryMessage.MessageArg();
                    arg.val_type = LobbyArgType.FLOAT;
                    arg.str_val = ((float)v).ToString();
                    protoData.m_Args.Add(arg);
                } else {
                    Msg_CLC_StoryMessage.MessageArg arg = new Msg_CLC_StoryMessage.MessageArg();
                    arg.val_type = LobbyArgType.STRING;
                    arg.str_val = v.ToString();
                    protoData.m_Args.Add(arg);
                }
            }

            try {
                Network.NodeMessage msg = new Network.NodeMessage(LobbyMessageDefine.Msg_CLC_StoryMessage, Network.UserNetworkSystem.Instance.Guid);
                msg.m_ProtoData = protoData;
                Network.NodeMessageDispatcher.SendMessage(msg);
            } catch (Exception ex) {
                LogSystem.Error("LobbyNetworkSystem.SendMessage throw Exception:{0}\n{1}", ex.Message, ex.StackTrace);
            }
            return false;
        }
        protected override bool ExecCommand(StoryInstance instance, long delta)
        {
            UserThread userThread = instance.Context as UserThread;
            if (null != userThread) {
                string _msg = m_Msg.Value;

                Msg_CLC_StoryMessage msg = new Msg_CLC_StoryMessage();
                msg.m_MsgId = _msg;

                for (int i = 0; i < m_Args.Count; ++i) {
                    IStoryValue<object> val = m_Args[i];
                    object v = val.Value;
                    if (null == v) {
                        Msg_CLC_StoryMessage.MessageArg arg = new Msg_CLC_StoryMessage.MessageArg();
                        arg.val_type = LobbyArgType.NULL;
                        arg.str_val = "";
                        msg.m_Args.Add(arg);
                    } else if (v is int) {
                        Msg_CLC_StoryMessage.MessageArg arg = new Msg_CLC_StoryMessage.MessageArg();
                        arg.val_type = LobbyArgType.INT;
                        arg.str_val = ((int)v).ToString();
                        msg.m_Args.Add(arg);
                    } else if (v is float) {
                        Msg_CLC_StoryMessage.MessageArg arg = new Msg_CLC_StoryMessage.MessageArg();
                        arg.val_type = LobbyArgType.FLOAT;
                        arg.str_val = ((float)v).ToString();
                        msg.m_Args.Add(arg);
                    } else {
                        Msg_CLC_StoryMessage.MessageArg arg = new Msg_CLC_StoryMessage.MessageArg();
                        arg.val_type = LobbyArgType.STRING;
                        arg.str_val = v.ToString();
                        msg.m_Args.Add(arg);
                    }
                }
                if (m_HaveUserGuid) {
                    ulong userGuid = m_UserGuid.Value;
                    userThread.NotifyUser(userGuid, LobbyMessageDefine.Msg_CLC_StoryMessage, msg);
                } else {
                    userThread.NotifyAllUser(LobbyMessageDefine.Msg_CLC_StoryMessage, msg);
                }
            }
            return false;
        }