public override void Run(RoleBase caster, Space space, MagicArgs args) { caster.ClearAttacher(); for (int i = 0; i < args.Number; i++) { Point p = new Point(caster.Coordinate.X + RandomSeed.Next(-5, 5), caster.Coordinate.Y + RandomSeed.Next(-5, 5)); if (!space.Terrain.InEffectiveRange(p) || (args.SpaceLayer == SpaceLayers.Ground && space.Terrain.Matrix[(int)p.X, (int)p.Y] == 0)) { p = caster.Coordinate; } AnimationBase magic = new AnimationBase() { Code = args.ResCode, SpaceLayer = args.SpaceLayer, Position = space.Terrain.GetPositionFromCoordinate(p), Z = args.MagicLayer == MagicLayers.Ground ? -1 : (int)args.Position.Y }; EventHandler handler = null; magic.Disposed += handler = delegate { magic.Disposed -= handler; space.RemoveAnimation(magic); }; space.AddAnimation(magic); //解析配置 XElement xMonster = Infos["Monster"].DescendantsAndSelf("Monsters").Elements().Single(X => X.Attribute("ID").Value == args.AdditionalEffect.ToString()); Monster monster = new Monster(space.Terrain) { ID = (int)xMonster.Attribute("ID") + countID, AttachID = caster.AttachID, Code = (int)xMonster.Attribute("Code"), ArmorCode = (int)xMonster.Attribute("ArmorCode"), AttackRange = (int)xMonster.Attribute("AttackRange"), FullName = string.Format("{0}的召唤兽", caster.FullName), Profession = Professions.Monster, Direction = caster.Direction, State = States.Walking, Camp = caster.Camp, LifeMax = Convert.ToDouble(args.Tag), Life = Convert.ToDouble(args.Tag), SpaceLayer = caster.SpaceLayer, Coordinate = p, TacticAI = TacticAIs.GuardMaster, ActionAI = ActionAIs.Simple, FullNameColor = Colors.Orange, ATK = ObjectBase.RandomSeed.Next(1300, 1600), DEF = ObjectBase.RandomSeed.Next(600, 900), MAG = ObjectBase.RandomSeed.Next(400, 500), DEX = ObjectBase.RandomSeed.Next(0, 30), }; if (xMonster.Attribute("LearnedMagic").Value != string.Empty) { string[] str = xMonster.Attribute("LearnedMagic").Value.Split(','); for (int j = 0; j < str.Count(); j++) { string[] value = str[j].Split('_'); monster.LearnedMagic.Add(Convert.ToInt32(value[0]), Convert.ToInt32(value[1])); } } space.AddRole(monster, new RoleAddedEventArgs() { RegisterDisposedEvent = (bool)xMonster.Attribute("RegisterDisposedEvent"), RegisterIntervalTriggerEvent = (bool)xMonster.Attribute("RegisterIntervalTriggerEvent"), RegisterActionTriggerEvent = (bool)xMonster.Attribute("RegisterActionTriggerEvent"), RegisterDoAttackEvent = (bool)xMonster.Attribute("RegisterDoAttackEvent"), RegisterDoCastingEvent = (bool)xMonster.Attribute("RegisterDoCastingEvent"), RegisterPositionChangedEvent = (bool)xMonster.Attribute("RegisterPositionChangedEvent"), RegisterLifeChangedEvent = (bool)xMonster.Attribute("RegisterLifeChangedEvent"), }); monster.Master = caster; caster.AttachRoles.Add(monster); countID++; if (countID == 10000) { countID = 0; } } }