当前位置: 首页>>代码示例>>C#>>正文


C# Char.EquipSlots方法代码示例

本文整理汇总了C#中System.Char.EquipSlots方法的典型用法代码示例。如果您正苦于以下问题:C# Char.EquipSlots方法的具体用法?C# Char.EquipSlots怎么用?C# Char.EquipSlots使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Char的用法示例。


在下文中一共展示了Char.EquipSlots方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SaveCharacter

        public void SaveCharacter(Account acc, Char chr)
        {
            MySqlCommand cmd = CreateQuery();
            cmd.CommandText = @"UPDATE characters SET
            [email protected],
            [email protected],
            [email protected],
            [email protected],
            [email protected],
            [email protected],
            [email protected],
            [email protected],
            [email protected],
            [email protected],
            [email protected]
            WHERE [email protected] AND [email protected];";
            cmd.Parameters.AddWithValue("@accId", acc.AccountId);
            cmd.Parameters.AddWithValue("@charId", chr.CharacterId);

            cmd.Parameters.AddWithValue("@level", chr.Level);
            cmd.Parameters.AddWithValue("@exp", chr.Exp);
            cmd.Parameters.AddWithValue("@fame", chr.CurrentFame);
            cmd.Parameters.AddWithValue("@items", Utils.GetCommaSepString(chr.EquipSlots()));
            cmd.Parameters.AddWithValue("@stats", Utils.GetCommaSepString(new[]
            {
                chr.MaxHitPoints,
                chr.MaxMagicPoints,
                chr.Attack,
                chr.Defense,
                chr.Speed,
                chr.HpRegen,
                chr.MpRegen,
                chr.Dexterity
            }));
            cmd.Parameters.AddWithValue("@hp", chr.HitPoints);
            cmd.Parameters.AddWithValue("@mp", chr.MagicPoints);
            cmd.Parameters.AddWithValue("@tex1", chr.Tex1);
            cmd.Parameters.AddWithValue("@tex2", chr.Tex2);
            cmd.Parameters.AddWithValue("@pet", chr.Pet);
            chr.PCStats =
                Convert.ToBase64String(ZlibStream.CompressBuffer(chr.FameStats.Write()))
                    .Replace('+', '-')
                    .Replace('/', '_');
            cmd.Parameters.AddWithValue("@fameStats", chr.PCStats);
            cmd.ExecuteNonQuery();

            cmd = CreateQuery();
            cmd.CommandText = @"INSERT INTO classstats(accId, objType, bestLv, bestFame)
            VALUES(@accId, @objType, @bestLv, @bestFame)
            ON DUPLICATE KEY UPDATE
            bestLv = GREATEST(bestLv, @bestLv),
            bestFame = GREATEST(bestFame, @bestFame);";
            cmd.Parameters.AddWithValue("@accId", acc.AccountId);
            cmd.Parameters.AddWithValue("@objType", chr.ObjectType);
            cmd.Parameters.AddWithValue("@bestLv", chr.Level);
            cmd.Parameters.AddWithValue("@bestFame", chr.CurrentFame);
            cmd.ExecuteNonQuery();

            SaveBackpacks(chr, acc);
        }
开发者ID:C453,项目名称:OryxKingdom,代码行数:60,代码来源:Database.cs

示例2: ProcessCreatePacket

        private void ProcessCreatePacket(CreatePacket pkt)
        {
            var nextCharId = 1;
            var maxChar = 2;
            nextCharId = db.GetNextCharId(account);
            var cmd = db.CreateQuery();
            cmd.CommandText = "SELECT maxCharSlot FROM accounts WHERE [email protected];";
            cmd.Parameters.AddWithValue("@accId", account.AccountId);
            try
            {
                maxChar = (int)cmd.ExecuteScalar();
            }
            catch
            {
            }
            cmd = db.CreateQuery();
            cmd.CommandText = "SELECT COUNT(id) FROM characters WHERE [email protected] AND dead = FALSE;";
            cmd.Parameters.AddWithValue("@accId", account.AccountId);
            var currChar = (int)(long)cmd.ExecuteScalar();

            if (currChar >= maxChar)
            {
                Disconnect();
                db.Dispose();
                return;
            }
            if (CheckAccountInUse(account.AccountId) != false)
            {
                Console.ForegroundColor = ConsoleColor.Blue;
                Console.WriteLine(@"Account in use: " + account.AccountId);
                Console.ForegroundColor = ConsoleColor.White;
                SendPacket(new FailurePacket
                {
                    Message = "Account in use! Retrying..."
                });
                db.Dispose();
                return;
            }

            character = Database.CreateCharacter(pkt.ObjectType, nextCharId);
            var stats = new int[]
            {
                character.MaxHitPoints,
                character.MaxMagicPoints,
                character.Attack,
                character.Defense,
                character.Speed,
                character.Dexterity,
                character.HpRegen,
                character.MpRegen,
            };

            var ok = true;
            cmd = db.CreateQuery();
            cmd.Parameters.AddWithValue("@accId", account.AccountId);
            cmd.Parameters.AddWithValue("@charId", nextCharId);
            cmd.Parameters.AddWithValue("@charType", pkt.ObjectType);
            cmd.Parameters.AddWithValue("@items", Utils.GetCommaSepString(character.EquipSlots()));
            cmd.Parameters.AddWithValue("@stats", Utils.GetCommaSepString(stats));
            cmd.Parameters.AddWithValue("@fameStats", character.FameStats.ToString());
            cmd.CommandText =
                "INSERT INTO characters (accId, charId, charType, level, exp, fame, items, hp, mp, stats, dead, pet, fameStats) VALUES (@accId, @charId, @charType, 1, 0, 0, @items, 100, 100, @stats, FALSE, -1, @fameStats);";
            var v = cmd.ExecuteNonQuery();
            ok = v > 0;

            if (ok)
            {
                if (account.Bonuses != null)
                    if (account.Bonuses.Count > 0)
                    {
                        var chrEquip = character.Equipment;
                        for (var i = 4; i < 12; i++)
                        {
                            if (chrEquip[i] == -1)
                            {
                                chrEquip[i] = account.Bonuses.First();
                                account.Bonuses.Remove(account.Bonuses.First());
                                SendPacket(new TextPacket
                                {
                                    Name = "",
                                    BubbleTime = 0,
                                    Stars = -1,
                                    Text = "You received " + XmlDatas.TypeToId[chrEquip[i]] + "."
                                });
                                if (account.Bonuses.Count == 0)
                                    break;
                            }
                        }
                        db.SetBonuses(account.AccountId, account.Bonuses);
                        character.Equipment = chrEquip;
                    }
                    else
                    {
                    }
                else
                {
                    account.Bonuses = new List<short>();
                }
                if (IP.Gifts != null)
                    if (IP.Gifts.Count > 0)
//.........这里部分代码省略.........
开发者ID:RoxyLalonde,项目名称:Phoenix-Realms,代码行数:101,代码来源:ClientProcessor.cs

示例3: SaveCharacter

        public void SaveCharacter(Account acc, Char chr)
        {
            if (acc == null || chr == null) return;
            MySqlCommand cmd = CreateQuery();
            cmd.CommandText = @"UPDATE characters SET
            [email protected],
            [email protected],
            [email protected],
            [email protected],
            [email protected],
            [email protected],
            [email protected],
            [email protected],
            [email protected],
            [email protected],
            [email protected],
            [email protected],
            [email protected],
            [email protected],
            [email protected],
            [email protected],
            [email protected],
            [email protected]
            WHERE [email protected] AND [email protected];";
            cmd.Parameters.AddWithValue("@accId", acc.AccountId);
            cmd.Parameters.AddWithValue("@charId", chr.CharacterId);

            cmd.Parameters.AddWithValue("@level", chr.Level);
            cmd.Parameters.AddWithValue("@exp", chr.Exp);
            cmd.Parameters.AddWithValue("@fame", chr.CurrentFame);
            cmd.Parameters.AddWithValue("@hpPots", chr.HealthStackCount);
            cmd.Parameters.AddWithValue("@mpPots", chr.MagicStackCount);
            cmd.Parameters.AddWithValue("@items", Utils.GetCommaSepString(chr.EquipSlots()));
            cmd.Parameters.AddWithValue("@stats", Utils.GetCommaSepString(new[]
            {
                chr.MaxHitPoints,
                chr.MaxMagicPoints,
                chr.Attack,
                chr.Defense,
                chr.Speed,
                chr.HpRegen,
                chr.MpRegen,
                chr.Dexterity
            }));
            cmd.Parameters.AddWithValue("@hp", chr.HitPoints);
            cmd.Parameters.AddWithValue("@mp", chr.MagicPoints);
            cmd.Parameters.AddWithValue("@hasBackpack", chr.HasBackpack);
            cmd.Parameters.AddWithValue("@tex1", chr.Tex1);
            cmd.Parameters.AddWithValue("@tex2", chr.Tex2);
            cmd.Parameters.AddWithValue("@pet", chr.Pet == null ? -1 : chr.Pet.InstanceId);
            cmd.Parameters.AddWithValue("@skin", chr.Skin);
            cmd.Parameters.AddWithValue("@xpTime", chr.XpTimer);
            cmd.Parameters.AddWithValue("@lootDropTime", chr.LDTimer);
            cmd.Parameters.AddWithValue("@lootTierTime", chr.LTTimer);
            chr.PCStats =
                Convert.ToBase64String(chr.FameStats.Write())
                    .Replace('+', '-')
                    .Replace('/', '_');
            cmd.Parameters.AddWithValue("@fameStats", chr.PCStats);
            cmd.ExecuteNonQuery();

            cmd = CreateQuery();
            cmd.CommandText = @"INSERT INTO classstats(accId, objType, bestLv, bestFame)
            VALUES(@accId, @objType, @bestLv, @bestFame)
            ON DUPLICATE KEY UPDATE
            bestLv = GREATEST(bestLv, @bestLv),
            bestFame = GREATEST(bestFame, @bestFame);";
            cmd.Parameters.AddWithValue("@accId", acc.AccountId);
            cmd.Parameters.AddWithValue("@objType", chr.ObjectType);
            cmd.Parameters.AddWithValue("@bestLv", chr.Level);
            cmd.Parameters.AddWithValue("@bestFame", chr.CurrentFame);
            cmd.ExecuteNonQuery();

            SaveBackpacks(chr, acc);
        }
开发者ID:SirAnuse,项目名称:fabiano-swagger-of-doom,代码行数:75,代码来源:Database.cs


注:本文中的System.Char.EquipSlots方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。