Esempio n. 1
0
 public void AddChatInfo(MessageCenterChatInfo messageCenterInfo)
 {
     if (messageCenterInfo != null)
     {
         ChatInfo chatInfo = new ChatInfo();
         chatInfo.name = messageCenterInfo.Name;
         chatInfo.lasttime = messageCenterInfo.LastTime;
         chatInfo.id = messageCenterInfo.Id;
         chatInfo.type = (int)messageCenterInfo.Type;
         ChatInfoList list = this.GetLocalChatInfoList();
         if (list != null && list.chatinfo != null)
         {
             ChatInfo info = this.FindChatInfoItem(list, chatInfo.id, chatInfo.type);
             if (info == null)
             {
                 list.chatinfo.Add(chatInfo);
             }
             else
             {
                 info.lasttime = chatInfo.lasttime;
                 info.name = chatInfo.name;
             }
         }
         else
         {
             list = new ChatInfoList();
             list.chatinfo.Add(chatInfo);
         }
         this.SaveLocalChatInfoList(list);
     }
 }
Esempio n. 2
0
 public ShowOneOffChatAction(NPC _npcToChat, string _textToShow, float _timeToShow)
 {
     chatInfo = new ChatInfo(_npcToChat, _textToShow, _timeToShow);
 }
Esempio n. 3
0
 public void SetAllChatInfo(System.Collections.Generic.List<MessageCenterChatInfo> list)
 {
     if (list != null)
     {
         ChatInfoList chatInfoList = new ChatInfoList();
         foreach (MessageCenterChatInfo info in list)
         {
             if (info != null)
             {
                 ChatInfo chatInfo = new ChatInfo();
                 chatInfo.id = info.Id;
                 chatInfo.name = info.Name;
                 chatInfo.lasttime = info.LastTime;
                 chatInfo.type = (int)info.Type;
                 chatInfoList.chatinfo.Add(chatInfo);
             }
         }
         this.SaveLocalChatInfoList(chatInfoList);
     }
 }
Esempio n. 4
0
 public NPCOneOffChat(ChatInfo chat)
     : base()
 {
     _chatTexts.Add(chat);
 }
Esempio n. 5
0
 public void AddChatInfo(ChatInfo chatToAdd)
 {
     _chatTexts.Add(chatToAdd);
 }
Esempio n. 6
0
    protected void SetConvoTasks(NPCConversation convo)
    {
        _tasksToDo.Clear();
        CheckWithinDistanceOfEachOther();
        CheckWaitForPlayer();

        foreach (Dialogue textToSay in convo.dialogueList) {
            if (textToSay._npc == 1) {
                chatInfo = new ChatInfo(_toManage, textToSay._TextToSay);
                chatInfoList = new List<ChatInfo>();
                chatInfoList.Add(chatInfo);
                chatToPerform = new NPCChat(chatInfoList);
                Add(new ConvoTask(new Task(new NPCConvoState((Character)_toManage, (Character)_npcTwo, chatToPerform)),
                    new Task(new IdleState(_npcTwo))));
            } else {
                chatInfo = new ChatInfo(_npcTwo, textToSay._TextToSay);
                chatInfoList = new List<ChatInfo>();
                chatInfoList.Add(chatInfo);
                chatToPerform = new NPCChat(chatInfoList);
                Add(new ConvoTask(new Task(new IdleState(_toManage)),
                    new Task(new NPCConvoState((Character)_npcTwo, (Character)_toManage, chatToPerform))));
            }
        }
    }
Esempio n. 7
0
        public int GetChatInfo(
            string strRights,
            string strName,
            string strDate,
            long lStart,
            int nMaxLines,
            bool bDisplayAllIP,
            out ChatInfo info,
            out string strError)
        {
            strError = "";
            info = null;

            ChatRoom room = this.ChatRooms.GetChatRoom(strRights,
                strName);

            if (room == null)
            {
                strError = "栏目 '" + strName + "' 不存在";
                return -1;
            }

            // return:
            //      -1  error
            //      0   file not found
            //      1   succeed
            return room.GetInfo(
                strDate,
                lStart,
                nMaxLines,
                bDisplayAllIP,
                out info,
                out strError);

        }
Esempio n. 8
0
 private static void ListMods(ChatInfo info, Match match)
 {
     showTable(info.playerId);
 }
Esempio n. 9
0
        private static void ActivateMod(ChatInfo info, Match match)
        {
            var mod = modManager.activateMod(match.Groups[1].Value);

            showTable(info.playerId, $"activated mod: {mod.title}");
        }
Esempio n. 10
0
 public RestoreCallbackQueryHandler(RaidBattlesContext context, RaidService raidService, IUrlHelper urlHelper, ChatInfo chatInfo, ITelegramBotClient bot)
 {
     myContext     = context;
     myRaidService = raidService;
     myUrlHelper   = urlHelper;
     myChatInfo    = chatInfo;
     myBot         = bot;
 }
Esempio n. 11
0
        public void Game_Event(CmdId cmdId, ushort seqNr, object data)
        {
            try
            {
                switch (cmdId)
                {
                case CmdId.Event_Player_Connected:
                    Id pc = (Id)data;
                    try { string[]    bagLines      = System.IO.File.ReadAllLines("Content\\Mods\\Xango\\players\\EID" + pc.id + "\\VirtualBackpack.txt");
                          int         itemStackSize = bagLines.Count();
                          ItemStack[] itStack       = new ItemStack[itemStackSize];
                          for (int i = 0; i < itemStackSize; ++i)
                          {
                              string[] bagLinesSplit = bagLines[i].Split(',');
                              itStack[i]         = new ItemStack(Convert.ToInt32(bagLinesSplit[1]), Convert.ToInt32(bagLinesSplit[2])); //1=ItemNumber, 2=StackSize
                              itStack[i].slotIdx = Convert.ToByte(bagLinesSplit[0]);                                                    //0=SlotNumber
                              itStack[i].ammo    = Convert.ToInt32(bagLinesSplit[3]);                                                   //3=Ammo
                              itStack[i].decay   = Convert.ToInt32(bagLinesSplit[4]);                                                   //4=Decay
                          }
                          vBackpackDictionary.Add(pc.id, itStack); }
                    catch { };
                    LogFile("chat.txt", "Player " + pc.id + " Connected");
                    try { System.IO.Directory.CreateDirectory("Content\\Mods\\Xango\\players\\EID" + pc.id); }
                    catch { };
                    break;

                case CmdId.Event_Player_Disconnected:
                    Id pd = (Id)data;
                    LogFile("chat.txt", "Player " + pd.id + " DisConnected");
                    vBackpackDictionary.Remove(pd.id);
                    break;

                case CmdId.Event_Player_Info:
                    PlayerInfo PlayerInfoReceived = (PlayerInfo)data;
                    if (BackpackChatDictionary.ContainsKey(PlayerInfoReceived.entityId))
                    {
                        BackpackChatDictionary.Remove(PlayerInfoReceived.entityId);
                        if (vBackpackDictionary.ContainsKey(PlayerInfoReceived.entityId))
                        {
                            BackpackChatDictionary.Remove(PlayerInfoReceived.entityId);
                            LogFile("Chat.txt", "show backpack");
                            GameAPI.Game_Request(CmdId.Request_Player_ItemExchange, (ushort)CmdId.Request_Player_ItemExchange, new ItemExchangeInfo(PlayerInfoReceived.entityId, "Virtual Backpack", "Extra Inventory Space, Yay!", "Save", vBackpackDictionary[PlayerInfoReceived.entityId]));
                            step = "Request ItemExchange";
                        }
                        else
                        {
                            if (System.IO.File.Exists("Content\\Mods\\Xango\\players\\EID" + Convert.ToString(PlayerInfoReceived.entityId) + "\\VirtualBackpack.txt"))
                            {
                                LogFile("Chat.txt", "Build Blank Backpack");
                                System.IO.File.Create("Content\\Mods\\Xango\\players\\EID" + Convert.ToString(PlayerInfoReceived.entityId) + "\\VirtualBackpack.txt");
                                buildItemStack(PlayerInfoReceived.entityId, "blank");
                            }
                            else
                            {
                                LogFile("Chat.txt", "Show Blank Backpack");
                                GameAPI.Game_Request(CmdId.Request_Player_ItemExchange, (ushort)CmdId.Request_Player_ItemExchange, new ItemExchangeInfo(PlayerInfoReceived.entityId, "Virtual Backpack", "Extra Inventory Space, Yay!", "Save", EmptyExchange));
                                step = "Request ItemExchange";
                            }
                        }
                    }
                    break;

                case CmdId.Event_Player_ItemExchange:
                    ItemExchangeInfo exchangeInfo = (ItemExchangeInfo)data;
                    vBackpackDictionary[exchangeInfo.id] = exchangeInfo.items;
                    System.IO.File.WriteAllText("Content\\Mods\\Xango\\players\\EID" + exchangeInfo.id + "\\VirtualBackpack.txt", string.Empty);
                    for (int i = 0; i <= exchangeInfo.items.Count(); i++)
                    {
                        LogFile("players\\EID" + exchangeInfo.id + "\\VirtualBackpack.txt", Convert.ToString(exchangeInfo.items[i].slotIdx) + "," + Convert.ToString(exchangeInfo.items[i].id) + "," + Convert.ToString(exchangeInfo.items[i].count) + "," + Convert.ToString(exchangeInfo.items[i].ammo) + "," + Convert.ToString(exchangeInfo.items[i].decay));
                    }
                    step = "itemExchange complete";
                    break;

                case CmdId.Event_Player_DisconnectedWaiting:
                    Id pdw = new Id();
                    GameAPI.Console_Write("Player " + pdw.id + " Failed Login Attempt");
                    break;

                case CmdId.Event_ChatMessage:
                    ChatInfo ci = (ChatInfo)data;
                    LogFile("Chat.txt", ci.playerId + " SAYS: " + ci.msg);
                    if (ci.msg.StartsWith("s! "))
                    {
                        ci.msg = ci.msg.Remove(0, 3);
                    }
                    ci.msg = ci.msg.ToLower();
                    if (ci.msg.StartsWith("/backpack"))
                    {
                        BackpackChatDictionary[ci.playerId] = ci.msg;
                        GameAPI.Game_Request(CmdId.Request_Player_Info, (ushort)CmdId.Request_Player_Info, new Eleon.Modding.Id(ci.playerId));
                        step = "Request Playerinfo";
                    }
                    break;

                case CmdId.Event_Error:
                    ErrorInfo err  = (ErrorInfo)data;
                    ErrorType err2 = (ErrorType)data;
                    LogFile("ERROR.txt", Convert.ToString(err2) + ": " + Convert.ToString(err));
                    break;

                default:
                    break;
                }
            }
            catch (Exception ex)
            {
                GameAPI.Console_Write(ex.Message);
            }
        }
Esempio n. 12
0
 public void AddChat(ChatInfo chatToAdd)
 {
     npcChat.AddChatInfo(chatToAdd);
 }
        private async Task OpenBackpack(ChatInfo info, Dictionary <string, string> args, BackpackConfiguration config, string name, Func <PlayerInfo, string> getConfigFileId)
        {
            Log($"**OpenBackpack {info.type}:{info.msg} {args.Aggregate("", (s, i) => s + i.Key + "/" + i.Value + " ")}");

            if (info.type == (byte)ChatType.Faction)
            {
                return;
            }

            var P = await Request_Player_Info(info.playerId.ToId());

            if (BackPackLastOpend.TryGetValue($"{P.steamId}{name}", out var time) && (DateTime.Now - time).TotalSeconds <= config.OpenCooldownSecTimer)
            {
                MessagePlayer(info.playerId, $"backpack open cooldown please wait {(new TimeSpan(0, 0, config.OpenCooldownSecTimer) - (DateTime.Now - time)).ToString(@"hh\:mm\:ss")}");
                return;
            }

            ConfigurationManager <BackpackData> currentBackpack = new ConfigurationManager <BackpackData>()
            {
                ConfigFilename = Path.Combine(EmpyrionConfiguration.SaveGameModPath, String.Format(config.FilenamePattern, getConfigFileId(P)))
            };

            currentBackpack.Load();

            if (!string.IsNullOrEmpty(currentBackpack.Current.OpendBySteamId) &&
                currentBackpack.Current.OpendBySteamId != P.steamId)
            {
                var onlinePlayers = await Request_Player_List();

                MessagePlayer(info.playerId, $"backpack currently opend by {currentBackpack.Current.OpendByName}");
                return;
            }

            if (config.ForbiddenPlayfields.Length > 0 && config.ForbiddenPlayfields.Contains(P.playfield))
            {
                MessagePlayer(info.playerId, $"backpacks are not allowed on this playfield");
                return;
            }

            if (config.AllowedPlayfields.Length > 0 && !config.AllowedPlayfields.Contains(P.playfield))
            {
                MessagePlayer(info.playerId, $"backpacks are not allowed on this playfield");
                return;
            }

            int usedBackpackNo = currentBackpack.Current.LastUsed;

            if (args.TryGetValue("number", out string numberArgs))
            {
                int.TryParse(numberArgs, out usedBackpackNo);
            }
            usedBackpackNo = Math.Max(1, usedBackpackNo);

            if (usedBackpackNo > config.MaxBackpacks)
            {
                MessagePlayer(info.playerId, $"max allowed backpacks #{config.MaxBackpacks}");
                return;
            }

            if (currentBackpack.Current.Backpacks.Length < usedBackpackNo)
            {
                if (config.Price > 0)
                {
                    MessagePlayer(info.playerId, $"you have only {currentBackpack.Current.Backpacks.Length} backpack(s) please buy one");
                    return;
                }

                var list = currentBackpack.Current.Backpacks?.ToList() ?? new List <BackpackItems>();
                for (int i = list.Count; i < usedBackpackNo; i++)
                {
                    list.Add(new BackpackItems()
                    {
                        Items = new ItemStack[] { }
                    });
                }
                currentBackpack.Current.Backpacks = list.ToArray();
            }

            currentBackpack.Current.LastUsed              = usedBackpackNo;
            currentBackpack.Current.OpendByName           = P.playerName;
            currentBackpack.Current.OpendBySteamId        = P.steamId;
            currentBackpack.Current.LastAccessPlayerName  = P.playerName;
            currentBackpack.Current.LastAccessFactionName = CurrentFactions != null?CurrentFactions.factions.FirstOrDefault(F => F.factionId == P.factionId).abbrev : P.factionId.ToString();

            currentBackpack.Save();

            Action <ItemExchangeInfo> eventCallback = null;

            eventCallback = (B) =>
            {
                if (P.entityId != B.id)
                {
                    return;
                }

                if (ContainsForbiddenItemStacks(config, B.items, out var errorMsg))
                {
                    OpenBackpackItemExcange(info.playerId, config, name, "Not allowed:" + errorMsg, currentBackpack, B.items).GetAwaiter().GetResult();
                }
                else
                {
                    Event_Player_ItemExchange -= eventCallback;
                    EmpyrionBackpackExtender_Event_Player_ItemExchange(B, currentBackpack, config, usedBackpackNo);
                }
            };

            Event_Player_ItemExchange += eventCallback;
            BackPackLastOpend.AddOrUpdate($"{P.steamId}{name}", DateTime.Now, (S, D) => DateTime.Now);

            await OpenBackpackItemExcange(info.playerId, config, name, "", currentBackpack, currentBackpack.Current.Backpacks[usedBackpackNo - 1].Items);
        }
Esempio n. 14
0
        public ReservierungErstellenDialog(IReservierungService reservierungService, IChatService chatService, Angebot angebot, ChatInfo chatInfo)
        {
            this.InitializeComponent();

            _reservierungService = reservierungService;
            _chatService         = chatService;
            _angebot             = angebot;
            _chatInfo            = chatInfo;

            _vm = new ReservierungViewModel();
            _vm.Reservierung.AngebotID   = angebot.Id;
            _vm.Reservierung.AusleiherID = _chatInfo.GegenseiteAnbieterID;
            _vm.Reservierung.AnbieterID  = angebot.AnbieterId;
        }
Esempio n. 15
0
        public SendMessageResult Send(ClientBaseMessage message)
        {
            ChatInfo chatInfo;
            var      mine = message.mine;

            chatInfo = new ChatInfo
            {
                addtime  = message.addtime,
                avatar   = mine.avatar,
                content  = mine.content,
                nickname = mine.username,
                qq       = mine.id,
                timespan = message.addtime.ToTimestamp(),
                roomid   = message.roomid,
                isfile   = mine.content.IndexOf("file[") > -1,
                isimg    = mine.content.IndexOf("img[") > -1
            };
            #region 这段代码暂时保留,但可以不用这么写,因为用不到to的内容

            /*
             * switch (message.type) {
             *  case ChatToClientType.ClientToClient:
             *      message = (ClientToClientMessage)message;
             *
             *      chatInfo = new ChatInfo
             *      {
             *          addtime = message.addtime,
             *          avatar = mine.avatar,
             *          content = mine.content,
             *          nickname = mine.username,
             *          qq = mine.id,
             *          timespan = 0,
             *          roomid = message.roomid,
             *          isfile = mine.content.IndexOf("file[") > -1,
             *          isimg = mine.content.IndexOf("img[") > -1
             *      };
             *      break;
             *  case ChatToClientType.ClientToGroup:
             *      message = (ClientToGroupMessage)message;
             *      chatInfo = new ChatInfo
             *      {
             *          addtime = message.addtime,
             *          avatar = mine.avatar,
             *          content = mine.content,
             *          nickname = mine.username,
             *          qq = mine.id,
             *          timespan = 0,
             *          roomid = message.roomid,
             *          isfile = mine.content.IndexOf("file[") > -1,
             *          isimg = mine.content.IndexOf("img[") > -1
             *      };
             *      break;
             *  default:
             *      chatInfo= new ChatInfo();
             *      break;
             * }
             */
            #endregion

            bool result = es.Index(chatInfo);
            return(new SendMessageResult(result));
        }
Esempio n. 16
0
    public void Inits(ChatInfo info)
    {
        SocialModel.Instance.curChatInfo = info;
        if (exitBtn.onClick == null)
        {
            exitBtn.onClick = delegate { Exit(); }
        }
        ;

        if (yuyinBtn.onClick == null)
        {
            yuyinBtn.onClick = delegate { OpenYuyin(); }
        }
        ;
        if (daziSendBtn.onClick == null)
        {
            daziSendBtn.onClick = delegate { SendDazi(); }
        }
        ;

        if (daziBtn.onClick == null)
        {
            daziBtn.onClick = delegate { OpenDazi(); }
        }
        ;

        if (put_yuyinBtn.onDown == null)
        {
            put_yuyinBtn.onDown = delegate { DownYuyin(); }
        }
        ;
        if (put_yuyinBtn.onUp == null)
        {
            put_yuyinBtn.onUp = delegate { OnUp(); }
        }
        ;

        this.curInfo = info;
        nameLb.text  = info.playerBaseInfo.userNickname;

        OpenDazi();
        LoadChatLog();
    }

    /// <summary>
    /// 在messagePanel里增加一条聊天记录
    /// </summary>
    void AddLogMessagePanel()
    {
        messagePanel.AddMessage(curInfo);
    }

    /// <summary>
    /// 在messagePanel里去掉一条聊天记录
    /// </summary>
    void RemoveLogMessagePanel()
    {
        messagePanel.RemoveMessage(curInfo);
    }

    #region 主聊天界面

    void OnValueChange(int index)
    {
        if (index == 0)
        {
            roleInfoView.SetVisibel(true);
            roleInfoView.Init(curInfo.playerBaseInfo, true);
        }
        else if (index == 1)
        {
            UIUtils.DestroyChildren(parent);
            RemoveLogMessagePanel();
            Exit();
            SocialModel.Instance.ClearChatLog(curInfo.chatWithId.ToString());
        }
        dropDown.value = 2;
    }

    void LoadChatLog()
    {
        UIUtils.DestroyChildren(parent);
        if (File.Exists(ConstantUtils.chatConfigPath))
        {
            JsonData jd     = JsonMapper.ToObject(File.ReadAllText(ConstantUtils.chatConfigPath));
            string   logStr = jd.TryGetString(curInfo.chatWithId.ToString());
            if (!string.IsNullOrEmpty(logStr))
            {
                logStr = jd[curInfo.chatWithId.ToString()].ToJson();
                JsonData chatData    = JsonMapper.ToObject(logStr);
                JsonData historyJson = chatData["history"];
                for (int i = 0; i < historyJson.Count; i++)
                {
                    ChatInfo info = JsonMapper.ToObject <ChatInfo>(JsonMapper.ToJson(historyJson[i]));
                    //JsonData chatInfoJson = historyJson[i]; print(int.Parse(historyJson[i]["sender"].ToJson().ToString()));
                    //ChatInfo info = new ChatInfo();
                    //info.senderId = (int)(float.Parse(historyJson[i]["sender"].ToJson()));
                    //info.text = historyJson[i]["value"].ToJson();
                    //info.timer = (int)(float.Parse(historyJson[i]["time"].ToJson()));
                    //info.type = (int)(float.Parse(historyJson[i]["type"].ToJson()));
                    LoadChatItem(info);
                }
            }
        }
    }

    /// <summary>
    /// 退出聊天
    /// </summary>
    void Exit()
    {
        SetVisible(false);
        messagePanel.gameObject.SetActive(true);
    }

    /// <summary>
    /// 打开语音界面
    /// </summary>
    void OpenYuyin()
    {
        yuyinObj.SetActive(true);
        daziObj.SetActive(false);
    }

    /// <summary>
    /// 打开打字界面
    /// </summary>
    void OpenDazi()
    {
        yuyinObj.SetActive(false);
        daziObj.SetActive(true);
    }