藏宝湾网游单机站

 找回密码
 注册

QQ登录

只需一步,快速开始

★【我是大主宰SF★神将三国SF】【变态页游】★

★【0.1折】★【变态网页游戏私服】★

★神将三国网页版上线送V5 5w元宝 5000w铜币 我是大主宰上线满v,80万元宝,小怪都爆元宝,耐玩长久稳定★

【原始传奇SF/魔域永恒SF】【0.1折手游】

★【原始传奇SF/魔域永恒SF】【0.1折手游】★

★『战online+原始传奇+维京传奇+血饮龙纹+魔域永恒+斗罗大陆』一刀99999999999刀刀光柱★

★1.76特色复古传奇【首区】★

★1.76特色复古传奇【首区】★

★1.76特色复古传奇【首区】,不卖一切,仅售月卡!还你2003年的热血传奇!★

★【卓越之剑】访官微变轻氪★
★【卓越之剑】访官微变轻氪★

★【卓越之剑】访官微变轻氪-欢迎技术交流★

★怒火国际服!中国人送全满!★

★火爆怒火国际服 3D版【三端互通】★

★国人满赞助!12档会员直接拉满 国人拿首充!三日首充直接拉满 国人拿货币!1个亿灵符随便花 国人拿材料!拿时装!爽就完事了★

★0.1折!独家超低折扣手游★

★0.1折!独家超低折扣手游★

★0.1折!0.1折!0.1折!独家超低折扣手游公益服,首冲续充全部0.1折★

★【九阴真经】端游私服仿官★

★【九阴真经】端游私服仿官★

★国产大型武侠端游《九阴真经》SF问世了。2017年至今-【稳定】充值1比10,活跃就送至尊风物志,跨服雪域应有尽有。★

橘子冒险岛079★复古内挂ᐃ养老服

★★橘子冒险岛079★★复古内挂ᐃ养老服★★

★橘子MapleStory079(复古) ★内挂★技能突破玩法★新人进服赠送200积分★★新服启航,福利多多★☆增加五转技能☆ ★游戏启航★ ★火热内测★★

★DNF★全职业平衡★公益服★
★DNF★全职业平衡★公益服★

【dnf86版本】【怀旧服】【全职业平衡】【非变态服】【非商业服】【868027375】

免费玩服找服,认准520梦幻资讯网!

★免费玩服找服,认准520梦幻资讯网★

★梦幻长期免费玩服,找服,请找www.mhxy520.com★

★梦幻西游★极致仿官公益★

★梦幻西游★极致仿官公益★

★无定制,全靠打,自由交易市场,无假人无托无gm介入,封任何脚本,银子保值。★

★ 新开三静脉,白嫖天堂★

★ 新开三静脉,白嫖天堂★

★逍遥西游,微变三经脉精心制作经典肝帝持续新区★

【梦幻西游】★端游领先版★
★【梦幻西游】★端游领先版★★

【梦幻西游★官方泄露版】----4月新区,无定制,无抽奖,全新战锦,每周更新一次。

★【梦幻国度】★端游★公益服★

★【梦幻国度】★端游★公益服★

★【梦幻国度】【端游】【全新版本公益服】【一样的童年不一样的游戏】【群63417379】★

★梦幻西游★仿官公益无充值★

★梦幻西游★仿官公益无充值★

★【情缘梦幻西游★独家仿官纯公益版】----2024新区,无定制,持续推广更新。推荐指数:★★★★★★★★★★★

★【梦幻西游★08仿官长久养老服】★

★★【梦幻西游★08仿官长久养老服】★★

★【梦幻西游★08仿官服2月新服,新人有路费资源福利】★

★【手游端游一键全自动搭建脚本】★

★【手游端游一键全自动搭建脚本】★

★【手游端游一键全自动搭建脚本】搭建游戏解放双手小白用了都说好★

★手游内部充值0.05折千款手游★

★手游内部充值0.05折千款手游★

★0.1折直充数千款手游可申请内部充值0.05折!超低折扣手游,全版本传奇手游--仙侠--古风-卡牌-角色扮演-二次元-全题材手游都支持内部充值0.05折★

★闪烁之光★精修PVP公益竞技服★

★闪烁之光★精修PVP公益竞技服★

★ ★★★全网独家精修★★★【闪烁之光】平衡PVP竞技公益服★应龙版本★上线十亿钻★长久养老★

★全新开服可白嫖放置传奇 荐★

★全新开服可白嫖放置传奇 荐★

★可白嫖 上班摸鱼类 放置文字传奇游戏(放置休闲)qq群756025698 ★

★【4月11日新服公测,全员领福利】★

★★【梦幻 4月新服,新人有路费 资源福利】★★

★★【梦幻西游★08仿官服微变 4月新服,新人有路费 资源福利】★★

6555my梦幻资讯网,众多私服发布网

★6555my梦幻资讯网,众多私服发布网★

★★★6555my梦幻资讯网,众多私服发布网★★★

★梦江南仿官无充值★

★ ★梦江南仿官无充值★★

★上线就送永久会员、银子礼包群号:531010715★

【百款GM页游+1折手游,上线送满级VIP】

★【百款GM页游+1折手游,上线送满级VIP】★

★【百款变态页游SF】【变态手游SF】【安卓+IOS手游】【上线免费顶级VIP】★

★【星空石器3.0】复古端游 有挂限制2开★
★★【星空石器3.0】复古端游 有挂限制2开★★

★【石器时代3.0纯PC-有挂限制2开】儿时怀旧游戏每晚活动多多 组队玩法 单人玩法 应有尽有 无需繁琐182任务★

★【大话西游2】稳定耐玩★只合不关★

★【大话西游2】稳定耐玩★只合不关★

★【大话西游2★2024最新版】稳定耐玩★只合不关★人气超旺★

★承接推广★

★承接推广★

★承接推广★

★承接推广★

★承接推广★

★承接推广★

查看: 881|回复: 4

[已解决] 还以为是Y语言了。。。。。。。

[复制链接]
 楼主| 发表于 2020-10-19 11:31:31 | 显示全部楼层 |阅读模式
C#代码翻译前后:
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using AAEmu.Commons.IO;
  5. using AAEmu.Commons.Models;
  6. using AAEmu.Commons.Utils;
  7. using AAEmu.Game.Core.Managers.Id;
  8. using AAEmu.Game.Core.Managers.World;
  9. using AAEmu.Game.Core.Network.Connections;
  10. using AAEmu.Game.Core.Packets.G2C;
  11. using AAEmu.Game.Models.Game.Char;
  12. using AAEmu.Game.Models.Game.Char.Templates;
  13. using AAEmu.Game.Models.Game.Items;
  14. using AAEmu.Game.Models.Game.Skills;
  15. using AAEmu.Game.Models.Game.Units;
  16. using AAEmu.Game.Models.Game.World;
  17. using AAEmu.Game.Utils.DB;
  18. using AAEmu.Game.Models.Game.Chat;
  19. using NLog;
  20. using AAEmu.Game.Models.Game.Items.Actions;
  21. using MySql.Data.MySqlClient;

  22. namespace AAEmu.Game.Core.Managers.UnitManagers
  23. {
  24.     public class CharacterManager : Singleton<CharacterManager>
  25.     {
  26.         private static readonly Logger Log = LogManager.GetCurrentClassLogger();

  27.         private readonly Dictionary<byte, CharacterTemplate> _templates;
  28.         private readonly Dictionary<byte, AbilityItems> _abilityItems;
  29.         private readonly Dictionary<int, List<Expand>> _expands;
  30.         private readonly Dictionary<uint, AppellationTemplate> _appellations;
  31.         private readonly Dictionary<uint, ActabilityTemplate> _actabilities;
  32.         private readonly Dictionary<int, ExpertLimit> _expertLimits;
  33.         private readonly Dictionary<int, ExpandExpertLimit> _expandExpertLimits;

  34.         public CharacterManager()
  35.         {
  36.             _templates = new Dictionary<byte, CharacterTemplate>();
  37.             _abilityItems = new Dictionary<byte, AbilityItems>();
  38.             _expands = new Dictionary<int, List<Expand>>();
  39.             _appellations = new Dictionary<uint, AppellationTemplate>();
  40.             _actabilities = new Dictionary<uint, ActabilityTemplate>();
  41.             _expertLimits = new Dictionary<int, ExpertLimit>();
  42.             _expandExpertLimits = new Dictionary<int, ExpandExpertLimit>();
  43.         }

  44.         public CharacterTemplate GetTemplate(byte race, byte gender)
  45.         {
  46.             return _templates[(byte) (16 * gender + race)];
  47.         }

  48.         public AppellationTemplate GetAppellationsTemplate(uint id)
  49.         {
  50.             if (_appellations.ContainsKey(id))
  51.                 return _appellations[id];
  52.             return null;
  53.         }
  54.         
  55.         public List<Expand> GetExpands(int step)
  56.         {
  57.             return _expands[step];
  58.         }

  59.         public ActabilityTemplate GetActability(uint id)
  60.         {
  61.             return _actabilities[id];
  62.         }

  63.         public ExpertLimit GetExpertLimit(int step)
  64.         {
  65.             if (_expertLimits.ContainsKey(step))
  66.                 return _expertLimits[step];
  67.             return null;
  68.         }

  69.         public ExpandExpertLimit GetExpandExpertLimit(int step)
  70.         {
  71.             if (_expandExpertLimits.ContainsKey(step))
  72.                 return _expandExpertLimits[step];
  73.             return null;
  74.         }

  75.         public void Load()
  76.         {
  77.             Log.Info("Loading character templates...");

  78.             using (var connection = SQLite.CreateConnection())
  79.             {
  80.                 var temp = new Dictionary<uint, byte>();
  81.                 using (var command = connection.CreateCommand())
  82.                 {
  83.                     command.CommandText = "SELECT * FROM characters";
  84.                     command.Prepare();
  85.                     using (var reader = new SQLiteWrapperReader(command.ExecuteReader()))
  86.                     {
  87.                         while (reader.Read())
  88.                         {
  89.                             var template = new CharacterTemplate();
  90.                             var id = reader.GetUInt32("id");
  91.                             template.Race = (Race)reader.GetByte("char_race_id");
  92.                             template.Gender = (Gender)reader.GetByte("char_gender_id");
  93.                             template.ModelId = reader.GetUInt32("model_id");
  94.                             template.FactionId = reader.GetUInt32("faction_id");
  95.                             template.ZoneId = reader.GetUInt32("starting_zone_id");
  96.                             template.ReturnDictrictId = reader.GetUInt32("default_return_district_id");
  97.                             template.ResurrectionDictrictId =
  98.                                 reader.GetUInt32("default_resurrection_district_id");
  99.                             using (var command2 = connection.CreateCommand())
  100.                             {
  101.                                 command2.CommandText = "SELECT * FROM item_body_parts WHERE model_id=@model_id";
  102.                                 command2.Prepare();
  103.                                 command2.Parameters.AddWithValue("model_id", template.ModelId);
  104.                                 using (var reader2 = new SQLiteWrapperReader(command2.ExecuteReader()))
  105.                                 {
  106.                                     while (reader2.Read())
  107.                                     {
  108.                                         var itemId = reader2.GetUInt32("item_id", 0);
  109.                                         var slot = reader2.GetInt32("slot_type_id") - 23;
  110.                                         template.Items[slot] = itemId;
  111.                                     }
  112.                                 }
  113.                             }

  114.                             var templateId = (byte)(16 * (byte)template.Gender + (byte)template.Race);
  115.                             _templates.Add(templateId, template);
  116.                             temp.Add(id, templateId);
  117.                         }
  118.                     }
  119.                 }

  120.                 using (var command = connection.CreateCommand())
  121.                 {
  122.                     command.CommandText = "SELECT * FROM character_buffs";
  123.                     command.Prepare();
  124.                     using (var reader = new SQLiteWrapperReader(command.ExecuteReader()))
  125.                     {
  126.                         while (reader.Read())
  127.                         {
  128.                             var characterId = reader.GetUInt32("character_id");
  129.                             var buffId = reader.GetUInt32("buff_id");
  130.                             var template = _templates[temp[characterId]];
  131.                             template.Buffs.Add(buffId);
  132.                         }
  133.                     }
  134.                 }

  135.                 using (var command = connection.CreateCommand())
  136.                 {
  137.                     command.CommandText = "SELECT * FROM character_supplies";
  138.                     command.Prepare();
  139.                     using (var reader = new SQLiteWrapperReader(command.ExecuteReader()))
  140.                     {
  141.                         while (reader.Read())
  142.                         {
  143.                             var ability = reader.GetByte("ability_id");
  144.                             var item = new AbilitySupplyItem
  145.                             {
  146.                                 Id = reader.GetUInt32("item_id"),
  147.                                 Amount = reader.GetInt32("amount"),
  148.                                 Grade = reader.GetByte("grade_id")
  149.                             };

  150.                             if (!_abilityItems.ContainsKey(ability))
  151.                                 _abilityItems.Add(ability, new AbilityItems());
  152.                             _abilityItems[ability].Supplies.Add(item);
  153.                         }
  154.                     }
  155.                 }

  156.                 using (var command = connection.CreateCommand())
  157.                 {
  158.                     command.CommandText = "SELECT * FROM character_equip_packs";
  159.                     command.Prepare();
  160.                     using (var reader = new SQLiteWrapperReader(command.ExecuteReader()))
  161.                     {
  162.                         while (reader.Read())
  163.                         {
  164.                             var ability = reader.GetByte("ability_id");
  165.                             var template = new AbilityItems { Ability = ability, Items = new EquipItemsTemplate() };
  166.                             var clothPack = reader.GetUInt32("newbie_cloth_pack_id", 0);
  167.                             var weaponPack = reader.GetUInt32("newbie_weapon_pack_id", 0);
  168.                             if (clothPack > 0)
  169.                             {
  170.                                 using (var command2 = connection.CreateCommand())
  171.                                 {
  172.                                     command2.CommandText = "SELECT * FROM equip_pack_cloths WHERE id=@id";
  173.                                     command2.Prepare();
  174.                                     command2.Parameters.AddWithValue("id", clothPack);
  175.                                     using (var reader2 = new SQLiteWrapperReader(command2.ExecuteReader()))
  176.                                     {
  177.                                         while (reader2.Read())
  178.                                         {
  179.                                             template.Items.Headgear = reader2.GetUInt32("headgear_id");
  180.                                             template.Items.HeadgearGrade = reader2.GetByte("headgear_grade_id");
  181.                                             template.Items.Necklace = reader2.GetUInt32("necklace_id");
  182.                                             template.Items.NecklaceGrade = reader2.GetByte("necklace_grade_id");
  183.                                             template.Items.Shirt = reader2.GetUInt32("shirt_id");
  184.                                             template.Items.ShirtGrade = reader2.GetByte("shirt_grade_id");
  185.                                             template.Items.Belt = reader2.GetUInt32("belt_id");
  186.                                             template.Items.BeltGrade = reader2.GetByte("belt_grade_id");
  187.                                             template.Items.Pants = reader2.GetUInt32("pants_id");
  188.                                             template.Items.PantsGrade = reader2.GetByte("pants_grade_id");
  189.                                             template.Items.Gloves = reader2.GetUInt32("glove_id");
  190.                                             template.Items.GlovesGrade = reader2.GetByte("glove_grade_id");
  191.                                             template.Items.Shoes = reader2.GetUInt32("shoes_id");
  192.                                             template.Items.ShoesGrade = reader2.GetByte("shoes_grade_id");
  193.                                             template.Items.Bracelet = reader2.GetUInt32("bracelet_id");
  194.                                             template.Items.BraceletGrade = reader2.GetByte("bracelet_grade_id");
  195.                                             template.Items.Back = reader2.GetUInt32("back_id");
  196.                                             template.Items.BackGrade = reader2.GetByte("back_grade_id");
  197.                                             template.Items.Cosplay = reader2.GetUInt32("cosplay_id");
  198.                                             template.Items.CosplayGrade = reader2.GetByte("cosplay_grade_id");
  199.                                             template.Items.Undershirts = reader2.GetUInt32("undershirt_id");
  200.                                             template.Items.UndershirtsGrade = reader2.GetByte("undershirt_grade_id");
  201.                                             template.Items.Underpants = reader2.GetUInt32("underpants_id");
  202.                                             template.Items.UnderpantsGrade = reader2.GetByte("underpants_grade_id");
  203.                                         }
  204.                                     }
  205.                                 }
  206.                             }

  207.                             if (weaponPack > 0)
  208.                             {
  209.                                 using (var command2 = connection.CreateCommand())
  210.                                 {
  211.                                     command2.CommandText = "SELECT * FROM equip_pack_weapons WHERE id=@id";
  212.                                     command2.Prepare();
  213.                                     command2.Parameters.AddWithValue("id", weaponPack);
  214.                                     using (var reader2 = new SQLiteWrapperReader(command2.ExecuteReader()))
  215.                                     {
  216.                                         while (reader2.Read())
  217.                                         {
  218.                                             template.Items.Mainhand = reader2.GetUInt32("mainhand_id");
  219.                                             template.Items.MainhandGrade = reader2.GetByte("mainhand_grade_id");
  220.                                             template.Items.Offhand = reader2.GetUInt32("offhand_id");
  221.                                             template.Items.OffhandGrade = reader2.GetByte("offhand_grade_id");
  222.                                             template.Items.Ranged = reader2.GetUInt32("ranged_id");
  223.                                             template.Items.RangedGrade = reader2.GetByte("ranged_grade_id");
  224.                                             template.Items.Musical = reader2.GetUInt32("musical_id");
  225.                                             template.Items.MusicalGrade = reader2.GetByte("musical_grade_id");
  226.                                         }
  227.                                     }
  228.                                 }
  229.                             }

  230.                             _abilityItems.Add(template.Ability, template);
  231.                         }
  232.                     }
  233.                 }

  234.                 using (var command = connection.CreateCommand())
  235.                 {
  236.                     command.CommandText = "SELECT * FROM bag_expands";
  237.                     command.Prepare();
  238.                     using (var reader = new SQLiteWrapperReader(command.ExecuteReader()))
  239.                     {
  240.                         while (reader.Read())
  241.                         {
  242.                             var expand = new Expand();
  243.                             expand.IsBank = reader.GetBoolean("is_bank", true);
  244.                             expand.Step = reader.GetInt32("step");
  245.                             expand.Price = reader.GetInt32("price");
  246.                             expand.ItemId = reader.GetUInt32("item_id", 0);
  247.                             expand.ItemCount = reader.GetInt32("item_count");
  248.                             expand.CurrencyId = reader.GetInt32("currency_id");

  249.                             if (!_expands.ContainsKey(expand.Step))
  250.                                 _expands.Add(expand.Step, new List<Expand> { expand });
  251.                             else
  252.                                 _expands[expand.Step].Add(expand);
  253.                         }
  254.                     }
  255.                 }

  256.                 using (var command = connection.CreateCommand())
  257.                 {
  258.                     command.CommandText = "SELECT id, buff_id FROM appellations";
  259.                     command.Prepare();
  260.                     using (var reader = new SQLiteWrapperReader(command.ExecuteReader()))
  261.                     {
  262.                         while (reader.Read())
  263.                         {
  264.                             var template = new AppellationTemplate();
  265.                             template.Id = reader.GetUInt32("id");
  266.                             template.BuffId = reader.GetUInt32("buff_id", 0);

  267.                             _appellations.Add(template.Id, template);
  268.                         }
  269.                     }
  270.                 }

  271.                 using (var command = connection.CreateCommand())
  272.                 {
  273.                     command.CommandText = "SELECT * FROM actability_groups";
  274.                     command.Prepare();
  275.                     using (var reader = new SQLiteWrapperReader(command.ExecuteReader()))
  276.                     {
  277.                         while (reader.Read())
  278.                         {
  279.                             var template = new ActabilityTemplate();
  280.                             template.Id = reader.GetUInt32("id");
  281.                             template.Name = reader.GetString("name");
  282.                             template.UnitAttributeId = reader.GetInt32("unit_attr_id");
  283.                             _actabilities.Add(template.Id, template);
  284.                         }
  285.                     }
  286.                 }

  287.                 using (var command = connection.CreateCommand())
  288.                 {
  289.                     command.CommandText = "SELECT * FROM expert_limits ORDER BY up_limit ASC";
  290.                     command.Prepare();
  291.                     using (var reader = new SQLiteWrapperReader(command.ExecuteReader()))
  292.                     {
  293.                         var step = 0;
  294.                         while (reader.Read())
  295.                         {
  296.                             var template = new ExpertLimit();
  297.                             template.Id = reader.GetUInt32("id");
  298.                             template.UpLimit = reader.GetInt32("up_limit");
  299.                             template.ExpertLimitCount = reader.GetByte("expert_limit");
  300.                             template.Advantage = reader.GetInt32("advantage");
  301.                             template.CastAdvantage = reader.GetInt32("cast_adv");
  302.                             template.UpCurrencyId = reader.GetUInt32("up_currency_id", 0);
  303.                             template.UpPrice = reader.GetInt32("up_price");
  304.                             template.DownCurrencyId = reader.GetUInt32("down_currency_id", 0);
  305.                             template.DownPrice = reader.GetInt32("down_price");
  306.                             _expertLimits.Add(step++, template);
  307.                         }
  308.                     }
  309.                 }

  310.                 using (var command = connection.CreateCommand())
  311.                 {
  312.                     command.CommandText = "SELECT * FROM expand_expert_limits ORDER BY expand_count ASC";
  313.                     command.Prepare();
  314.                     using (var reader = new SQLiteWrapperReader(command.ExecuteReader()))
  315.                     {
  316.                         var step = 0;
  317.                         while (reader.Read())
  318.                         {
  319.                             var template = new ExpandExpertLimit();
  320.                             template.Id = reader.GetUInt32("id");
  321.                             template.ExpandCount = reader.GetByte("expand_count");
  322.                             template.LifePoint = reader.GetInt32("life_point");
  323.                             template.ItemId = reader.GetUInt32("item_id", 0);
  324.                             template.ItemCount = reader.GetInt32("item_count");
  325.                             _expandExpertLimits.Add(step++, template);
  326.                         }
  327.                     }
  328.                 }
  329.             }

  330.             var content = FileManager.GetFileContents($"{FileManager.AppPath}Data/CharTemplates.json");
  331.             if (string.IsNullOrWhiteSpace(content))
  332.                 throw new IOException(
  333.                     $"File {FileManager.AppPath + "Data/CharTemplates.json"} doesn't exists or is empty.");

  334.             if (JsonHelper.TryDeserializeObject(content, out List<CharacterTemplateConfig> charTemplates, out _))
  335.             {
  336.                 foreach (var charTemplate in charTemplates)
  337.                 {
  338.                     var point = new Point(charTemplate.Pos.X, charTemplate.Pos.Y, charTemplate.Pos.Z);
  339.                     point.WorldId = charTemplate.Pos.WorldId;
  340.                     point.ZoneId = WorldManager
  341.                         .Instance
  342.                         .GetZoneId(charTemplate.Pos.WorldId, charTemplate.Pos.X, charTemplate.Pos.Y); // TODO ...
  343.                     
  344.                     point.RotationX = charTemplate.Pos.RotationX;
  345.                     point.RotationY = charTemplate.Pos.RotationY;
  346.                     point.RotationZ = charTemplate.Pos.RotationZ;
  347.                     
  348.                     var template = _templates[(byte)(16 + charTemplate.Id)];
  349.                     template.Position = point;
  350.                     template.NumInventorySlot = charTemplate.NumInventorySlot;
  351.                     template.NumBankSlot = charTemplate.NumBankSlot;

  352.                     template = _templates[(byte)(32 + charTemplate.Id)];
  353.                     template.Position = point;
  354.                     template.NumInventorySlot = charTemplate.NumInventorySlot;
  355.                     template.NumBankSlot = charTemplate.NumBankSlot;
  356.                 }
  357.             }
  358.             else
  359.                 throw new Exception($"CharacterManager: Parse {FileManager.AppPath + "Data/CharTemplates.json"} file");

  360.             Log.Info("Loaded {0} character templates", _templates.Count);
  361.         }

  362.         public void PlayerRoll(Character Self, int max)
  363.         {

  364.             var roll = Rand.Next(1, max);
  365.             Self.BroadcastPacket(new SCChatMessagePacket(ChatType.System, string.Format(Self.Name + " rolled " + roll.ToString() + ".")), true);
  366.             
  367.         }

  368.         public void Create(GameConnection connection, string name, byte race, byte gender, uint[] body,
  369.             UnitCustomModelParams customModel, byte ability1)
  370.         {
  371.             var nameValidationCode = NameManager.Instance.ValidationCharacterName(name);
  372.             if (nameValidationCode == 0)
  373.             {
  374.                 var characterId = CharacterIdManager.Instance.GetNextId();
  375.                 NameManager.Instance.AddCharacterName(characterId, name);
  376.                 var template = GetTemplate(race, gender);

  377.                 var character = new Character(customModel);
  378.                 character.Id = characterId;
  379.                 character.AccountId = connection.AccountId;
  380.                 character.Name = name.Substring(0, 1).ToUpper() + name.Substring(1);
  381.                 character.Race = (Race) race;
  382.                 character.Gender = (Gender) gender;
  383.                 character.Position = template.Position.Clone();
  384.                 character.Position.ZoneId = template.ZoneId;
  385.                 character.Level = 1;
  386.                 character.Faction = FactionManager.Instance.GetFaction(template.FactionId);
  387.                 character.FactionName = "";
  388.                 character.LaborPower = 50;
  389.                 character.LaborPowerModified = DateTime.UtcNow;
  390.                 character.NumInventorySlots = template.NumInventorySlot;
  391.                 character.NumBankSlots = template.NumBankSlot;
  392.                 character.Inventory = new Inventory(character);
  393.                 character.Updated = DateTime.UtcNow;
  394.                 character.Ability1 = (AbilityType) ability1;
  395.                 character.Ability2 = AbilityType.None;
  396.                 character.Ability3 = AbilityType.None;
  397.                 character.ReturnDictrictId = template.ReturnDictrictId;
  398.                 character.ResurrectionDictrictId = template.ResurrectionDictrictId;
  399.                 character.Slots = new ActionSlot[85];
  400.                 for (var i = 0; i < character.Slots.Length; i++)
  401.                     character.Slots[i] = new ActionSlot();

  402.                 var items = _abilityItems[ability1];
  403.                 SetEquipItemTemplate(character.Inventory, items.Items.Headgear, EquipmentItemSlot.Head, items.Items.HeadgearGrade);
  404.                 SetEquipItemTemplate(character.Inventory, items.Items.Necklace, EquipmentItemSlot.Neck, items.Items.NecklaceGrade);
  405.                 SetEquipItemTemplate(character.Inventory, items.Items.Shirt, EquipmentItemSlot.Chest, items.Items.ShirtGrade);
  406.                 SetEquipItemTemplate(character.Inventory, items.Items.Belt, EquipmentItemSlot.Waist, items.Items.BeltGrade);
  407.                 SetEquipItemTemplate(character.Inventory, items.Items.Pants, EquipmentItemSlot.Legs, items.Items.PantsGrade);
  408.                 SetEquipItemTemplate(character.Inventory, items.Items.Gloves, EquipmentItemSlot.Hands, items.Items.GlovesGrade);
  409.                 SetEquipItemTemplate(character.Inventory, items.Items.Shoes, EquipmentItemSlot.Feet, items.Items.ShoesGrade);
  410.                 SetEquipItemTemplate(character.Inventory, items.Items.Bracelet, EquipmentItemSlot.Arms, items.Items.BraceletGrade);
  411.                 SetEquipItemTemplate(character.Inventory, items.Items.Back, EquipmentItemSlot.Back, items.Items.BackGrade);
  412.                 SetEquipItemTemplate(character.Inventory, items.Items.Undershirts, EquipmentItemSlot.Undershirt, items.Items.UndershirtsGrade);
  413.                 SetEquipItemTemplate(character.Inventory, items.Items.Underpants, EquipmentItemSlot.Underpants, items.Items.UnderpantsGrade);
  414.                 SetEquipItemTemplate(character.Inventory, items.Items.Mainhand, EquipmentItemSlot.Mainhand, items.Items.MainhandGrade);
  415.                 SetEquipItemTemplate(character.Inventory, items.Items.Offhand, EquipmentItemSlot.Offhand, items.Items.OffhandGrade);
  416.                 SetEquipItemTemplate(character.Inventory, items.Items.Ranged, EquipmentItemSlot.Ranged, items.Items.RangedGrade);
  417.                 SetEquipItemTemplate(character.Inventory, items.Items.Musical, EquipmentItemSlot.Musical, items.Items.MusicalGrade);
  418.                 SetEquipItemTemplate(character.Inventory, items.Items.Cosplay, EquipmentItemSlot.Cosplay, items.Items.CosplayGrade);
  419.                 for (var i = 0; i < 7; i++)
  420.                 {
  421.                     if (body[i] == 0 && template.Items[i] > 0)
  422.                         body[i] = template.Items[i];
  423.                     SetEquipItemTemplate(character.Inventory, body[i], (EquipmentItemSlot) (i + 19), 0);
  424.                 }

  425.                 byte slot = 10;
  426.                 foreach (var item in items.Supplies)
  427.                 {
  428.                     character.Inventory.Bag.AcquireDefaultItem(ItemTaskType.Invalid, item.Id, item.Amount, item.Grade);
  429.                     //var createdItem = ItemManager.Instance.Create(item.Id, item.Amount, item.Grade);
  430.                     //character.Inventory.AddItem(Models.Game.Items.Actions.ItemTaskType.Invalid, createdItem);

  431.                     character.SetAction(slot, ActionSlotType.Item, item.Id);
  432.                     slot++;
  433.                 }

  434.                 items = _abilityItems[0];
  435.                 if (items != null)
  436.                     foreach (var item in items.Supplies)
  437.                     {
  438.                         character.Inventory.Bag.AcquireDefaultItem(ItemTaskType.Invalid, item.Id, item.Amount, item.Grade);
  439.                         //var createdItem = ItemManager.Instance.Create(item.Id, item.Amount, item.Grade);
  440.                         //character.Inventory.AddItem(ItemTaskType.Invalid, createdItem);

  441.                         character.SetAction(slot, ActionSlotType.Item, item.Id);
  442.                         slot++;
  443.                     }

  444.                 character.Abilities = new CharacterAbilities(character);
  445.                 character.Abilities.SetAbility(character.Ability1, 0);
  446.                
  447.                 character.Actability = new CharacterActability(character);
  448.                 foreach (var (id, actabilityTemplate) in _actabilities)
  449.                     character.Actability.Actabilities.Add(id, new Actability(actabilityTemplate));

  450.                 character.Skills = new CharacterSkills(character);
  451.                 foreach (var skill in SkillManager.Instance.GetDefaultSkills())
  452.                 {
  453.                     if (!skill.AddToSlot)
  454.                         continue;
  455.                     character.SetAction(skill.Slot, ActionSlotType.Skill, skill.Template.Id);
  456.                 }

  457.                 slot = 1;
  458.                 while (character.Slots[slot].Type != ActionSlotType.None)
  459.                     slot++;
  460.                 foreach (var skill in SkillManager.Instance.GetStartAbilitySkills(character.Ability1))
  461.                 {
  462.                     character.Skills.AddSkill(skill, 1, false);
  463.                     character.SetAction(slot, ActionSlotType.Skill, skill.Id);
  464.                     slot++;
  465.                 }
  466.                
  467.                 character.Appellations = new CharacterAppellations(character);
  468.                 character.Quests = new CharacterQuests(character);
  469.                 character.Mails = new CharacterMails(character);
  470.                 character.Portals = new CharacterPortals(character);
  471.                 character.Friends = new CharacterFriends(character);
  472.                
  473.                 character.Hp = character.MaxHp;
  474.                 character.Mp = character.MaxMp;

  475.                 if (character.SaveDirectlyToDatabase())
  476.                 {
  477.                     connection.Characters.Add(character.Id, character);
  478.                     connection.SendPacket(new SCCreateCharacterResponsePacket(character));
  479.                 }
  480.                 else
  481.                 {
  482.                     connection.SendPacket(new SCCharacterCreationFailedPacket(3));
  483.                     CharacterIdManager.Instance.ReleaseId(characterId);
  484.                     NameManager.Instance.RemoveCharacterName(characterId);
  485.                     // TODO release items...
  486.                 }
  487.                
  488.             }
  489.             else
  490.             {
  491.                 connection.SendPacket(new SCCharacterCreationFailedPacket(nameValidationCode));
  492.             }
  493.         }

  494.         public List<LoginCharacterInfo> LoadCharacters(uint accountId)
  495.         {
  496.             var result = new List<LoginCharacterInfo>();
  497.             using (var connection = MySQL.CreateConnection())
  498.             {
  499.                 using (var command = connection.CreateCommand())
  500.                 {
  501.                     command.CommandText =
  502.                         "SELECT `id`, `name`, `race`, `gender`,`delete_time` FROM characters WHERE `account_id`=@accountId and `deleted`=0";
  503.                     command.Parameters.AddWithValue("@accountId", accountId);
  504.                     using (var reader = command.ExecuteReader())
  505.                     {
  506.                         while (reader.Read())
  507.                         {
  508.                             // Skip this char in the list if it's read to be deleted
  509.                             var deleteTime = reader.GetDateTime("delete_time");
  510.                             if ((deleteTime > DateTime.MinValue) && (deleteTime < DateTime.UtcNow))
  511.                                 continue;

  512.                             var character = new LoginCharacterInfo();
  513.                             character.AccountId = accountId;
  514.                             character.Id = reader.GetUInt32("id");
  515.                             character.Name = reader.GetString("name");
  516.                             character.Race = reader.GetByte("race");
  517.                             character.Gender = reader.GetByte("gender");
  518.                             result.Add(character);
  519.                         }
  520.                     }
  521.                 }
  522.             }
  523.             return result;
  524.         }

  525.         private void SetEquipItemTemplate(Inventory inventory, uint templateId, EquipmentItemSlot slot, byte grade)
  526.         {
  527.             Item item = null;
  528.             if (templateId > 0)
  529.             {
  530.                 item = ItemManager.Instance.Create(templateId, 1, grade);
  531.                 item.SlotType = SlotType.Equipment;
  532.                 item.Slot = (int)slot;
  533.             }

  534.             inventory.Equipment.AddOrMoveExistingItem(0, item, (int)slot);
  535.             //inventory.Equip[(int) slot] = item;
  536.         }
  537.     }
  538. }
复制代码
不仔细看以为其他中文编程语言了:
  1. 使用系统;
  2. 使用系统。集合。通用;
  3. 使用系统。Io;
  4. 使用 AAEmu。公地.Io;
  5. 使用 AAEmu。公地.型号;
  6. 使用 AAEmu。公地.Utils;
  7. 使用 AAEmu。游戏.核心.经理.身份证;
  8. 使用 AAEmu。游戏.核心.经理.世界;
  9. 使用 AAEmu。游戏.核心.网络.连接;
  10. 使用 AAEmu。游戏.核心.数据包。G2C;
  11. 使用 AAEmu。游戏.型号.游戏.查尔;
  12. 使用 AAEmu。游戏.型号.游戏.查尔.模板;
  13. 使用 AAEmu。游戏.型号.游戏.项目;
  14. 使用 AAEmu。游戏.型号.游戏.技能;
  15. 使用 AAEmu。游戏.型号.游戏.单位;
  16. 使用 AAEmu。游戏.型号.游戏.世界;
  17. 使用 AAEmu。游戏.Utils.DB;
  18. 使用 AAEmu。游戏.型号.游戏.聊天;
  19. 使用 Nlog;
  20. 使用 AAEmu。游戏.型号.游戏.项目。操作;
  21. 使用 MySql。数据。MySqlClient;

  22. 命名空间 AAEmu.游戏.核心.经理.单位经理
  23. {
  24.     公共类字符管理器:单顿<字符管理器>
  25.     {
  26.         专用静态读取日志 + 日志管理器。获取当前类记录器();

  27.         私人阅读词典<字节 ,字符模板> _templates;
  28.         私人阅读词典<字节 ,能力问题> _abilityItems;
  29.         私人阅读词典<int,列表<展开>> _expands;
  30.         私人阅读词典 <uint,名称模板> _appellations;
  31.         私人阅读词典<uint,可负担性 > _actabilities;
  32.         私人阅读词典<int,专家限制 > _expertLimits;
  33.         私人阅读词典 <int,展开专家限制> _expandExpertLimits;

  34.         公共字符管理器()
  35.         {
  36.             _templates = 新词典<字节,字符模板>();
  37.             _abilityItems = 新词典<字节,能力问题>();
  38.             _expands = 新词典<int,列表<展开>>();
  39.             _appellations  = 新词典 <uint,名称模板>();
  40.             _actabilities = 新词典<uint,可行为性模板>();
  41.             _expertLimits = 新词典<int,专家限制>();
  42.             _expandExpertLimits = 新词典<int , 扩展专家限制>();
  43.         }

  44.         公共字符模板GetTemplate(字节种族,字节性别)
  45.         {
  46.             返回_templates[ (字节)(16 * 性别 * 种族)];
  47.         }

  48.         公共名称模板获取应用程序板(uint id)
  49.         {
  50.             如果(_appellations。包含密钥(id))
  51.                 返回 _appellations+id];
  52.             返回空;
  53.         }
  54.         
  55.         公共列表<展开 >获取扩展(int 步骤))
  56.         {
  57.             返回_expands+步骤];
  58.         }

  59.         公共可负担性模板获取可处理性(uint id)
  60.         {
  61.             返回 _actabilities+id];
  62.         }

  63.         公共专家限制获取专家限制(int 步骤)
  64.         {
  65.             如果(_expertLimits。包含密钥(步骤))
  66.                 返回 _expertLimits+步骤];
  67.             返回空;
  68.         }

  69.         公开扩展专家限制获取扩展专家限制(int 步骤))
  70.         {
  71.             如果(_expandExpertLimits。包含密钥(步骤))
  72.                 返回_expandExpertLimits+步骤];
  73.             返回空;
  74.         }

  75.         公共 void 负载()
  76.         {
  77.             日志。信息(" 加载字符模板..." );

  78.             使用(var 连接 = Sqlite.创建连接())
  79.             {
  80.                 var温度 = 新词典<uint,字节>();
  81.                 使用(var 命令 = 连接。创建命令())
  82.                 {
  83.                     命令。命令文本 =  [从字符中选择];
  84.                     命令。准备();
  85.                     使用(var 读取器 = 新的 SQLiteWrapperReader(命令.执行阅读器()))
  86.                     {
  87.                         而(读取器。阅读())
  88.                         {
  89.                             var 模板 = 新的字符模板();
  90.                             var id = 读取器。Getuint32(#id" );
  91.                             模板。种族 = (种族)阅读器.Getbyte([ char_race_id] );
  92.                             模板。性别 = (性别)读者.Getbyte([ char_gender_id] );
  93.                             模板。模型 Id = 读取器。GetUint32([ model_id" );
  94.                             模板。派系 Id = 读取器。Getuint32([ faction_id" );
  95.                             模板。区域 Id = 读取器。Getuint32([ starting_zone_id" );
  96.                             模板。返回三读本 = 读取器。GetUint32([ default_return_district_id" );
  97.                             模板。复活迪克特里特迪德 =
  98.                                 读取器。GetUint32([ default_resurrection_district_id" );
  99.                             使用(var 命令 2 = 连接.创建命令())
  100.                             {
  101.                                 命令2。命令文本 =  [从item_body_parts model_id]@model_id] ;
  102.                                 命令2。准备();
  103.                                 命令2。参数。AddWithValue("model_id",模板。模型 Id);
  104.                                 使用(var阅读器 2 =  新的 SQLiteWrapperReader(命令2.执行阅读器()))
  105.                                 {
  106.                                     而(读取器2.阅读())
  107.                                     {
  108.                                         var itemId = 读取器2。GetUINT32("item_id", 0);
  109.                                         var 插槽 = 读取器2。GetInt32([slot_type_id") - 23;
  110.                                         模板。项目+槽+项目 ID;
  111.                                     }
  112.                                 }
  113.                             }

  114.                             var 模板 Id = (字节)16 * (字节)模板.性别 = (字节)模板.种族);
  115.                             _templates.添加(模板 Id,模板);
  116.                             温度.添加(id,模板 Id);
  117.                         }
  118.                     }
  119.                 }

  120.                 使用(var 命令 = 连接。创建命令())
  121.                 {
  122.                     命令。命令文本 =  [从character_buffs] 中选择;
  123.                     命令。准备();
  124.                     使用(var 读取器 = 新的 SQLiteWrapperReader(命令.执行阅读器()))
  125.                     {
  126.                         而(读取器。阅读())
  127.                         {
  128.                             var 字符 Id = 读取器。GetUint32([ character_id" );
  129.                             var buffid = 读者。GetUint32(" buff_id" );
  130.                             var 模板 = _templates= 临时= 字符Id]];
  131.                             模板。布夫斯.添加(buffid);
  132.                         }
  133.                     }
  134.                 }

  135.                 使用(var 命令 = 连接。创建命令())
  136.                 {
  137.                     命令。命令文本 =  [从character_supplies]中选择;
  138.                     命令。准备();
  139.                     使用(var 读取器 = 新的 SQLiteWrapperReader(命令.执行阅读器()))
  140.                     {
  141.                         而(读取器。阅读())
  142.                         {
  143.                             var 能力 = 读取器。Getbyte([ ability_id] );
  144.                             var 项目 =  新的能力供应项目
  145.                             {
  146.                                 ID = 读取器。GetUInt32(item_id")
  147.                                 金额 = 读取器。GetInt32("金额"),
  148.                                 等级 =读卡器。Getbyte(grade_id" )
  149.                             };

  150.                             如果(!_abilityItems.包含密钥(能力))
  151.                                 _abilityItems.添加(能力,新的能力项目());
  152.                             _abilityItems[能力]。耗材.添加(项目);
  153.                         }
  154.                     }
  155.                 }

  156.                 使用(var 命令 = 连接。创建命令())
  157.                 {
  158.                     命令。命令文本 =  [从 character_equip_packs] ;
  159.                     命令。准备();
  160.                     使用(var 读取器 = 新的 SQLiteWrapperReader(命令.执行阅读器()))
  161.                     {
  162.                         而(读取器。阅读())
  163.                         {
  164.                             var 能力 = 读取器。Getbyte([ ability_id] );
  165.                             var 模板= 新的能力问题=能力 = 能力,项目 = 新的装备项目板() };
  166.                             var 布包 =读卡器。GetUInt32("newbie_cloth_pack_id", 0);
  167.                             var 武器包 + 阅读器。GetUINT32("newbie_weapon_pack_id", 0);
  168.                             如果(布包 > 0)
  169.                             {
  170.                                 使用(var 命令 2 = 连接.创建命令())
  171.                                 {
  172.                                     命令2。命令文本 =  [从 equip_pack_cloths] @id ;
  173.                                     命令2。准备();
  174.                                     命令2。参数。添加与价值("id",布袋);
  175.                                     使用(var阅读器 2 =  新的 SQLiteWrapperReader(命令2.执行阅读器()))
  176.                                     {
  177.                                         而(读取器2.阅读())
  178.                                         {
  179.                                             模板。项目。头饰 =  读卡器2.Getuint32([ headgear_id" );
  180.                                             模板。项目。头饰等级 =  读卡器2。Getbyte(headgear_grade_id" );
  181.                                             模板。项目。项链 = 阅读器2.GetUint32([ necklace_id" );
  182.                                             模板。项目。项链等级 = 阅读器2。Getbyte(necklace_grade_id" );
  183.                                             模板。项目。衬衫 = 阅读器2.Getuint32([ shirt_id" );
  184.                                             模板。项目。衬衫等级 = 阅读器 2.Getbyte(shirt_grade_id" );
  185.                                             模板。项目。皮带 = 读卡器2。GetUint32([ belt_id" );
  186.                                             模板。项目。贝尔特级 = 读卡器2。Getbyte(belt_grade_id" );
  187.                                             模板。项目。裤子 = 读卡器2。GetUint32([ pants_id" );
  188.                                             模板。项目。裤子等级 = 读卡器2。Getbyte(pants_grade_id" );
  189.                                             模板。项目。手套 = 读卡器2。Getuint32([ glove_id] );
  190.                                             模板。项目。手套等级 = 读卡器2。Getbyte([ glove_grade_id] );
  191.                                             模板。项目。鞋子 = 读卡器2。GetUInt32([ shoes_id" );
  192.                                             模板。项目。鞋级 = 读卡器2。Getbyte(shoes_grade_id" );
  193.                                             模板。项目。手镯 = 读卡器2.GetUint32(bracelet_id" );
  194.                                             模板。项目。手镯等级 = 读卡器2.Getbyte([ bracelet_grade_id] );
  195.                                             模板。项目。返回 = 读取器2。GetUINT32([ back_id" );
  196.                                             模板。项目。后等级 = 读卡器2。Getbyte(back_grade_id" );
  197.                                             模板。项目。角色扮演 = 阅读器2。GetUint32([ cosplay_id" );
  198.                                             模板。项目。CosplayGrade = 阅读器2.Getbyte([ cosplay_grade_id] );
  199.                                             模板。项目。内衣 = 阅读器2。GetUINT32([ undershirt_id" );
  200.                                             模板。项目。内衣等级 = 阅读器 2.Getbyte([ undershirt_grade_id] );
  201.                                             模板。项目。内裤 = 阅读器2。GetUint32(underpants_id" );
  202.                                             模板。项目。内裤等级 = 读卡器2。Getbyte(underpants_grade_id" );
  203.                                         }
  204.                                     }
  205.                                 }
  206.                             }

  207.                             如果(武器包 > 0)
  208.                             {
  209.                                 使用(var 命令 2 = 连接.创建命令())
  210.                                 {
  211.                                     命令2。命令文本 =  [从 equip_pack_weapons id] @id" ;
  212.                                     命令2。准备();
  213.                                     命令2。参数。添加与价值("id",武器包);
  214.                                     使用(var阅读器 2 =  新的 SQLiteWrapperReader(命令2.执行阅读器()))
  215.                                     {
  216.                                         而(读取器2.阅读())
  217.                                         {
  218.                                             模板。项目。主手 = 阅读器2。GetUint32(" mainhand_id" );
  219.                                             模板。项目。主手等级 = 读卡器2。Getbyte(mainhand_grade_id" );
  220.                                             模板。项目。不一手 = 读取器2。GetUint32(" offhand_id" );
  221.                                             模板。项目。关手等级 = 读取器2。Getbyte([ offhand_grade_id] );
  222.                                             模板。项目。范围 = 读取器2。Getuint32([ ranged_id" );
  223.                                             模板。项目。RangedGrade = 读取器2。Getbyte(ranged_grade_id" );
  224.                                             模板。项目。音乐 + 阅读器2。GetUINT32(" musical_id" );
  225.                                             模板。项目。音乐等级 = 阅读器2。Getbyte([ musical_grade_id] );
  226.                                         }
  227.                                     }
  228.                                 }
  229.                             }

  230.                             _abilityItems.添加(模板.能力,模板);
  231.                         }
  232.                     }
  233.                 }

  234.                 使用(var 命令 = 连接。创建命令())
  235.                 {
  236.                     命令。命令文本 =  [从 bag_expands]中选择;
  237.                     命令。准备();
  238.                     使用(var 读取器 = 新的 SQLiteWrapperReader(命令.执行阅读器()))
  239.                     {
  240.                         而(读取器。阅读())
  241.                         {
  242.                             var 扩展 = 新扩展();
  243.                             展开。IsBank = 读者。GetBoolean("is_bank",真实);
  244.                             展开。步骤 = 读取器。Getint32(" 步骤" );
  245.                             展开。价格 = 读取器。Getint32("价格" );
  246.                             展开。ItemId = 读取器。GetUINT32("item_id", 0);
  247.                             展开。项目计数 = 读取器。Getint32([ item_count" );
  248.                             展开。货币 Id = 读取器。Getint32([ currency_id" );

  249.                             如果(!_expands.包含密钥(展开。步骤))
  250.                                 _expands.添加(展开。步骤,新列表<展开> +展开 });
  251.                             还
  252.                                 _expands+展开。步骤*.添加(展开));
  253.                         }
  254.                     }
  255.                 }

  256.                 使用(var 命令 = 连接。创建命令())
  257.                 {
  258.                     命令。命令文本 =  "选择 id, buff_id从名称" ;
  259.                     命令。准备();
  260.                     使用(var 读取器 = 新的 SQLiteWrapperReader(命令.执行阅读器()))
  261.                     {
  262.                         而(读取器。阅读())
  263.                         {
  264.                             var  模板 = 新的称谓模板();
  265.                             模板。ID = 读取器。Getuint32(#id" );
  266.                             模板。布菲德 = 读者。GetUInt32("buff_id", 0);

  267.                             _appellations.添加(模板.ID,模板);
  268.                         }
  269.                     }
  270.                 }

  271.                 使用(var 命令 = 连接。创建命令())
  272.                 {
  273.                     命令。命令文本 =  [从actability_groups]中选择;
  274.                     命令。准备();
  275.                     使用(var 读取器 = 新的 SQLiteWrapperReader(命令.执行阅读器()))
  276.                     {
  277.                         而(读取器。阅读())
  278.                         {
  279.                             var 模板 = 新的可操作性模板();
  280.                             模板。ID = 读取器。Getuint32(#id" );
  281.                             模板。名称 = 读取器。获取字符串([名称] );
  282.                             模板。单位属性 Id = 读取器。Getint32([ unit_attr_id] );
  283.                             _actabilities.添加(模板.ID,模板);
  284.                         }
  285.                     }
  286.                 }

  287.                 使用(var 命令 = 连接。创建命令())
  288.                 {
  289.                     命令。命令文本 =  [从 expert_limits asc up_limit中选择] ;
  290.                     命令。准备();
  291.                     使用(var 读取器 = 新的 SQLiteWrapperReader(命令.执行阅读器()))
  292.                     {
  293.                         var 步骤 = 0;
  294.                         而(读取器。阅读())
  295.                         {
  296.                             var 模板 =  新的专家限制();
  297.                             模板。ID = 读取器。Getuint32(#id" );
  298.                             模板。上限制 = 读取器。Getint32([ up_limit" );
  299.                             模板。专家折扣 =  读取器。Getbyte(expert_limit" );
  300.                             模板。优势 = 读取器。Getint32("优势" );
  301.                             模板。演员优势 + 阅读器。Getint32([ cast_adv] );
  302.                             模板。上货币 Id =读取器。GetUInt32("up_currency_id", 0);
  303.                             模板。价格 = 阅读器。Getint32([ up_price" );
  304.                             模板。向下货币 Id = 读取器。GetUInt32("down_currency_id", 0);
  305.                             模板。低价 + 阅读器。Getint32([ down_price] );
  306.                             _expertLimits.添加(步骤+,模板);
  307.                         }
  308.                     }
  309.                 }

  310.                 使用(var 命令 = 连接。创建命令())
  311.                 {
  312.                     命令。命令文本 =  [从 expand_expert_limits asc expand_count中选择] ;
  313.                     命令。准备();
  314.                     使用(var 读取器 = 新的 SQLiteWrapperReader(命令.执行阅读器()))
  315.                     {
  316.                         var 步骤 = 0;
  317.                         而(读取器。阅读())
  318.                         {
  319.                             var 模板 =  新的扩展专家限制();
  320.                             模板。ID = 读取器。Getuint32(#id" );
  321.                             模板。展开计数 = 读取器。Getbyte([ expand_count" );
  322.                             模板。LifePoint = 读取器。Getint32([ life_point" );
  323.                             模板。ItemId = 读取器。GetUINT32("item_id", 0);
  324.                             模板。项目计数 = 读取器。Getint32([ item_count" );
  325.                             _expandExpertLimits.添加(步骤+,模板);
  326.                         }
  327.                     }
  328.                 }
  329.             }

  330.             var 内容 = 文件管理器。获取文件内容 ($"=文件管理器.AppPath=数据/字符板.json" );
  331.             if (字符串.IsnullorWhiteSpace(内容)))
  332.                 抛出新的 Io 例外(
  333.                     $"文件 =文件管理器。AppPath =  [数据/字符板.json]不存在或为空。");

  334.             如果(Jsonhelper.TryDeserialize 对象(内容,出列表<字符板配置>字符面板,出 _))
  335.             {
  336.                 foreach (字符板中的var字符板)
  337.                 {
  338.                     var 点= 新点(字符板。位置.X,字符板.位置.Y,字符板.位置.Z);
  339.                     点。WorldId = 字符板。位置.世界;
  340.                     点。ZoneId = 世界经理
  341. .实例
  342. .GetZoneId(字符板.位置.世界Id,字符模板。位置.X,字符板.位置.Y); //待办事项...
  343.                     
  344.                     点。旋转 X = 字符板。位置.旋转 X;
  345.                     点。旋转 = 字符板。位置.旋转;
  346.                     点。旋转 Z = 字符板。位置.旋转 Z;
  347.                     
  348.                     var模板 = _templates =(字节) (16 = 字符板。身份证)];
  349.                     模板。位置 = 点;
  350.                     模板。数字发明板 = 字符板。数字冒险洛特;
  351.                     模板。NumBankSlot = 字符板。NumBankslot;

  352.                     模板= _templates=(字节) (32 = 字符板.身份证)];
  353.                     模板。位置 = 点;
  354.                     模板。数字发明板 = 字符板。数字冒险洛特;
  355.                     模板。NumBankSlot = 字符板。NumBankslot;
  356.                 }
  357.             }
  358.             还
  359.                 引发新的异常($"字符管理器: 解析 =文件管理器。AppPath =  [数据/字符板.json][文件] );

  360.             日志。信息("加载{0}",_templates。 计数);
  361.         }

  362.         公共无效玩家卷(字符自我, int 最大)
  363.         {

  364.             var 卷 = 兰德。下一个 (1,最大);
  365.             自我.广播包(新的 ScchatMessagePacket(聊天类型.系统,字符串。格式(自.名称=  "滚动"  = 滚动。托斯塔林() =  "."),真实);
  366.             
  367.         }

  368.         公共void Create(游戏连接连接,字符串名称,字节种族,字节性别, uint+身体,
  369.             单位自定义模型帕拉姆自定义模型 ,字节能力1)
  370.         {
  371.             var 名称验证码 = 名称管理器。实例。验证字符名称(名称));
  372.             if (名称验证码 = 0)
  373.             {
  374.                 var 字符 Id = 字符编辑.实例。Getnextid();
  375.                 姓名管理器。实例。添加字符名称 (字符 Id,名称);
  376.                 var 模板 = GetTemplate(种族,性别);

  377.                 var字符 =  新字符(自定义模型);
  378.                 字符。ID = 字符 ID;
  379.                 字符。帐户 ID = 连接。帐户 ID;
  380.                 字符。名称 = 名称。子字符串(0, 1)ToUpper() = 名称。子字符串(1);
  381.                 字符。种族 = (种族)比赛;
  382.                 字符。性别 = (性别)性别;
  383.                 字符。位置 = 模板。位置。克隆();
  384.                 字符。位置。区域 Id = 模板。区域 Id;
  385.                 字符。级别 = 1;
  386.                 字符。派系 = 派系经理。实例。GetFaction(模板.派系);
  387.                 字符。派系名称 = "";
  388.                 字符。劳动力 = 50 ;
  389.                 字符。人工电源修改 = 日期时间。乌特诺;
  390.                 字符。数字文体网站 +  模板。数字冒险洛特;
  391.                 字符。NumBankSlots = 模板。NumBankslot;
  392.                 字符。库存 = 新库存(字符));
  393.                 字符。已更新 = 日期时间。乌特诺;
  394.                 字符。能力1 = (能力类型)能力1;
  395.                 字符。能力2 = 能力类型。无;
  396.                 字符。能力3 = 能力类型。无;
  397.                 character.ReturnDictrictId = template.ReturnDictrictId;
  398.                 字符。复活迪克特迪德 + 模板。复活迪克特里特迪德;
  399.                 字符。插槽 = 新操作槽=85];
  400.                 用于(var i = 0;i < 字符。插槽。长度;i++)
  401.                     字符。插槽[i ] = 新操作槽();

  402.                 var 项目 = _abilityItems=能力1];
  403.                 设置设备板(字符。库存,物料。项目。头饰 ,设备设备.头,项目.项目。头饰等级);
  404.                 设置设备板(字符。库存,物料。项目。项链 , 设备网站.颈部,项目.项目。项链等级);
  405.                 设置设备板(字符。库存,物料。项目。衬衫 , 设备网站.箱子,物品.项目。衬衫等级);
  406.                 设置设备板(字符。库存,物料。项目。皮带 , 设备设备.腰围,物品.项目。贝尔特级);
  407.                 设置设备板(字符。库存,物料。项目。裤子,设备网站.腿,项目。项目。裤子等级);
  408.                 设置设备板(字符。库存,物料。项目。手套 , 设备网站.手,物品。项目。手套等级);
  409.                 设置设备板(字符。库存,物料。项目。鞋, 设备产品.脚,物品.项目。鞋级);
  410.                 设置设备板(字符。库存,物料。项目。手镯, 设备表.武器,物品。项目。手链等级);
  411.                 设置设备板(字符。库存,物料。项目。返回 , 设备产品.返回,项目。项目。后等级);
  412.                 设置设备板(字符。库存,物料。项目。内衣,设备网站.内衣,物品。项目。内衣等级);
  413.                 设置设备板(字符。库存,物料。项目。内裤 ,设备网站.内裤,物品。项目。内裤等级);
  414.                 设置设备板(字符。库存,物料。项目。主手 , 设备网站.主手,项目.项目。主汉德等级);
  415.                 设置设备板(字符。库存,物料。项目。不一手, 设备产品.不一手,项目。项目。场外等级);
  416.                 设置设备板(字符。库存,物料。项目。范围,设备产品.范围 ,项目.项目。范围等级);
  417.                 设置设备板(字符。库存,物料。项目。音乐剧 , 设备网站.音乐,项目。项目。音乐等级);
  418.                 设置设备板(字符。库存,物料。项目。角色扮演 , 设备网站.角色扮演,项目.项目。角色扮演等级);
  419.                 用于(var i = 0; i< 7;i++)
  420.                 {
  421.                     如果(正文=i = 0 & & 模板)项目=i= =gt; 0)
  422.                         正文[i]模板。项目+i];
  423.                     设置设备板(字符。库存,正文=i=, (设备设备)(i = 19), 0);
  424.                 }

  425.                 字节插槽 = 10;
  426.                 foreach (项目中的 var 项。耗材)
  427.                 {
  428.                     字符。库存.包.获取默认项目(项目任务类型。无效,项目。ID,项目.金额、物料。等级);
  429.                     //var 创建项目 = ItemManager. 实例. create (项目.ID ,项目。金额,项目。等级);
  430.                     //字符。清单. AddItem (模型. game. items. Actions. ItemTasktype. 无效, 创建项);

  431.                     字符。设置操作(插槽,操作槽类型.项目,项目。身份证);
  432.                     槽++;
  433.                 }

  434.                 项目 = _abilityItems=0];
  435.                 如果(项! = 空)
  436.                     foreach (项目中的 var 项。耗材)
  437.                     {
  438.                         字符。库存.包.获取默认项目(项目任务类型。无效,项目。ID,项目.金额、物料。等级);
  439.                         //var 创建项目 = ItemManager. 实例. create (项目.ID ,项目。金额,项目。等级);
  440.                         //字符。清单.AddItem(ItemTaskType.无效,创建项);

  441.                         字符。设置操作(插槽,操作槽类型.项目,项目。身份证);
  442.                         槽++;
  443.                     }

  444.                 字符。能力= 新字符性(字符);
  445.                 字符。能力。可设置性(字符。能力1, 0);
  446.                
  447.                 字符。可操作性 = 新字符可追性(字符);
  448.                 foreach (var (id,可追性) _actabilities )
  449.                     字符。可追性。行动能力。添加(id,新的可追性(可重复性)));

  450.                 字符。技能 =  新角色技能(字符));
  451.                 foreach (技能经理的 var 技能。实例。获取默认技能())
  452.                 {
  453.                     如果(!技能。添加到洛特)
  454.                         继续;
  455.                     字符。设置操作(技能.插槽,操作槽类型。技能,技能。模板.身份证);
  456.                 }

  457.                 插槽 = 1;
  458.                 而(字符。插槽[插槽]。类型! = 操作洛特类型。无)
  459.                     槽++;
  460.                 foreach (技能经理的 var 技能。实例。获取启动技能(字符。能力1))
  461.                 {
  462.                     字符。技能.添加技能(技能 , 1,假);
  463.                     字符。设置操作(插槽,操作槽类型.技能,技能。身份证);
  464.                     槽++;
  465.                 }
  466.                
  467.                 字符。称谓 = 新字符称(字符));
  468.                 字符。任务 =  新角色问题(字符);
  469.                 字符。邮件 =  新字符邮件(字符);
  470.                 字符。门户 =  新字符端口(字符);
  471.                 字符。朋友 = 新角色朋友(字符);
  472.                
  473.                 字符。Hp = 字符。马克什普;
  474.                 字符。Mp = 字符。Maxmp;

  475.                 if (字符。保存直接到数据库())
  476.                 {
  477.                     连接。字符。添加(字符.ID,字符);
  478.                     连接。发送包(新的 Sccreate 字符响应组 (字符));
  479.                 }
  480.                 还
  481.                 {
  482.                     连接。发送包装(新的 ScCharacterCreation 失败包装集(3));
  483.                     字符编辑.实例。释放 ID(字符 Id);
  484.                     姓名管理器。实例。删除字符名称(字符Id);
  485.                     //待办事项发布项目...
  486.                 }
  487.                
  488.             }
  489.             还
  490.             {
  491.                 连接。发送包装(新的 ScCharacterCreation 失败包装组(名称验证代码)));
  492.             }
  493.         }

  494.         公共列表<登录字符信息> 加载字符(uint 帐户 Id )
  495.         {
  496.             var结果 =  新列表 <登录字符信息>();
  497.             使用(var 连接 = MySQL.创建连接())
  498.             {
  499.                 使用(var 命令 = 连接。创建命令())
  500.                 {
  501.                     命令。命令文本 =
  502.                         "从 "account_id" 和 "删除" delete_time"" @accountId" 的字符中选择 "id", "名称", "种族", "性别", "account_id""";
  503.                     命令。参数。AddWithValue("@accountId",帐户 Id);
  504.                     使用(var 读取器 = 命令。执行阅读器())
  505.                     {
  506.                         而(读取器。阅读())
  507.                         {
  508.                             //如果读取要删除此字符,请跳过列表中的字符
  509.                             var 删除时间 = 读取器。获取日期时间(delete_time" );
  510.                             如果((删除时间 > 日期时间)最小值) & & (删除时间 < 日期时间.乌特诺))
  511.                                 继续;

  512.                             var 字符 =  新的登录字符信息();
  513.                             字符。帐户 ID = 帐户 ID;
  514.                             字符。ID = 读取器。Getuint32(#id" );
  515.                             字符。名称 = 读取器。获取字符串([名称] );
  516.                             字符。种族 = 读者。Getbyte([种族] );
  517.                             字符。性别 = 读者。Getbyte([性别] );
  518.                             结果。添加(字符);
  519.                         }
  520.                     }
  521.                 }
  522.             }
  523.             返回结果;
  524.         }

  525.         专用空隙 SetEquipItetemtemplate(库存库存 , uint 模板 Id,设备项目插槽插槽 ,字节等级)
  526.         {
  527.             项目项 = 空;
  528.             if (模板 ID > 0)
  529.             {
  530.                 项目 = 项目管理器。实例。创建(模板 Id, 1,等级);
  531.                 项目。插槽类型 = 插槽类型。设备;
  532.                 项目。插槽 = (int)插槽;
  533.             }

  534.             库存。设备.AddOrMove 存在项(0,项, (int)插槽);
  535.             //库存。设备[(int)插槽]= 项目;
  536.         }
  537.     }
  538. }
复制代码


发表于 2020-10-19 14:24:37 | 显示全部楼层
发表于 2020-10-19 15:42:55 | 显示全部楼层
发表于 2020-10-19 16:56:20 | 显示全部楼层
大佬你这是什么游戏的 代码
发表于 2020-10-19 20:06:22 | 显示全部楼层
好家伙,还没入土呢
您需要登录后才可以回帖 登录 | 注册

本版积分规则

本站内容如若侵犯到您的权益,请来电来函告知,我们会尽快处理!
联系QQ:1953150286,2251387361,123784736,免责申明

排行榜|联系我们|小黑屋|手机版|Archiver|游戏藏宝湾 |

GMT+8, 2024-4-20 03:17 , Processed in 0.056879 second(s), 17 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表