Esempio n. 1
0
 public void EnterChat(int friendId)
 {
     if (curInstance != null)
     {
         curInstance.OnExit();
     }
     curInstance = pairId2Instance [GetPairID(curUserId, friendId)];
     curInstance.OnEnter();
 }
Esempio n. 2
0
    //
    public void OnFriendsLstChange()
    {
        foreach (var item in pairId2Instance.Values)
        {
            item.OnExit();
        }
        pairId2Instance.Clear();
        List <int> friends = XMLSaver.saveData.GetFriendsLst(curUserId);

        if (init2NameDic == null)
        {
            init2NameDic = new Dictionary <char, List <int> >();
            for (int i = 0; i < 26; i++)
            {
                init2NameDic.Add((char)(i + 65), new List <int>());
            }
            init2NameDic.Add('#', new List <int>());
        }
        else
        {
            foreach (var item in init2NameDic.Values)
            {
                item.Clear();
            }
        }
        for (int i = 0; i < friends.Count; i++)
        {
            int          friendId = friends[i];
            int          id       = GetPairID(curUserId, friendId);
            ChatInstance instance = new ChatInstance();
            instance.OnInit(friendId);
            pairId2Instance.Add(id, instance);

            AccountSaveData data = XMLSaver.saveData.GetAccountData(friendId);
            char            c;
            if (!string.IsNullOrEmpty(data.nickname))
            {
                c = Utils.GetSpellCode(data.nickname)[0];
            }
            else if (!string.IsNullOrEmpty(data.realName))
            {
                c = Utils.GetSpellCode(data.realName)[0];
            }
            else
            {
                c = '#';
            }
            init2NameDic[c].Add(friendId);
            //char c = Utils.GetSpellCode(data);
        }
        RefreshMsg();
    }
Esempio n. 3
0
 public void EnterChat(string name1, string name2 = "")
 {
     if (name2 == "")
     {
         name2 = curName;
     }
     if (curInstance != null)
     {
         curInstance.OnExit();
     }
     curInstance = pairId2Instance [GetPairID(name1, name2)];
     curInstance.OnEnter();
 }
    void TryOpen()
    {
        ChatInstance instance     = ChatManager.Instance.curExecuteInstance;
        Node         runningNode  = instance.curRunningNode;
        Node         nextReadNode = instance.nextReadNode;
        Node         front        = null;

        if (CanShow(nextReadNode, runningNode))
        {
            front = nextReadNode;
        }
        else if (nextReadNode == null)
        {
            front = instance.curSection.GetLast();
        }
        else
        {
            front = instance.GetFront(nextReadNode, true);
        }
        if (front == null)
        {
            front = instance.curSection.GetLast();
        }
        if (front == null)
        {
            return;
        }
        NodeItemProxy item = GetItem(front.enname == ChatManager.Instance.curName?1:0);

        ChatManager.Instance.curExecuteInstance.ActiveNode(front);
        float itemHeight = item.SetData(front);

        item.cachedRectTransform.anchoredPosition = new Vector2(0.0f, itemHeight - contextTrans.sizeDelta.y);
        contextTrans.anchoredPosition             = new Vector2(0.0f, contextTrans.sizeDelta.y - viewPortTrans.sizeDelta.y);
        if (front == nextReadNode)
        {
            item.FadeIn();
            instance.ReadNext();
            ChatManager.Instance.curInstance.saveData.totalRectHeight += itemHeight;
            contextTrans.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, contextTrans.sizeDelta.y + itemHeight);
            item.cachedRectTransform.anchoredPosition = new Vector2(0.0f, itemHeight - contextTrans.sizeDelta.y);
        }
        _activeItems.Add(item);
        item.gameObject.SetActive(true);
    }
Esempio n. 5
0
    //
    public void OnEnter(string name)
    {
        id2Name.Clear();
        foreach (var item in name2Id.Keys)
        {
            id2Name.Add(name2Id[item], item);
        }
        pairId2Instance.Clear();
        List <string> friends = XMLSaver.saveData.GetFriendsLst(name);

        for (int i = 0; i < friends.Count; i++)
        {
            string       otherName = friends[i];
            int          id        = GetPairID(curName, friends[i]);
            ChatInstance instance  = new ChatInstance();
            instance.OnInit(name, otherName, id);
            pairId2Instance.Add(id, instance);
        }
        Refresh();
    }
Esempio n. 6
0
    public override void SetData(object o)
    {
        base.SetData(o);
        instance = o as ChatInstance;
        AccountSaveData data = XMLSaver.saveData.GetAccountData(instance.friendId);

        HeadSpriteUtils.Instance.SetHead(head, data.accountId);
        if (!string.IsNullOrEmpty(data.nickname))
        {
            userName.text = data.nickname;
        }
        else if (!string.IsNullOrEmpty(data.realName))
        {
            userName.text = data.realName;
        }
        else
        {
            userName.text = ContentHelper.Read(ContentHelper.NotSetNickName);
        }
        OnRefresh();
    }
Esempio n. 7
0
 public Node GetLastRunningNode()
 {
     curExecuteInstance = curInstance;
     return(curInstance.GetLastRunningNode());
 }
 public override void Destruct()
 {
     this.ChatInstance.Remove(this);
     this.ChatInstance = null;
     base.Destruct();
 }
 public ChatSession(StartServerSessionMessage message) : base(message)
 {
     this.LogicMessageManager = new LogicMessageManager(this);
     this.ChatInstance        = ChatInstanceManager.GetJoinableInstance(this.Country);
     this.ChatInstance.Add(this);
 }