예제 #1
0
파일: Teleporter.cs 프로젝트: jpx/blazera
 public Teleporter(Teleporter copy)
     : base(copy)
 {
     MapName = copy.MapName;
     WarpPointName = copy.WarpPointName;
     Area = copy.Area == null ? null : new IntRect(copy.Area);
 }
예제 #2
0
파일: Door.cs 프로젝트: jpx/blazera
        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();
        }