protected override void Initialize() { Registry = new ServiceRegistry(); Registry.Register(m_SpriteBatch = new SpriteBatchExtended(this)); m_SpriteBatch.Initialize(); Registry.Register(m_InputManager = new InputManager(Window.Handle)); m_InputProvider = new InputProvider(m_InputManager); m_DisplayProvider = new DisplayProvider(m_SpriteBatch); m_Emulator = new Emulator(); m_Emulator.Initialize(m_DisplayProvider, m_InputProvider); m_Curses = new Curses(GraphicsDevice, c_ConsoleWidth, c_ConsoleHeight, c_CursesFont, true); m_Effect = new EffectState(m_SpriteBatch.LoadEffectContent("BasicEffect"), SamplerState.PointClamp); m_EffectCRT = new EffectState(m_SpriteBatch.LoadEffectContent("CRTEffect"), SamplerState.AnisotropicClamp); m_Graphics.PreferredBackBufferWidth = c_WindowW * 2; m_Graphics.PreferredBackBufferHeight = c_WindowH; m_Graphics.IsFullScreen = false; m_Graphics.ApplyChanges(); IsMouseVisible = true; base.Initialize(); SystemFunctions.SetFocus(Window.Handle); }
public void Listen(IInputActionMapper inputActionMapper) { _inputProvider = new InputProvider(); _inputActionMapper = inputActionMapper; lastInputReceivedAt = DateTime.Now; _inputProvider.InputReceived += OnInputReceived; var inactiveAfterMs = ConfigurationProvider.Configuration.Application.InactiveAfterMs; var inputPollingRateMs = ConfigurationProvider.Configuration.Application.InputPollingRate; while (true) { var lastInputInMilliseconds = DateTime.Now.Subtract(lastInputReceivedAt).TotalMilliseconds; if (lastInputInMilliseconds >= inactiveAfterMs && !hasIconsBeenHidden) { _inputActionMapper.HandleInput(); hasIconsBeenHidden = true; } else if (lastInputInMilliseconds < inactiveAfterMs && hasIconsBeenHidden) { _inputActionMapper.HandleInput(); hasIconsBeenHidden = false; } Thread.Sleep(inputPollingRateMs); } }
static void Main(string[] args) { using var ruleProvider = new InputProvider <string>("Rules.txt", GetString); foreach (var line in ruleProvider) { var rule = new Rule(line); ruleDatabase.Add(rule.Id, rule); } var targetRule = ruleDatabase[0]; using var inputProvider = new InputProvider <string>("Input.txt", GetString); var input = inputProvider.ToList(); int countPart1 = input.Count(w => { var match = targetRule.IsMatch(w, 0); return(match.isMatch && match.charsUsed.Any(ww => ww == w.Length)); }); Console.WriteLine($"Part 1: Inputs that matches rule 0: {countPart1}"); // for part 2 replace two rules ruleDatabase[8] = new Rule("8: 42 | 42 8"); ruleDatabase[11] = new Rule("11: 42 31 | 42 11 31"); int countPart2 = input.Count(w => { var match = targetRule.IsMatch(w, 0); return(match.isMatch && match.charsUsed.Any(ww => ww == w.Length)); }); Console.WriteLine($"Part 2: Inputs that matches rule 0: {countPart2}"); }
protected override void Initialize() { IsFixedTimeStep = true; IsMouseVisible = false; GameSettings.Initialize(Graphics, Game.VirtualResolution); var Services = new GameServiceContainer(); Services.AddService(typeof(IGraphicsDeviceService), Graphics); Services.AddService(typeof(ISkipContent), this); InputProvider = new UserInputProvider(); StackEngine = new StackEngine(Game, Services, InputProvider, GameSettings); if (GameSettings.Debug) { InputProvider.Handler += HandleDebugInputEvent; } InputProvider.Handler += HandleSkipInputEvent; StackEngine.OnExit += Exit; Counter = new FrameRateCounter(); SetSpeed(GameSpeed.Default); base.Initialize(); }
public StackEngine(StackGame game, IServiceProvider services, InputProvider input, GameSettings gameSettings) { GameSettings = gameSettings; Services = services; gameSettings.SetCulture(); var ConsoleLogHandler = new ConsoleLogHandler(Console); EngineContent = new ContentLoader(Services); Renderer = new Renderer(Services, EngineContent, game.VirtualResolution, gameSettings.GetTargetResolution(game.VirtualResolution), gameSettings.Bloom); Game = game; Console = new Console(this); ConsoleLogHandler.Console = Console; _Paused = true; InputProvider = input; if (InputProvider != null) { InputProvider.DisplaySettings = Renderer.DisplaySettings; } EngineVariables.EnableGUI = true; Game.Start(this); }
static void Main(string[] args) { var changeProvider = new InputProvider <int>(@"Input.txt", StringToIntConverter); int currentFrequency = 0; HashSet <int> alreadySeenFrequencies = new HashSet <int>(); bool foundRepeatedValue = false; while (!foundRepeatedValue) { for (; changeProvider.MoveNext(); currentFrequency += changeProvider.Current) { Console.WriteLine($"Resulting frequency: {currentFrequency}"); if (alreadySeenFrequencies.Contains(currentFrequency)) { foundRepeatedValue = true; break; } else { alreadySeenFrequencies.Add(currentFrequency); } } changeProvider.Reset(); } ; Console.WriteLine(); Console.WriteLine($"Resulting frequency: {currentFrequency}"); Console.WriteLine("Press any key to continue;"); Console.ReadKey(); }
protected override Task <int> Solve() { var inputProvider = new InputProvider <string>(3, 1); var inputs = inputProvider.GetInputs(); long multiplication = 1; var treeCount = CountTrees(inputs, 1, 1); multiplication *= treeCount; treeCount = CountTrees(inputs, 3, 1); multiplication *= treeCount; Console.WriteLine($"Day 03 part 1: {treeCount}"); treeCount = CountTrees(inputs, 5, 1); multiplication *= treeCount; treeCount = CountTrees(inputs, 7, 1); multiplication *= treeCount; treeCount = CountTrees(inputs, 1, 2); multiplication *= treeCount; Console.WriteLine($"Day 03 part 2: {multiplication}"); return(Task.FromResult(0)); }
private void HandleAttack() { if (InputProvider.GetButtonDown("Attack")) { Attack.TryToActivate(GetDirection()); } }
private void HandleSkill() { if (InputProvider.GetButtonDown("Skill")) { Skill.TryToActivate(GetDirection()); } }
private static int[] GetLicenseInput() { var licenseProvider = new InputProvider <int[]>("Input.txt", GetNumbersInLine); licenseProvider.MoveNext(); return(licenseProvider.Current); }
public Game1() { _graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; _input = new InputProvider(this); ui = new UI(this); Components.Add(ui); map = new Map(this); Components.Add(map); sync = new Synchronizer(this); Components.Add(sync); Map.Sync = sync; Map.Ui = ui; Tile.Map = map; UI.Map = map; UI.Input = _input; UI.Sync = sync; Synchronizer.Ui = ui; Synchronizer.Map = map; Card.Sync = sync; Card.Map = map; Unit.Map = map; Unit.Sync = sync; _graphics.PreferredBackBufferWidth = 1360; _graphics.PreferredBackBufferHeight = 730; IsMouseVisible = true; TargetElapsedTime = TimeSpan.FromMilliseconds(30); }
public void RegisterInputProvider(InputProvider inputProvider) { var inputs = inputProvider.LoadInputs(); InputHandler.Init(); InputHandler.RegisterInputs(inputs); }
protected override Task <int> Solve() { var inputProvider = new InputProvider <string>(7, 1); var inputs = inputProvider.GetInputs(); var translationTable = inputs.DetermineBagTypes(); var bagProperties = inputs.DetermineBagContentsWith(translationTable); var shinyGoldBagId = translationTable["shiny gold"]; WriteVerboseLine($"Found {translationTable.Count} colors of bags."); WriteVerboseLine($"Shiny gold bag has ID {shinyGoldBagId}"); var canContainGoldShinyBag = new Dictionary <int, bool>(); foreach (var bag in bagProperties) { canContainGoldShinyBag[bag.Key] = CanHold(bag.Key, shinyGoldBagId, bagProperties, canContainGoldShinyBag); } var bagCount = canContainGoldShinyBag.Count(result => result.Value); WriteHeaderLine("Day 7; part 1"); WriteSuccessLine($"There are {bagCount} bags that can hold a shiny gold bag."); WriteLine(); var nestedBags = CountNestedBags(shinyGoldBagId, bagProperties); WriteHeaderLine("Day 7; part 2"); WriteSuccessLine($"A gold shiny bag can hold {nestedBags} other bags."); WriteLine(); return(Task.FromResult(0)); }
static void Main(string[] args) { var observationProvider = new InputProvider <Star>("Input.txt", GetStar); var stars = new List <Star>(); while (observationProvider.MoveNext()) { stars.Add(observationProvider.Current); } for (int step = 0; true; step++) { var maxStarsOnSameX = stars.GroupBy(w => w.Position.X).Select(group => group.Count()).Max(); var maxStarsOnSameY = stars.GroupBy(w => w.Position.Y).Select(group => group.Count()).Max(); if (maxStarsOnSameX + maxStarsOnSameY > 50) { Console.Clear(); Console.WriteLine($"Step {step}:\n"); var minX = stars.Min(w => w.Position.X); var maxX = stars.Max(w => w.Position.X); VisualizeSky(new EnumerableReader <Star>(stars.OrderBy(w => w.Position.Y).ToArray()), minX, maxX); Console.ReadKey(); } stars.ForEach(star => star.MakeStep()); } Console.WriteLine(); Console.WriteLine($"Done. Num of stars: {stars.Count}"); Console.ReadKey(); }
private void Awake() { inputProvider = GetComponent <InputProvider>(); sePlayer = GetComponent <SEPlayer>(); sceneLoader = GetComponent <SceneLoader>(); scoreManager = GetComponent <ScoreManager>(); }
public Application(DisplayController display) { DisplayController displayController = display; if (displayController == null) { throw new ArgumentException(); } this.display = displayController; WindowManager.EnsureInstance(this.display); Application._stylusMaxX = (int)this.display.ActiveSettings.Width; Application._stylusMaxY = (int)this.display.ActiveSettings.Height; lock (typeof(Application.GlobalLock)) { if (Application._appCreatedInThisAppDomain) { throw new InvalidOperationException("application is a singleton"); } Application._appInstance = this; Application.IsShuttingDown = false; Application._appCreatedInThisAppDomain = true; } this.InitializeForEventSource(); this.InputProvider = new InputProvider(this); Dispatcher.SetFinalDispatcherExceptionHandler(new DispatcherExceptionEventHandler(Application.DefaultContextExceptionHandler)); this.Dispatcher.BeginInvoke(new DispatcherOperationCallback(this.StartupCallback), (object)null); }
public void InstallInputProvider(InputProvider inputPrefab) { if (!inputPrefab) { //Debug.LogError("Invalid InputProvider (null)"); return; } //Debug.Log("TouchManager: using " + inputPrefab.name); if (inputProvider) { Destroy(inputProvider.gameObject); } inputProvider = ResourceSystem.NewObject(inputPrefab) as InputProvider; inputProvider.name = inputPrefab.name; inputProvider.transform.parent = this.transform; InitFingers(MaxFingers); if (OnInputProviderChanged != null) { OnInputProviderChanged(); } }
private void StartGame(UserHub host, UserHub guest) { IInputProvider inputProvider = new InputProvider(); IEngine engine = new TwoPlyersEngine(inputProvider); IGameInitializationStrategy strategy = new TwoPlayersInitializationStrategy(); engine.Initialize(strategy, host.Username, guest.Username); IOutputProvider outputProvider = new WebOutputProvider(); Guid gameId = Guid.NewGuid(); var players = new List <UserHub>() { host, guest }; var game = new GameHub(players, engine); Games.Add(game); var board = outputProvider.GetBoardToRender(engine); var nextPlayerName = players.FirstOrDefault(p => p.ConnectionId == game.NextPlayerId).Username; Clients.Client(host.ConnectionId).startGame(board); Clients.Client(guest.ConnectionId).startGame(board); Clients.Client(host.ConnectionId).recieveMessage($"Next player: {nextPlayerName}", "Judge"); Clients.Client(guest.ConnectionId).recieveMessage($"Next player: {nextPlayerName}", "Judge"); }
private void Awake() { Debug.Assert(rollovers.Length > 0); _inputProvider = MonoBehaviour.FindObjectOfType <InputProvider>(); _HandleGroupActivation(); }
private void Awake() { _characterController = GetComponent <CharacterController>(); _gravityProvider = GetComponent <IGravityProvider>(); _movementProvider = GetComponent <IMovementProvider>(); _jumpProvider = GetComponent <IJumpProvider>(); _inputProvider = GetComponent <InputProvider>(); }
public OpenTKPluginProvider() { _plugins = new OpenTKPlugins(); Graphics = new GraphicsProvider(this); Audio = new AudioProvider(this); Input = new InputProvider(this); Timer = new TimerProvider(this); }
private int GetSubscriberCount(InputProvider input) { var fieldInfo = typeof(InputProvider).GetField("Handler", BindingFlags.NonPublic | BindingFlags.Instance); var field = fieldInfo.GetValue(input); var eventDelegate = (MulticastDelegate)field; return(eventDelegate.GetInvocationList().Count()); }
/// <summary> /// Implementation should over-ride Start, but still run base.Start() to set /// Context.Entity.MaxVersion and Context.Entity.MinVersion. In addition, the /// implementation should: /// /// * query and set Context.Entity.BatchId (the max. TflBatchId) /// * query and set Context.Entity.Identity (the max. TflKey) /// * query if output has any records and use in conjunction with MinVersion determine Content.Entity.IsFirstRun (MinVersion == null && outputCount == 0) /// </summary> public virtual void Start() { Context.Debug(() => "Starting"); Context.Entity.MaxVersion = InputProvider.GetMaxVersion(); Context.Entity.MinVersion = OutputProvider.GetMaxVersion(); Context.Entity.BatchId = OutputProvider.GetNextTflBatchId(); Context.Entity.Identity = OutputProvider.GetMaxTflKey(); }
//----------------------------------------------------------------------------------- public void LinkToIp(InputProvider ip) { //Add callbacks to button RegisterButton(ip, m_btnUp, InputProvider.EInputAction.ROTATE); RegisterButton(ip, m_btnDown, InputProvider.EInputAction.DOWN); RegisterButton(ip, m_btnLeft, InputProvider.EInputAction.LEFT); RegisterButton(ip, m_btnRight, InputProvider.EInputAction.RIGHT); }
private Direction GetDirection() { var horizontal = InputProvider.GetAxis("Horizontal"); return(Mathf.Abs(horizontal) > MinHorizontalMovement ? horizontal > 0 ? Direction.RIGHT : Direction.LEFT : _looksLeft ? Direction.LEFT : Direction.RIGHT); }
private static void Main() { var inputProvider = new InputProvider(); inputProvider.KeyboardInputReceived += OnKeyboardInputReceived; inputProvider.MouseInputReceived += OnMouseInputReceived; Console.ReadLine(); }
private void Awake() { _rayProvider = GetComponent <IRayProvider>(); _inputProvider = GetComponent <InputProvider>(); _bulletFlashParticleSystem = GetComponentInChildren <ParticleSystem>(); _weapon.CurrentAmmoInClip = _weapon.MaxAmmoInClip; _weapon.CurrentAmmo = _weapon.maxAmmo; AmmoUI(); }
static void Main(string[] args) { using var inputProvider = new InputProvider <string>("Input.txt", GetString); var input = inputProvider.ToList(); Part1(input); Part2(input[1]); }
public void Init(InputProvider inputProvider, BoundaryProvider boundaryProvider, BulletPool bulletPool) { this.boundaryProvider = boundaryProvider; weapon.Init(bulletPool); healthSystem.Init(); inputProvider.OnAttackAxisChangedAsObservable().Subscribe(x => { weapon.Shoot(); }); inputProvider.OnAxisChangedAsObservable().Subscribe(Move); healthSystem.OnDied += () => { Debug.LogError("Deeeeeeeeeeeed"); }; }
static void Main(string[] args) { using var inputProvider = new InputProvider <Instruction?>("Input.txt", GetInstruction); var inputs = inputProvider.Where(w => w != null).Cast <Instruction>().ToList(); Part1(inputs); Part2(inputs); }
public Calibration(InputProvider ip) { inputProvider = ip; InitializeComponent(); FormBorderStyle = FormBorderStyle.None; WindowState = FormWindowState.Maximized; Resized(); }
public MainForm() { inputProvider = new InputProvider(false); inputProvider.Initialize(); if (inputProvider.Camera == null) return; inputProvider.Start(); InitializeComponent(); SetUpCameras(); SetUpScriptEditor(); }
// Use this for initialization void Start() { m_ItemName = InitItemName; m_ItemType = InitItemType; m_TextMesh = InitTextMesh; m_TextMesh.text = m_ItemName; m_InputProvider = InitInputProvider; }
public SensorHandler(InputProvider inputProvider) { this.inputProvider = inputProvider; }
/** * @fn public Vector3 ProcessMotion(Vector3 spritePosition, InputProvider inputProvider) * @brief Handles processing motion based on the values SpriteMotion were created with. * @author Eagan * @date 9/18/2013 * @param spritePosition The sprite transform.position value. * @param inputProvider The angle the controller is pointing. * @return Vector3 specifying the new position of the sprite. */ public Vector3 ProcessMotion(Vector3 spritePosition, InputProvider inputProvider) { Vector3 returnValue = new Vector3(spritePosition.x, spritePosition.y, spritePosition.z); HandleInputAcceleration(); ProcessChangesInMagnitude(inputProvider.Data.Magnitude); ApplyChangesInVelocity(inputProvider.Data.Angle, inputProvider.Data.Magnitude); HandleJumpStateActivation(inputProvider.Data.JumpState); returnValue.x += myVelocity.x; returnValue.y += myVelocity.y; return returnValue; }