void SetArea(IntRect rect) { Area = rect; TeleportationBB = new EBoundingBox(this, EBoundingBoxType.Event, Area.Left, Area.Top, Area.Right, Area.Bottom); TeleportationEvent = new ObjectEvent(ObjectEventType.In); TeleportationEvent.AddAction(new WarpAction(MapName, WarpPointName)); TeleportationBB.AddEvent(TeleportationEvent); AddEventBoundingBox(TeleportationBB, EventBoundingBoxType.Internal); }
public ObjectEvent(ObjectEvent copy) { Type = copy.Type; ActionKeyMode = copy.ActionKeyMode; ActionKey = copy.ActionKey; Actions = new List<Action>(copy.Actions); IsActive = copy.IsActive; }
public void BindTo(Door door) { if (Binding != null || door == null) return; Binding = door; // teleporter associate to the door Teleporter = Create.Teleporter("Invisible"); Teleporter.SetSetting(Binding.Map.Type, Binding.WarpPoint.Name, Area); Teleporter.SetMap(Map, Position.X, Position.Y, Z); OnMove += new MoveEventHandler(Door_OnMove); // block BB when the door is closed BlockBB = new BBoundingBox(this, 0, 42, 32, 46); AddBoundingBox(BlockBB); // sides block BB AddBoundingBox(new BBoundingBox(this, 0, 42, 2, 46)); AddBoundingBox(new BBoundingBox(this, 30, 42, 32, 46)); // switch open/close state event BB EBoundingBox doorBB = new EBoundingBox(this, EBoundingBoxType.Event, 0 - 5, 44, 32 + 5, 56); AddEventBoundingBox(doorBB, EventBoundingBoxType.Internal); ObjectEvent doorEvt = new ObjectEvent(ObjectEventType.Normal, true, InputType.Action); doorBB.AddEvent(doorEvt); doorEvt.AddAction(new DefaultAction((args) => { if (IsLocked() && args.Player.DirectionHandler.IsFacing(this)) LaunchLockedMessage(); if (IsLocked() || IsClosing() || IsOpening()) return; if (args.Player.DirectionHandler.IsFacing(this)) { if (IsOpen()) Close(); else Open(); } })); TrySetState("Open"); // anti loop event if (ANTI_LOOP_CHECK_IS_ACTIVE) SetAntiLoop(); }
public void AddEvent(ObjectEvent evt) { Events.Add(evt); evt.SetParent(this); }
public void RemoveEvent(ObjectEvent evt) { EventsToRemove.Enqueue(evt); }
protected override Dictionary<String, Object> OnValidate() { ObjectEvent objectEvent = new ObjectEvent( (ObjectEventType)Enum.Parse(typeof(ObjectEventType), TypeDownList.GetCurrent()), ActionKeyModeCheckBox.IsChecked, (InputType)Enum.Parse(typeof(InputType), ActionKeyDownList.GetCurrent())); foreach (BlazeraLib.Action action in Actions.Values) objectEvent.AddAction(action); return new Dictionary<String, Object>() { { "Event", objectEvent } }; }
public override void Open(OpeningInfo openingInfo = null) { base.Open(openingInfo); if (openingInfo == null) return; if (!openingInfo.IsModeValid()) return; switch (OpeningMode = openingInfo.GetMode()) { case "BoundingBoxCreator_Edit_Mode": CurrentEditedEvent = openingInfo.GetArg<ObjectEvent>("Event"); TypeDownList.DownList.SetCurrent(CurrentEditedEvent.Type.ToString()); if (CurrentEditedEvent.ActionKeyMode) { ActionKeyModeCheckBox.SetIsChecked(true); ActionKeyDownList.DownList.SetCurrent(CurrentEditedEvent.ActionKey.ToString()); } foreach (BlazeraLib.Action action in CurrentEditedEvent.Actions) AddAction(action); break; } }
public String EventToString(ObjectEvent objectEvent) { return "Event ( " + objectEvent.Type.ToString() + " )"; }
void SetAntiLoop() { if (Binding.Teleporter == null) { // binded door is not itself binded return; } // if binded warp point contains player future position // we avoid to re-teleport the player Teleporter.TeleportationEvent += new DefaultAction((args) => { Binding.Teleporter.TeleportationEvent.Activate(false); ObjectEvent lockEvent = new TemporaryEvent(1, ObjectEventType.Out); Binding.Teleporter.TeleportationBB.AddEvent(lockEvent); lockEvent += new DefaultAction((args2) => { Binding.Teleporter.TeleportationEvent.Activate(true); }); AntiLoopCheckEvent = new TemporaryEvent(1, ObjectEventType.In); Binding.Teleporter.TeleportationBB.AddEvent(AntiLoopCheckEvent); AntiLoopCheckEvent += new DefaultAction((args2) => { BindingContainsBindedWarpPoint = true; }); Binding.OnUpdate += new UpdateEventHandler(Binding_OnUpdate); }); }