Beispiel #1
0
    // 创建一封邮件
    public void NewMail(Proto.MailData mail)
    {
        Transform tmpTran = Instantiate(mailPrefab);

        tmpTran.SetParent(mailParent, false);
        tmpTran.GetComponent <MailPrefab>().Init(mail);
        tmpTran.GetComponent <Toggle>().group = mailToggleGroup;
    }
Beispiel #2
0
 void SVR_onNewMail(string _msg)
 {
     Proto.MailData mail = JsonUtility.FromJson <Proto.MailData>(_msg);
     PlayerInfo.mails.Add(mail);
     if (commonCb.ContainsKey(CommonHandlerCb.onNewMail))
     {
         commonCb[CommonHandlerCb.onNewMail]?.Invoke(mail);
     }
 }
Beispiel #3
0
 // 删除邮件的回调
 void SVR_delMailBack(string _msg)
 {
     Proto.ReadMailRsp msg  = JsonUtility.FromJson <Proto.ReadMailRsp>(_msg);
     Proto.MailData    mail = FindMail(msg.id);
     if (mail == null)
     {
         return;
     }
     DeleteMail(mail);
 }
Beispiel #4
0
 // 邮件状态改变
 void ChangeMailStatus(Proto.MailData mail, int tmpStatus)
 {
     mail.status = tmpStatus;
     if (nowMail == mail)
     {
         nowMailObj.GetComponent <MailPrefab>().Init(mail);
     }
     else
     {
         Transform mailObj = mailParent.Find(mail.id.ToString());
         if (mailObj != null)
         {
             mailObj.GetComponent <MailPrefab>().Init(mail);
         }
     }
 }
Beispiel #5
0
 // 阅读邮件的回调
 void SVR_readMailBack(string _msg)
 {
     Proto.ReadMailRsp msg  = JsonUtility.FromJson <Proto.ReadMailRsp>(_msg);
     Proto.MailData    mail = FindMail(msg.id);
     if (mail == null)
     {
         return;
     }
     if (msg.code == 0)
     {
         ChangeMailStatus(mail, 1);
     }
     else if (msg.code == 1)
     {
         DeleteMail(mail);
     }
 }
Beispiel #6
0
    // 点击阅读邮件
    public void OnMailToggleClick(GameObject mailObj, Proto.MailData mail)
    {
        nowMailObj          = mailObj;
        nowMail             = mail;
        senderText.text     = mail.sendName;
        topicText.text      = mail.topic;
        expireTimeText.text = "到期时间:" + mail.expireTime;
        contentText.text    = mail.content;
        delBtn.gameObject.SetActive(true);

        if (mail.sendUid == 0)
        {
            responseBtn.SetActive(false);
        }
        else
        {
            responseBtn.SetActive(true);
        }

        if (mail.items.Count == 0)
        {
            getAwardBtn.gameObject.SetActive(false);
            InitMailAward(null);
        }
        else
        {
            getAwardBtn.gameObject.SetActive(true);
            if (mail.status == 2)
            {
                getAwardBtn.interactable = false;
            }
            else
            {
                getAwardBtn.interactable = true;
            }
            InitMailAward(mail.items);
        }

        if (mail.status == 0)
        {
            Proto.MailReq tmp = new Proto.MailReq();
            tmp.id  = mail.id;
            tmp.uid = mail.uid;
            SocketClient.SendMsg(Route.info_mail_readMail, tmp);
        }
    }
Beispiel #7
0
 // 当没有邮件被选中时,清除显示
 void NoMailSet()
 {
     if (nowMail != null)
     {
         return;
     }
     nowMail             = null;
     nowMailObj          = null;
     senderText.text     = "";
     topicText.text      = "";
     expireTimeText.text = "";
     contentText.text    = "";
     delBtn.gameObject.SetActive(false);
     getAwardBtn.gameObject.SetActive(false);
     responseBtn.SetActive(false);
     InitMailAward(null);
 }
Beispiel #8
0
 // 删除邮件
 void DeleteMail(Proto.MailData mail)
 {
     PlayerInfo.mails.Remove(mail);
     if (nowMail == mail)
     {
         nowMail = null;
         Destroy(nowMailObj);
         NoMailSet();
     }
     else
     {
         Transform mailObj = mailParent.Find(mail.id.ToString());
         if (mailObj != null)
         {
             Destroy(mailObj.gameObject);;
         }
     }
 }
Beispiel #9
0
 // 邮件领奖的回调
 void SVR_getMailAwardBack(string _msg)
 {
     Proto.ReadMailRsp msg  = JsonUtility.FromJson <Proto.ReadMailRsp>(_msg);
     Proto.MailData    mail = FindMail(msg.id);
     if (mail == null)
     {
         return;
     }
     if (msg.code == 0)
     {
         getAwardBtn.interactable = false;
         ChangeMailStatus(mail, 2);
         UIManager.instance.SetTileInfo("邮件奖励领取成功");
     }
     else if (msg.code == 1)
     {
         DeleteMail(mail);
     }
 }
Beispiel #10
0
    public void Init(Proto.MailData _mail)
    {
        mail            = _mail;
        gameObject.name = mail.id.ToString();
        transform.Find("sender").GetComponent <Text>().text = mail.sendName;
        transform.Find("time").GetComponent <Text>().text   = mail.createTime;
        if (mail.status != 0)
        {
            transform.Find("open").GetComponent <Image>().sprite = MailPanel.instance.mailReadImg;
        }

        if (mail.items.Count == 0)
        {
            transform.Find("item").gameObject.SetActive(false);
        }
        else if (mail.status == 2)
        {
            transform.Find("item").GetComponent <Image>().sprite = MailPanel.instance.boxOpenImg;
        }
    }