Пример #1
0
    public void Receive(FriendView v)
    {
        viewList = pop.viewList;
        if (point > v.data.heartamount && v.data.heartamount > 0)
        {
            C2sSprotoType.recvheart.request obj = new C2sSprotoType.recvheart.request();
            List <C2sSprotoType.heartlist>  l   = new List <C2sSprotoType.heartlist>();
            DateTime dt = DateTime.Now;
            string   t  = string.Format("{0:yyyyMMddHHmmss}", dt);
            C2sSprotoType.heartlist f = new C2sSprotoType.heartlist();
            f.friendid  = v.data.id;
            f.type      = 0;
            f.signtime  = v.data.signtime;
            f.amount    = v.data.heartamount;
            f.csendtime = t;
            l.Add(f);
            obj.hl          = l;
            obj.totalamount = v.data.heartamount;
            NetworkManager.Instance.ReceviceHeart(obj);

            point = point - v.data.heartamount;
            pop.SetPoint(point);
            UserManager.Instance.AddFriendPoint(v.data.heartamount);
            v.data.isReceive   = false;
            v.data.heartamount = 0;
            v.CheckBtn();
        }
    }
Пример #2
0
    public void ReceiveAll()
    {
        viewList = pop.viewList;
        int temp = 0;

        if (viewList.Count > 0)
        {
            C2sSprotoType.recvheart.request obj = new C2sSprotoType.recvheart.request();
            List <C2sSprotoType.heartlist>  l   = new List <C2sSprotoType.heartlist>();
            DateTime dt = DateTime.Now;
            string   t  = string.Format("{0:yyyyMMddHHmmss}", dt);
            for (int i = 0; i < viewList.Count; i++)
            {
                FriendView v = viewList[i] as FriendView;
                temp += v.data.heartamount;
                if (v.data.heartamount > 0 && temp < point)
                {
                    C2sSprotoType.heartlist f = new C2sSprotoType.heartlist();
                    f.friendid  = v.data.id;
                    f.type      = 0;
                    f.signtime  = v.data.signtime;
                    f.amount    = Def.RecHeart;
                    f.csendtime = t;
                    l.Add(f);
                }
            }
            obj.hl          = l;
            obj.totalamount = temp;

            if (point > temp)
            {
                UserManager.Instance.AddFriendPoint(temp);
                NetworkManager.Instance.ReceviceHeart(obj);
                point = point - temp;
                pop.SetPoint(point);
                for (int i = 0; i < viewList.Count; i++)
                {
                    FriendView v = pop.GetView(i);
                    if (v != null)
                    {
                        if (v.data.isReceive != false)
                        {
                            v.data.isReceive   = false;
                            v.data.heartamount = 0;
                            v.CheckBtn();
                        }
                    }
                }
            }
            else
            {
                ToastManager.Instance.Show("达到领取上线");
            }
        }
    }