コード例 #1
0
	void Start()
	{
		// When a new usb device is detected, the controls are reassigned
		// for the players without devices
		this.tt("RefreshDevices").Add(1, () =>
		{
			if (InputManager.Devices.Count != deviceCount)
			{
				deviceCount = InputManager.Devices.Count;
				AssignFreeDevicesToFreePlayers();
			}
		})
		.Repeat();


		// On 'Space' or 'Enter', a free tank will be activated for the
		// keyboard.
		this.tt("KeyboardPlayerDetection").Loop((ttHandler t) =>
		{
			if (Input.GetKeyDown(KeyCode.Space) || Input.GetKeyDown(KeyCode.KeypadEnter))
			{
				keyboardPlayer = players.Where(
				                     p => p.inputDevice == null ||
				                     !InputManager.Devices.Contains(p.inputDevice)).FirstOrDefault();


				// If there is a free lion
				if (keyboardPlayer != null)
				{
					keyboardPlayer.gameObject.SetActive(true);

					keyboardPlayer.useKeyboard = true;
					keyboardPlayer.forceActiveDevice = true;
					keyboardPlayer.SetInputDevice(null, -1);

					AssignFreeDevicesToFreePlayers();
				}
			}
		})
		.Wait();
		
		// Look for all the compatible players, except the active device
		players = FindObjectsOfType<GamepadInControl>().ToList();
	}
コード例 #2
0
ファイル: CarActor.cs プロジェクト: tzamora/superteam
	void SetGamepad (){
	
		gamepad = GetComponent<GamepadInControl> ();
	}