Exemple #1
0
    public override void Info(object obj)
    {
        item = (MailAccessoryData)obj;
        if (null != obj)
        {
            if (item.ItemType == 6 || item.ItemType == 3)
            {
                debris.gameObject.SetActive(true);
            }
            else
            {
                debris.gameObject.SetActive(false);
            }
            if (item.ItemType == 3)
            {
                debris.GetComponent <UISprite>().spriteName = "materialdebris";
                debris.GetComponent <UISprite>().MakePixelPerfect();
            }
            else if (item.ItemType == 6)
            {
                debris.GetComponent <UISprite>().spriteName = "linghunshi";
                debris.GetComponent <UISprite>().MakePixelPerfect();
            }
            icon.GetComponent <UISprite>().atlas = item.UiAtlas;
            if (GameLibrary.Instance().ItemStateList.ContainsKey(item.Id))
            {
                icon.spriteName = GameLibrary.Instance().ItemStateList[item.Id].icon_name;
            }

            if (item.Type == MailGoodsType.ItemType)
            {
                count.text = item.Count.ToString();
            }
            else if (item.Type == MailGoodsType.GoldType)
            {
                count.text      = item.Gold.ToString();
                icon.spriteName = "jinbi";
            }
            else if (item.Type == MailGoodsType.DiamomdType)
            {
                count.text      = item.Diamond.ToString();
                icon.spriteName = "zuanshi";
            }

            if (item.IsHaveGet)
            {
                getMask.gameObject.SetActive(true);
            }
            else
            {
                getMask.gameObject.SetActive(false);
            }
            sprite.spriteName = ItemData.GetFrameByGradeType(item.GradeType);
        }
    }
Exemple #2
0
    /// <summary>
    /// 服务器回调:获取所有邮箱信息列表
    /// </summary>
    /// <param name="packet"></param>
    /// <returns></returns>

    private bool AllMailListResult(CReadPacket packet)
    {
        //{msgid=4602,ret=返回值,desc=返回描述,start=开始邮件索引,cc=当前个数,mct=最大个数,mail=[{idx=邮件ID,sn=发信人昵称,tit=标题,c=内容,mt=主类型,st=类型,ct=创建时间,ot=结束时间,nf=新邮件标志,item={id=物品id,at=数量},gold=邮件附带金币,diamond=邮件附带钻石},{}..{}]}

        Dictionary <string, object> data = packet.data;
        int resolt = int.Parse(data["ret"].ToString());

        if (resolt == 0)
        {
            object[] mailItem = data["mail"] as object[];
            if (mailItem != null)
            {
                playerData.GetInstance().mailData.mailItemList.Clear();//清空一下邮件列表
                playerData.GetInstance().mailData.unReadMailCount = 0;
                playerData.GetInstance().mailData.startIndex = int.Parse(data["start"].ToString());
                playerData.GetInstance().mailData.currentCount = int.Parse(data["count"].ToString());
                playerData.GetInstance().mailData.maxCount = int.Parse(data["maxCount"].ToString());
                for (int i = 0; i < mailItem.Length; i++)
                {
                    Dictionary <string, object> mailItemDataDic = mailItem[i] as Dictionary <string, object>;
                    MailItemData mailItemData = new MailItemData();
                    mailItemData.Id             = long.Parse(mailItemDataDic["idx"].ToString());
                    mailItemData.NiceName       = mailItemDataDic["sn"].ToString();
                    mailItemData.Title          = mailItemDataDic["tt"].ToString();
                    mailItemData.Content        = mailItemDataDic["c"].ToString();
                    mailItemData.MainType       = mailItemDataDic["mt"].ToString();
                    mailItemData.Type           = mailItemDataDic["st"].ToString();
                    mailItemData.IsHaveGetGoods = int.Parse(mailItemDataDic["dit"].ToString());
                    mailItemData.CreatTime      = long.Parse(mailItemDataDic["ct"].ToString());
                    mailItemData.EndTime        = long.Parse(mailItemDataDic["ot"].ToString());
                    mailItemData.NewMailFlag    = int.Parse(mailItemDataDic["nf"].ToString());
                    if (mailItemData.NewMailFlag == 1)
                    {
                        playerData.GetInstance().mailData.unReadMailCount++;
                    }
                    int goldcount    = int.Parse(mailItemDataDic["gold"].ToString());
                    int diamondcount = int.Parse(mailItemDataDic["diamond"].ToString());
                    mailItemData.accessoryDataList.Clear();//清空一下附件物品list
                    if (goldcount > 0)
                    {
                        MailAccessoryData accessoryData = new MailAccessoryData();
                        accessoryData.Type      = MailGoodsType.GoldType;
                        accessoryData.Gold      = goldcount;
                        accessoryData.Diamond   = 0;
                        accessoryData.GradeType = GradeType.Green;
                        if (mailItemData.IsHaveGetGoods == 1)
                        {
                            accessoryData.IsHaveGet = false;
                        }
                        else
                        {
                            accessoryData.IsHaveGet = true;
                        }
                        accessoryData.UiAtlas = ResourceManager.Instance().GetUIAtlas("Prop");
                        mailItemData.accessoryDataList.Add(accessoryData);
                    }
                    if (diamondcount > 0)
                    {
                        MailAccessoryData accessoryData = new MailAccessoryData();
                        accessoryData.Type      = MailGoodsType.DiamomdType;
                        accessoryData.Diamond   = diamondcount;
                        accessoryData.Gold      = 0;
                        accessoryData.GradeType = GradeType.Green;
                        if (mailItemData.IsHaveGetGoods == 1)
                        {
                            accessoryData.IsHaveGet = false;
                        }
                        else
                        {
                            accessoryData.IsHaveGet = true;
                        }
                        accessoryData.UiAtlas = ResourceManager.Instance().GetUIAtlas("Prop");
                        mailItemData.accessoryDataList.Add(accessoryData);
                    }

                    object[] itemList = mailItemDataDic["item"] as object[];
                    if (itemList != null)
                    {
                        for (int j = 0; j < itemList.Length; j++)
                        {
                            Dictionary <string, object> itemDataDic   = itemList[j] as Dictionary <string, object>;
                            MailAccessoryData           accessoryData = new MailAccessoryData();
                            accessoryData.Type  = MailGoodsType.ItemType;
                            accessoryData.Id    = int.Parse(itemDataDic["id"].ToString());
                            accessoryData.Count = long.Parse(itemDataDic["at"].ToString());
                            if (mailItemData.IsHaveGetGoods == 1)
                            {
                                accessoryData.IsHaveGet = false;
                            }
                            else
                            {
                                accessoryData.IsHaveGet = true;
                            }
                            switch (GameLibrary.Instance().ItemStateList[accessoryData.Id].grade) //(VOManager.Instance().GetCSV<ItemCSV>("Item").GetVO(accessoryData.Id).grade)
                            {
                            case 1:
                                accessoryData.GradeType = GradeType.Gray;
                                break;

                            case 2:
                                accessoryData.GradeType = GradeType.Green;
                                break;

                            case 4:
                                accessoryData.GradeType = GradeType.Blue;
                                break;

                            case 7:
                                accessoryData.GradeType = GradeType.Purple;
                                break;

                            case 11:
                                accessoryData.GradeType = GradeType.Orange;
                                break;

                            case 16:
                                accessoryData.GradeType = GradeType.Red;
                                break;
                            }
                            ItemNodeState itemnodestate = null;
                            if (GameLibrary.Instance().ItemStateList.ContainsKey(accessoryData.Id))
                            {
                                itemnodestate          = GameLibrary.Instance().ItemStateList[accessoryData.Id];
                                accessoryData.ItemType = itemnodestate.types;
                                if (itemnodestate.types == 6)
                                {
                                    accessoryData.UiAtlas = ResourceManager.Instance().GetUIAtlas("UIHeroHead");
                                }
                                else
                                {
                                    accessoryData.UiAtlas = ResourceManager.Instance().GetUIAtlas("Prop");
                                }
                            }

                            mailItemData.accessoryDataList.Add(accessoryData);
                        }
                    }
                    playerData.GetInstance().mailData.mailItemList.Add(mailItemData);
                }
                if (SceneManager.GetActiveScene().name == GameLibrary.UI_Major)
                {
                    //playerData.GetInstance().NewMailHandler(playerData.GetInstance().mailData.unReadMailCount);
                    //Control.ShowGUI(UIPanleID.UIMail);
                    //Control.ShowGUI(GameLibrary.UIMailPanel);
                }
            }
        }
        else
        {
            Debug.Log(string.Format("获取邮箱列表失败:{0}", data["desc"].ToString()));
        }
        return(true);
    }
Exemple #3
0
    /// <summary>
    /// 服务器回调:获得单个邮箱信息
    /// </summary>
    /// <param name="packet"></param>
    /// <returns></returns>
    private bool SingleMailInfoResult(CReadPacket packet)
    {
        Debug.Log("SingleMailInfoResult");
        Dictionary <string, object> data = packet.data;
        int resolt = int.Parse(data["ret"].ToString());

        if (resolt == 0)
        {
            //object[] mailItem = data["mail"] as object[];
            Dictionary <string, object> mailItem = data["mail"] as Dictionary <string, object>;
            if (mailItem != null)
            {
                MailItemData mailItemData = new MailItemData();
                mailItemData.Id             = long.Parse(mailItem["idx"].ToString());
                mailItemData.NiceName       = mailItem["sn"].ToString();
                mailItemData.Title          = mailItem["tit"].ToString();
                mailItemData.Content        = mailItem["c"].ToString();
                mailItemData.MainType       = mailItem["mt"].ToString();
                mailItemData.Type           = mailItem["st"].ToString();
                mailItemData.IsHaveGetGoods = int.Parse(mailItem["dit"].ToString());
                mailItemData.CreatTime      = long.Parse(mailItem["ct"].ToString());
                mailItemData.EndTime        = long.Parse(mailItem["ot"].ToString());
                mailItemData.NewMailFlag    = int.Parse(mailItem["nf"].ToString());
                if (mailItemData.NewMailFlag == 1)
                {
                    playerData.GetInstance().mailData.unReadMailCount++;
                }
                int goldcount    = int.Parse(mailItem["gold"].ToString());
                int diamondcount = int.Parse(mailItem["diamond"].ToString());
                mailItemData.accessoryDataList.Clear();//清空一下附件物品list
                if (goldcount > 0)
                {
                    MailAccessoryData accessoryData = new MailAccessoryData();
                    accessoryData.Type      = MailGoodsType.GoldType;
                    accessoryData.Gold      = goldcount;
                    accessoryData.Diamond   = 0;
                    accessoryData.GradeType = GradeType.Green;
                    if (mailItemData.IsHaveGetGoods == 1)
                    {
                        accessoryData.IsHaveGet = false;
                    }
                    else
                    {
                        accessoryData.IsHaveGet = true;
                    }
                    accessoryData.UiAtlas = ResourceManager.Instance().GetUIAtlas("Prop");
                    mailItemData.accessoryDataList.Add(accessoryData);
                }
                if (diamondcount > 0)
                {
                    MailAccessoryData accessoryData = new MailAccessoryData();
                    accessoryData.Type      = MailGoodsType.DiamomdType;
                    accessoryData.Diamond   = diamondcount;
                    accessoryData.Gold      = 0;
                    accessoryData.GradeType = GradeType.Green;
                    if (mailItemData.IsHaveGetGoods == 1)
                    {
                        accessoryData.IsHaveGet = false;
                    }
                    else
                    {
                        accessoryData.IsHaveGet = true;
                    }
                    accessoryData.UiAtlas = ResourceManager.Instance().GetUIAtlas("Prop");
                    mailItemData.accessoryDataList.Add(accessoryData);
                }

                object[] itemList = mailItem["item"] as object[];
                if (itemList != null)
                {
                    for (int j = 0; j < itemList.Length; j++)
                    {
                        Dictionary <string, object> itemDataDic   = itemList[j] as Dictionary <string, object>;
                        MailAccessoryData           accessoryData = new MailAccessoryData();
                        accessoryData.Type  = MailGoodsType.ItemType;
                        accessoryData.Id    = int.Parse(itemDataDic["id"].ToString());
                        accessoryData.Count = long.Parse(itemDataDic["at"].ToString());
                        if (mailItemData.IsHaveGetGoods == 1)
                        {
                            accessoryData.IsHaveGet = false;
                        }
                        else
                        {
                            accessoryData.IsHaveGet = true;
                        }
                        switch (GameLibrary.Instance().ItemStateList[accessoryData.Id].grade) //(VOManager.Instance().GetCSV<ItemCSV>("Item").GetVO(accessoryData.Id).grade)
                        {
                        case 1:
                            accessoryData.GradeType = GradeType.Gray;
                            break;

                        case 2:
                            accessoryData.GradeType = GradeType.Green;
                            break;

                        case 4:
                            accessoryData.GradeType = GradeType.Blue;
                            break;

                        case 7:
                            accessoryData.GradeType = GradeType.Purple;
                            break;

                        case 11:
                            accessoryData.GradeType = GradeType.Orange;
                            break;

                        case 16:
                            accessoryData.GradeType = GradeType.Red;
                            break;
                        }
                        ItemNodeState itemnodestate = null;
                        if (GameLibrary.Instance().ItemStateList.ContainsKey(accessoryData.Id))
                        {
                            itemnodestate          = GameLibrary.Instance().ItemStateList[accessoryData.Id];
                            accessoryData.ItemType = itemnodestate.types;
                            if (itemnodestate.types == 6 || itemnodestate.types == 7)
                            {
                                accessoryData.UiAtlas = ResourceManager.Instance().GetUIAtlas("UIHeroHead");
                            }
                            else
                            {
                                accessoryData.UiAtlas = ResourceManager.Instance().GetUIAtlas("Prop");
                            }
                        }

                        mailItemData.accessoryDataList.Add(accessoryData);
                    }
                }
                playerData.GetInstance().mailData.mailItemList.Insert(0, mailItemData);
                playerData.GetInstance().mailData.currentCount++;
                playerData.GetInstance().mailData.maxCount++;//服务器第一次给的最大值和邮箱当前数量一样,所以暂时也++,
                //if (Singleton<SceneManage>.Instance.Current == EnumSceneID.UI_MajorCity01)
                //{
                //    playerData.GetInstance().NewMailHandler(playerData.GetInstance().mailData.unReadMailCount);
                //    //Control.ShowGUI(GameLibrary.UIMail);
                //    //if (Control.GetGUI(GameLibrary.UIMailPanel).gameObject.activeSelf)
                //    //{
                //    //    UIMailPanel.Instance.InitMailItemData();
                //    //}
                //}

                //未打开邮箱界面 只增加新邮件信息和更新界面数量提示即可
                //如果推送新邮件时 邮箱界面在打开界面,刷新一下邮箱内容
            }
            //playerData.GetInstance().mailData.unReadMailCount = 0;
            //playerData.GetInstance().mailData.startIndex = int.Parse(data["start"].ToString());
            //playerData.GetInstance().mailData.currentCount = int.Parse(data["count"].ToString());
            //playerData.GetInstance().mailData.maxCount = int.Parse(data["maxCount"].ToString());
        }
        else
        {
            Debug.Log(string.Format("获取单个邮箱信息失败:{0}", data["desc"].ToString()));
        }

        return(true);
    }