コード例 #1
0
        public static List <AccAttr> LoadPlayerInfos(string file, bool reload = false)
        {
            if (!reload && m_playersAttrList.Count != 0)
            {
                return(m_playersAttrList);
            }

            List <AccAttr> AccAttrList = new List <AccAttr>();

            AccAttrList.Clear();

            string dbfile = file;

            if (!File.Exists(dbfile))
            {
                AccAttrList.Clear();
                return(AccAttrList);
            }

            if (File.Exists(@".\\Temp\\players.dat"))
            {
                File.SetAttributes(@".\\Temp\\players.dat", FileAttributes.Normal);
                File.Copy(dbfile, @".\\Temp\\players.dat", true);
            }
            else
            {
                File.Copy(dbfile, @".\\Temp\\players.dat", false);
            }


            FileStream  fs   = new FileStream(".\\Temp\\players.dat", FileMode.Open, FileAccess.ReadWrite);
            AccAttrHead head = new AccAttrHead();

            int ret = 0;

            byte[] bytData = new byte[Marshal.SizeOf(head)];
            ret = fs.Read(bytData, 0, Marshal.SizeOf(head));
            while (ret > 0)
            {
                AccAttr aa             = new AccAttr();
                byte[]  bytAccAttrData = new byte[Marshal.SizeOf(aa)];
                ret = fs.Read(bytAccAttrData, 0, Marshal.SizeOf(aa));
                if (ret <= 0)
                {
                    break;
                }
                AccAttr acc_attr = CStructBytesFormat.BytesToStruct <AccAttr>(bytAccAttrData);

                AccAttrList.Add(acc_attr);
            }

            fs.Close();

            //更新本地list
            m_playersAttrList.Clear();
            m_playersAttrList = AccAttrList;

            return(AccAttrList);
        }
コード例 #2
0
        private void button14_Click(object sender, EventArgs e)
        {
            if (!m_Active)
            {
                MessageBox.Show("软件尚未激活! 请联系软件发布人给予激活!");
                return;
            }
            try
            {
                DialogResult dr = MessageBox.Show("请确保游戏不处于运行状态!", "", MessageBoxButtons.OKCancel);
                if (dr != DialogResult.OK)//如果点击“确定”按钮
                {
                    return;
                }

                if (cbx_skillsAll.Checked)
                {
                    if (rdb_playersAll.Checked)
                    {
                        //增加 || 删除
                        if (rdb_skillAdd.Checked)
                        {
                            CSkillCtrl.AddAllPlayersAllSkills();
                        }
                        else if (rdb_skillDel.Checked)
                        {
                            CSkillCtrl.ClearAllPlayersAllSkills();
                        }
                    }
                    else if (rdb_playersSub.Checked)
                    {
                        //players
                        List <int> players = new List <int>();
                        if (txt_handleSkills.Text != "")
                        {
                            var tmp = txt_handlePlayers.Text.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
                            foreach (var item in tmp)
                            {
                                string  name = item.Split(';')[1];
                                AccAttr attr = CPlayerCtrl.GetAttrByName(name);

                                players.Add((int)attr.nIndex);
                            }
                        }

                        //增加 || 删除
                        if (rdb_skillAdd.Checked)
                        {
                            CSkillCtrl.AddPlayerAllSkills(players);
                        }
                        else if (rdb_skillDel.Checked)
                        {
                            CSkillCtrl.ClearPlayerAllSkills(players);
                        }
                    }
                }
                else
                {
                    //skills
                    List <int> skills = new List <int>();
                    if (txt_handleSkills.Text != "")
                    {
                        var tmp = txt_handleSkills.Text.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
                        foreach (var item in tmp)
                        {
                            int skillid = int.Parse(item.Split(';')[0]);
                            skills.Add(skillid);
                        }
                    }

                    if (rdb_playersAll.Checked)
                    {
                        //增加 || 删除
                        if (rdb_skillAdd.Checked)
                        {
                            CSkillCtrl.AddAllPlayersSkills(skills);
                        }
                        else if (rdb_skillDel.Checked)
                        {
                            CSkillCtrl.ClearAllPlayersSkills(skills);
                        }
                    }
                    else if (rdb_playersSub.Checked)
                    {
                        //players
                        List <int> players = new List <int>();
                        if (txt_handleSkills.Text != "")
                        {
                            var tmp = txt_handlePlayers.Text.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
                            foreach (var item in tmp)
                            {
                                string  name = item.Split(';')[1];
                                AccAttr attr = CPlayerCtrl.GetAttrByName(name);

                                players.Add((int)attr.nIndex);
                            }
                        }

                        //增加 || 删除
                        if (rdb_skillAdd.Checked)
                        {
                            CSkillCtrl.AddSubSkills(players, skills);
                        }
                        else if (rdb_skillDel.Checked)
                        {
                            CSkillCtrl.ClearSubSkills(players, skills);
                        }
                    }
                }
                CSkillCtrl.SaveSkillsData(txt_svrForder.Text + "\\DataBase\\saves\\skill.dat");
                MessageBox.Show("DONE!");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }