Beispiel #1
0
    private void OnRoleLevelUpgrade(byte[] buffer)
    {
        PRoleList ret = Net.Deserialize <PRoleList>(buffer);

        if (!Net.CheckErrorCode(ret.errorCode, eCommand.PUSH_ROLELEVEL_UPGRADE))
        {
            return;
        }

        if (ret.roleAttr != null)
        {
            Deserialize(ret.roleAttr);
        }

        if (ret.heroAttr != null)
        {
            HeroInfo heroInfo = GetHeroInfo(ret.heroAttr.heroId);
            if (heroInfo != null)
            {
                heroInfo.Deserialize(ret.heroAttr, false);
            }
        }

        UIManager.Instance.RefreshWindow <UINewHeroView>();
        EventDispatcher.TriggerEvent(EventID.EVENT_UI_MAIN_REFRESH_VALUE);
    }
Beispiel #2
0
    public void Deserialize(PPlayerInfo data)
    {
        if (data.pBattlePT.Count < 2)
        {
            Log.Error("Error Battle Formation");
            return;
        }

        // pvp的阵型数据
        PBattlePT formation = data.pBattlePT[1];

        // 英雄
        HeroList.Clear();
        foreach (var item in formation.heroPT)
        {
            HeroInfo info = new HeroInfo();
            info.Deserialize(item.hero, false);
            HeroList.Add(info);
        }

        SoldierList.Clear();
        foreach (var item in formation.buildPT)
        {
            BuildingInfo binfo = CityManager.Instance.CreateBuilding(item.build.cfgId);
            if (binfo == null)
            {
                continue;
            }

            TroopBuildingInfo tbinfo = binfo as TroopBuildingInfo;
            if (tbinfo != null)
            {
                // TODO 暂时只处理兵营数据,将来再处理校场,校场含有士兵等级数据
                binfo.Deserialize(item.build);

                SoldierInfo info = new SoldierInfo();
                info.ConfigID = tbinfo.SoldierConfigID;
                SoldierList.Add(info);
            }


            if (binfo.BuildingType == CityBuildingType.TRAIN)
            {
                // 校场,持有士兵等级数据
            }
            else if (binfo.BuildingType == CityBuildingType.TROOP)
            {
                // 兵营
            }
        }
    }
Beispiel #3
0
    public void OnMsgCreateHero(byte[] buffer)
    {
        PHeroAttr ret = Net.Deserialize <PHeroAttr>(buffer);

        if (!Net.CheckErrorCode(ret.errorCode, eCommand.CREATE_HERO))
        {
            return;
        }

        HeroInfo info = new HeroInfo();

        info.Deserialize(ret, false);
        UserManager.Instance.HeroList.Add(info);

        Log.Info("添加英雄:" + ret.heroId);
    }
Beispiel #4
0
    // 卸下装备
    public bool RequestTakeOffEquip(long heroID, long itemID)
    {
        HeroInfo heroInfo = GetHeroInfo(heroID);

        if (heroInfo == null)
        {
            return(false);
        }

        PUseCommonItem builder = new PUseCommonItem();

        builder.heroId = heroID;

        ItemInfo itemInfo = heroInfo.GetItem(itemID);

        if (itemInfo == null)
        {
            return(false);
        }

        PComItem ibuilder = new PComItem();

        ibuilder.id = itemID;
        builder.comItem.Add(ibuilder);

        NetworkManager.Instance.Send(eCommand.FIT_DOWN_EQUIP, builder, (buffer) => {
            PHeroAttr ret = Net.Deserialize <PHeroAttr>(buffer);
            if (!Net.CheckErrorCode(ret.errorCode, eCommand.FIT_DOWN_EQUIP))
            {
                return;
            }

            // 把装备放到背包里
            AddItem(itemInfo, false);

            heroInfo.Deserialize(ret, true);

            UIManager.Instance.RefreshWindow <UINewHeroView>();
            UIManager.Instance.RefreshWindow <UINewHeroListView>();
        });
        return(true);
    }
Beispiel #5
0
    //吃经验书增加英雄经验
    public void RequestUseExpBook(long heroID, long itemID, int number)
    {
        HeroInfo info = GetHeroInfo(heroID);

        if (info == null)
        {
            return;
        }

        // 英雄等级不能超过玩家的等级
        if (info.Level >= Level)
        {
            UIUtil.ShowMsgFormat("MSG_HERO_PLAYER_LEVEL_LIMIT");
            return;
        }

        PUsedExpBook builder = new PUsedExpBook();

        builder.heroId  = heroID;
        builder.goodId  = itemID;
        builder.goodNum = number;

        NetworkManager.Instance.Send(eCommand.USED_EXPBOOK, builder, (buffer) => {
            PHeroAttr ret = Net.Deserialize <PHeroAttr>(buffer);
            if (!Net.CheckErrorCode(ret.errorCode, eCommand.USED_EXPBOOK))
            {
                return;
            }

            info.Deserialize(ret, true);

            UseItem(itemID, number);

            UIManager.Instance.RefreshWindow <UINewHeroView>();
            UIManager.Instance.RefreshWindow <UINewHeroListView>();
            UIManager.Instance.RefreshWindow <UISelectHeroView>();
        });
    }
Beispiel #6
0
    // 请求穿戴装备
    public bool RequestEquipItem(long heroID, long itemID)
    {
        HeroInfo heroInfo = GetHeroInfo(heroID);

        if (heroInfo == null)
        {
            return(false);
        }

        if (heroInfo.GetItem(itemID) != null)
        {
            // 已经装备
            return(false);
        }

        ItemInfo itemInfo = GetItem(itemID);

        if (itemInfo == null)
        {
            // 没有物品
            return(false);
        }

        if (itemInfo.Cfg.Level > heroInfo.Level)
        {
            // 等级不足
            UIUtil.ShowMsgFormat("MSG_HERO_LEVEL_LIMIT");
            return(false);
        }

        PUseCommonItem builder = new PUseCommonItem();

        builder.heroId = heroID;

        PComItem ibuilder = new PComItem();

        ibuilder.id = itemInfo.EntityID;
        builder.comItem.Add(ibuilder);

        NetworkManager.Instance.Send(eCommand.FIT_UP_EQUIP, builder, (buffer) => {
            PHeroAttr ret = Net.Deserialize <PHeroAttr>(buffer);
            if (!Net.CheckErrorCode(ret.errorCode, eCommand.FIT_UP_EQUIP))
            {
                return;
            }

            // 把旧装备放在背包里面
            ItemInfo oldItemInfo = heroInfo.GetItemByType((ItemType)itemInfo.Cfg.Type);
            if (oldItemInfo != null)
            {
                AddItem(oldItemInfo, false);
                heroInfo.EquipedItem.Remove(oldItemInfo);
            }

            // 同步英雄属性
            heroInfo.Deserialize(ret, true);

            // 移除背包内的装备
            UseItem(itemID, 1);

            UIManager.Instance.RefreshWindow <UINewHeroView>();
            UIManager.Instance.RefreshWindow <UINewHeroListView>();
        });

        return(true);
    }
Beispiel #7
0
    // 英雄升星
    public void RequestHeroUpgradeStar(long heroID)
    {
        HeroInfo info = GetHeroInfo(heroID);

        if (info == null)
        {
            return;
        }

        if (info.StarLevel >= GameConfig.MAX_HERO_STAR)
        {
            // 已经最高星了,无法继续升级
            UIUtil.ShowMsgFormat("MSG_HERO_STAR_MAX");
            return;
        }

        if (!CheckHeroUpgradeStarItem(info))
        {
            UIUtil.ShowMsgFormat("MSG_HERO_UPGRADE_STAR_LIMIT");
            return;
        }

        PCMLong builder = new PCMLong();

        builder.arg = heroID;

        NetworkManager.Instance.Send(eCommand.HERO_UPGRADE_STAR, builder, (buffer) =>
        {
            PHeroAttr ret = Net.Deserialize <PHeroAttr>(buffer);
            Log.Info("英雄升星成功");
            if (!Net.CheckErrorCode(ret.errorCode, eCommand.HERO_UPGRADE_STAR))
            {
                return;
            }

            HeroInfo heroInfo = GetHeroInfo(heroID);
            if (heroInfo == null)
            {
                return;
            }

            int starCost      = GetHeroStarUpgradeCost(heroInfo.ConfigID, heroInfo.StarLevel);
            ItemInfo itemInfo = GetItemByConfigID(heroInfo.Cfg.Cost);
            if (itemInfo == null || itemInfo.Number < starCost)
            {
                Log.Error("碎片不足");
                return;
            }

            HeroInfo oriHeroInfo = heroInfo.Clone();

            // 同步服务器数据 主要是获取新的技能
            heroInfo.Deserialize(ret, false);

            UseItemByConfigID(heroInfo.Cfg.Cost, starCost);

            UIManager.Instance.RefreshWindow <UINewHeroView>();
            UIManager.Instance.RefreshWindow <UINewHeroListView>();

            UIManager.Instance.OpenWindow <UIHeroStarRisingSuccView>(oriHeroInfo, heroInfo);
        });
    }
Beispiel #8
0
    public void Deserialize(PPlayerInfo data)
    {
        EntityID     = data.roleAttrs.roleId;
        RoleConfigID = data.roleAttrs.roleCfgId;
        RoleName     = data.roleAttrs.roleName;
        Sex          = (int)data.roleAttrs.sex;
        Level        = data.roleAttrs.level;
        Exp          = data.roleAttrs.xiuwei;
        VipLevel     = data.roleAttrs.vipLevel;
        SP           = data.roleAttrs.energy;

        Wood  = data.assertAttr.wood;
        Stone = data.assertAttr.stone;
        Money = data.assertAttr.gold;
        Gold  = data.assertAttr.yuanbao;

        //Forage = data.assertAttr.forage;

        // 英雄
        HeroList.Clear();
        foreach (var item in data.heroAttrs)
        {
            HeroInfo info = new HeroInfo();
            info.Deserialize(item, false);
            HeroList.Add(info);
        }

        // 初始化物品
        ItemList.Clear();
        foreach (var item in data.itemList)
        {
            ItemInfo info = new ItemInfo();
            info.Deserialize(item);
            ItemList.Add(info);
        }

        PVEHeroList.Clear();
        foreach (var item in data.pBattlePT)
        {
            if (item.type == eLineUpType.BT_PVE)
            {
                foreach (var hero in item.heroPT)
                {
                    HeroInfo heroInfo = GetHeroInfo(hero.hero.heroId);
                    if (heroInfo != null)
                    {
                        // 上阵英雄
                        PVEHeroList.Add(heroInfo);
                    }
                }
                break;
            }
        }

        // 战斗力和战功牌
        BattleFeats = data.roleAttrs.battleFeat;

        EventDispatcher.TriggerEvent(EventID.EVENT_UI_MAIN_REFRESH_VALUE);

        UIManager.Instance.RefreshWindow <UINewBagView>();
    }