123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300 |
- using System;
- using System.Collections.Generic;
- using System.Text;
- using CommonLang.Property;
- using CommonAI.RTS; using CommonLang.Vector;
- using CommonAI.Zone.Instance;
- using CommonAI.Zone.Attributes;
- using CommonAI.Zone.EventTrigger;
- namespace CommonAI.Zone.ZoneEditor.EventTrigger
- {
- [DescAttribute("客户端")]
- public abstract class ClientAction : AbstractAction
- {
- [DescAttribute("发送给谁(为空表示广播)", "发送者")]
- public UnitValue Sender = new UnitValue.Trigging();
- public abstract ClientEvent AsEvent(EventTriggerAdapter api, EventArguments args);
- override public void DoAction(EventTriggerAdapter api, EventArguments args)
- {
- ClientEvent evt = AsEvent(api, args);
- if (evt != null)
- {
- evt.sender = Sender.GetValue(api, args);
- api.ZoneAPI.queueEvent(evt);
- }
- }
- }
- [DescAttribute("客户端动作序列", "客户端 - 动作序列")]
- public class ClientActionQueue : ClientAction
- {
- [DescAttribute("序列")]
- [ListAttribute(typeof(ClientAction))]
- public List<ClientAction> ActionQueue = new List<ClientAction>();
- public override string ToString()
- {
- StringBuilder sb = new StringBuilder("动作序列: ");
- foreach (ClientAction ca in ActionQueue)
- {
- sb.Append(ca.ToString());
- if (ActionQueue[ActionQueue.Count - 1] != ca)
- {
- sb.Append(" -> ");
- }
- }
- return sb.ToString();
- }
- public override ClientEvent AsEvent(EventTriggerAdapter api, EventArguments args)
- {
- ClientEventQueue queue = new ClientEventQueue();
- foreach (ClientAction ca in ActionQueue)
- {
- ClientEvent evt = ca.AsEvent(api, args);
- if (evt != null)
- {
- queue.EventQueue.Add(evt);
- }
- }
- return queue;
- }
- }
- [DescAttribute("提示玩家显示箭头(CheckPoint)", "客户端")]
- public class ShowCheckPoint : ClientAction
- {
- [DescAttribute("位置")]
- public PositionValue Position = new PositionValue.VALUE();
- public override string ToString()
- {
- return string.Format("提示玩家显示箭头到({0})", Position);
- }
- public override ClientEvent AsEvent(EventTriggerAdapter api, EventArguments args)
- {
- Vector2 pos = Position.GetValue(api, args);
- if (pos != null)
- {
- return new LookAtEvent("", pos.X, pos.Y);
- }
- return null;
- }
- }
- [DescAttribute("改变游戏运行速度", "客户端")]
- public class ChangeTimeScale : ClientAction
- {
- [DescAttribute("时间尺度百分比")]
- public float TimeScalePct = 100f;
- public override string ToString()
- {
- return string.Format("改变游戏运行速度{0}%", TimeScalePct);
- }
- public override ClientEvent AsEvent(EventTriggerAdapter api, EventArguments args)
- {
- return new ChangeTimeScaleEvent(TimeScalePct);
- }
- }
- [DescAttribute("暂停游戏", "客户端")]
- public class GamePause : ClientAction
- {
- [DescAttribute("暂停多少秒,如果为0,则无限暂停")]
- public float Seconds = 0f;
- public override string ToString()
- {
- if (Seconds > 0)
- {
- return string.Format("暂停游戏{0}秒", Seconds);
- }
- return string.Format("暂停游戏");
- }
- public override ClientEvent AsEvent(EventTriggerAdapter api, EventArguments args)
- {
- return new GamePauseEvent(Seconds);
- }
- }
- [DescAttribute("继续游戏", "客户端")]
- public class GameResume : ClientAction
- {
- public override string ToString()
- {
- return string.Format("继续游戏");
- }
- public override ClientEvent AsEvent(EventTriggerAdapter api, EventArguments args)
- {
- return new GameResumeEvent();
- }
- }
- [DescAttribute("发送消息到客户端", "客户端")]
- public class GameNotify : ClientAction
- {
- [DescAttribute("消息")]
- public StringValue Message = new StringValue.VALUE();
- public override string ToString()
- {
- return string.Format("发送消息到客户端:{0}", Message);
- }
- public override ClientEvent AsEvent(EventTriggerAdapter api, EventArguments args)
- {
- return new ClientMsgEvent(Message.GetValue(api, args));
- }
- }
- [DescAttribute("镜头锁定在某处一段时间", "客户端 - 镜头变换")]
- public class CameraHold : ClientAction
- {
- [DescAttribute("位置")]
- public PositionValue Position = new PositionValue.VALUE();
- [DescAttribute("镜头锁定的总时间(毫秒)")]
- public IntegerValue TotalTimeMS = new IntegerValue.VALUE(1000);
- public override string ToString()
- {
- return string.Format("锁定镜头到({0})持续({1})毫秒", Position, TotalTimeMS);
- }
- public override ClientEvent AsEvent(EventTriggerAdapter api, EventArguments args)
- {
- Vector2 pos = Position.GetValue(api, args);
- int timeMS = TotalTimeMS.GetValue(api, args);
- if (pos != null)
- {
- return new CameraHoldEvent(pos.X, pos.Y, timeMS);
- }
- return null;
- }
- }
- [DescAttribute("移动镜头到", "客户端 - 镜头变换")]
- public class CameraMoveTo : ClientAction
- {
- [DescAttribute("位置")]
- public PositionValue Position = new PositionValue.VALUE();
- [DescAttribute("相机高度")]
- public RealValue Height = new RealValue.VALUE();
- [DescAttribute("镜头移动速度(每秒距离)")]
- public float MoveSpeedSec = 1f;
- public override string ToString()
- {
- return string.Format("移动镜头到({0})", Position);
- }
- public override ClientEvent AsEvent(EventTriggerAdapter api, EventArguments args)
- {
- Vector2 pos = Position.GetValue(api, args);
- if (pos != null)
- {
- return new CameraMoveToEvent(pos.X, pos.Y, Height.GetValue(api,args), MoveSpeedSec, 0);
- }
- return null;
- }
- }
- [DescAttribute("移动镜头到(根据时间)", "客户端 - 镜头变换")]
- public class CameraMoveToByTime : ClientAction
- {
- [DescAttribute("位置")]
- public PositionValue Position = new PositionValue.VALUE();
- [DescAttribute("相机高度")]
- public RealValue Height = new RealValue.VALUE();
- [DescAttribute("镜头移动过去的总时间(毫秒)")]
- public IntegerValue TotalTimeMS = new IntegerValue.VALUE(1000);
- public override string ToString()
- {
- return string.Format("移动镜头到({0})", Position);
- }
- public override ClientEvent AsEvent(EventTriggerAdapter api, EventArguments args)
- {
- Vector2 pos = Position.GetValue(api, args);
- int timeMS = TotalTimeMS.GetValue(api, args);
- if (pos != null)
- {
- return new CameraMoveToEvent(pos.X, pos.Y, Height.GetValue(api, args), 0, timeMS);
- }
- return null;
- }
- }
- [DescAttribute("锁定镜头到单位", "客户端 - 镜头变换")]
- public class CameraFocusUnit : ClientAction
- {
-
- [DescAttribute("单位 - 某个单位")]
- public UnitValue Unit = new UnitValue.Trigging();
- public override string ToString()
- {
-
- return string.Format("锁定镜头到({0})", Unit);
- }
- public override ClientEvent AsEvent(EventTriggerAdapter api, EventArguments args)
- {
- InstanceUnit unit = Unit.GetValue(api, args);
- if (unit != null)
- {
- return new CameraFocusUnitEvent(unit.ID);
- }
- return null;
- }
- }
- [DescAttribute("拉近镜头", "客户端 - 镜头变换")]
- public class CameraZoomTo : ClientAction
- {
- [DescAttribute("镜头拉近距离")]
- public float ZoomDistance = 10f;
- [DescAttribute("镜头拉近速度(每秒距离)")]
- public float ZoomSpeedSec = 1f;
- public override string ToString()
- {
- return string.Format("拉近镜头到({0})", ZoomDistance);
- }
- public override ClientEvent AsEvent(EventTriggerAdapter api, EventArguments args)
- {
- return new CameraZoomToEvent(ZoomDistance, ZoomSpeedSec);
- }
- }
- [DescAttribute("旋转镜头", "客户端 - 镜头变换")]
- public class CameraRotateTo : ClientAction
- {
- [DescAttribute("镜头旋转角度(0~360)")]
- public float RotateAngle = 10f;
- [DescAttribute("镜头旋转速度(每秒角度)")]
- public float RotateSpeedSec = 1f;
- public override string ToString()
- {
- return string.Format("旋转镜头到({0})", RotateAngle);
- }
- public override ClientEvent AsEvent(EventTriggerAdapter api, EventArguments args)
- {
- return new CameraRotateToEvent(RotateAngle, RotateSpeedSec);
- }
- }
- [DescAttribute("重置镜头", "客户端 - 镜头变换")]
- public class CameraReset : ClientAction
- {
- public override string ToString()
- {
- return string.Format("重置镜头");
- }
- public override ClientEvent AsEvent(EventTriggerAdapter api, EventArguments args)
- {
- return new CameraResetEvent();
- }
- }
- }
|