public virtual void Awake() { meshRenderers = GetComponentsInChildren <MeshRenderer>(); materialFSM[MaterialState.Normal].Exit = delegate { foreach (var interpolator in interpolators.Values) { interpolator.Forward(); interpolator.Begin(); } }; materialFSM[MaterialState.Changed].Exit = delegate { foreach (var interpolator in interpolators.Values) { interpolator.Backward(); interpolator.Begin(); } }; KeyboardHandler.AddEntry(KeyCode.J, "Start Material Changer", Change); KeyboardHandler.AddEntry(KeyCode.K, "Reverse Material Changer", Reverse); KeyboardHandler.AddEntry(KeyCode.H, "Cleanup Material Changer", Cleanup); Refresh(); }
private void KeyboardHandler_KeysPressed(object sender, Keys e) { if (!this.IsLocked && this.HasFocus) { switch (e) { case Microsoft.Xna.Framework.Input.Keys.Back: this.Back(); break; case Microsoft.Xna.Framework.Input.Keys.Enter: this.Enter(); break; case Microsoft.Xna.Framework.Input.Keys.Left: this.Left(); break; case Microsoft.Xna.Framework.Input.Keys.Right: this.Right(); break; case Microsoft.Xna.Framework.Input.Keys.Delete: this.Delete(); break; default: this.AcceptKeystroke(KeyboardHandler.ToChar(e)); break; } } }
/// <summary> /// Method used to update help page. /// </summary> /// <returns></returns> public override void Update() { KeyboardHandler.AnyKey(() => { this.FireOptionChosen(this); }); }
public Game() { settings = GetSettings(); // Connect players if (settings.Players.Count(p => p == PlayerType.AI) > 0) { SocketForm socketForm = new SocketForm(settings); socketForm.Show(); socketManager = socketForm.CreateSocketManager(); socketForm.Close(); if (socketManager == null) { return; } } // Setup graphics graphics = new FormGraphics(); graphics.Show(); graphics.Closed += (sender, args) => Dispose(); // Get keyboard control KeyboardHandler keyboardHandler = new KeyboardHandler(graphics); gameManager = new GameManager(settings, keyboardHandler, socketManager, graphics); // Start game gameManager.Start(); }
public Game() { settings = GetSettings(); // Connect players if (settings.Players.Count(p => p == PlayerType.AI) > 0) { SocketForm socketForm = new SocketForm(settings); socketForm.Show(); socketManager = socketForm.CreateSocketManager(); socketForm.Close(); if (socketManager == null) return; } // Setup graphics graphics = new FormGraphics(); graphics.Show(); graphics.Closed += (sender, args) => Dispose(); // Get keyboard control KeyboardHandler keyboardHandler = new KeyboardHandler(graphics); gameManager = new GameManager(settings, keyboardHandler, socketManager, graphics); // Start game gameManager.Start(); }
public virtual void ViewDidLoad() { if (View.HandleKeyboard && View is UIViewController viewController && viewController.View != null) { _keyboardHandler = new KeyboardHandler(viewController.View); } }
public QuickCaptureWindow() { InitializeComponent(); ReInitilize(); if (Directory.Exists(StartProcess.APPDATA_PLANZ_PATH) == false) { Directory.CreateDirectory(StartProcess.APPDATA_PLANZ_PATH); } textBox_Note.Text = newNoteText; this.Activate(); textBox_Note.Select(newNoteText.Length, 0); textBox_Note.Focus(); checkBox_URI.Content = "No link available"; hotkey_handler = new KeyboardHandler(this); updateComboBox_SaveLoc(); if (comboBox_SaveLoc.Items.Count > 0 && comboBox_SaveLoc.SelectedIndex == -1) { comboBox_SaveLoc.SelectedIndex = 0; } this.Title = "Quick Capture (Windows logo key + C)"; }
public MainWindow() { InitializeComponent(); TerminalCtl.GlyphSheet = GlyphSheet.Terminal10x12; _mapHandler = new MapHandler(TerminalCtl, MapHost, _game); _keyboard = new KeyboardHandler(_game); }
private static int GlobalHookCallback(HookType Type, int code, IntPtr wParam, IntPtr lParam) { switch (Type) { case HookType.WH_KEYBOARD_LL: { if (!KeyboardHandler.Dispatch(code, wParam, lParam)) { return(1); } break; } case HookType.WH_MOUSE_LL: { if (!MouseHandler.Dispatch(code, wParam, lParam)) { return(1); } break; } default: break; } return(User32.CallNextHookEx(IntPtr.Zero, code, wParam, lParam)); }
public static async Task Execute(CallbackData data) { var receiver = data.Sender.Id; if (int.TryParse(((TextMessage)data.Message).Text, out int userValue)) { //учесть данные в поле трекинга var trackingData = ViberBotTrackingData.Get(data.Message.TrackingData); var flatNumber = trackingData.Data[DataField.FlatNumber.ToString()]; trackingData.Add(DataField.FlatValue.ToString(), userValue.ToString()); //запросить подтверждение var message = new KeyboardMessage { Receiver = receiver, Sender = client.BotUserData, Text = $"Для квартиры - {flatNumber}. Вы указали - {userValue}. Данные верны?", TrackingData = ViberBotTrackingData.Build("СonfirmSendDataAction", "SendDataAction", trackingData.Data), Keyboard = KeyboardHandler.YesNoCancel() }; await client.SendMessage(receiver, message); } else { //неверное значение await client.SendTextMessage(receiver, BotError.BadValue); } }
public static async Task Execute(CallbackData data) { //достать данные из таблицы var flats = Handlers.GoogleSheetsHandler.CheckFlatData(data.Sender.Id); if (flats.Count > 0) { //отправить подтверждение var receiver = data.Sender.Id; var message = new KeyboardMessage { Receiver = receiver, Sender = client.BotUserData, Text = $"Вы указывали квартиры : {String.Join(",", flats)}. Выберите действие.", TrackingData = ViberBotTrackingData.Build("", "StartSetFlatNumberAction"), Keyboard = KeyboardHandler.CustomButtons(new string[][] { new string[] { "Добавить квартиру", "AddFlatNumberAction" }, new string[] { "Удалить квартиру", "ConfirmDeleteFlatNumberAction" }, new string[] { "Отмена", "Cancel" } }) }; await client.SendMessage(receiver, message); } else { await AddFlatNumberAction.Execute(data); } }
public RadioManager(IAudioReaderAndSender <SendableRadioModel> reader, IAudioReceiverAndPlayer <ReceivableRadioModel> player, KeyboardHandler keyboardHandler) { _reader = reader; _player = player; _keyboardHandler = keyboardHandler; }
public static async Task Execute(CallbackData data) { var text = ((TextMessage)data.Message).Text; var receiver = data.Sender.Id; var trackingData = ViberBotTrackingData.Get(data.Message.TrackingData); if (text == "no") { await StartSetFlatNumberAction.Execute(data); return; } else if (text == "yes") { var flatNumber = trackingData.Data[DataField.FlatNumber.ToString()]; //сохранить в таблицу Handlers.GoogleSheetsHandler.AddUserFlatNumber(flatNumber, data.Sender); await client.SendTextMessage(receiver, "Данные успешно сохранены."); } else { var message = new KeyboardMessage { Receiver = receiver, Sender = client.BotUserData, Text = $"Выберите действи из списка.", TrackingData = ViberBotTrackingData.Build("SetFlatNumberAction", "SetFlatNumberAction", trackingData.Data), Keyboard = KeyboardHandler.YesNoCancel() }; await client.SendMessage(receiver, message); } }
private static void Init() { var player = map.Actors.Single(a => a is Player) as Player; var mapConsole = new MapConsole(game, true, new AStarPathFinder()); var logConsole = new LogConsole(); var messageConsole = new MessageConsole(); var statusConsole = new StatusConsole(player); var menuConsole = new MenuConsole(Width, Height); var inventory = new InventoryConsole(player); var keyboardHandler = new KeyboardHandler(mapConsole, logConsole, messageConsole, player, inventory, menuConsole, game, () => StartGame(rnd)); var mainConsole = new MainConsole(mapConsole, logConsole, messageConsole, statusConsole, keyboardHandler, inventory); mainConsole.Children.Add(mapConsole); mainConsole.Children.Add(logConsole); mainConsole.Children.Add(messageConsole); mainConsole.Children.Add(statusConsole); mainConsole.Children.Add(inventory); mainConsole.Children.Add(menuConsole); SadConsole.Game.Instance.Screen = mainConsole; }
private void GameLoop() { var stopwatch = new Stopwatch(); var millisecondsPassed = 0L; stopwatch.Start(); while (Alive) { if (stopwatch.ElapsedMilliseconds <= 100) { continue; } CurrentBoard.ShallowClear(); _inputHandler.HandlePlayerMovement(KeyboardHandler.GetDirection(), true); if (millisecondsPassed > 1000) { CurrentBoard.ShallowClear(); _inputHandler.HandlePlayerMovement(KeyCommand.Down); millisecondsPassed = 0L; } if (HasChanged) { Show(); } HasChanged = false; millisecondsPassed += stopwatch.ElapsedMilliseconds; stopwatch.Restart(); } }
private void Awake() { m_battleManager = GameObject.FindGameObjectWithTag("BattleManager").GetComponent <BattleManager>(); m_generator = GameObject.FindGameObjectWithTag("QuestionControl").GetComponent <ChosungGeneratorDefault>(); m_judgement = GameObject.FindGameObjectWithTag("QuestionControl").GetComponent <Judgement>(); m_keyboardHandler = GameObject.FindGameObjectWithTag("KeyboardHandler").GetComponent <KeyboardHandler>(); }
public static async Task Execute(CallbackData data) { //достать данные из таблицы var receiver = data.Sender.Id; var flats = Handlers.GoogleSheetsHandler.CheckFlatData(data.Sender.Id); if (flats.Any()) { var flatButtonsData = new List <string[]>(); foreach (var flat in flats) { flatButtonsData.Add(new string[] { flat.ToString(), flat.ToString() }); } flatButtonsData.Add(new string[] { "Отмена", "Cancel" }); //отправить подтверждение var message = new KeyboardMessage { Receiver = receiver, Sender = client.BotUserData, Text = $"Выберите номер квартиру для удаления.", TrackingData = ViberBotTrackingData.Build("ConfirmDeleteFlatNumberAction", "DeleteFlatNumberAction"), Keyboard = KeyboardHandler.CustomButtons(flatButtonsData.ToArray()) }; await client.SendMessage(receiver, message); } else { await client.SendTextMessage(receiver, "Нет привязаных квартир."); } }
public void RunFullVersion() { MatrixColumns matrixBlocks = new MatrixColumns(); MatrixRain matrixRain = new MatrixRain(); MatrixQuotes matrixSpeech = new MatrixQuotes(); KeyboardHandler matrixKeyboard = new KeyboardHandler(); while (true) { if (SkipIntro) { matrixRain.RunMatrixRain(); matrixSpeech.ShowRandomQuote(); matrixKeyboard.WaitPressedKey(); } else { matrixSpeech.ShowIntroQuote(3); matrixBlocks.RunDigitalColumns(); matrixBlocks.RunSymbolColumns(); matrixBlocks.ShowTextAscii(TextASCII); SkipIntro = true; } } }
public TrueCraftGame(MultiplayerClient client, IPEndPoint endPoint) { Window.Title = "TrueCraft"; Content.RootDirectory = "Content"; Graphics = new GraphicsDeviceManager(this); Graphics.SynchronizeWithVerticalRetrace = false; Graphics.IsFullScreen = UserSettings.Local.IsFullscreen; Graphics.PreferredBackBufferWidth = UserSettings.Local.WindowResolution.Width; Graphics.PreferredBackBufferHeight = UserSettings.Local.WindowResolution.Height; Graphics.ApplyChanges(); Window.ClientSizeChanged += Window_ClientSizeChanged; Client = client; EndPoint = endPoint; LastPhysicsUpdate = DateTime.MinValue; NextPhysicsUpdate = DateTime.MinValue; PendingMainThreadActions = new ConcurrentBag<Action>(); MouseCaptured = true; Bobbing = 0; KeyboardComponent = new KeyboardHandler(this); Components.Add(KeyboardComponent); MouseComponent = new MouseHandler(this); Components.Add(MouseComponent); GamePadComponent = new GamePadHandler(this); Components.Add(GamePadComponent); }
public Engine() { kbHandler = new KeyboardHandler(); //gpHandler = new PS4GamePadHandler(0); //TODO: Add support for PS4 controller reqHandler = new RequestHandler(); RenderState.activeGamepad = gpHandler; //Assign new palette to GLControl palette = Palettes.createPalettefromBasePalettes(); renderMgr = new renderManager(); //Init renderManager of the engine //Input Polling Timer inputPollTimer = new System.Timers.Timer(); inputPollTimer.Elapsed += new ElapsedEventHandler(input_poller); inputPollTimer.Interval = 1; //Camera Movement Timer cameraMovementTimer = new System.Timers.Timer(); cameraMovementTimer.Elapsed += new ElapsedEventHandler(camera_timer); cameraMovementTimer.Interval = 20; //cameraMovementTimer.Start(); Start in the main function //Systems Init actionSys = new ActionSystem(); animationSys = new AnimationSystem(); actionSys.SetEngine(this); animationSys.SetEngine(this); }
public void InitialStartup(ref int progress) { BoundHandler.Initialize(); progress++; KeyboardHandler.Initialize(); progress++; }
public override void Initialize() { interfaceSpriteBatch = new SpriteBatch(currentGame.GraphicsDevice); finalSpriteBatch = new SpriteBatch(currentGame.GraphicsDevice); StartServerButton = new Button(currentGame, asset: "StartServerButton"); JoinGameButton = new Button(currentGame, asset: "JoinGameButton"); EditDecksButton = new Button(currentGame, asset: "EditDecksButton"); OptionsButton = new Button(currentGame, asset: "OptionsButton"); // Add buttons to layout manager LayoutManager.AddElement(StartServerButton); LayoutManager.AddElement(JoinGameButton); LayoutManager.AddElement(EditDecksButton); LayoutManager.AddElement(OptionsButton); OnScreenElements = new List <IClickable>(); // Add elements from all layout containers to OnScreenElements foreach (IClickable element in LayoutManager.Elements) { OnScreenElements.Add(element); } currentInputEvent = InputEvent.None; keyboardHandler = new KeyboardHandler(currentGame); }
static void Main() { RNG = new Random(); IdGen = new IdGen(); LogHandler = new LogHandler(); ShaderHandler = new ShaderHandler(); KeyboardHandler = new KeyboardHandler(false); // we don't want repeat enabled for a video game (except in menus or when writing something) ResourceHandler = new ResourceHandler(); switch (Config.TextureDisplayMode) { case TextureDisplayMode.Smooth: RenderHandler = new RenderHandlerSmooth(); break; default: RenderHandler = new RenderHandlerPixelPerfect(); break; } SceneHandler = new SceneHandler(); Camera = new Camera(50, 100); SpriteSets = new Dictionary <string, SpriteSet> { { "cube", new SpriteSet("cube.png", 79, 71) }, { "tileset1", new SpriteSet("tileset.png", 3, 2, 16, 16) }, }; // TODO do an enum and a GetSpriteSet like for Scenes? Window = new MainWindow(); Window.Run(Config.UPS); // option sets the amount of times OnUpdateFrame(e) is called every second }
void Start() { print("start called in game state handler"); kh = GetComponent <KeyboardHandler>(); kh.TabPressed += OnTabPressed; //Register the OnTabPressed delegate to the event player = GameObject.FindWithTag("Player"); }
void PlatformInit() { Form form = (Form)Form.FromHandle(Window.Handle); form.FormClosing += (o, e) => { if (CanClose != null) { e.Cancel = !CanClose(this); } }; _keyboardHandler = new KeyboardHandler(form.Handle); _keyboardHandler.OnCharacter += (c) => { if (_currentFocus != null) { if (c == '\r') { c = '\n'; } _currentFocus.OnCharacter(c); } }; _keyboardHandler.OnKey += (k) => { if (_currentFocus != null) { _currentFocus.OnKey(k); } }; }
private void Update() { if (KeyboardHandler.IsOkButtonDown()) { Jump(); } }
private void OnLoadInternal(object sender, EventArgs e) { var window = (GameWindow)sender; KeyboardHandler.Init(window); MouseHandler.Init(window); OnLoad(); }
private ProcessHandler(IntPtr foregroundHWnd, IntPtr windowRectHWnd, IntPtr screenshotHWnd, IntPtr keyboardHWnd, IntPtr mouseHWnd) { _foreground = new ForegroundHandler(foregroundHWnd); _windowRect = new WindowRectHandler(windowRectHWnd); _screenshot = new ScreenshotHandler(screenshotHWnd); _keyboard = new KeyboardHandler(keyboardHWnd); _mouse = new MouseHandler(mouseHWnd); }
public Game() { win = new Window(1280, 720, "Prototype"); c = win.GetCamara(); gObj = new GameObject(); keyboard = new KeyboardHandler(); }
public MainWindow() { ViewModel = new MainWindowViewModel(world); InitializeComponent(); keyboardHandler = new KeyboardHandler(tickInterval); keyboardHandler.HoldableKeys.Add(new HoldableKey(Key.Left, (duration) => World.Instance.ControlledCar.X -= 5, null)); keyboardHandler.HoldableKeys.Add(new HoldableKey(Key.Right, (duration) => World.Instance.ControlledCar.X += 5, null)); keyboardHandler.HoldableKeys.Add(new HoldableKey(Key.Up, (duration) => World.Instance.ControlledCar.Y -= 5, null)); keyboardHandler.HoldableKeys.Add(new HoldableKey(Key.Down, (duration) => World.Instance.ControlledCar.Y += 5, null)); hmiDebug = new HMIDebug(); keyboardHandler.PressableKeys.Add(new PressableKey(Key.D1, () => hmiDebug.OnDebugAction(1))); keyboardHandler.PressableKeys.Add(new PressableKey(Key.D2, () => hmiDebug.OnDebugAction(2))); keyboardHandler.PressableKeys.Add(new PressableKey(Key.D3, () => hmiDebug.OnDebugAction(3))); keyboardHandler.PressableKeys.Add(new PressableKey(Key.D4, () => hmiDebug.OnDebugAction(4))); timer.Interval = TimeSpan.FromMilliseconds(tickInterval); timer.Tick += logic; timer.Start(); // make my dockpanel focus of this game MainDockPanel.Focus(); world.Width = 2000; world.Height = 1000; var circle = new Circle(400, 200, "circle.png", 20); circle.Width = 40; circle.Height = 40; circle.ZIndex = 2; world.AddObject(circle); var controlledCar = new Models.AutomatedCar(50, 50, "car_1_white.png"); controlledCar.Width = 108; controlledCar.Height = 240; // read the world object polygons, get the one for the car in a primitive way // this is just a sample, the proecssing shold be much more general string json_text = System.IO.File.ReadAllText($"Assets/worldobject_polygons.json"); dynamic stuff = JObject.Parse(json_text); var geom = new Polyline(); // get the points from the json and add to the polyline foreach (var i in stuff["objects"][0]["polys"][0]["points"]) { geom.Points.Add(new Point(i[0].ToObject <int>(), i[1].ToObject <int>())); } // add polyline to the car controlledCar.Geometry = geom; world.AddObject(controlledCar); world.ControlledCar = controlledCar; controlledCar.Start(); }
void MainWindow_Initialized(object sender, EventArgs e) { m_cmdHandler = new MainWindowCommandHandler(this); GameData.Data.GameModeChanged += OnGameModeChanged; GameData.Data.FocusedObjectChanged += OnFocusedObjectChanged; this.ToolMode = ClientToolMode.Info; this.MapControl.GotSelection += MapControl_GotSelection; // for some reason this prevents the changing of focus from mapcontrol with cursor keys KeyboardNavigation.SetDirectionalNavigation(this, KeyboardNavigationMode.Once); // add default commands m_cmdHandler.AddCommandBindings(GameMode.Undefined); this.KeyboardHandler = new KeyboardHandler(this.MapControl); }
public void Update(KeyboardHandler keyboardHandler, MouseHandler mouseHandler) { if (keyboardHandler.KeyPressed(Keys.W)) { _currentIndex -= 1; } if (keyboardHandler.KeyPressed(Keys.X)) { _currentIndex += 1; } if (keyboardHandler.KeyPressed(Keys.Enter)) { _thresholdGame.Log(_menuOptions[_currentIndex]); if (_currentIndex == 2) { _thresholdGame.Exit(); } } if (_currentIndex < 0) _currentIndex = _menuOptions.Count - 1; if (_currentIndex >= _menuOptions.Count) _currentIndex = 0; }
private void init() { mouse = new Logic.Mouse(); keyboard = new KeyboardHandler(); player = new Player(this); critter = new Critter(this); tower = new Tower(this); RandomHandler.Init(); }
public void Update(KeyboardHandler keyboardHandler, MouseHandler mouseHandler) { if (_currentGameState != null) _currentGameState.Update(keyboardHandler, mouseHandler); }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { IsMouseVisible = true; _keyboardHandler = new KeyboardHandler(); _mouseHandler = new MouseHandler(); _gameStateManager = new GameStateManager(); _gameStateManager.Push(new MenuGameState(this)); _map = new Map(); _map.Width = 10; _map.Height = 10; _map.TileSet = new TileSet(); _map.TileSet.Tiles = new List<Tile> { new Tile { Name = "Void", Glyph = 8, Color = Color.White, Walkable = false, Transparent = true }, new Tile { Name = "Floor", Glyph = 249, Color = Color.White, Walkable = false, Transparent = true }, new Tile { Name = "Wall", Glyph = 219, Color = Color.White, Walkable = false, Transparent = true }, }; _map.TileSet.TileWidth = 8; _map.TileSet.TileHeight = 8; _map.TileData = new int[_map.Width, _map.Height]; for (var x = 0; x < _map.Width; x++) { for (var y = 0; y < _map.Width; y++) { _map.TileData[x, y] = 1; } } _player = new Player { X = 0, Y = 0 }; _statusView = new StatusView(new Rectangle(0, 89, 160, 90)); _consoleView = new ConsoleView(new Rectangle(0, 0, 80, 89), Color.Green); _console = new Console(); _console.Log("test"); _worldView = new WorldView(new Rectangle(80, 0, 80, 89)); base.Initialize(); }
/// <summary> /// this is done just once, to globally initialize CefSharp/CEF /// </summary> private void InitBrowser() { CefSettings settings = new CefSettings(); settings.Locale = "zh_CN"; settings.CachePath = System.IO.Directory.GetCurrentDirectory() + @"/BrowserCache"; settings.AcceptLanguageList = "zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3"; settings.LocalesDirPath = System.IO.Directory.GetCurrentDirectory() + @"/localeDir"; settings.LogFile = System.IO.Directory.GetCurrentDirectory() + @"/LogData"; settings.PersistSessionCookies = true; settings.UserDataPath = System.IO.Directory.GetCurrentDirectory() + @"/UserData"; settings.UserAgent = UserAgent; settings.IgnoreCertificateErrors = true; Cef.Initialize(settings); dHandler = new DownloadHandler(this); lHandler = new LifeSpanHandler(this); mHandler = new ContextMenuHandler(this); kHandler = new KeyboardHandler(this); rHandler = new RequestHandler(this); host = new HostHandler(this); AddNewBrowser(CefFaTabStripItem, HomepageURL); }