Exemplo n.º 1
0
        private void AddElementAttribute(WeaponElementType weaponElement)
        {
            if (weaponElement != WeaponElementType.Null)
            {
                WeaponElement     = weaponElement;
                ElementAttributes =
                    new KeyValuePair <WeaponElementType, Dictionary <AttributeCode, float> >(weaponElement,
                                                                                             new Dictionary <AttributeCode, float>(new EnumComparer <AttributeCode>())
                {
                    { (AttributeCode)Enum.Parse(typeof(AttributeCode), "Enhance_" + weaponElement), 0 }
                });

                int num = Convert.ToInt32(Enum.Parse(typeof(WeaponElementType), weaponElement.ToString()));
                int mul = 0;
                while ((num += mul * DataConstraint.ElementMaxSize) <=
                       Enum.GetValues(typeof(ElementExtraAttribute)).Length)
                {
                    var s = Enum.GetName(typeof(ElementExtraAttribute), num);
                    if (s != null)
                    {
                        ElementAttributes.Value.Add((AttributeCode)Enum.Parse(typeof(AttributeCode), s), 0);
                    }
                    mul++;
                }
            }
        }
Exemplo n.º 2
0
 public void UpdateElementAttribute(WeaponElementType weaponElement)
 {
     ClearElementAttribute();
     AddElementAttribute(weaponElement);
 }
Exemplo n.º 3
0
        public Dictionary <int, KeyValuePair <AttributeCode, float> > ForgingAttributes; // 锻造附加属性

        /// <summary>
        /// 类型:方法
        /// 名称:Weapon
        /// 作者:taixihuase
        /// 作用:通过数据库中获得的数据构造武器装备实例
        /// 编写日期:2015/8/16
        /// </summary>
        /// <param name="fixedId"></param>
        /// <param name="allocatedId"></param>
        /// <param name="name"></param>
        /// <param name="occupation"></param>
        /// <param name="limit"></param>
        /// <param name="upgrade"></param>
        /// <param name="cur"></param>
        /// <param name="dur"></param>
        /// <param name="elem"></param>
        /// <param name="distance"></param>
        /// <param name="type"></param>
        /// <param name="weaponAttackType"></param>
        /// <param name="weaponElement"></param>
        /// <param name="speed"></param>
        public Weapon(int fixedId, int allocatedId, string name, OccupationCode occupation, int limit, bool upgrade,
                      int cur, int dur, int elem, float speed, float distance,
                      WeaponType type, WeaponAttackType weaponAttackType, WeaponElementType weaponElement)
            : base(fixedId, allocatedId, name, occupation, limit, upgrade, cur, dur, EquipmentType.Weapon)
        {
            Type = type;

            #region 武器属性初始化

            WeaponAttack = weaponAttackType;
            if (weaponAttackType == WeaponAttackType.Both)
            {
                AttackLimit =
                    new Dictionary <WeaponAttackType, KeyValuePair <int, int> >(new EnumComparer <WeaponAttackType>())
                {
                    [WeaponAttackType.Magic]    = new KeyValuePair <int, int>(0, 0),
                    [WeaponAttackType.Physical] = new KeyValuePair <int, int>(0, 0)
                };
            }
            else
            {
                AttackLimit =
                    new Dictionary <WeaponAttackType, KeyValuePair <int, int> >(new EnumComparer <WeaponAttackType>())
                {
                    [weaponAttackType] = new KeyValuePair <int, int>(0, 0)
                };
            }

            #endregion

            ForgingAttributes = new Dictionary <int, KeyValuePair <AttributeCode, float> >
            {
                { -1, new KeyValuePair <AttributeCode, float>(AttributeCode.Null, 0) }
            };
            FixedAttackSpeed    = speed;
            FixedAttackDistance = distance;

            #region 武器元素初始化

            WeaponElement        = weaponElement;
            CurrentElementEnergy = elem;
            if (weaponElement != WeaponElementType.Null)
            {
                ElementAttributes =
                    new KeyValuePair <WeaponElementType, Dictionary <AttributeCode, float> >(weaponElement,
                                                                                             new Dictionary <AttributeCode, float>(new EnumComparer <AttributeCode>())
                {
                    { (AttributeCode)Enum.Parse(typeof(AttributeCode), "Enhance_" + weaponElement), 0 }
                });

                int num = Convert.ToInt32(Enum.Parse(typeof(WeaponElementType), weaponElement.ToString()));
                int mul = 0;
                while ((num += mul * DataConstraint.ElementMaxSize) <=
                       Enum.GetValues(typeof(ElementExtraAttribute)).Length)
                {
                    var s = Enum.GetName(typeof(ElementExtraAttribute), num);
                    if (s != null)
                    {
                        ElementAttributes.Value.Add((AttributeCode)Enum.Parse(typeof(AttributeCode), s), 0);
                    }
                    mul++;
                }
            }
            else
            {
                ElementAttributes =
                    new KeyValuePair <WeaponElementType, Dictionary <AttributeCode, float> >(WeaponElementType.Null,
                                                                                             new Dictionary <AttributeCode, float>(new EnumComparer <AttributeCode>())
                {
                    { AttributeCode.Null, 0 }
                });
            }

            #endregion
        }
Exemplo n.º 4
0
        public Dictionary<int, KeyValuePair<AttributeCode, float>> ForgingAttributes; // 锻造附加属性

        #endregion Fields

        #region Constructors

        /// <summary>
        /// 类型:方法
        /// 名称:Weapon
        /// 作者:taixihuase
        /// 作用:通过数据库中获得的数据构造武器装备实例
        /// 编写日期:2015/8/16
        /// </summary>
        /// <param name="fixedId"></param>
        /// <param name="allocatedId"></param>
        /// <param name="name"></param>
        /// <param name="occupation"></param>
        /// <param name="limit"></param>
        /// <param name="upgrade"></param>
        /// <param name="cur"></param>
        /// <param name="dur"></param>
        /// <param name="elem"></param>
        /// <param name="distance"></param>
        /// <param name="type"></param>
        /// <param name="weaponAttackType"></param>
        /// <param name="weaponElement"></param>
        /// <param name="speed"></param>
        public Weapon(int fixedId, int allocatedId, string name, OccupationCode occupation, int limit, bool upgrade,
            int cur, int dur, int elem, float speed, float distance, 
            WeaponType type, WeaponAttackType weaponAttackType, WeaponElementType weaponElement)
            : base(fixedId, allocatedId, name, occupation, limit, upgrade, cur, dur, EquipmentType.Weapon)
        {
            Type = type;

            #region 武器属性初始化

            WeaponAttack = weaponAttackType;
            if (weaponAttackType == WeaponAttackType.Both)
            {
                AttackLimit =
                    new Dictionary<WeaponAttackType, KeyValuePair<int, int>>(new EnumComparer<WeaponAttackType>())
                    {
                        [WeaponAttackType.Magic] = new KeyValuePair<int, int>(0, 0),
                        [WeaponAttackType.Physical] = new KeyValuePair<int, int>(0, 0)
                    };
            }
            else
            {
                AttackLimit =
                    new Dictionary<WeaponAttackType, KeyValuePair<int, int>>(new EnumComparer<WeaponAttackType>())
                    {
                        [weaponAttackType] = new KeyValuePair<int, int>(0, 0)
                    };
            }

            #endregion

            ForgingAttributes = new Dictionary<int, KeyValuePair<AttributeCode, float>>
            {
                {-1, new KeyValuePair<AttributeCode, float>(AttributeCode.Null, 0)}
            };
            FixedAttackSpeed = speed;
            FixedAttackDistance = distance;

            #region 武器元素初始化

            WeaponElement = weaponElement;
            CurrentElementEnergy = elem;
            if (weaponElement != WeaponElementType.Null)
            {
                ElementAttributes =
                    new KeyValuePair<WeaponElementType, Dictionary<AttributeCode, float>>(weaponElement,
                        new Dictionary<AttributeCode, float>(new EnumComparer<AttributeCode>())
                        {
                            {(AttributeCode) Enum.Parse(typeof (AttributeCode), "Enhance_" + weaponElement), 0}
                        });

                int num = Convert.ToInt32(Enum.Parse(typeof (WeaponElementType), weaponElement.ToString()));
                int mul = 0;
                while ((num += mul*DataConstraint.ElementMaxSize) <=
                       Enum.GetValues(typeof (ElementExtraAttribute)).Length)
                {
                    var s = Enum.GetName(typeof (ElementExtraAttribute), num);
                    if (s != null)
                    {
                        ElementAttributes.Value.Add((AttributeCode) Enum.Parse(typeof (AttributeCode), s), 0);
                    }
                    mul++;
                }
            }
            else
            {
                ElementAttributes =
                    new KeyValuePair<WeaponElementType, Dictionary<AttributeCode, float>>(WeaponElementType.Null,
                        new Dictionary<AttributeCode, float>(new EnumComparer<AttributeCode>())
                        {
                            {AttributeCode.Null, 0}
                        });
            }

            #endregion
        }
Exemplo n.º 5
0
        private void AddElementAttribute(WeaponElementType weaponElement)
        {
            if (weaponElement != WeaponElementType.Null)
            {
                WeaponElement = weaponElement;
                ElementAttributes =
                    new KeyValuePair<WeaponElementType, Dictionary<AttributeCode, float>>(weaponElement,
                        new Dictionary<AttributeCode, float>(new EnumComparer<AttributeCode>())
                        {
                            {(AttributeCode) Enum.Parse(typeof (AttributeCode), "Enhance_" + weaponElement), 0}
                        });

                int num = Convert.ToInt32(Enum.Parse(typeof(WeaponElementType), weaponElement.ToString()));
                int mul = 0;
                while ((num += mul * DataConstraint.ElementMaxSize) <=
                       Enum.GetValues(typeof(ElementExtraAttribute)).Length)
                {
                    var s = Enum.GetName(typeof(ElementExtraAttribute), num);
                    if (s != null)
                    {
                        ElementAttributes.Value.Add((AttributeCode)Enum.Parse(typeof(AttributeCode), s), 0);
                    }
                    mul++;
                }
            }
        }
Exemplo n.º 6
0
 public void UpdateElementAttribute(WeaponElementType weaponElement)
 {
     ClearElementAttribute();
     AddElementAttribute(weaponElement);
 }
Exemplo n.º 7
0
 public void ClearElementAttribute()
 {
     WeaponElement = WeaponElementType.Null;
     CurrentElementEnergy = 0;
     ElementAttributes =
         new KeyValuePair<WeaponElementType, Dictionary<AttributeCode, float>>(WeaponElementType.Null,
             new Dictionary<AttributeCode, float>(new EnumComparer<AttributeCode>())
             {
                 {AttributeCode.Null, 0}
             });
 }