using CommonAI.RTS; using CommonAI.Zone; using CommonAI.Zone.Attributes; using CommonAI.Zone.EventTrigger; using CommonAI.Zone.Instance; using CommonAI.Zone.ZoneEditor.EventTrigger; using CommonLang; using CommonLang.Property; using CommonLang.Vector; using System; using System.Collections.Generic; using System.Linq; using System.Text; using XmdsCommonServer.Plugin.Scene; namespace XmdsCommonServer.Plugin.Editor { [DescAttribute("触发中的玩家添加AOI单位", "Xmds扩展 - 位面")] public class XmdsAddUnitActionAOI : AbstractAction { [DescAttribute("玩家")] public UnitValue Player = new UnitValue.Trigging(); [DescAttribute("单位模板ID")] [TemplateIDAttribute(typeof(UnitInfo))] public int UnitTemplateID = 0; [DescAttribute("单位等级")] [TemplateLevelAttribute] public int UnitLevel = 0; [DescAttribute("单位阵营")] public IntegerValue Force = new IntegerValue.VALUE(0); [DescAttribute("用户定义名字(编辑器名字)")] public string UnitName; [DescAttribute("位置")] public PositionValue Position = new PositionValue.VALUE(); [DescAttribute("朝向")] public float Direction; [DescAttribute("开始寻路")] public FlagValue.EditorPoint StartPoint; public override string ToString() { return string.Format("玩家({0})添加单位({1})到({2})", Player, UnitTemplateID, Position); } override public void DoAction(EventTriggerAdapter api, EventArguments args) { InstancePlayer player = Player.GetValue(api, args) as InstancePlayer; Vector2 pos = Position.GetValue(api, args); if (pos != null && player != null && player.AoiStatus != null) { InstanceUnit unit = api.ZoneAPI.AddUnit(UnitTemplateID, UnitName, (byte)Force.GetValue(api, args), UnitLevel, pos.X, pos.Y, Direction); if (unit != null) { unit.setAoiStatus(player.AoiStatus); if (unit is InstanceGuard && StartPoint != null) { InstanceGuard guard = unit as InstanceGuard; InstanceFlag flag = StartPoint.GetValue(api, args); if (flag != null) { guard.attackTo(flag as ZoneWayPoint); } } } } } } [DescAttribute("玩家进入位面", "Xmds扩展 - 位面")] public class PlayerEnterAOI : AbstractAction { [DescAttribute("玩家")] public UnitValue Player = new UnitValue.Trigging(); [DescAttribute("别人可看到自己")] public BooleanValue CanSeeMe = new BooleanValue.VALUE(false); [DescAttribute("自己可看到别人")] public BooleanValue CanSeeOther = new BooleanValue.VALUE(false); [DescAttribute("队伍范围如果为0则代表玩家独立进入位面")] public IntegerValue TeamRadius = new IntegerValue.VALUE(0); [DescAttribute("怪物全部死亡则销毁位面")] public BooleanValue isDestoryedOnMonsterDead = new BooleanValue.VALUE(false); [DescAttribute("死亡则销毁位面")] public BooleanValue DeadExit = new BooleanValue.VALUE(false); [DescAttribute("完成指定任务ID,自动退出位面")] public StringValue QuestId = new StringValue.VALUE(""); public override string ToString() { return string.Format("玩家({0})进入位面", Player); } override public void DoAction(EventTriggerAdapter api, EventArguments args) { InstancePlayer player = Player.GetValue(api, args) as InstancePlayer; if (player != null && !player.isTeamMemberAndFollow()) //TODO 队员跟随状态不能进入位面 { var aoi = new XmdsPlayerAOI(player, CanSeeMe.GetValue(api, args), CanSeeOther.GetValue(api, args), isDestoryedOnMonsterDead.GetValue(api, args), DeadExit.GetValue(api, args), QuestId.GetValue(api, args) ); player.setAoiStatus(aoi); // -- 判断进入位面的队伍 var tr = TeamRadius.GetValue(api, args); if (tr > 0) { var teamList = (player.Virtual as XmdsVirtual).TeamList; foreach (var uuid in teamList) { var p = player.Parent.getPlayerByUUID(uuid); if (p != null && CMath.intersectRound(player.X, player.Y, tr, p.X, p.Y, p.Info.BodySize)) { p.setAoiStatus(aoi); } } } // END } } } [DescAttribute("玩家离开位面", "Xmds扩展 - 位面")] public class PlayerLeaveAOI : AbstractAction { [DescAttribute("玩家")] public UnitValue Player = new UnitValue.Trigging(); public override string ToString() { return string.Format("玩家({0})离开位面", Player); } override public void DoAction(EventTriggerAdapter api, EventArguments args) { InstancePlayer player = Player.GetValue(api, args) as InstancePlayer; if (player != null && player.AoiStatus is XmdsPlayerAOI) { var aoi = player.AoiStatus as XmdsPlayerAOI; using (var list = ListObjectPool.AllocAutoRelease(aoi.Objects)) { foreach (var obj in list) { if (obj != player && !(obj is InstancePlayer) && !(obj is InstanceSpell)) { api.ZoneAPI.RemoveObjectByID(obj.ID); } } } player.setAoiStatus(null); } } } [DescAttribute("单位是否在位面", "Xmds扩展 - 位面")] public class UnitInAOIStatus : BooleanValue { [DescAttribute("单位")] public UnitValue Player = new UnitValue.Trigging(); public override string ToString() { return string.Format("单位({0})是否在位面", Player); } public override bool GetValue(IEditorValueAdapter api, EventArguments args) { var player = Player.GetValue(api, args); if (player != null) { return player.AoiStatus != null; } return false; } } [DescAttribute("单位位面宿主", "Xmds扩展 - 位面")] public class UnitAOIOwnerUnit : UnitValue { [DescAttribute("单位")] public UnitValue Unit = new UnitValue.Trigging(); public override string ToString() { return string.Format("({0})位面宿主", Unit); } public override InstanceUnit GetValue(IEditorValueAdapter api, EventArguments args) { var unit = Unit.GetValue(api, args); if (unit != null && unit.AoiStatus is XmdsPlayerAOI) { return (unit.AoiStatus as XmdsPlayerAOI).Owner; } return null; } } [DescAttribute("位面内单位数", "Xmds扩展 - 位面")] public class GetAOIUnitCount : IntegerValue { [DescAttribute("宿主")] public UnitValue Owner = new UnitValue.Trigging(); [DescAttribute("指定Force")] public IntegerValue Force = new IntegerValue.UnitForce(); [DescAttribute("指定TemplateID")] public IntegerValue TemplateID = new IntegerValue.UnitTemplateID(); public override string ToString() { return string.Format("({0})位面内单位数", Owner); } public override int GetValue(IEditorValueAdapter api, EventArguments args) { var unit = Owner.GetValue(api, args); if (unit != null && unit.AoiStatus is XmdsPlayerAOI) { return (unit.AoiStatus as XmdsPlayerAOI).GetUnitCount( Force.GetValue(api, args), TemplateID.GetValue(api, args)); } return 0; } } [DescAttribute("位面内单位数ByForce", "Xmds扩展 - 位面")] public class GetAOIUnitCountByForce : IntegerValue { [DescAttribute("宿主")] public UnitValue Owner = new UnitValue.Trigging(); [DescAttribute("指定Force")] public IntegerValue Force = new IntegerValue.UnitForce(); public override string ToString() { return string.Format("({0})位面内(Force={1})单位数", Owner, Force); } public override int GetValue(IEditorValueAdapter api, EventArguments args) { var unit = Owner.GetValue(api, args); if (unit != null && unit.AoiStatus is XmdsPlayerAOI) { return (unit.AoiStatus as XmdsPlayerAOI).GetUnitCountByForce( Force.GetValue(api, args)); } return 0; } } [DescAttribute("位面内单位数ByTemplateID", "Xmds扩展 - 位面")] public class GetAOIUnitCountByTemplateID : IntegerValue { [DescAttribute("宿主")] public UnitValue Owner = new UnitValue.Trigging(); [DescAttribute("指定TemplateID")] public IntegerValue TemplateID = new IntegerValue.UnitTemplateID(); public override string ToString() { return string.Format("({0})位面内(模板={1})单位数", Owner, TemplateID); } public override int GetValue(IEditorValueAdapter api, EventArguments args) { var unit = Owner.GetValue(api, args); if (unit != null && unit.AoiStatus is XmdsPlayerAOI) { return (unit.AoiStatus as XmdsPlayerAOI).GetUnitCountByTemplateID( TemplateID.GetValue(api, args)); } return 0; } } [DescAttribute("找到指定宿主创建的单位ByTemplateID", "Xmds扩展 - 位面")] public class GetAOIUnitByTemplateID : UnitValue { [DescAttribute("宿主")] public UnitValue Owner = new UnitValue.Trigging(); [DescAttribute("指定TemplateID")] public IntegerValue TemplateID = new IntegerValue.UnitTemplateID(); public override string ToString() { return string.Format("({0})位面内(TemplateID={1})的单位", Owner, TemplateID); } public override InstanceUnit GetValue(IEditorValueAdapter api, EventArguments args) { var unit = Owner.GetValue(api, args); if (unit != null && unit.AoiStatus is XmdsPlayerAOI) { return (unit.AoiStatus as XmdsPlayerAOI).FindUnitByTemplateID(TemplateID.GetValue(api, args)); } return null; } } [DescAttribute("找到指定宿主创建的单位ByName", "Xmds扩展 - 位面")] public class GetAOIUnitByName : UnitValue { [DescAttribute("宿主")] public UnitValue Owner = new UnitValue.Trigging(); [DescAttribute("指定Name")] public StringValue Name = new StringValue.VALUE(""); public override string ToString() { return string.Format("({0})位面内(Name={1})的单位", Owner, Name); } public override InstanceUnit GetValue(IEditorValueAdapter api, EventArguments args) { var unit = Owner.GetValue(api, args); if (unit != null && unit.AoiStatus is XmdsPlayerAOI) { return (unit.AoiStatus as XmdsPlayerAOI).FindUnitByName(Name.GetValue(api, args)); } return null; } } }