コード例 #1
0
 public bool Add(int index, Armor armor)
 {
     if (!_armors.ContainsKey(index) && index >= 0)
     {
         _armors.Add(index, armor);
         return true;
     }
     return false;
 }
コード例 #2
0
        /// <summary>
        /// 类型:方法
        /// 名称:GetCharacter
        /// 作者:taixihuase
        /// 作用:尝试从数据库获取玩家游戏角色信息
        /// 编写日期:2015/7/24
        /// </summary>
        /// <param name="character"></param>
        /// <returns></returns>
        public CharacterCollection.CharacterReturn GetCharacter(Character character)
        {
            CharacterCollection.CharacterReturn characterReturn = new CharacterCollection.CharacterReturn();

            if (character.Nickname == "abcd" || character.Nickname == "efgh")
            {
                #region 测试用例

                character.Position.SetPosition(10, 20, 30);
                int[] exp = new int[DataConstraint.CharacterMaxLevel];
                exp[0] = 0;
                for (int i = 1; i < exp.Length; i++)
                {
                    exp[i] = exp[i - 1] + 10;
                }
                character.Experience.SetEachLevelDemand(exp);
                character.Experience.SetExperience(0, 0, 0, 0);
                character.Experience.GainExperience(0);

                character.Occupation.UpdateOccupation(OccupationCode.Warrior, "战士");
                character.Occupation.BaseHitPoint = 50;
                character.Occupation.BaseLifeRecovery = 5;
                character.Occupation.BaseMana = 10;
                character.Occupation.BaseManaRecovery = 1;
                character.Occupation.Apply(character.Attribute);

                Weapon w = new Weapon(1, 2, "刀", OccupationCode.Warrior | OccupationCode.Paladin, 1, true, 1,
                    DataConstraint.EquipmentMaxDurability, 0, 200, 200, Weapon.WeaponType.Null,
                    Weapon.WeaponAttackType.Physical,
                    Weapon.WeaponElementType.Null);

                character.Weapons.Add(1, w);
                w.UpdateAttackLimit(100, 200, null, null);
                w.UpdateFixedAttribute(AttributeCode.Attack_Physical, 100);
                w.UpdateFixedAttribute(AttributeCode.Attack_Percent_Both, 10);
                w.Upgrade();
                w.Upgrade();
                w.Upgrade(AttributeCode.Attack_Percent_Both, 90);
                w.UpdateElementAttribute(Weapon.WeaponElementType.Lightning);
                w.UpgradeElementAttribute(0);
                w.UpgradeElementEnhanceAttribute(300);
                w.UpgradeElementExtraAttribute(10, 2);

                Armor a = new Armor(10, 20, "头盔", OccupationCode.Warrior, 1, true, 1,
                    DataConstraint.EquipmentMaxDurability, Armor.ArmorType.Helmet);

                character.Armors.Add(1, a);
                a.UpdateDefensePoints(1000, 2000);
                a.UpdateFixedAttribute(AttributeCode.Life_Increase, 1000);
                a.Upgrade();
                a.Upgrade(AttributeCode.Life_Increase_Percent, 50);

                Jewel j = new Jewel(100, 200, "戒指", OccupationCode.Common, 1, false, 1,
                    DataConstraint.EquipmentMaxDurability, Jewel.JewelType.Ring, Jewel.JewelAttributeType.Null);

                character.Jewels.Add(1, j);
                j.UpdateFixedAttribute(AttributeCode.Resistance_All, 22222);
                j.UpdateRandomAttribute(AttributeCode.Attr_Strength, 1234);

                #endregion

                characterReturn.ReturnCode = Success;
                characterReturn.DebugMessage.Append("成功获取角色数据");
            }
            else
            {
                characterReturn.ReturnCode = CharacterNotFound;
                characterReturn.DebugMessage.Append("当前账号尚未创建角色");
            }

            return characterReturn;
        }