Ejemplo n.º 1
0
        internal static ControlProperty <T> Value <T, C>(C control, Func <C, T> getter, Action <C, T> setter) where C : UIControl
        {
            var source = Observable.Create <T>(observer =>
            {
                if (control == null)
                {
                    observer.OnCompleted();
                    return(Disposable.Empty);
                }
                observer.OnNext(getter(control));

                var controlTarget = new ControlTarget(control, (UIControlEvent.AllEditingEvents | UIControlEvent.ValueChanged),
                                                      c =>
                {
                    if (control == null)
                    {
                        return;
                    }
                    observer.OnNext(getter(control));
                });
                return(Disposable.Create(() => controlTarget.Dispose()));
            });
            var bindingObserver = new UIBindingObserver <C, T>(control, setter);

            return(new ControlProperty <T>(source, bindingObserver));
        }
Ejemplo n.º 2
0
 public override void OnThink()
 {
     if (ControlTarget != null)
     {
         ControlTarget.Location = Location;
         ControlTarget.Freeze(TimeSpan.FromSeconds(.5));
     }
     base.OnThink();
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Returns An <c>IOBservable<T></c> instance for T when the <c>UIControlEvent is generated</c>
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="rx"></param>
        /// <param name="controlEvent"></param>
        /// <returns>An <c>IOBservable</c> instance for <c>T</c> when the <c>UIControlEvent</c> is generated</returns>
        public static ControlEvent <T> ControlEvent <T>(this Reactive <T> rx, UIControlEvent controlEvent) where T : UIControl
        {
            var source = Observable.Create <T>(observer =>
            {
                if (rx.Parent == null)
                {
                    observer.OnCompleted();
                    return(Disposable.Empty);
                }
                var controltarget = new ControlTarget(rx.Parent, controlEvent, uiControl => observer.OnNext(rx.Parent));
                return(Disposable.Create(() => controltarget.Dispose()));
            }); //.TakeUntil(self.deallocated?);

            return(new ControlEvent <T>(source));
        }
Ejemplo n.º 4
0
        public override void OnThink()
        {
            CantWalk = !Controlled;

            if (AlwaysFollow != null)
            {
                ControlOrder  = OrderType.Follow;
                ControlTarget = AlwaysFollow;
            }

            if (DateTime.Now > m_Delay)
            {
                if (!Controlled)
                {
                    switch (Utility.Random(6))
                    {
                    case 0: Say("Please help me."); break;

                    case 1: Say("I want to go home."); break;

                    case 2: Say("*cries*"); break;

                    case 3: Say("Help me"); break;

                    case 4: Say("Wait, come over here."); break;

                    case 5: Say("I don't want to die."); break;
                    }
                }
                else if (X > 1960 && X < 1965 && Y > 490 && Y < 500)
                {
                    // Tele helper
                    MoveToWorld(new Point3D(1960, 643, -26), Map.Ilshenar);
                }
                else if (X > 2020 && X < 2030 && Y > 695 && Y < 705)
                {
                    // Tele helper
                    MoveToWorld(new Point3D(1963, 685, -21), Map.Ilshenar);
                }
                else if (X > 1970 && X < 1980 && Y > 825 && Y < 830)
                {
                    // Auto Life's animation
                    PlaySound(0x214);

                    Effects.SendLocationParticles(
                        EffectItem.Create(new Point3D(X - 1, Y - 1, Z), Map, EffectItem.DefaultDuration),
                        0x3709, 10, 30, 1153, 4, 0, 0);
                    Effects.SendLocationParticles(
                        EffectItem.Create(new Point3D(X - 1, Y + 1, Z), Map, EffectItem.DefaultDuration),
                        0x3709, 10, 30, 1153, 4, 0, 0);
                    Effects.SendLocationParticles(
                        EffectItem.Create(new Point3D(X + 1, Y - 1, Z), Map, EffectItem.DefaultDuration),
                        0x3709, 10, 30, 1153, 4, 0, 0);
                    Effects.SendLocationParticles(
                        EffectItem.Create(new Point3D(X + 1, Y + 1, Z), Map, EffectItem.DefaultDuration),
                        0x3709, 10, 30, 1153, 4, 0, 0);

                    if (ControlTarget is PlayerMobile)                       // Did it somehow switch?
                    {
                        ControlTarget.SendMessage("As a reward for freeing the pixie she teaches you Auto Life!");
                        BlueMageControl.CheckKnown(ControlTarget, typeof(AutoLifeSpell), true);
                    }

                    Delete();
                }

                m_Delay = DateTime.Now + TimeSpan.FromSeconds(Utility.RandomMinMax(7, 14));
            }

            base.OnThink();
        }
Ejemplo n.º 5
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            Cursor.visible   = true;
            Cursor.lockState = CursorLockMode.None;
        }


        //handle left mouse button
        if (Input.GetMouseButtonDown(0))
        {
            if (UseMapControls)
            {
                PrimaryMapClickDown();
            }
            else
            {
                mouseLeftInProgress = true;
                ControlTarget.PrimaryAction(ActionPhase.Start);
            }
        }

        if (mouseLeftInProgress)
        {
            if (UseMapControls)
            {
                PrimaryMapClick();
            }
            else
            {
                ControlTarget.PrimaryAction(ActionPhase.On);
            }
        }

        if (Input.GetMouseButtonUp(0))
        {
            if (UseMapControls)
            {
                PrimaryMapClickUp();
            }
            else
            {
                ControlTarget.PrimaryAction(ActionPhase.End);
            }
            mouseLeftInProgress = false;
        }

        //handle Right mouse button
        if (Input.GetMouseButtonDown(1))
        {
            if (UseMapControls)
            {
                SecondaryMapClickDown();
            }
            else
            {
                ControlTarget.SecondaryAction(ActionPhase.Start);
            }
        }

        if (mouseRightInProgress)
        {
            if (UseMapControls)
            {
                SecondaryMapClick();
            }
            else
            {
                ControlTarget.PrimaryAction(ActionPhase.On);
            }
        }

        if (Input.GetMouseButtonUp(1))
        {
            if (UseMapControls)
            {
                SecondaryMapClickUp();
            }
            else
            {
                ControlTarget.PrimaryAction(ActionPhase.End);
            }
            mouseRightInProgress = false;
        }

        //  if (Input.GetButtonDown("Action")) selectedCluster.Release("Tired");

        if (Input.GetKeyDown(KeyCode.Alpha1))
        {
            IngameUI.KeyPressed("1");
        }
        if (Input.GetKeyDown(KeyCode.Alpha2))
        {
            IngameUI.KeyPressed("2");
        }
        if (Input.GetKeyDown(KeyCode.Alpha3))
        {
            IngameUI.KeyPressed("3");
        }
        if (Input.GetKeyDown(KeyCode.Alpha4))
        {
            IngameUI.KeyPressed("4");
        }

        Vector3 moveDirection   = Vector3.zero;
        int     rotateDirection = 0;

        if (Input.GetKey(KeyCode.Q))
        {
            rotateDirection += -1;
        }
        if (Input.GetKey(KeyCode.E))
        {
            rotateDirection += 1;
        }

        if (Input.GetKey(KeyCode.W))
        {
            moveDirection += Vector3.forward;
        }
        if (Input.GetKey(KeyCode.A))
        {
            moveDirection += Vector3.left;
        }
        if (Input.GetKey(KeyCode.S))
        {
            moveDirection += Vector3.back;
        }
        if (Input.GetKey(KeyCode.D))
        {
            moveDirection += Vector3.right;
        }

        ControlTarget.Move(moveDirection);
        ControlTarget.Rotate(rotateDirection);

        float scrollAmount = Input.GetAxis("Mouse ScrollWheel");

        if (scrollAmount != 0)
        {
            CameraControl.Scroll(scrollAmount);
        }

        if (Input.GetKeyDown(KeyCode.LeftControl))
        {
            onEnterCtrlMode.Invoke();
        }
        if (Input.GetKeyUp(KeyCode.LeftControl))
        {
            onExitCtrlMode.Invoke();
        }
        if (Input.GetKeyDown(KeyCode.LeftAlt))
        {
            onEnterAltMode.Invoke();
        }
        if (Input.GetKeyUp(KeyCode.LeftAlt))
        {
            onExitAltMode.Invoke();
        }

        CameraControl.MouseInputX(Input.GetAxis("Mouse X"));
        CameraControl.MouseInputY(Input.GetAxis("Mouse Y"));

        if (Input.GetKeyUp(KeyCode.Escape))
        {
            Application.Quit();
        }
    }