Ejemplo n.º 1
0
        //创建军团
        public void CreateLegion(int player_id, String legion_name, String leader_name, byte title, long money, String notice)
        {
            //已经创建军团的过程中,返回
            for (int i = 0; i < mListTemp.Count; i++)
            {
                if (mListTemp[i].leader_id == player_id)
                {
                    return;
                }
            }
            LegionOption option = new LegionOption();

            option.SetCreateTag();
            option.player_id         = player_id;
            option.mInfo.leader_id   = player_id;
            option.mInfo.leader_name = leader_name;
            option.mInfo.name        = legion_name;
            option.mInfo.money       = money;
            option.mInfo.notice      = notice;
            DBServer.Instance().GetDBClient().SendData(option.GetBuffer());

            LegionInfo info = new LegionInfo();

            info.leader_id   = player_id;
            info.name        = legion_name;
            info.leader_name = leader_name;
            info.money       = money;
            info.notice      = notice;
            mListTemp.Add(info);
        }
Ejemplo n.º 2
0
        //创建军团
        public void CreateLegion(LegionInfo info, int player_id)
        {
            int legion_id        = Data.CreateLegion(info);
            CreateLegion_Ret ret = new CreateLegion_Ret();

            if (legion_id != -1)
            {
                ret.ret = 1;
            }
            ret.play_id   = player_id;
            ret.legion_id = legion_id;
            info.id       = (uint)legion_id;

            mDicInfo[info.id] = info;

            LegionMember member = new LegionMember();

            member.money        = info.money;
            member.members_name = info.leader_name;
            member.rank         = GameBase.Config.Define.LEGION_PLACE_JUNTUANZHANG;
            member.money        = info.money; //初始化的贡献度
            AddLegionMembers(info.id, member);
            ret.money   = info.money;
            ret.boss_id = member.id;
            SessionManager.Instance().SendMapServer(0, ret.GetBuffer());
        }
Ejemplo n.º 3
0
        //创建军团 成功返回军团id,失败返回-1
        public static int CreateLegion(LegionInfo info)
        {
            MySqlCommand command;

            info.name   = Coding.GB2312ToLatin1(info.name);
            info.notice = Coding.GB2312ToLatin1(info.notice);
            String leader_name = Coding.GB2312ToLatin1(info.leader_name);
            String sql         = String.Format(MysqlString.CREATE_LEGION, info.name, info.title, info.leader_id, leader_name, info.money, info.notice);
            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_legion";

            command = new MySqlCommand(_key, MysqlConn.GetConn());
            MysqlConn.Conn_Open();
            MySqlDataReader reader = command.ExecuteReader();
            int             ret    = -1;

            reader.Read();
            if (reader.HasRows)
            {
                ret = Convert.ToInt32(reader[0].ToString());
            }
            MysqlConn.Conn_Close();
            command.Dispose();
            return(ret);
        }
Ejemplo n.º 4
0
        //从数据库载入军团配置
        public void DB_Load()
        {
            LegionInfo   info    = null;
            String       sql     = string.Format("select * from cq_legion");
            MySqlCommand command = new MySqlCommand(sql, MysqlConn.GetConn());

            MysqlConn.Conn_Open();
            MySqlDataReader reader = command.ExecuteReader();

            while (reader.Read())
            {
                if (!reader.HasRows)
                {
                    break;
                }
                info              = new LegionInfo();
                info.id           = reader.GetUInt32("id");
                info.name         = reader.GetString("name");
                info.name         = Coding.Latin1ToGB2312(info.name);
                info.title        = reader.GetByte("member_title");
                info.leader_id    = reader.GetInt32("leader_id");
                info.leader_name  = reader.GetString("leader_name");
                info.leader_name  = Coding.Latin1ToGB2312(info.leader_name);
                info.money        = reader.GetInt64("money");
                info.notice       = reader.GetString("notice");
                info.notice       = Coding.Latin1ToGB2312(info.notice);
                mDicInfo[info.id] = info;
            }

            MysqlConn.Conn_Close();
            command.Dispose();
            //载入行会成员信息

            foreach (LegionInfo obj in mDicInfo.Values)
            {
                sql     = string.Format("select * from cq_legion_members where legion_id={0}", obj.id);
                command = new MySqlCommand(sql, MysqlConn.GetConn());
                MysqlConn.Conn_Open();
                reader = command.ExecuteReader();
                while (reader.Read())
                {
                    if (!reader.HasRows)
                    {
                        break;
                    }
                    LegionMember member = new LegionMember();
                    member.rank         = reader.GetInt16("rank");
                    member.members_name = reader.GetString("members_name");
                    member.members_name = Coding.Latin1ToGB2312(member.members_name);
                    member.money        = reader.GetInt64("money");
                    obj.list_member.Add(member);
                }
                MysqlConn.Conn_Close();
                command.Dispose();
            }
        }
Ejemplo n.º 5
0
        //更新军团信息
        public static void UpdateLegion(LegionInfo info)
        {
            info.name        = Coding.GB2312ToLatin1(info.name);
            info.notice      = Coding.GB2312ToLatin1(info.notice);
            info.leader_name = Coding.GB2312ToLatin1(info.leader_name);
            String       sql = string.Format(MysqlString.UPDATE_LEGION, info.name, info.title, info.leader_id, info.leader_name, info.money, info.notice, info.id);
            MySqlCommand command;

            command = new MySqlCommand(sql, MysqlConn.GetConn());
            MysqlConn.Conn_Open();
            command.ExecuteNonQuery();
            MysqlConn.Conn_Close();
            command.Dispose();
        }
Ejemplo n.º 6
0
        //创建军团返回
        public void CreateLegion_Ret(CreateLegion_Ret info)
        {
            LegionInfo le = null;

            for (int i = 0; i < mListTemp.Count; i++)
            {
                if (mListTemp[i].leader_id == info.play_id)
                {
                    le    = mListTemp[i];
                    le.id = (uint)info.legion_id;
                    mListTemp.Remove(le);
                    break;
                }
            }
            if (info == null || info.ret == 0 || le == null)
            {
                return;
            }
            PlayerObject play = UserEngine.Instance().FindPlayerObjectToPlayerId(info.play_id);

            if (play == null)
            {
                return;
            }

            //加入军团长
            LegionMember member = new LegionMember();

            member.boChange     = true;
            member.members_name = play.GetName();
            member.money        = info.money;
            member.id           = info.boss_id;
            member.rank         = GameBase.Config.Define.LEGION_PLACE_JUNTUANZHANG;
            le.list_member.Add(member);



            Legion l = new Legion();

            l.SetBaseInfo(le);
            mDicLegion[le.id] = l;
            play.GetLegionSystem().SetLegion(l, true);
        }
Ejemplo n.º 7
0
 //更新军团
 public void UpdateLegion(LegionInfo info)
 {
     if (!mDicInfo.ContainsKey(info.id))
     {
         return;
     }
     mDicInfo[info.id] = info;
     //更新军团长信息
     Data.UpdateLegion(info);
     //更新军团成员信息
     for (int i = 0; i < info.list_member.Count; i++)
     {
         if (info.list_member[i].boChange)
         {
             Data.UpdateLegionMembers(info.id, info.list_member[i]);
             info.list_member[i].boChange = false;
         }
     }
 }
Ejemplo n.º 8
0
 public void SetBaseInfo(LegionInfo info)
 {
     mInfo = info;
 }