Esempio n. 1
0
    public void FriendChatOk(COM_ContactInfo contact, COM_Chat msg)
    {
        COM_ContactInfo frined = Get(contact.name_, friends_);

        if (frined == null)
        {
            COM_ContactInfo offens = Get(contact.name_, offens_);
            if (offens == null)
            {
                AddOffen(contact);
                AddNoChat(contact.name_, msg);
            }
        }

        if (_chatDic.ContainsKey(contact.name_))
        {
            _chatDic [contact.name_].Add(msg);
        }
        else
        {
            List <COM_Chat> str = new List <COM_Chat>();
            str.Add(msg);
            _chatDic [contact.name_] = str;
        }


        if (FriendChat != null)
        {
            FriendChat(contact, msg);
        }
    }
Esempio n. 2
0
    //player say
    public static void PushRecord(COM_Chat info)
    {
        COM_ChatInfo c = new COM_ChatInfo();

        c.ck_      = info.ck_;
        c.content_ = info.content_;
        //c.audioId_ = info.audioId_;
        c.audio_      = info.audio_;
        c.assetId_    = (ushort)GamePlayer.Instance.GetIprop(PropertyType.PT_AssetId);
        c.playerName_ = GamePlayer.Instance.InstName; //only player
        PushRecord(c);
    }
Esempio n. 3
0
 public void AddNoChat(string name, COM_Chat msg)
 {
     if (_noChatDic.ContainsKey(name))
     {
         _noChatDic [name].Add(msg);
     }
     else
     {
         List <COM_Chat> str = new List <COM_Chat>();
         str.Add(msg);
         _noChatDic [name] = str;
     }
 }
Esempio n. 4
0
    void OnClickMegaphone(ButtonScript obj, object args, int param1, int param2)
    {
        timelabel.gameObject.SetActive(true);
        startTime   = 30;
        currentTime = 0;
        isCountDown = true;
        COM_Chat chat_com = new COM_Chat();

        chat_com.ck_      = ChatKind.CK_World;
        chat_com.content_ = LanguageManager.instance.GetValue("yijianhanhua").Replace("{n}", TeamInfo.leaderName_).Replace("{n1}", TeamInfo.minLevel_.ToString()).Replace("{n2}", TeamInfo.maxLevel_.ToString()).Replace("{t1}", TeamInfo.teamId_.ToString()).Replace("{t2}", TeamInfo.needPassword_.ToString());
        NetConnection.Instance.sendChat(chat_com, "");
        MegaphoneBtn.isEnabled = false;
    }
Esempio n. 5
0
    private void OnPrassVoice(GameObject sender, bool isPrass)
    {
        COM_Chat chat_com = new COM_Chat();

        if (isPrass)
        {
            //	ChatSystem.instance.StartRecord();
        }
        else
        {
            // ChatSystem.instance.StopRecord();
            // ChatSystem.instance.GetClip(ref chat_com.audio_);
            chat_com.ck_ = ChatType;
            NetConnection.Instance.sendChat(chat_com, "");
        }
    }
Esempio n. 6
0
    private void OnClickSend(ButtonScript obj, object args, int param1, int param2)
    {
        string   text     = NGUIText.StripSymbols(chatInput.value);
        COM_Chat chat_com = new COM_Chat();

        if (!string.IsNullOrEmpty(text))
        {
            if (chatInput.value[0] == '^')
            {
                chat_com.ck_      = ChatKind.CK_GM;
                chat_com.content_ = chatInput.value.Substring(1);
                NetConnection.Instance.sendChat(chat_com, "");
            }
            else
            {
                if (!TeamSystem.IsInTeam() && chatType == ChatKind.CK_Team)
                {
                    //ErrorTipsUI.ShowMe(LanguageManager.instance.GetValue("teamMessage"));
                    PopText.Instance.Show(LanguageManager.instance.GetValue("teamMessage"));
                }
                else
                if (chatType == ChatKind.CK_Guild)
                {
                    //ErrorTipsUI.ShowMe(LanguageManager.instance.GetValue("gonghui"));
                    PopText.Instance.Show(LanguageManager.instance.GetValue("gonghui"));
                }
                else
                {
                    chat_com.ck_      = chatType;
                    chat_com.content_ = chatInput.value;
                    NetConnection.Instance.sendChat(chat_com, "");
                }
            }

            chatInput.value      = "";
            chatInput.isSelected = false;
        }
    }
Esempio n. 7
0
//	private bool isCountDown = false;
    void OnClickHuanhua(ButtonScript obj, object args, int param1, int param2)
    {
        timelabel.gameObject.SetActive(true);
//		startTime = 30;
//		currentTime = 0;


        GlobalInstanceFunction.isOnkeyCountDown = true;
        COM_Chat chat = new COM_Chat();

        chat.ck_           = ChatKind.CK_World;
        chat.teamId_       = (int)TeamSystem._MyTeamInfo.teamId_;
        chat.teamMaxLevel_ = (short)TeamSystem._MyTeamInfo.maxLevel_;
        chat.teamMinLevel_ = (short)TeamSystem._MyTeamInfo.minLevel_;
        chat.teamType_     = TeamSystem._MyTeamInfo.type_;
        chat.audio_        = null;
        chat.audioTime_    = 0;
        chat.content_      = " ";
        //string content_ = LanguageManager.instance.GetValue ("yijianhanhua").Replace ("{n}",LanguageManager.instance.GetValue( TeamSystem._MyTeamInfo.type_.ToString())).Replace ("{n1}", TeamSystem._MyTeamInfo.minLevel_.ToString()).Replace ("{n2}", TeamSystem._MyTeamInfo.maxLevel_.ToString()).Replace("{t1}","1").Replace("{t2}",TeamSystem._MyTeamInfo.teamId_.ToString());
        //ChatSystem.SendToServer(ChatKind.CK_World,"",content_);
        NetConnection.Instance.sendChat(chat, "");
        hanhuaBt.isEnabled = false;
    }
Esempio n. 8
0
    public static void SendToServer(ChatKind ck, string target, string content, byte[] audio = null, int audioTime = 0)
    {
        if (content == "" && target == "" && audio == null)
        {
            return;
        }
        _SendRecords.AddLast(content);
        if (_SendRecords.Count > _SendRecordSize)
        {
            _SendRecords.RemoveFirst();
        }

        COM_Chat cc = new COM_Chat();

        cc.ck_ = ck;
        //if(content == "openlog")
        //{
        //    ApplicationEntry.Openlog = true;
        //}
        //else if(content == "closelog")
        //{
        //    ApplicationEntry.Openlog = false;
        //}
        if (content.IndexOf("^") == 0)
        {
            cc.ck_      = ChatKind.CK_GM;
            cc.content_ = content.Substring(1);
        }
        else
        {
            cc.audio_     = audio;
            cc.audioTime_ = audioTime;
            cc.content_   = content;
        }
        NetConnection.Instance.sendChat(cc, target);
    }
Esempio n. 9
0
    void Update()
    {
        if (istargetPrass)
        {
            if (Input.GetMouseButtonDown(0))
            {
                mousePosition_Y = Input.mousePosition.y;
            }
            if (Input.GetMouseButton(0))
            {
                if (Input.mousePosition.y - mousePosition_Y > 80)
                {
                    isCanel = true;
                }
            }
            tt = Mathf.Max(0, maxTime - (Time.realtimeSinceStartup - PrassTime));
            if (tt == 0)
            {
                yuyinTips.SetActive(false);
                int audiolen = Mathf.RoundToInt(Time.realtimeSinceStartup - PrassTime);
                ChatSystem.StopRecord();
                if (ChatSystem.AsyncGetCallBack == null)
                {
                    ChatSystem.AsyncGetCallBack = delegate(byte[] datas)
                    {
                        audioChat_            = new COM_Chat();
                        audioChat_.audio_     = datas;
                        audioChat_.isAudio_   = true;
                        audioChat_.audioTime_ = audiolen;
                        //int le = Mathf.RoundToInt(ChatSystem.GetClipLength(audioChat_.audio_));
                        ChatSystem.SendToServer(_SendChatKind, "", "", audioChat_.audio_, audioChat_.audioTime_);
                        ClientLog.Instance.Log("audioChat_.audio_====+++++=" + audioChat_.audio_.Length);
                        ischaoshi     = true;
                        istargetPrass = false;
                        audioChat_    = null;
                    };
                    ChatSystem.AsyncGet();
                }
            }
        }
        if (!_IsDirty)
        {
            return;
        }

        if (!ChatSystem.GetChannelInfo(_OpenChannels, ref _ChannelInfo, ref index))
        {
            return;
        }

        if (_ChannelInfo.Count == 0)
        { //木有
            _CachedFreeGridItem(0);
            _IsDirty = false;
            return;
        }

        for (int i = 0; i < _ChannelInfo.Count; ++i)
        {
            _MakedGridItem(i, _ChannelInfo[i]);  //链表下标访问 是不是很
        }
        _CachedFreeGridItem(_ChannelInfo.Count); //清理多余物件

//        GlobalInstanceFunction.Instance.Invoke(() =>
//        {
        cGrid.Reposition();
        if (!isLock)
        {
            _Sb.value = 1;
        }
//        }, 2);



        _IsDirty = false;
    }
Esempio n. 10
0
    private void OnPrassVoice(GameObject sender, bool isPrass)
    {
#if UNITY_ANDROID
        if (!XyskAndroidAPI.hasMicrophoneAuth() && isPrass)
        {
            PopText.Instance.Show(LanguageManager.instance.GetValue("microphoneforbidden"), PopText.WarningType.WT_Warning);
            return;
        }
#elif UNITY_IOS
        if (!XyskIOSAPI.HasMicrophoneAuth() && isPrass)
        {
            PopText.Instance.Show(LanguageManager.instance.GetValue("microphoneforbidden"), PopText.WarningType.WT_Warning);
            return;
        }
#endif
        if (Microphone.devices.Length == 0)
        {
            ClientLog.Instance.Log("No Record Device!");
            return;
        }

        if (isPrass)
        {
            isCanel       = false;
            ischaoshi     = false;
            PrassTime     = Time.realtimeSinceStartup;
            istargetPrass = true;
            ChatSystem.StartRecord();
            yuyinTips.SetActive(true);
        }
        else
        {
            istargetPrass = false;
            yuyinTips.SetActive(false);
            if (ischaoshi)
            {
                return;
            }
            float tm = Time.realtimeSinceStartup - PrassTime;
            ChatSystem.StopRecord();
            if (tm < 1)
            {
                PopText.Instance.Show(LanguageManager.instance.GetValue("chatVeTime"));
            }
            else
            {
                if (isCanel)
                {
                    return;
                }
                if (ChatSystem.AsyncGetCallBack == null)
                {
                    ChatSystem.AsyncGetCallBack = delegate(byte[] datas)
                    {
                        audioChat_            = new COM_Chat();
                        audioChat_.audio_     = datas;
                        audioChat_.isAudio_   = true;
                        audioChat_.audioTime_ = (int)tm;
                        //int le = Mathf.RoundToInt(ChatSystem.GetClipLength(audioChat_.audio_));
                        ChatSystem.SendToServer(_SendChatKind, "", "", audioChat_.audio_, audioChat_.audioTime_);
                        ClientLog.Instance.Log("audioChat_.audio_=====" + audioChat_.audio_.Length);
                        audioChat_ = null;
                    };
                    ChatSystem.AsyncGet();
                }
            }
        }
    }
Esempio n. 11
0
    void OnLineEvent(bool line)
    {
        if (string.IsNullOrEmpty(friendChatLab.text.Trim()))
        {
            PopText.Instance.Show(LanguageManager.instance.GetValue("bunengweikong"));
            return;
        }
        if (!line)
        {
            PopText.Instance.Show(LanguageManager.instance.GetValue("frinedonline"));
            return;
        }

        else if (chat_com != null)
        {
            chat_com.ck_ = ChatKind.CK_Friend;
            Filt(ref chat_com.content_, 0, 1);
            NetConnection.Instance.sendChat(chat_com, _selectFriend.name_);
            if (chat_com.content_.Length > 30)
            {
                //PopText.Instance.Show(LanguageManager.instance.GetValue("chatLineMax"));
                //return;
            }

            //COM_Chat comC = new COM_Chat();
            chat_com.ck_      = ChatKind.CK_Friend;
            chat_com.content_ = friendChatLab.text;
            chat_com.isMe     = true;
            //	NetConnection.Instance.sendChat (comC,_selectFriend.name_);

            GameObject tf = null;
            tf = GameObject.Instantiate(_GridItem) as GameObject;
            cGrid.AddChild(tf.transform);
            tf.transform.localScale = Vector3.one;
            tf.gameObject.SetActive(true);
            ChatMaxCell  cmi  = tf.gameObject.GetComponent <ChatMaxCell>();
            COM_ChatInfo info = new COM_ChatInfo();            // (COM_ChatInfo)comC ;
            info.playerName_ = GamePlayer.Instance.InstName;

            info.content_ = friendChatLab.text;
            Filt(ref info.content_, 0, 1);
            info.ck_      = ChatKind.CK_Friend;
            info.assetId_ = (ushort)GamePlayer.Instance.GetIprop(PropertyType.PT_AssetId);
            cmi.Info      = info;
            cmi._LChatKindBackground.gameObject.SetActive(false);
            cmi._RChatKindBackground.gameObject.SetActive(false);
            chat_com = null;
            FriendSystem.Instance().addMyChat(_selectFriend.name_, chat_com);
            chatCellList.Add(tf);

            friendChatLab.text = "";
            chatInput.value    = "";
        }
        else
        {
            if (string.IsNullOrEmpty(friendChatLab.text.Trim()))
            {
                PopText.Instance.Show(LanguageManager.instance.GetValue("bunengweikong"));
                return;
            }
            if (friendChatLab.text.Length > 30)
            {
                //PopText.Instance.Show(LanguageManager.instance.GetValue("chatLineMax"));
                //return;
            }
            COM_Chat comC = new COM_Chat();
            comC.ck_      = ChatKind.CK_Friend;
            comC.content_ = friendChatLab.text;
            Filt(ref comC.content_, 0, 1);
            NetConnection.Instance.sendChat(comC, _selectFriend.name_);

            GameObject tf = null;
            tf = GameObject.Instantiate(_GridItem) as GameObject;
            cGrid.AddChild(tf.transform);
            tf.transform.localScale = Vector3.one;
            tf.gameObject.SetActive(true);
            ChatMaxCell  cmi  = tf.gameObject.GetComponent <ChatMaxCell>();
            COM_ChatInfo info = new COM_ChatInfo();
            info.playerName_ = GamePlayer.Instance.InstName;
            info.content_    = friendChatLab.text;
            Filt(ref info.content_, 0, 1);
            info.ck_      = ChatKind.CK_Friend;
            info.assetId_ = (ushort)GamePlayer.Instance.GetIprop(PropertyType.PT_AssetId);
            cmi.Info      = info;
            cmi._LChatKindBackground.gameObject.SetActive(false);
            cmi._RChatKindBackground.gameObject.SetActive(false);
            comC.isMe          = true;
            friendChatLab.text = "";
            chatInput.value    = "";
            FriendSystem.Instance().addMyChat(_selectFriend.name_, comC);
            chatCellList.Add(tf);
        }
        cGrid.Reposition();
        scrollBar.value = 1;
    }
Esempio n. 12
0
    void OnFriendChat(COM_ContactInfo contact, COM_Chat msg)
    {
        if (_selectFriend != null && contact.instId_ == _selectFriend.instId_)
        {
            /*GameObject obj = Object.Instantiate(chatCell.gameObject) as GameObject;
             * obj.SetActive(true);
             * FriendItem cellUI = obj.GetComponent<FriendItem>();
             * cellUI._chatInfo = msg;
             * if(msg.audio_ != null && msg.audio_.Length > 0)
             * {
             * //	obj.transform.Find ("info").GetComponent<UILabel> ().gameObject.SetActive(false);
             *      obj.transform.Find ("vButton").GetComponent<UIButton> ().gameObject.SetActive(true);
             * }
             * else
             * {
             *      obj.transform.Find ("vButton").GetComponent<UIButton> ().gameObject.SetActive(false);
             * }
             * //obj.transform.Find ("info").GetComponent<UILabel> ().text = msg.content_;
             *
             * //cellUI.SetInfoBack(msg.content_);
             * cellUI.ParseSymbol(msg.content_);
             *
             * HeadIconLoader.Instance.LoadIcon(EntityAssetsData.GetData((int)contact.assetId_).assetsIocn_, obj.transform.Find ("icon").Find ("Sprite").GetComponent<UITexture>());
             * if(!_icons.Contains(EntityAssetsData.GetData((int)contact.assetId_).assetsIocn_))
             * {
             *      _icons.Add(EntityAssetsData.GetData((int)contact.assetId_).assetsIocn_);
             * }
             *
             * cellUI.name_.text = contact.name_;
             * //cellUI.level_.text = contact.level_.ToString ();
             * chatGrid.AddChild(obj.transform);
             * obj.transform.localScale = Vector3.one;
             */



            GameObject tf = null;
            tf = GameObject.Instantiate(_GridItem) as GameObject;
            cGrid.AddChild(tf.transform);
            tf.transform.localScale = Vector3.one;
            tf.gameObject.SetActive(true);
            ChatMaxCell  cmi  = tf.gameObject.GetComponent <ChatMaxCell>();
            COM_ChatInfo info = new COM_ChatInfo();
            Filt(ref msg.content_, 0, 1);
            info.content_    = msg.content_;
            info.ck_         = ChatKind.CK_Friend;
            info.playerName_ = contact.name_;
            info.assetId_    = (ushort)contact.assetId_;
            cmi.Info         = info;
            cmi._LChatKindBackground.gameObject.SetActive(false);
            cmi._RChatKindBackground.gameObject.SetActive(false);
            chatCellList.Add(tf);
        }
        else
        {
            foreach (var x in friendCellList)
            {
                if (x.GetComponent <FriendItem>().ContactInfo.instId_ == contact.instId_)
                {
                    //x.GetComponent<FriendItem>().red.gameObject.SetActive(true);
                    x.GetComponent <UISprite>().MarkOn();                   //UISprite.MarkAnthor.MA_RightTop,0,0);
                    break;
                }
            }
            foreach (COM_ContactInfo f in FriendSystem.Instance().offens_)
            {
                if (f.instId_ == contact.instId_)
                {
                    offTabBtn.GetComponentInChildren <UISprite>().MarkOn(UISprite.MarkAnthor.MA_RightTop, -10, -10);
                    break;
                }
            }
        }
    }
Esempio n. 13
0
    private void OnPrassVoice(GameObject sender, bool isPrass)
    {
#if UNITY_ANDROID
        if (!XyskAndroidAPI.hasMicrophoneAuth())
        {
            PopText.Instance.Show(LanguageManager.instance.GetValue("microphoneforbidden"), PopText.WarningType.WT_Warning);
            return;
        }
#elif UNITY_IOS
        if (!XyskIOSAPI.HasMicrophoneAuth() && isPrass)
        {
            PopText.Instance.Show(LanguageManager.instance.GetValue("microphoneforbidden"), PopText.WarningType.WT_Warning);
            return;
        }
#endif
        if (Microphone.devices.Length == 0)
        {
            ClientLog.Instance.Log("No Record Device!");
            return;
        }
        if (isPrass)
        {
            isCanel       = false;
            ischaoshi     = false;
            PrassTime     = Time.realtimeSinceStartup;
            istargetPrass = true;
            ChatSystem.StartRecord();
            yuyinTips.SetActive(true);
        }
        else
        {
            istargetPrass = false;
            yuyinTips.SetActive(false);
            chat_com = new COM_Chat();
            if (ischaoshi)
            {
                return;
            }
            float tm = Time.realtimeSinceStartup - PrassTime;
            if (tm < 1)
            {
                PopText.Instance.Show(LanguageManager.instance.GetValue("chatVeTime"));
            }
            else
            {
                if (isCanel)
                {
                    return;
                }
                ChatSystem.StopRecord();
                if (ChatSystem.AsyncGetCallBack == null)
                {
                    ChatSystem.AsyncGetCallBack = delegate(byte[] datas)
                    {
                        chat_com.audio_ = datas;
                        NetConnection.Instance.queryOnlinePlayerbyName(_selectFriend.name_);
                    };
                    ChatSystem.AsyncGet();
                }
                //ChatSystem.GetClip(ref chat_com.audio_);
                //NetConnection.Instance.queryOnlinePlayerbyName (_selectFriend.name_);

                //ChatSystem.SendToServer(_SendChatKind,"","",chat_com.audio_);
            }
        }
    }
Esempio n. 14
0
 public static void PushPlayerSay(COM_Chat c)
 {
     PushRecord(c);
 }