Exemplo n.º 1
0
        public DtoHero(int id, int typeId, int team, int maxHp, int attack, int defense,
                       double attackDistance, double attackInterval, string name, int maxMp, double speed, int[] skillIds)
            : base(id, typeId, team, maxHp, attack, defense, attackDistance, attackInterval, speed, name)
        {
            CurMp    = MaxMp = maxMp;
            Level    = 1;
            Exp      = 0;
            Money    = 500;
            SkillIds = skillIds;
            SP       = 1;
            Kill     = 0;
            Death    = 0;

            // 初始化装备id为-1
            Equipments = new int[ServerConfig.ItemMaxCount];
            for (int i = 0; i < Equipments.Length; i++)
            {
                Equipments[i] = -1;
            }

            // 初始化技能
            Skills = new DtoSkill[SkillIds.Length];
            for (int i = 0; i < SkillIds.Length; i++)
            {
                SkillModel model = SkillData.GetSkill(SkillIds[i]);
                if (model != null)
                {
                    Skills[i] = new DtoSkill(model, 0);
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 升级技能
        /// </summary>
        /// <param name="skillId"></param>
        /// <returns></returns>
        public DtoSkill UpgradeSkill(int skillId)
        {
            DtoSkill skill = null;

            foreach (DtoSkill item in Skills)
            {
                if (item.Id == skillId)
                {
                    skill = item;
                    break;
                }
            }
            if (skill == null)
            {
                return(null);
            }

            SP -= 1;
            // 升级技能
            skill.Upgrade();
            return(skill);
        }