예제 #1
0
    private void OnReq_UpgradePet(MessageRecv obj)
    {
        System.IO.MemoryStream ms  = new System.IO.MemoryStream(obj.Data);
        ReqUpgradePet          req = Serializer.Deserialize <ReqUpgradePet>(ms);

        AckUpgradePet ack = new AckUpgradePet();

        ack.ID = req.ID;
        ack.UseItems.AddRange(req.UseItems);
        NetworkManager.Instance.Send(MessageID.MSG_ACK_UPGRADE_PET, ack, 0, 0);
    }
예제 #2
0
    public void TryUpgradePet(int id, List <XItem> items)
    {
        if (items == null || items == null)
        {
            GTItemHelper.ShowTip("缺少食物");
            return;
        }
        for (int i = 0; i < items.Count; i++)
        {
            if (MLPet.Instance.IsFood(items[i].Id) == false)
            {
                GTItemHelper.ShowTip("加入的食品列表有误");
                return;
            }
        }
        DActor db   = ReadCfgActor.GetDataById(id);
        XPet   data = DataDBSPet.GetDataById(id);

        if (data != null)
        {
            int count = 0;
            foreach (var current in ReadCfgPetLevel.Dict)
            {
                if (current.Value.Quality == db.Quality)
                {
                    count++;
                }
            }

            if (data.Level >= count)
            {
                GTItemHelper.ShowTip("宠物等级已满");
                return;
            }
        }

        ReqUpgradePet req = new ReqUpgradePet();

        req.ID = id;
        req.UseItems.AddRange(items);
        NetworkManager.Instance.Send <ReqUpgradePet>(MessageID.MSG_REQ_UPGRADE_PET, req);
    }