public void SetChoices(BaseStructure structure1, BaseStructure structure2)
        {
            CurrentSelectionModeState = SelectionMode.Double;

            towerType1 = structure1.GetType();
            towerType2 = structure2.GetType();

            StructureChoice1.DisplayChoice(structure1);
            StructureChoice2.DisplayChoice(structure2);

            StructureChoice1.HasEvents            = true;
            StructureChoice1.ExposeChildrenEvents = false;

            StructureChoice2.HasEvents            = true;
            StructureChoice2.ExposeChildrenEvents = false;

            structure1.X             = StructureChoice1.X;
            structure1.Y             = StructureChoice1.Y - 260;
            structure1.Z             = 2;
            structure1.IsBeingPlaced = false;

            structure2.X             = StructureChoice2.X;
            structure2.Y             = StructureChoice2.Y - 260;
            structure2.Z             = 2;
            structure2.IsBeingPlaced = false;

            StructureChoice1.Click += StructureChoice1_Click;
            StructureChoice2.Click += StructureChoice2_Click;

            ConfirmButton.Click += (unused) => ConfirmTowerSelection?.Invoke(this);
        }
Esempio n. 2
0
        public static void HandleEvent(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
        {
            var args = new WindowEventArgs(hwnd, msg, wParam, lParam, handled);

            WindowEvent?.Invoke(Handle, args);
            handled = args.Handled;
        }
Esempio n. 3
0
        public void PollEvent()
        {
            while (SDL_PollEvent(out SDL_Event e) != 0)
            {
                switch (e.type)
                {
                case SDL_EventType.SDL_WINDOWEVENT:
                    switch (e.window.windowEvent)
                    {
                    case SDL_WindowEventID.SDL_WINDOWEVENT_CLOSE:
                        WindowEvent?.Invoke(new InputCallbackEventArg()
                        {
                            CallbackType = InputCallbackType.WindowClose
                        });
                        break;

                    case SDL_WindowEventID.SDL_WINDOWEVENT_FOCUS_GAINED:
                        WindowEvent?.Invoke(new InputCallbackEventArg()
                        {
                            CallbackType = InputCallbackType.FocusGained
                        });
                        break;

                    case SDL_WindowEventID.SDL_WINDOWEVENT_FOCUS_LOST:
                        WindowEvent?.Invoke(new InputCallbackEventArg()
                        {
                            CallbackType = InputCallbackType.FocusLost
                        });
                        break;

                    case SDL_WindowEventID.SDL_WINDOWEVENT_EXPOSED:
                        WindowEvent?.Invoke(new InputCallbackEventArg()
                        {
                            CallbackType = InputCallbackType.WindowExposed
                        });
                        break;

                    case SDL_WindowEventID.SDL_WINDOWEVENT_SHOWN:
                        WindowEvent?.Invoke(new InputCallbackEventArg()
                        {
                            CallbackType = InputCallbackType.WindowShown
                        });
                        break;
                    }
                    break;

                case SDL_EventType.SDL_KEYDOWN:
                    if (_keys.ContainsKey(e.key.keysym.sym))
                    {
                        _keys[e.key.keysym.sym] = true;
                    }
                    else
                    {
                        _keys.Add(e.key.keysym.sym, true);
                    }
                    break;

                case SDL_EventType.SDL_KEYUP:
                    if (_keys.ContainsKey(e.key.keysym.sym))
                    {
                        _keys[e.key.keysym.sym] = false;
                    }
                    else
                    {
                        _keys.Add(e.key.keysym.sym, false);
                    }
                    break;

                case SDL_EventType.SDL_MOUSEBUTTONDOWN:
                    switch (e.button.button)
                    {
                    case (byte)SDL_BUTTON_LEFT:
                        _leftMB = true;
                        break;

                    case (byte)SDL_BUTTON_RIGHT:
                        _rightMB = true;
                        break;

                    case (byte)SDL_BUTTON_MIDDLE:
                        _middleMB = true;
                        break;
                    }
                    break;

                case SDL_EventType.SDL_MOUSEBUTTONUP:
                    switch (e.button.button)
                    {
                    case (byte)SDL_BUTTON_LEFT:
                        _leftMB = false;
                        break;

                    case (byte)SDL_BUTTON_RIGHT:
                        _rightMB = false;
                        break;

                    case (byte)SDL_BUTTON_MIDDLE:
                        _middleMB = false;
                        break;
                    }
                    break;

                case SDL_EventType.SDL_RENDER_DEVICE_RESET:
                    EngineEvent?.Invoke(new InputCallbackEventArg()
                    {
                        CallbackType = InputCallbackType.RenderDeviceReset
                    });
                    break;
                }
            }
        }