private IEnumerator updateCoroutine() { // Written, 16.07.2018 if (MoControlsSaveData.loadedSaveData.monitiorXboxControllerConnectionStatus) { if (xboxController != null) { if (xboxController.isConnected != controllerConnection.currentConnectionStatus) { controllerConnection.previousConnectionStatus = controllerConnection.currentConnectionStatus; controllerConnection.currentConnectionStatus = xboxController.isConnected; if (controllerConnection.currentConnectionStatus == true) { XboxControllerManager.onControllerConnected(new ControllerConnectionEventArgs(xboxController)); } else { if (controllerConnection.currentConnectionStatus == false) { XboxControllerManager.onControllerDisconnected(new ControllerConnectionEventArgs(xboxController)); } } } } yield return(null); } }
void Start() { _animator = GetComponent <Animator>(); _movement = GetComponent <CharacterMovement>(); _itemController = GetComponentInChildren <CharacterItemController>(); _xboxController = XboxControllerManager.Instance; }
private void Start() { // Written, 17.10.2020 xboxControllerManager = GetComponent <XboxControllerManager>(); controllerConnection = new ControllerConnection(); }
private void Start() { _playerManager = PlayerManager.Instance; _xboxControllerManager = XboxControllerManager.Instance; for (int i = 0; i < _buttons.Length; i++) { _buttons[i].color = new Color(1, 1, 1, 0); // hide all buttons } }
private void Start() { if (!_loadScene) { _xboxControllerManager = XboxControllerManager.Instance; _playerManager = PlayerManager.Instance; _loadScene = true; DontDestroyOnLoad(transform.parent.gameObject); Time.timeScale = 0; StartCoroutine(LoadNewScene()); } }
private void Start() { _selectionButtons = GetComponent <PlayerSelectionButtonIdentifier>(); _playerManager = PlayerManager.Instance; _xboxControllerManager = XboxControllerManager.Instance; for (int i = 0; i < 4; i++) { Sprite tSprite = Resources.Load <Sprite>(SpritePaths.SpritePath[SpriteType.CHARACTER_SELECT_YELLOW + i]); if (tSprite == null) { Debug.LogError("Sprite not found!!!! given path:" + SpritePaths.SpritePath[SpriteType.CHARACTER_SELECT_BLUE + i]); return; } _characterPrefabReferences.Add(tSprite, CharacterType.CHARACTER_YELLOW + i); Debug.Log("sprite added " + SpritePaths.SpritePath[SpriteType.CHARACTER_SELECT_BLUE + i] + " " + tSprite); _sprites.Add(tSprite); } }
private static void ConfigureServices(IServiceCollection services, IConfiguration config) { //setup keybinding configs _ = services .AddKeyBindings(config.GetSection(nameof(KeyBindingConfig))); //setup game services _ = services .AddGameIDService() .AddOperatorModules() .AddScoped <IOperatorModuleFactory <IOperatorInputModule>, OperatorModuleFactory <IOperatorInputModule> >() .AddScoped <IOperatorModuleFactory <IOperatorUIModule>, OperatorModuleFactory <IOperatorUIModule> >() .AddScoped <IGamepadService, GamepadService>() .AddScoped <IRoleResolverService, RoleResolverService>() .AddScoped <IOperatorInputProcessorService, OperatorInputProcessorService>() .AddSingleton((sp) => { var xm = XboxControllerManager.GetInstance(); xm.UpdateFrequency = 50; return(xm); }) ; //setup ArdNet _ = services .AddArdNetClient(config) .AddDebugLogger() .AddReleaseCrasher(); //setup main window _ = services .AddTransient <MainWindow>() .AddTransient <MainWindowVM>() .AddTransient <GameScopeControl>() .AddTransient <GameScopeControlVM>() .AddTransient <ClientNameControl>() .AddTransient <ClientNameControlVM>() .AddTransient <OperatorModuleControl>() .AddTransient <OperatorModuleControlVM>() ; }
static async Task <int> Main() { Console.Title = Constants.GameName; TraceListener t = new ConsoleTraceListener(); _ = Trace.Listeners.Add(t); //create local message broker //used to pass messages between ardnet feature nodes //can also be hooked by other systems using var msgHub = new MessageHub(); msgHub.Start(); //get player count as int Range playerCountRange = 1..6; int playerCount = -1; do { Write("How many players? "); } while (!int.TryParse(ReadLine(), out playerCount) || !playerCountRange.Contains(playerCount)); Write("Keep dead games alive? (Y|N)? "); bool persistDeadGames = string.Equals(ReadLine(), "y", StringComparison.OrdinalIgnoreCase); Write("Bind local controller (Y|N)? "); bool bindLocalController = string.Equals(ReadLine(), "y", StringComparison.OrdinalIgnoreCase); //application scope while (true) { GamepadService gamepadSvc = null; try { //create ardnet server using var ardServ = ArdNetFactory.GetArdServer(msgHub); //create game communincation manager //watches for clients //tracks command inputs using var commState = await TankSimCommService.Create(ardServ, playerCount); //create gamepad watcher //hook into server event stream //bind controls for all operator roles if (bindLocalController) { var xm = XboxControllerManager.GetInstance(); xm.UpdateFrequency = 50; gamepadSvc = new GamepadService(ardServ, xm); _ = gamepadSvc.TrySetControllerIndex(0); gamepadSvc.SetRoles(OperatorRoles.All); } //print game ID so clients know where to connect WriteLine($"Game ID: {commState.GameID}"); //wait for all players to join await commState.GetConnectionTask(); WriteLine("Game Started."); //setup async command event watchers //any inbound events will trigger the associated handler var cmdFacade = commState.CmdFacade; cmdFacade.MovementChanged += (s, e) => WriteLine($"{s.Endpoint}: Dir: {e}"); cmdFacade.AimChanged += (s, e) => WriteLine($"{s.Endpoint}: Aim.{e}"); cmdFacade.PrimaryWeaponFired += (s, e) => { if (e == PrimaryWeaponFireState.Valid) { WriteLine($"{s.Endpoint}: Fire.Primary"); } else if (e == PrimaryWeaponFireState.Misfire) { WriteLine($"{s.Endpoint}: Fire.Primary (MISFIRE)"); } else if (e == PrimaryWeaponFireState.Empty) { WriteLine($"{s.Endpoint}: Fire.Primary (EMPTY)"); } }; cmdFacade.SecondaryWeaponFired += (s) => WriteLine($"{s.Endpoint}: Fire.Secondary"); cmdFacade.PrimaryGunLoaded += (s) => WriteLine($"{s.Endpoint}: Loader.Load"); cmdFacade.PrimaryAmmoCycled += (s) => WriteLine($"{s.Endpoint}: Loader.Cycle"); while (true) { Thread.Sleep(10); //if player count drops, then restart outer loop if (persistDeadGames) { _ = ReadLine(); break; } else if (ardServ.ConnectedClientCount < playerCount) { break; } } } finally { gamepadSvc?.Dispose(); } } }
private void Awake() { _playerManager = PlayerManager.Instance; _xboxControllerManager = XboxControllerManager.Instance; }
public Character Init(PlayerInformation iPlayerInformation) { this.pPlayerInformation = iPlayerInformation; pXboxControllerManager = XboxControllerManager.Instance; return(this); }
void Start() { _xboxController = XboxControllerManager.Instance; _playerManager = PlayerManager.Instance; }