123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348 |
- using CommonAI.Zone.Attributes;
- using CommonAI.Zone.EventTrigger;
- using CommonAI.Zone.Instance;
- using CommonAI.Zone.ZoneEditor.EventTrigger;
- using CommonLang;
- using CommonLang.Property;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using XmdsCommon.Message;
- using XmdsCommonServer.Message;
- using XmdsCommonServer.Plugin.Scene;
- namespace XmdsCommonServer.Plugin.Editor
- {
- [DescAttribute("Xmds脚本-通知客户端添加单位", "Xmds扩展")]
- public class ScriptUnitAddedAction : AbstractAction
- {
- [DescAttribute("单位")]
- public UnitValue Unit = new UnitValue.LastAdded();
- public override string ToString()
- {
- return string.Format("Xmds脚本-通知客户端添加单位({0})", Unit);
- }
- override public void DoAction(EventTriggerAdapter api, EventArguments args)
- {
- InstanceUnit unit = Unit.GetValue(api, args);
- if (unit != null)
- {
- api.ZoneAPI.queueEvent(new ScriptAddUnitEventsB2C(unit));
- }
- }
- }
- [DescAttribute("Xmds脚本-通知客户端删除", "Xmds扩展")]
- public class ScriptUnitRemovedAction : AbstractAction
- {
- [DescAttribute("单位")]
- public UnitValue Unit = new UnitValue.LastKilled();
- public override string ToString()
- {
- return string.Format("Xmds脚本-通知客户端删除单位({0})", Unit);
- }
- override public void DoAction(EventTriggerAdapter api, EventArguments args)
- {
- InstanceUnit unit = Unit.GetValue(api, args);
- if (unit != null)
- {
- api.ZoneAPI.queueEvent(new ScriptRemoveUnitEventsB2C(unit));
- }
- }
- }
- [DescAttribute("Xmds扩展事件-通知服务端传送单位", "Xmds扩展")]
- public class XmdsTransUnitEventAction : AbstractAction
- {
- [DescAttribute("单位")]
- public UnitValue Unit = new UnitValue.LastKilled();
- [DescAttribute("目的地场景ID")]
- public int SceneID = 0;
- [DescAttribute("场景坐标X")]
- public int X = 0;
- [DescAttribute("场景坐标Y")]
- public int Y = 0;
- public override string ToString()
- {
- return string.Format("Xmds扩展事件-通知服务端传送单位{0}至场景{1},坐标:X = {2} Y = {3}", Unit, SceneID, X, Y);
- }
- public override void DoAction(EventTriggerAdapter api, EventArguments args)
- {
- InstancePlayer unit = Unit.GetValue(api, args) as InstancePlayer;
- if (unit != null)
- {
- TransUnitEventB2R evt = new TransUnitEventB2R();
- evt.playerId = unit.PlayerUUID;
- evt.SceneID = SceneID;
- evt.TargetX = X;
- evt.TargetY = Y;
- unit.queueEvent(evt);
- }
- }
- }
- [DescAttribute("Xmds扩展事件-通知战斗服重置所有状态", "Xmds扩展")]
- public class XmdsUnitResetAction : AbstractAction
- {
- [DescAttribute("单位")]
- public UnitValue Unit = new UnitValue.LastKilled();
- public override string ToString()
- {
- return string.Format("Xmds扩展事件-重置指定单位{0}所有状态", Unit);
- }
- public override void DoAction(EventTriggerAdapter api, EventArguments args)
- {
- InstancePlayer unit = Unit.GetValue(api, args) as InstancePlayer;
- if (unit != null)
- {
- (unit.Virtual as XmdsVirtual).Reset();
- }
- }
- }
- [DescAttribute("Xmds扩展事件-事件计时器重置", "Xmds扩展")]
- public class ResetTriggerTimerAction : AbstractAction
- {
- [DescAttribute("重置触发器名字")]
- public string TriggerName = null;
- [DescAttribute("触发器")]
- public override string ToString()
- {
- return string.Format("Xmds扩展事件-重置计时器");
- }
- public override void DoAction(EventTriggerAdapter api, EventArguments args)
- {
- EventTriggerAdapter eta = api.Group.GetEditEvent(TriggerName);
- if (eta != null)
- {
- eta.ResetTimeTask();
- }
- }
- }
- [DescAttribute("某个玩家的剧情脚本已结束", "Xmds扩展")]
- public class DramaOverTrigger : AbstractTrigger
- {
- public override void Listen(EventTriggerAdapter api, EventArguments args)
- {
- var args2 = args.Clone();
- XmdsServerScene scene = (api.ZoneAPI as XmdsServerScene);
- XmdsServerScene.OnHandleObjectActionHandler handler = new XmdsServerScene.OnHandleObjectActionHandler((unit, action) =>
- {
- if (action is PlayerDramaEndAction)
- {
- args2.TriggingUnit = unit as InstanceUnit;
- api.SetAttribute("TriggingDramaID", (action as PlayerDramaEndAction).dramaId);
- api.TestAndDoAction(args2);
- }
- });
- scene.OnHandleObjectAction += handler;
- api.OnDisposed += (a) =>
- {
- scene.OnHandleObjectAction -= handler;
- };
- }
- public override string ToString()
- {
- return string.Format("某个玩家的剧情脚本已结束");
- }
- }
- [DescAttribute("触发中的剧情ID", "Xmds扩展")]
- public class TriggingDramaID : StringValue
- {
- public override string ToString()
- {
- return string.Format("触发中的剧情ID");
- }
- public override string GetValue(IEditorValueAdapter api, EventArguments args)
- {
- return api.GetAttribute("TriggingDramaID") as string;
- }
- }
- /// <summary>
- /// 发送战中特殊飘字事件.
- /// </summary>
- [DescAttribute("Xmds扩展事件-发送战中飘字事件", "Xmds扩展")]
- public class SendBattleFloatTipsEventAction : AbstractAction
- {
- [DescAttribute("单位")]
- public UnitValue Unit = new UnitValue.Trigging();
- [DescAttribute("飘字类型")]
- public CommonAI.XmdsConstConfig.BattleFloatTipsType Type;
- public override string ToString()
- {
- return string.Format("Xmds扩展事件-向{0}发送战中飘字事件", Unit);
- }
- public override void DoAction(EventTriggerAdapter api, EventArguments args)
- {
- InstancePlayer unit = Unit.GetValue(api, args) as InstancePlayer;
- if (unit != null)
- {
- BattleFloatTipsEventB2C evt = new BattleFloatTipsEventB2C();
- evt.Type = Type;
- (unit.Virtual as XmdsVirtual).SendBattleFloatTipsEventB2C(evt);
- }
- }
- }
- [DescAttribute("Xmds扩展事件-通知游戏服触发场景事件", "Xmds扩展")]
- public class XmdsTriggerSceneEventtAction : AbstractAction
- {
- [DescAttribute("单位")]
- public UnitValue Unit = new UnitValue.LastKilled();
- [DescAttribute("事件ID")]
- public string EventID = null;
- public override string ToString()
- {
- return string.Format("Xmds扩展事件-通知服务端玩家单位{0}触发场景事件{1}", Unit, EventID);
- }
- public override void DoAction(EventTriggerAdapter api, EventArguments args)
- {
- InstancePlayer unit = Unit.GetValue(api, args) as InstancePlayer;
- if (unit != null)
- {
- TriggerSceneEventB2R evt = new TriggerSceneEventB2R();
- evt.playerId = unit.PlayerUUID;
- evt.EventID = EventID;
- unit.queueEvent(evt);
- }
- }
- }
- [DescAttribute("Xmds扩展事件-通知客户端指定单位播放声音.", "Xmds扩展")]
- public class XmdsPlaySoundForOne : AbstractAction
- {
- [DescAttribute("单位")]
- public UnitValue Unit = new UnitValue.LastKilled();
- [DescAttribute("声音文件")]
- [ResourceIDAttribute]
- public string SoundName = null;
- public override string ToString()
- {
- return string.Format("Xmds扩展事件-通知客户端向个别单位播放声音");
- }
- public override void DoAction(EventTriggerAdapter api, EventArguments args)
- {
- InstancePlayer unit = Unit.GetValue(api, args) as InstancePlayer;
- if (unit != null)
- {
- PlaySoundEventB2CForOne evt = new PlaySoundEventB2CForOne();
- evt.SoundName = SoundName;
- unit.queueEvent(evt);
- }
- }
- }
- [DescAttribute("Xmds扩展事件-通知客户端广播播放声音.", "Xmds扩展")]
- public class XmdsPlaySoundForAll : AbstractAction
- {
- [DescAttribute("声音文件名")]
- [ResourceIDAttribute]
- public string SoundName = null;
- public override string ToString()
- {
- return string.Format("Xmds扩展事件-通知客户端广播播放声音");
- }
- public override void DoAction(EventTriggerAdapter api, EventArguments args)
- {
- PlaySoundEventB2CForAll evt = new PlaySoundEventB2CForAll();
- evt.SoundName = SoundName;
- api.ZoneAPI.queueEvent(evt);
- }
- }
- [DescAttribute("Xmds扩展事件-向游戏服发送战报", "Xmds扩展")]
- public class SendXmdsBattleReportAction : AbstractAction
- {
- public override string ToString()
- {
- return string.Format("Xmds扩展事件-向游戏服发送战报");
- }
- public override void DoAction(EventTriggerAdapter api, EventArguments args)
- {
- var e = new BattleReportEventB2R
- {
- instanceId = api.ZoneAPI.UUID
- };
- // using (var a = ListObjectPool<InstancePlayer>.AllocAutoRelease(api.ZoneAPI.AllPlayers))
- using (var a = ListObjectPool<InstanceUnit>.AllocAutoRelease(api.ZoneAPI.AllUnits))
- {
- e.data = new List<UnitBattleReportDetail>();
- foreach (var b in a.Where(b => b.Statistic.TotalDamage > 0 || b.Statistic.TotalHealing > 0))
- {
- e.data.Add(new UnitBattleReportDetail()
- {
- ID = b.ID,
- PlayerUUID = b.PlayerUUID,
- TemplateID = b.Info.TemplateID,
- Force = b.Force,
- TotalDamage = (int)b.Statistic.TotalDamage,
- TotalHealing = (int)b.Statistic.TotalHealing,
- });
- }
- }
- api.ZoneAPI.queueEvent(e);
- }
- }
- /// <summary>
- /// 发送BOSS被击杀通知.
- /// </summary>
- [DescAttribute("Xmds扩展事件-向游戏服发送谁击杀了BOSS.", "Xmds扩展")]
- public class SendBossKillEventAction : AbstractAction
- {
- [DescAttribute("单位")]
- public UnitValue Unit = new UnitValue.LastKilled();
- public override string ToString()
- {
- return string.Format("Xmds扩展事件-向游戏服发送谁击杀了BOSS");
- }
- public override void DoAction(EventTriggerAdapter api, EventArguments args)
- {
- InstancePlayer unit = Unit.GetValue(api, args) as InstancePlayer;
- if (unit != null && unit.Virtual != null)
- {
- var evt = new KillBossEventB2R();
- evt.instanceId = api.ZoneAPI.UUID;
- evt.PlayerUUID = (unit.Virtual as XmdsVirtual).GetPlayerUUID();
- api.ZoneAPI.queueEvent(evt);
- }
- }
- }
- }
|