Пример #1
0
        public InputUI(Core.GameObject parent) : base(parent)
        {
            ActionBinding clicked;

            clicked = InputManager.Manager.GetActionBinding("click");
            if (clicked == null)
            {
                clicked = new ActionBinding(EMouseButton.Left);
            }

            clicked.OnTrigger += OnClick;

            if (InputManager.Manager.GetActionBinding("click") == null)
            {
                InputManager.Manager.AddActionBinding("click", clicked);
            }

            InputManager.Manager.OnMouseMove += MouseMove;
        }
Пример #2
0
        public override void Destroy()
        {
            // AxisBinding horizontalBinding = InputManager.Manager.GetAxisBinding(horizontalBindingName);
            // AxisBinding verticalBinding = InputManager.Manager.GetAxisBinding(verticalBindingName);

            DetachBindings();

            ActionBinding spawnBinding = InputManager.Manager.GetActionBinding(shootBindingName);

            if (spawnBinding != null)
            {
                spawnBinding.OnTrigger -= StartShooting;
            }

            InputManager.Manager.RemoveBinding(shootBindingName);
            InputManager.Manager.RemoveBinding(horizontalBindingName);
            InputManager.Manager.RemoveBinding(verticalBindingName);
            base.Destroy();
        }
Пример #3
0
        public InputComponent(Core.GameObject parent) : base(parent)
        {
            moveComp = parent.GetComponent <Navigation.MovementComponent>();
            gun      = Parent.GetComponent <Gameplay.Gun>();

            verticalAxis      = new AxisBinding(Keys.S, Keys.W);
            horizontalAxis    = new AxisBinding(Keys.D, Keys.A);
            shootBinding      = new ActionBinding(EMouseButton.Left);
            interactBinding   = new ActionBinding(Keys.E);
            scrollUpBinding   = new ActionBinding(EMouseButton.WheelUp);
            scrollDownBinding = new ActionBinding(EMouseButton.WheelDown);
            reloadBinding     = new ActionBinding(Keys.R);

            pistolSwapBinding   = new ActionBinding(Keys.D1);
            riffleSwapBinding   = new ActionBinding(Keys.D2);
            shotgunSwapBinding  = new ActionBinding(Keys.D3);
            launcherSwapBinding = new ActionBinding(Keys.D4);

            AttachBindings();

            InputManager.Manager.AddAxisBinding(verticalBindingName, verticalAxis);
            InputManager.Manager.AddAxisBinding(horizontalBindingName, horizontalAxis);

            InputManager.Manager.AddActionBinding(shootBindingName, shootBinding);
            InputManager.Manager.AddActionBinding(interactBindName, interactBinding);

            InputManager.Manager.AddActionBinding(scrollDownBindName, scrollDownBinding);
            InputManager.Manager.AddActionBinding(scrollUpBindName, scrollUpBinding);
            InputManager.Manager.AddActionBinding(reloadBindName, reloadBinding);

            InputManager.Manager.AddActionBinding(pistolSwapName, pistolSwapBinding);
            InputManager.Manager.AddActionBinding(riffleSwapName, riffleSwapBinding);
            InputManager.Manager.AddActionBinding(launcherSwapName, launcherSwapBinding);
            InputManager.Manager.AddActionBinding(shotgunSwapName, shotgunSwapBinding);

            moveComp.CurrentFocus             = target;
            InputManager.Manager.OnMouseMove += MoveTarget;
        }