Esempio n. 1
0
        private void InitControls()
        {
            inputContext = Window.CreateInput();
            context      = new ListenContext()
            {
                Active = true
            };

            Keyboard        = new Keyboard(inputContext);
            Mouse           = new Mouse(Screen, inputContext);
            PhoneBackButton = new BackButton();
            TouchPanel      = new TouchPanel();

            controllers     = new List <IController>();
            GameControllers = new List <GamePad>(4);

            GameControllers.Add(new GamePad(inputContext, 0));
            GameControllers.Add(new GamePad(inputContext, 1));
            GameControllers.Add(new GamePad(inputContext, 2));
            GameControllers.Add(new GamePad(inputContext, 3));
            controllers.AddRange(GameControllers);

            controllers.Add(Mouse);

            controllers.Add(Keyboard);

            controllers.Add(Accelerometer);
            controllers.Add(TouchPanel);

            controllers.Add(PhoneBackButton);
        }
Esempio n. 2
0
        private void InitControls()
        {
            _context = new ListenContext()
            {
                Active = true
            };

            Keyboard        = new Keyboard();
            Mouse           = new Mouse(Screen);
            PhoneBackButton = new BackButton();
            TouchPanel      = new TouchPanel(Screen);

            GameControllers = new List <GamePad>(4);
            GameControllers.Add(new GamePad(PlayerIndex.One));
            GameControllers.Add(new GamePad(PlayerIndex.Two));
            GameControllers.Add(new GamePad(PlayerIndex.Three));
            GameControllers.Add(new GamePad(PlayerIndex.Four));

            _controllers = new List <Controller>();
            _controllers.Add(Keyboard);
#if !WINDOWS_PHONE && !ANDROID
            _controllers.Add(Mouse);
#endif
            _controllers.Add(Accelerometer);
            _controllers.Add(TouchPanel);
#if WINDOWS_PHONE || ANDROID
            _controllers.Add(PhoneBackButton);
#endif
#if NETCOREAPP
            _controllers.AddRange(GameControllers);
#endif

            IsMouseVisible = true;
        }
Esempio n. 3
0
        /// <summary>
        /// Alustaa Widgetin ohjaimet käyttöön.
        /// Sinun ei tarvitse kutsua tätä
        /// </summary>
        public void InitControl()
        {
            if (ControlContext == null || ControlContext.IsDestroyed)
            {
                context = new ListenContext();
            }

            Objects.ItemAdded   += InitChildContext;
            Objects.ItemRemoved += ResetChildContext;

            Removed += RemoveListeners;
        }
Esempio n. 4
0
        public Cannonselector(List <CannonTemplate> cannons)
        {
            var context = new ListenContext();

            context.Enable();
            Layout               = new HorizontalLayout();
            Layout.LeftPadding   = 5;
            Layout.RightPadding  = 5;
            Layout.BottomPadding = 5;
            Layout.TopPadding    = 5;

            Color       = new Color(193, 66, 66, 120);
            BorderColor = Color.Red;
            IsModal     = false;

            // Need to update Jypeli so that this works and disables window dragging.
            // IsCapturingMouse = false;

            foreach (var cannon in cannons)
            {
                Widget main = new Widget(40, 40);
                main.Color       = defaultColor;
                main.BorderColor = Color.Black;
                main.Tag         = cannon.Name;
                Widget image = new Widget(30, 30);
                image.Image = GameManager.Images[cannon.Image];
                main.Add(image);
                Add(main);

                wcannons.Add(main);

                Game.Instance.Mouse.ListenOn(main, MouseButton.Left, ButtonState.Pressed, () => Select(main), null).InContext(context);
            }

            selected = wcannons.First();
            Select(wcannons.First());

            Game.Instance.Mouse.ListenOn(this, HoverState.Enter, MouseButton.None, ButtonState.Irrelevant, () =>
            {
                GameManager.ListenContext.Disable();
            }, null).InContext(context);
            Game.Instance.Mouse.ListenOn(this, HoverState.Exit, MouseButton.None, ButtonState.Irrelevant, () =>
            {
                GameManager.ListenContext.Enable();
            }, null).InContext(context);
        }
Esempio n. 5
0
 private void setContext(ref ListenContext context, bool enable, ContextHandler operation)
 {
     if ((context != null) == enable)
     {
         return;
     }
     if (enable)
     {
         context        = Game.Instance.ControlContext.CreateSubcontext();
         context.Active = true;
         operation(context);
     }
     else
     {
         context.Destroy();
         context = null;
     }
 }
Esempio n. 6
0
        public TouchListener(Predicate <Touch> triggerRule, ControlContexted contexted, string helpText, Delegate handler, params object[] args)
        {
            this.isDestroyed     = false;
            this.Destroyed       = null;
            this.isTriggered     = triggerRule;
            this.handler         = handler;
            this._helpText       = helpText;
            this.dynamicContext  = true;
            this.context         = null;
            this.contextedObject = contexted;

            this.handlerParams = new object[args.Length + 1];

            if (args.Length > 0)
            {
                Array.ConstrainedCopy(args, 0, handlerParams, 1, handlerParams.Length - 1);
            }
        }
Esempio n. 7
0
 /// <summary>
 /// Kuuntelee tapahtumaa vain tietyssä kontekstissa.
 /// </summary>
 /// <param name="context"></param>
 public Listener InContext(ListenContext context)
 {
     this.dynamicContext = false;
     this.context        = context;
     return(this);
 }