Ejemplo n.º 1
0
        public void ProcessAddRoleData_Item(byte[] data)
        {
            GameBase.Network.Internal.AddRoleData_Item info = new GameBase.Network.Internal.AddRoleData_Item();
            info.Create(data);
            uint _key = 0;

            if (!Data.AddRoleData_Item(info, ref _key))
            {
                Log.Instance().WriteLog("保存角色物品信息失败,角色id:" + info.item.playerid.ToString());
            }
            GameBase.Network.Internal.AddRoleData_Item_Ret ret = new GameBase.Network.Internal.AddRoleData_Item_Ret();
            ret.id     = _key;
            ret.gameid = info.gameid;
            ret.sordid = info.sortid;
            SessionManager.Instance().SendMapServer(0, ret.GetBuffer());
        }
Ejemplo n.º 2
0
        public static bool AddRoleData_Item(GameBase.Network.Internal.AddRoleData_Item info, ref uint nkey)
        {
            try
            {
                info.item.forgename = Coding.GB2312ToLatin1(info.item.forgename);
                MySqlCommand command;
                String       sql = String.Format(MysqlString.SAVEROLE_ITEM, info.item.playerid, info.item.itemid, info.item.postion, info.item.stronglv, info.item.gem1,
                                                 info.item.gem2, info.item.forgename, info.item.amount, info.item.war_ghost_exp, info.item.di_attack, info.item.shui_attack, info.item.huo_attack, info.item.feng_attack,
                                                 info.item.property, info.item.gem3, info.item.god_exp, info.item.god_strong);
                String utf_sql = sql;
                command = new MySqlCommand(utf_sql, MysqlConn.GetConn());
                MysqlConn.Conn_Open();
                command.ExecuteNonQuery();

                MysqlConn.Conn_Close();
                command.Dispose();

                //取主键-- 不能用于多线程或者多个程序操作该数据库。。切记
                String _key = "select max(id) from cq_item";
                command = new MySqlCommand(_key, MysqlConn.GetConn());
                MysqlConn.Conn_Open();
                MySqlDataReader reader = command.ExecuteReader();
                nkey = 0;
                reader.Read();
                if (reader.HasRows)
                {
                    nkey = reader.GetUInt32(0);
                }
                MysqlConn.Conn_Close();
                command.Dispose();
            }
            catch (System.Exception ex)
            {
                Log.Instance().WriteLog("createrole error!");
                Log.Instance().WriteLog(ex.Message);
                Log.Instance().WriteLog(ex.StackTrace);
                return(false);
            }

            return(true);
        }
Ejemplo n.º 3
0
        //这个函数用于玩家丢弃的道具,然后又捡起来应用..所以不叠加
        public GameStruct.RoleItemInfo AwardItem(GameStruct.RoleItemInfo info)
        {
            if (IsGold(info.itemid))
            {
                play.ChangeAttribute(GameStruct.UserAttribute.GOLD, info.property);
                play.LeftNotice(string.Format("获得{0}金币!", info.property));
                return null;
            }
            GameStruct.ItemTypeInfo baseitem = ConfigManager.Instance().GetItemTypeInfo(info.itemid);
            if (baseitem == null)
            {
                Log.Instance().WriteLog("创建道具失败,道具不存在 id:" + info.itemid.ToString());
                //  return null;
                if (!GameServer.IsTestMode()) return null;
                baseitem = new GameStruct.ItemTypeInfo();
                baseitem.id = info.itemid;
            }
            uint key = (uint)mDicAddItem.Count + 1;

            GameStruct.RoleItemInfo item = new GameStruct.RoleItemInfo();
            item.itemid = baseitem.id;
            item.postion = info.postion;
            item.stronglv = info.stronglv;
            item.gemcount = info.gemcount;
            item.amount = info.amount;
            item.gem1= info.gem1;
            item.gem2 = info.gem2;
            item.forgename = info.forgename;
            item.war_ghost_exp = info.war_ghost_exp;
            item.di_attack = info.di_attack;
            item.huo_attack = info.huo_attack;
            item.shui_attack = info.shui_attack;
            item.feng_attack = info.feng_attack;
            item.property = info.property;
            item.gem3 = info.gem3;
            item.god_strong = info.god_strong;
            item.god_exp = info.god_exp;

            item.typeid = info.typeid;
            mDicAddItem[key] = item;

            //发给dbserver 通知增加这个道具
            GameBase.Network.Internal.AddRoleData_Item dbitem = new GameBase.Network.Internal.AddRoleData_Item();
            dbitem.item.playerid = play.GetBaseAttr().player_id;
            dbitem.gameid = play.GetGameID();
            dbitem.item.postion = item.postion;
            dbitem.item.itemid = item.itemid;
            dbitem.item.stronglv = item.stronglv;

            dbitem.item.amount = item.amount;
            dbitem.item.gem1 = item.gem1;
            dbitem.item.gem2 = item.gem2;
            dbitem.item.forgename = item.forgename;
            dbitem.item.war_ghost_exp = item.war_ghost_exp;
            dbitem.item.di_attack = item.di_attack;
            dbitem.item.huo_attack = item.huo_attack;
            dbitem.item.shui_attack = item.shui_attack;
            dbitem.item.feng_attack = item.feng_attack;
            dbitem.item.property = item.property;
            dbitem.item.gem3 = item.gem3;
            dbitem.item.god_strong = item.god_strong;
            dbitem.item.god_exp = item.god_exp;
            dbitem.sortid = key;
            DBServer.Instance().GetDBClient().SendData(dbitem.GetBuffer());
            return item;
        }
Ejemplo n.º 4
0
        //public RoleData_Eudemon AwardEudemon(uint itemid)
        //{
        //}
        //创建物品参数说明
        //postion:道具位置
        //amount:数量
        //stronglv: 强化等级
        //gem1: 第一洞宝石 255为打孔
        //gem2: 第二洞镶嵌的宝石 255为打孔
        //gem3: 第三洞镶嵌的宝石 255为打孔
        //warghost_exp: 战魂等级 最高9级
        //di_attack : 地攻击 最高255级
        //shui_attack: 水攻击 最高255级
        //huo_attack: 火攻击 最高255级
        //feng_attack: 风攻击 最高255级
        //limit: 是否叠加
        public GameStruct.RoleItemInfo AwardItem(uint itemid, byte postion, byte amount = 1, byte stronglv = 0,byte gem1 = 0,byte gem2 = 0,byte gem3 = 0,byte warghost_exp = 0,
            byte di_attack = 0,byte shui_attack = 0,byte huo_attack = 0,byte feng_attack = 0,bool limit = true/*是否叠加*/)
        {
            //是金币
            if (IsGold(itemid))
            {
                return null;
            }
            GameStruct.ItemTypeInfo baseitem = ConfigManager.Instance().GetItemTypeInfo(itemid);
            if (baseitem == null)
            {
                Log.Instance().WriteLog("创建道具失败,道具不存在 id:" + itemid.ToString());
              //  return null;
                if (!GameServer.IsTestMode()) return null;
                baseitem = new GameStruct.ItemTypeInfo();
                baseitem.id = itemid;
            }

            GameStruct.RoleItemInfo item = null;
            //可叠加
            if (!IsEquip(baseitem.id) && limit && baseitem.amount_limit > 1)
            {
                item = ItemLimit(itemid, (byte)baseitem.amount);
                if(item  != null)
                {
                    return item;
                }
            }
            uint key = (uint)mDicAddItem.Count + 1;

            item = new GameStruct.RoleItemInfo();
            item.itemid = baseitem.id;
            item.postion = postion;
            item.stronglv = stronglv;
            item.gem1 = gem1;
            item.gem2 = gem2;
            item.gem3 = gem3;
            item.war_ghost_exp = warghost_exp * 100;
            item.di_attack = di_attack;
            item.shui_attack = shui_attack;
            item.huo_attack = huo_attack;
            item.feng_attack = feng_attack;
            item.amount = baseitem.amount;
               // item.amount = IsEquip(baseitem.id) == true ? baseitem.amount_limit : amount;

            //宝石属性
            GameStruct.GemInfo gem = ConfigManager.Instance().GetGemInfo(item.itemid);
            if (gem != null)
            {
                item.gem1 = (uint)gem.type;
            }
            mDicAddItem[key] = item;

            //发给dbserver 通知增加这个道具
            GameBase.Network.Internal.AddRoleData_Item dbitem = new GameBase.Network.Internal.AddRoleData_Item();
            dbitem.item.playerid = play.GetBaseAttr().player_id;
            dbitem.gameid = play.GetGameID();
            dbitem.item.postion = postion;
            dbitem.item.itemid = item.itemid;
            dbitem.item.stronglv = stronglv;

            dbitem.item.amount = amount;
            dbitem.sortid = key;
            DBServer.Instance().GetDBClient().SendData(dbitem.GetBuffer());
            return item;
        }