Ejemplo n.º 1
0
        public static void InitSkills(this SkillComponent self)
        {
            DUnit             role          = self.GetParent <DUnit>();
            UnitTypeComponent typeComponent = role.GetComponent <UnitTypeComponent>();
            JsonData          parameter     = null;

            if (typeComponent.UnitType == UnitType.UnitRole)
            {
                parameter = JsonMapper.ToObject(role.GetComponent <URoleConfigComponent>().RoleConfig.Skills);
            }
            else if (typeComponent.UnitType == UnitType.UnitTower)
            {
                parameter = JsonMapper.ToObject(role.GetComponent <UTowerConfigComponent>().TowerConfig.Skills);
            }
            else if (typeComponent.UnitType == UnitType.UnitTrap)
            {
                parameter = JsonMapper.ToObject(role.GetComponent <UTrapConfigComponent>().TrapConfig.Skills);
            }
            else
            {
                parameter = JsonMapper.ToObject(role.GetComponent <UShellConfigComponent>().ShellConfig.Skills);
            }

            JsonData skills = parameter["skills"];

            if (skills != null)
            {
                for (int i = 0; i < skills.Count; i++)
                {
                    int skillid = (int)skills[i];
                    self.AddSkill(skillid);
                }
            }
        }
Ejemplo n.º 2
0
        public static void EnterDamageTrigger(this Skill self, DUnit unit)
        {
            // 如果符合阵营条件
            if (!SkillTargetHelper.IsTargetCamp(self.TargetCamp, self.Self.GetComponent <CampComponent>().Camp, unit.GetComponent <CampComponent>().Camp))
            {
                return;
            }

            // 如果符合类型条件
            UnitTypeComponent typeComponent = unit.GetComponent <UnitTypeComponent>();

            if (typeComponent.UnitType == UnitType.UnitRole)
            {
                URoleConfigComponent uRoleConfig = unit.GetComponent <URoleConfigComponent>();
                if (!SkillTargetHelper.IsTargetType(self.TargetType, uRoleConfig.RoleType))
                {
                    return;
                }
            }

            self.DamageList.List.Add(unit.Id);
        }