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;
}
}
///
/// 发送战中特殊飘字事件.
///
[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.AllocAutoRelease(api.ZoneAPI.AllPlayers))
using (var a = ListObjectPool.AllocAutoRelease(api.ZoneAPI.AllUnits))
{
e.data = new List();
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);
}
}
///
/// 发送BOSS被击杀通知.
///
[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);
}
}
}
}