Пример #1
0
    public static ViewPlayerData BuildViewData(uint uid, string name, uint job, int level, uint sex = 0)
    {
        retData          = new ViewPlayerData();
        retData.job      = job;
        retData.sex      = sex;
        retData.userid   = uid;
        retData.username = name;
        table.RobotDataBase data = GameTableManager.Instance.GetTableItem <table.RobotDataBase>(job, level);
        if (data != null)
        {
            retData.power = data.power;

            retData.user_level = data.dwLevel;

            retData.viewRoleData       = new GameCmd.ViewRoleData();
            retData.viewRoleData.maxhp = (uint)(data.hp * 1.15f);
            retData.viewRoleData.maxsp = (uint)(data.mp * 1.15f);

            retData.viewRoleData.pdam_min = (uint)(data.pdam * 0.8f);
            retData.viewRoleData.pdam_max = (uint)(data.pdam * 1.15f);

            retData.viewRoleData.mdam_min = (uint)(data.mdam * 0.8f);
            retData.viewRoleData.mdam_max = (uint)(data.mdam * 1.15f);

            retData.viewRoleData.pdef_min = (uint)(data.mdef * 0.8f);
            retData.viewRoleData.pdef_max = (uint)(data.mdef * 1.15f);

            retData.viewRoleData.liliang      = data.liliang;
            retData.viewRoleData.minjie       = data.minjie;
            retData.viewRoleData.zhili        = data.zhili;
            retData.viewRoleData.tizhi        = data.tizhi;
            retData.viewRoleData.jingshen     = data.jingshen;
            retData.viewRoleData.esdam        = data.esdam;
            retData.viewRoleData.ssdam        = data.ssdam;
            retData.viewRoleData.lsdam        = data.lsdam;
            retData.viewRoleData.vsdam        = data.vsdam;
            retData.viewRoleData.lucky        = data.lucky;
            retData.viewRoleData.mlucky       = data.mlucky;
            retData.viewRoleData.criti_ratio  = data.criti_ratio;
            retData.viewRoleData.cure         = data.cure;
            retData.viewRoleData.phit         = data.phit;
            retData.viewRoleData.hide_per     = data.hide_per;
            retData.viewRoleData.pabs         = data.pabs;
            retData.viewRoleData.mabs         = data.mabs;
            retData.viewRoleData.harm_add_per = data.harm_add_per;
            retData.viewRoleData.harm_sub_per = data.harm_sub_per;

            List <uint> equipList = new List <uint>();

            /*1;    //  头盔
            *  2;    //  护肩
            *  3;    //  上衣
            *  4;    //  护腿
            *  5;    //  戒指
            *  7;    //  盾牌
            *  8;    //  武器
            *  9;    //  鞋子
            *  10;   //  护腕
            *  11;   //  腰带
            *  12;   //  披风
            *  13;   //  项链*/
            equipList.Add(data.Hat);
            equipList.Add(data.Shoulder);
            equipList.Add(data.Coat);
            equipList.Add(data.Leg);
            equipList.Add(data.Adornl_1);
            equipList.Add(data.Adornl_2);
            equipList.Add(data.Shield);
            equipList.Add(data.Equip);
            equipList.Add(data.Shoes);
            equipList.Add(data.Cuff);
            equipList.Add(data.Belf);
            equipList.Add(data.Necklace);

            GameCmd.ItemSerialize item = null;
            for (int i = 0; i < equipList.Count; i++)
            {
                if (equipList[i] == 0)
                {
                    continue;
                }
                table.ItemDataBase itemdb = GameTableManager.Instance.GetTableItem <table.ItemDataBase>(equipList[i]);
                if (itemdb == null)
                {
                    continue;
                }
                //GameCmd.eItemAttribute
                item            = new GameCmd.ItemSerialize();
                item.dwObjectID = equipList[i];

                GameCmd.EquipPos[] pos = EquipDefine.GetEquipPosByEquipType((GameCmd.EquipType)itemdb.subType);
                if (pos.Length == 2)
                {
                    uint loc = 0;
                    if (i == 4)
                    {
                        loc = ItemDefine.TransformLocal2ServerLocation(GameCmd.PACKAGETYPE.PACKAGETYPE_EQUIP, new UnityEngine.Vector2()
                        {
                            x = 0, y = (int)pos[0]
                        });
                    }
                    else if (i == 5)
                    {
                        loc = ItemDefine.TransformLocal2ServerLocation(GameCmd.PACKAGETYPE.PACKAGETYPE_EQUIP, new UnityEngine.Vector2()
                        {
                            x = 0, y = (int)pos[1]
                        });
                    }

                    item.pos = new GameCmd.tItemLocation()
                    {
                        loc = loc
                    };
                }
                else if (pos.Length == 1)
                {
                    uint loc = ItemDefine.TransformLocal2ServerLocation(GameCmd.PACKAGETYPE.PACKAGETYPE_EQUIP, new UnityEngine.Vector2()
                    {
                        x = 0, y = (int)pos[0]
                    });
                    item.pos = new GameCmd.tItemLocation()
                    {
                        loc = loc
                    };
                }
                item.dwNum = 1;
                item.numbers.Add(new GameCmd.PairNumber()
                {
                    id = (int)GameCmd.eItemAttribute.Item_Attribute_Bind, value = itemdb.bindMask
                });
                item.numbers.Add(new GameCmd.PairNumber()
                {
                    id = (int)GameCmd.eItemAttribute.Item_Attribute_Grade, value = itemdb.grade
                });

                table.EquipDataBase equipdb = GameTableManager.Instance.GetTableItem <table.EquipDataBase>(itemdb.itemID);
                if (equipdb == null)
                {
                    continue;
                }
                item.numbers.Add(new GameCmd.PairNumber()
                {
                    id = (int)GameCmd.eItemAttribute.Item_Attribute_Dur, value = equipdb.maxDurable
                });
                item.numbers.Add(new GameCmd.PairNumber()
                {
                    id = (int)GameCmd.eItemAttribute.Item_Attribute_HoleNum, value = 0
                });
                item.numbers.Add(new GameCmd.PairNumber()
                {
                    id = (int)GameCmd.eItemAttribute.Item_Attribute_FightPower, value = equipdb.fightPower
                });

                retData.itemList.Add(item);

                if (equipdb.act_show != 0)
                {
                    table.SuitDataBase suitDb = GameTableManager.Instance.GetTableItem <table.SuitDataBase>(equipdb.act_show, 1);
                    if (suitDb != null)
                    {
                        retData.suit_data.Add(new GameCmd.SuitData()
                        {
                            baseid = suitDb.base_id, suit_type = (GameCmd.EquipSuitType)suitDb.type
                        });
                    }
                }
            }
        }

        return(retData);
    }
Пример #2
0
    public void OnReceiveAllSuitData(stSendAllSuitPropertyUserCmd_S msg)
    {
        IPlayer player = MainPlayerHelper.GetMainPlayer();

        if (player == null)
        {
            Log.Error("收到所有时装数据 但是还没有主角创建");
            return;
        }
        uint userID = player.GetID();
        List <stSuitData> suitList = msg.data;
        string            suitName = "";

        for (int i = 0; i < suitList.Count; i++)
        {
            stSuitData     sd  = suitList[i];
            ClientSuitData csd = new ClientSuitData();
            csd.suitBaseID = sd.base_id;
            csd.leftTime   = sd.time;
            Client.GameEventID eventtype = Client.GameEventID.Unknow;
            if (sd.status == SuitStatus.SuitStatus_Common)
            {
                csd.suitState = SuitState.HasBuy;
                AddSuitData(userID, sd.base_id, csd);
                //直接装备
                if (msg.type == SuitOPType.SuitOPType_Buy || msg.type == SuitOPType.SuitOPType_Renew)
                {
                    stOpSuitPropertyUserCmd_C cmd = new stOpSuitPropertyUserCmd_C();
                    cmd.type = SuitOPType.SuitOPType_Equip;
                    //固定3当装备
                    cmd.suit_id = (sd.base_id << 16) + 3;
                    NetService.Instance.Send(cmd);
                }
            }
            else if (sd.status == SuitStatus.SuitStatus_Equip)
            {
                csd.suitState = SuitState.Equip;
                AddSuitData(userID, sd.base_id, csd);
            }
            else if (sd.status == SuitStatus.SuitStatus_Overdue)
            {
                csd.suitState = SuitState.NoEffect;
                AddSuitData(userID, sd.base_id, csd);
            }
            else if (sd.status == SuitStatus.SuitStatus_Acti)
            {
                csd.suitState = SuitState.Active;
                AddSuitData(userID, sd.base_id, csd);
            }
            else if (sd.status == SuitStatus.SuitStatus_UNActi)
            {
                csd.suitState = SuitState.Show;
                AddSuitData(userID, sd.base_id, csd);
            }
            table.SuitDataBase db = GameTableManager.Instance.GetTableItem <table.SuitDataBase>(sd.base_id, 1);
            if (db != null)
            {
                suitName = db.name;
            }

            Engine.Utility.EventEngine.Instance().DispatchEvent((int)Client.GameEventID.UIEVENTFASHIONDATA, sd.base_id);
            //SendChangeBody((int)sd.type, sd.base_id, player);
        }

        ShowTips(msg.type, suitName);
    }