Exemplo n.º 1
0
        public void AddBuff(uint buffId)
        {
            var template = SkillManager.Instance.GetPassiveBuffTemplate(buffId);

            if (template.AbilityId > 0 &&
                template.AbilityId != (byte)Owner.Ability1 &&
                template.AbilityId != (byte)Owner.Ability2 &&
                template.AbilityId != (byte)Owner.Ability3)
            {
                return;
            }
            var points = ExpirienceManager.Instance.GetSkillPointsForLevel(Owner.Level);

            points -= GetUsedSkillPoints();
            if (template.ReqPoints > points)
            {
                return;
            }
            if (PassiveBuffs.ContainsKey(buffId))
            {
                return;
            }
            var buff = new PassiveBuff();

            buff.Id       = buffId;
            buff.Template = template;
            PassiveBuffs.Add(buff.Id, buff);
            Owner.BroadcastPacket(new SCBuffLearnedPacket(Owner.ObjId, buff.Id), true);
            // TODO apply buff effect
        }
Exemplo n.º 2
0
        public void Load(MySqlConnection connection)
        {
            using (var command = connection.CreateCommand())
            {
                command.CommandText = "SELECT * FROM skills WHERE `owner` = @owner";
                command.Parameters.AddWithValue("@owner", Owner.Id);
                using (var reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        var type = (SkillType)Enum.Parse(typeof(SkillType), reader.GetString("type"), true);
                        switch (type)
                        {
                        case SkillType.Skill:
                            var skill = new Skill
                            {
                                Id    = reader.GetUInt32("id"),
                                Level = reader.GetByte("level")
                            };
                            Skills.Add(skill.Id, skill);
                            break;

                        case SkillType.Buff:
                            var buff = new PassiveBuff {
                                Id = reader.GetUInt32("id")
                            };
                            PassiveBuffs.Add(buff.Id, buff);
                            break;
                        }
                    }
                }
            }

            foreach (var skill in Skills.Values)
            {
                if (skill != null)
                {
                    skill.Template = SkillManager.Instance.GetSkillTemplate(skill.Id);
                }
            }
        }
Exemplo n.º 3
0
        public void Reset(AbilityType abilityId) // TODO with price...
        {
            foreach (var skill in new List <Skill>(Skills.Values))
            {
                if (skill.Template.AbilityId != (byte)abilityId)
                {
                    continue;
                }
                Skills.Remove(skill.Id);
                _removed.Add(skill.Id);
            }

            foreach (var buff in new List <PassiveBuff>(PassiveBuffs.Values))
            {
                if (buff.Template.AbilityId != (byte)abilityId)
                {
                    continue;
                }
                PassiveBuffs.Remove(buff.Id);
                _removed.Add(buff.Id);
            }

            Owner.BroadcastPacket(new SCSkillsResetPacket(Owner.ObjId, abilityId), true);
        }