123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344 |
- using CommonAI.Zone.Attributes;
- using CommonAI.Zone.EventTrigger;
- using CommonAI.Zone.Helper;
- using CommonAI.Zone.Instance;
- using CommonLang.Property;
- using CommonLang.Vector;
- using System;
- using System.Collections.Generic;
- namespace CommonAI.Zone.ZoneEditor.EventTrigger
- {
- [DescAttribute("发送系统聊天消息", "场景")]
- public class SendChatMessage : AbstractAction
- {
- [DescAttribute("消息")]
- public StringValue Message = new StringValue.VALUE("你好世界!");
- [DescAttribute("消息类型")]
- public ChatMessageType SendTo = ChatMessageType.SystemToAll;
- [DescAttribute("持续时间(毫秒)")]
- public uint KeepTimeMS = 2000;
- [DescAttribute("预计发送的阵营", "可选")]
- public IntegerValue ToForce = new IntegerValue.VALUE(0);
- [DescAttribute("预计发送的单位", "可选")]
- public UnitValue ToPlayer = new UnitValue.NA();
- public override string ToString()
- {
- return string.Format("发送聊天消息: \"{0}\"", Message);
- }
- override public void DoAction(EventTriggerAdapter api, EventArguments args)
- {
- string msg = Message.GetValue(api, args);
- if (!string.IsNullOrEmpty(msg))
- {
- ChatEvent chat = new ChatEvent(SendTo, KeepTimeMS);
- chat.Message = msg;
- chat.To = SendTo;
- switch (SendTo)
- {
- case ChatMessageType.SystemToPlayer:
- InstancePlayer target = ToPlayer.GetValue(api, args) as InstancePlayer;
- if (target == null)
- {
- break;
- }
- chat.ToPlayerUUID = target.PlayerUUID;
- #region <<判断演绎位面>>
- if (target.isTeamMemberAndFollow())
- {
- return;
- }
- var evt_param = msg.Split('|');
- if (evt_param.Length == 2)
- {
- var e = evt_param[0];
- var p = evt_param[1].Split(',');
- if (e == "Drama.Start" && p.Length > 1 && p[1] == "AOI")
- {
- if (!target.IsRobot)
- {
- target.setAoiStatus(new DarmaAOI(p[0]));
- }
- }
- }
- #endregion
- break;
- case ChatMessageType.SystemToForce:
- chat.Force = (byte)ToForce.GetValue(api, args);
- break;
- case ChatMessageType.SystemToAll:
- break;
- }
- api.ZoneAPI.queueEvent(chat);
- }
- }
- }
- [DescAttribute("游戏结束", "场景")]
- public class GameOverAction : AbstractAction
- {
- [DescAttribute("胜利方")]
- public IntegerValue WinForce = new IntegerValue.VALUE(0);
- [DescAttribute("消息")]
- public string Message;
- public override string ToString()
- {
- return string.Format("游戏结束 胜利方:{0} 消息:\"{1}\"", WinForce, Message);
- }
- override public void DoAction(EventTriggerAdapter api, EventArguments args)
- {
- api.ZoneAPI.send_game_over(WinForce.GetValue(api, args), Message);
- }
- }
- [DescAttribute("游戏结束(变量)", "场景")]
- public class GameOverActionVar : AbstractAction
- {
- [DescAttribute("胜利方")]
- public IntegerValue WinForce = new IntegerValue.VALUE(0);
- [DescAttribute("消息")]
- public StringValue Message = new StringValue.VALUE("");
- public override string ToString()
- {
- return string.Format("游戏结束 胜利方:{0} 消息:\"{1}\"", WinForce, Message);
- }
- override public void DoAction(EventTriggerAdapter api, EventArguments args)
- {
- api.ZoneAPI.send_game_over(WinForce.GetValue(api, args), Message.GetValue(api, args));
- }
- }
- [DescAttribute("客户端执行脚本文件", "场景")]
- public class RunClientScriptFileAction : AbstractAction
- {
- [DescAttribute("脚本文件")]
- public StringValue Script = new StringValue.NULL();
- public override string ToString()
- {
- return string.Format("客户端执行脚本文件:{0}", Script);
- }
- override public void DoAction(EventTriggerAdapter api, EventArguments args)
- {
- string sc = Script.GetValue(api, args);
- if (sc != null)
- {
- api.ZoneAPI.do_client_script(sc);
- }
- }
- }
- [DescAttribute("客户端执行脚本代码", "场景")]
- public class RunScriptCodeAction : AbstractAction
- {
- [DescAttribute("脚本代码")]
- public StringValue Script = new StringValue.NULL();
- public override string ToString()
- {
- return string.Format("客户端执行脚本代码:{0}", Script);
- }
- override public void DoAction(EventTriggerAdapter api, EventArguments args)
- {
- string sc = Script.GetValue(api, args);
- if (sc != null)
- {
- api.ZoneAPI.send_script_command(sc);
- }
- }
- }
- [DescAttribute("改变背景音乐", "场景")]
- public class ChangeBGMAction : AbstractAction
- {
- [DescAttribute("背景音乐文件")]
- [ResourceIDAttribute]
- public string MusicFile;
- public override string ToString()
- {
- return string.Format("改变背景音乐");
- }
- override public void DoAction(EventTriggerAdapter api, EventArguments args)
- {
- api.ZoneAPI.queueEvent(new ChangeBGMEvent(MusicFile));
- }
- }
- [DescAttribute("激活场景事件触发器", "场景触发器")]
- public class EventTriggerActive : AbstractAction
- {
- [DescAttribute("事件触发器名字")]
- [SceneEventIDAttribute]
- public string EventName;
- public override string ToString()
- {
- return string.Format("激活场景事件触发器({0})", EventName);
- }
- override public void DoAction(EventTriggerAdapter api, EventArguments args)
- {
- api.Group.EventActive(EventName, args);
- }
- }
- [DescAttribute("关闭场景事件触发器", "场景触发器")]
- public class EventTriggerDeactive : AbstractAction
- {
- [DescAttribute("事件触发器名字")]
- [SceneEventIDAttribute]
- public string EventName;
- public override string ToString()
- {
- return string.Format("关闭场景事件触发器({0})", EventName);
- }
- override public void DoAction(EventTriggerAdapter api, EventArguments args)
- {
- api.Group.EventDeactive(EventName, args);
- }
- }
- [DescAttribute("在指定地点放一个特效", "特效表现")]
- public class AddZoneEffect : AbstractAction
- {
- [DescAttribute("特效")]
- public LaunchEffect Effect = new LaunchEffect();
- [DescAttribute("位置")]
- public PositionValue Pos = new PositionValue.VALUE();
- [DescAttribute("方向")]
- public RealValue Direction = new RealValue.VALUE();
- public override string ToString()
- {
- return string.Format("在({0})位置添加特效({1})", Pos, Effect);
- }
- override public void DoAction(EventTriggerAdapter api, EventArguments args)
- {
- Vector2 pos = Pos.GetValue(api, args);
- if (pos != null)
- {
- float d = Direction.GetValue(api, args);
- api.ZoneAPI.queueEvent(new AddEffectEvent(0 , pos.X, pos.Y, d, Effect));
- }
- }
- }
- [DescAttribute("在指定单位身上放一个特效", "特效表现")]
- public class AddUnitEffect : AbstractAction
- {
- [DescAttribute("特效")]
- public LaunchEffect Effect = new LaunchEffect();
- [DescAttribute("单位 - 某个单位")]
- public UnitValue Unit = new UnitValue.Trigging();
- public override string ToString()
- {
- return string.Format("在({0})添加特效({1})", Unit, Effect);
- }
- override public void DoAction(EventTriggerAdapter api, EventArguments args)
- {
- InstanceUnit u = Unit.GetValue(api, args);
- if (u != null)
- {
- u.queueEvent(new UnitEffectEvent(u.ID, Effect));
- }
- }
- }
- [DescAttribute("发送消息到游戏服", "游戏服")]
- public class SendMessageToGS : AbstractAction
- {
- [DescAttribute("消息")]
- public StringValue Message = new StringValue.VALUE("msg");
- public override string ToString()
- {
- return string.Format("发送消息到游戏服:{0}", Message);
- }
- override public void DoAction(EventTriggerAdapter api, EventArguments args)
- {
- string msg = Message.GetValue(api, args);
- if (!string.IsNullOrEmpty(msg))
- {
- if(msg.Contains("{objid}"))
- {
- var unit = args.TriggingUnit;
- if(unit == null)
- {
- return;
- }
- msg = msg.Replace("{objid}", $"{unit.get_id()}");
- }
- api.ZoneAPI.SendMessageToGameServer(msg);
- }
- }
- }
- [DescAttribute("气泡聊天", "场景")]
- public class BubbleTalk : AbstractAction
- {
- [DescAttribute("是否暂停战斗")]
- public bool PauseBattle = false;
- [DescAttribute("内容")]
- [ListAttribute(typeof(TalkInfo))]
- public List<TalkInfo> Talks = new List<TalkInfo>();
- [DescAttribute("单位 - 某个单位")]
- public UnitValue TalkUnit = new UnitValue.NA();
- public override string ToString()
- {
- return string.Format("气泡聊天");
- }
- public override void DoAction(EventTriggerAdapter api, EventArguments args)
- {
- InstancePlayer pointUnit = TalkUnit.GetValue(api, args) as InstancePlayer;
- BubbleTalkEvent e = new BubbleTalkEvent();
- e.PauseBattle = PauseBattle;
- e.TalkInfos.Clear();
- foreach (TalkInfo t in Talks)
- {
- if (t.IsNarrator)
- {
- BubbleTalkEvent.TalkInfo info = new BubbleTalkEvent.TalkInfo(0, t.TalkContent, t.TalkActionType, t.TalkDelayTimeMS, t.TalkKeepTimeMS);
- e.TalkInfos.Add(info);
- }
- else
- {
- InstanceUnit unit = t.TalkUnit.GetValue(api, args);
- if (unit != null)
- {
- BubbleTalkEvent.TalkInfo info = new BubbleTalkEvent.TalkInfo(unit.ID, t.TalkContent, t.TalkActionType, t.TalkDelayTimeMS, t.TalkKeepTimeMS);
- e.TalkInfos.Add(info);
- }
- }
- }
- if(pointUnit == null)
- {
- api.ZoneAPI.queueEvent(e);
- }
- else
- {
- api.ZoneAPI.doSendMsgToPlayer(pointUnit, e);
- }
- }
- [DescAttribute("聊天内容")]
- [Expandable]
- public class TalkInfo
- {
- [DescAttribute("单位 - 某个单位")]
- public UnitValue TalkUnit = new UnitValue.NA();
- [DescAttribute("是否是旁边白")]
- public bool IsNarrator = false;
- [LocalizationTextAttribute]
- [DescAttribute("内容")]
- public string TalkContent;
- [DescAttribute("动作")]
- public string TalkActionType;
- [DescAttribute("延迟时间")]
- public int TalkDelayTimeMS;
- [DescAttribute("持续时间")]
- public int TalkKeepTimeMS;
- }
- }
- }
|