Example #1
0
 //-------------------------------一些接口--------------------------
 public void updateEmailTitleItem(Email email, int id, string author,
                                  CommonUtil.EmailContent content, string title, string date, bool hasRead)
 {
     _emailID    = id;
     _email      = email;
     _title.text = title;
     _date.text  = date;
     _author     = author;
     _content    = content;
     _notRead.gameObject.SetActive(!hasRead);
     _hasRead  = hasRead;
     _titleStr = title;
 }
Example #2
0
    public EmailTitleItem createEmailItem(int index, int id, string author, CommonUtil.EmailContent content,
                                          bool hasRead, string date, string title)
    {
        EmailTitleItem emailItem = Instantiate(_emailTitleItemPrefab, new Vector3(0, 0, 0), Quaternion.identity);

        emailItem.transform.SetParent(_emailRoot.transform);

        emailItem.transform.localPosition = new Vector3(0, -index * 160 - 40, 0);

        emailItem.updateEmailTitleItem(this, id, author, content, title, date, hasRead);

        emailItem.transform.localScale = emailItem.transform.localScale * CommonUtil.Util.getScreenScale();

        return(emailItem);
    }
Example #3
0
    //设置是否存在未领取的奖励
    public void checkAllAwardBtnCanShow()
    {
        bool hasAward = false;

        for (int i = 0; i < _emailList.Count; i++)
        {
            CommonUtil.EmailContent content = _emailList[i].getContent();
            if (content.hasAward)
            {
                hasAward = true;
                break;
            }
        }

        if (hasAward)
        {
            _allAwardBtn.gameObject.SetActive(true);
        }
        else
        {
            _allAwardBtn.gameObject.SetActive(false);
        }

        // 是否已经全部领取
        bool hasAllGotten = true;

        for (int i = 0; i < _emailList.Count; i++)
        {
            CommonUtil.EmailContent content = _emailList[i].getContent();
            if (content.hasAward && !content.hasGottenAward)
            {
                hasAllGotten = false;
                break;
            }
        }
        if (hasAllGotten)
        {
            //_allAwardBtn.interactable = false;
            _allAwardBtn.gameObject.SetActive(false);
        }
        else
        {
            _allAwardBtn.interactable = true;
        }
    }
Example #4
0
 public static string serialize(EmailContent ec)
 {
     return(JsonUtility.ToJson(ec));
 }
Example #5
0
 public void updateContent(CommonUtil.EmailContent content)
 {
     _content = content;
 }
Example #6
0
    //-------------------------------一些接口--------------------------
    public void selectEmailTitleItem(int emailID)
    {
        int id = -1;

        for (int i = 0; i < _emailList.Count; i++)
        {
            if (_emailList [i].getEmailID() != emailID)
            {
                _emailList [i].unselectItem();
            }
            else
            {
                id = i;
                _emailList [i].selectItem();
            }
        }

        if (id == -1)
        {
            return;
        }

        _currentSelectEmailID = id;

        if (!_emailList [_currentSelectEmailID].getHasRead())
        {
            LobbyEvent.sV2C_ReqUpdateEmail re;
            re.id   = _emailList [_currentSelectEmailID].getEmailID();
            re.type = CommonDefine.eUpdateEmailType.READ;
            LobbyEvent.EM().InvokeEvent(LobbyEvent.EVENT.REQ_UPDATE_EMAIL, (object)re);
        }

        //右侧信息刷新
        CommonUtil.EmailContent content = _emailList [id].getContent();
        _emailContent.text = content.content;
        _emailAuthor.text  = _emailList [id].getAuthor();
        _emailTime.text    = _emailList [id].getDate();

        if (content.hasAward)
        {
            _awardPanel.SetActive(true);

            /*
             * public AWARD_TYPE type;
             * public int prop_id;//如果有
             * public string awardIcon;//可以从道具列表中查到相关图标
             */

            if (content.hasGottenAward)
            {
                _awardBtn.interactable = false;
                Text txt = _awardBtn.GetComponentInChildren <Text> ();
                txt.text = "已领取";
            }
            else
            {
                _awardBtn.interactable = true;
            }

            _awardCnt.text = "x" + content.awardCnt;

            //_awardIcon.sprite = CommonUtil.Util.getPropIconByPropID (content.prop_id);
        }
        else
        {
            _awardPanel.SetActive(false);
        }
    }
Example #7
0
    public void onShowUpdateEmailResult(object data)
    {
        LobbyEvent.sV2C_ReqUpdateEmail re = (LobbyEvent.sV2C_ReqUpdateEmail)data;

        int index = -1;

        for (int i = 0; i < _emailList.Count; i++)
        {
            if (_emailList [i].getEmailID() == re.id)
            {
                index = i;
                break;
            }
        }
        if (index == -1)
        {
            return;
        }

        if (re.type == CommonDefine.eUpdateEmailType.READ)
        {
            //设置已读
            _emailList [index].updateHasRead();
        }
        else if (re.type == CommonDefine.eUpdateEmailType.DEL)
        {
            //删除
            Destroy(_emailList [index].gameObject);
            _emailList.RemoveAt(index);
            //需要刷新整个界面
            //将默认选择移动到第一个,设置当前选择
            updateDefaultSelect();
        }
        else if (re.type == CommonDefine.eUpdateEmailType.GET_AWARD)
        {
            //恭喜获得xx 提示
            ViewManagerEvent.s_ShowDialog d;
            d.callBack  = onClickDialogBtn;
            d.hasCancel = false;
            d.hasClose  = true;
            d.hasOk     = false;
            d.tip       = "温馨提示";
            CommonUtil.EmailContent content = _emailList [index].getContent();
            if (content.type == CommonUtil.EmailContent.AWARD_TYPE.GOLD)
            {
                d.tip = "恭喜获得" + content.awardCnt + "积分!祝您游戏愉快~";
            }
            else if (_emailList [index].getContent().type == CommonUtil.EmailContent.AWARD_TYPE.PROP)
            {
                d.tip = "恭喜获得永久皮肤" + "吃遍天下" + "!祝您游戏愉快~";
            }

            d.type = CommonDefine.eDialogEventType.LOBBY_EMAIL_GET_AWARD_RESULT;

            ViewManagerEvent.EM().InvokeEvent(ViewManagerEvent.EVENT.SHOW_DIALOG, (object)d);

            _emailList [index].getContent().hasGottenAward = true;
            //更新
            _awardBtn.interactable = false;
            Text txt = _awardBtn.GetComponentInChildren <Text> ();
            txt.text = "已领取";

            //all btn
            Invoke("checkIsGettingAllAward", 0.001f);
        }
        updateReadUnRead();
    }
Example #8
0
    void  OnRespUpdateEmail(Message msg)
    {
        ViewManagerEvent.EM().InvokeEvent(ViewManagerEvent.EVENT.SHOW_LOADING_ANI, false);


        msgReqUpdateEmail resp = msgReqUpdateEmail.deserialize(msg);

        int find = -1;

        for (int i = 0; i < Lobby.Lobby.privateMsgList.Count; i++)
        {
            if (Lobby.Lobby.privateMsgList [i].id == resp.awardEmailId)
            {
                find = i;
                break;
            }
        }
        if (find == -1)
        {
            //邮件不存在
            return;
        }
        LobbyEvent.PrivateMsg psm;
        psm.author    = Lobby.Lobby.privateMsgList [find].author;
        psm.content   = Lobby.Lobby.privateMsgList [find].content;
        psm.end_time  = Lobby.Lobby.privateMsgList [find].end_time;
        psm.has_read  = Lobby.Lobby.privateMsgList [find].has_read;
        psm.id        = Lobby.Lobby.privateMsgList [find].id;
        psm.send_time = Lobby.Lobby.privateMsgList [find].send_time;
        psm.title     = Lobby.Lobby.privateMsgList [find].title;

        if (resp.type == CommonDefine.eUpdateEmailType.READ)
        {
            //更新邮件缓存列表
            psm.has_read = 1;
            Lobby.Lobby.privateMsgList [find] = psm;

            checkIfHasUnReadEmail();
        }
        else if (resp.type == CommonDefine.eUpdateEmailType.DEL)
        {
            //删除
            Lobby.Lobby.privateMsgList.RemoveAt(find);

            checkIfHasUnReadEmail();
        }
        else if (resp.type == CommonDefine.eUpdateEmailType.GET_AWARD)
        {
            CommonUtil.EmailContent ec = CommonUtil.EmailContent.deserialize(Lobby.Lobby.privateMsgList[find].content);

            if (ec.hasGottenAward)
            {
                //已经领取过奖励了
                CommonUtil.Util.showDialog("温馨提示", "您已经领取过奖励了 :)");

                return;
            }
            else
            {
                ec.hasGottenAward = true;
                psm.content       = CommonUtil.EmailContent.serialize(ec);
                Lobby.Lobby.privateMsgList [find] = psm;

                // 奖励需要同时更新 用户金币以及包裹信息
                if (ec.type == CommonUtil.EmailContent.AWARD_TYPE.GOLD)
                {
                    Account.updateUserGold(ec.awardCnt);
                    //已经可以更新用户相关界面信息
                    onEventShowUserInfo(null);
                }
                else if (ec.type == CommonUtil.EmailContent.AWARD_TYPE.PROP)
                {
                    //重新请求一遍
                    msgReqPackageList package = new msgReqPackageList();
                    package.game = GameType.GAME_LIANQI;
                    ProtocolManager.getInstance().sendMsg(LobbyProtocol.P_LOBBY_REQ_PACKAGE_LIST, package, OnRespPackageList);
                }
            }
        }

        LobbyEvent.sV2C_ReqUpdateEmail re;
        re.id   = resp.awardEmailId;
        re.type = resp.type;
        LobbyEvent.EM().InvokeEvent(LobbyEvent.EVENT.SHOW_UPDATE_EMAIL_RESULT, (object)re);
    }