using System; using CommonAI.Zone.EventTrigger; using CommonLang.Property; using XmdsCommon.Message; using XmdsCommonServer.Plugin.Scene; using CommonAI.Zone.ZoneEditor.EventTrigger; using XmdsCommonServer.Plugin.Units; using CommonAI.Zone.Attributes; using CommonAI.Zone; using CommonAI.Zone.Instance; using XmdsCommon.Plugin; using CommonAI.Data; using CommonLang; namespace XmdsCommonServer.Plugin.Editor { [DescAttribute("某个单位进入战斗", "Xmds扩展 - 战斗")] public class XmdsUnitCombatStateChanged : AbstractTrigger { public override void Listen(EventTriggerAdapter api, EventArguments args) { var args2 = args.Clone(); var scene = (api.ZoneAPI as XmdsServerScene); var handler = new XmdsServerScene.CombatStateChangeHandler((unit, status) => { if (status != BattleStatus.None) { args2.TriggingUnit = unit; api.TestAndDoAction(args2); } }); scene.OnCombatStateChange += handler; api.OnDisposed += (a) => { scene.OnCombatStateChange -= handler; }; } public override string ToString() { return string.Format("某个单位进入战斗"); } } [DescAttribute("激活单位", "Xmds扩展 - 战斗")] public class XmdsPlayerReady : AbstractAction { [DescAttribute("玩家")] public UnitValue Player = new UnitValue.Trigging(); public override void DoAction(EventTriggerAdapter api, EventArguments args) { var unit = Player.GetValue(api, args) as XmdsInstancePlayer; if (unit != null) { unit.PlayerReady(); } } public override string ToString() { return string.Format("激活单位{0}", Player); } } [DescAttribute("添加变身单位", "Xmds扩展 - 战斗")] public class UnitShapeshiftingAction : AbstractAction { [DescAttribute("单位")] public readonly UnitValue Unit = new UnitValue.Trigging(); [DescAttribute("变身前动作")] public string PreAnimationName; [DescAttribute("变身前动作持续时间(秒)")] public RealValue PreAnimationTimeSEC = new RealValue.VALUE(); [DescAttribute("变身后模板ID")] [TemplateIDAttribute(typeof(UnitInfo))] public int ShapeshiftingTemplateID = 0; public override string ToString() { return string.Format("添加({0})->变身({1})", Unit, ShapeshiftingTemplateID); } override public void DoAction(EventTriggerAdapter api, EventArguments args) { var unit1 = Unit.GetValue(api, args) as InstanceGuard; var state1 = new InstanceUnit.ForceStateActionTime(unit1, PreAnimationTimeSEC.GetValue(api, args), PreAnimationName); state1.AddStopOnce((obj, st) => { addShapeshifting(api, args, unit1); api.ZoneAPI.RemoveObject(unit1); }); unit1.queueState(state1); } void addShapeshifting(EventTriggerAdapter api, EventArguments args, InstanceGuard src) { var info = api.ZoneAPI.Templates.getUnit(ShapeshiftingTemplateID); // var unit2 = api.ZoneAPI.AddUnit(info, src.Name, src.Force, src.Level, src.X, src.Y, src.Direction) as InstanceGuard; unit2.CurrentHP = CUtils.CastInt(src.CurrentHP_Pct * 0.01f * unit2.MaxHP); var c_target = src.TracingTarget; if (c_target != null) { unit2.queueState(new InstanceUnit.StateFollowAndAttack(unit2, c_target)); } } } }