本文整理汇总了C#中XInputDotNetPure.GamePadState类的典型用法代码示例。如果您正苦于以下问题:C# GamePadState类的具体用法?C# GamePadState怎么用?C# GamePadState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GamePadState类属于XInputDotNetPure命名空间,在下文中一共展示了GamePadState类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Update
// Update is called once per frame
void Update () {
#region Update Controller State
// update controller state
prevState = state;
state = GamePad.GetState(playerIndex);
// Find a PlayerIndex, for a single player game
// Will find the first controller that is connected ans use it
if (!playerIndexSet || !prevState.IsConnected)
{
for (int i = 0; i < 4; ++i)
{
PlayerIndex testPlayerIndex = (PlayerIndex)i;
GamePadState testState = GamePad.GetState(testPlayerIndex);
if (testState.IsConnected)
{
//Debug.Log(string.Format("GamePad found {0}", testPlayerIndex));
playerIndex = testPlayerIndex;
playerIndexSet = true;
}
}
}
#endregion
// OVR RESET
if (state.Buttons.Back == ButtonState.Pressed)
{
OVRManager.display.RecenterPose(); // OVR Reset function for 0.4.3
}
}
开发者ID:Soverance,项目名称:EndlessReach,代码行数:33,代码来源:XInputState.cs
示例2: GetDirection
public static InputDirection.Direction GetDirection(XBOX_DIRECTION direction, GamePadState pad)
{
InputDirection.Direction d = new InputDirection.Direction(0, 0);
if (!pad.IsConnected)
{
return d;
}
switch (direction)
{
case XBOX_DIRECTION.Pad:
if (pad.DPad.Down == ButtonState.Pressed)
d.y--;
if (pad.DPad.Up == ButtonState.Pressed)
d.y++;
if (pad.DPad.Right == ButtonState.Pressed)
d.x++;
if (pad.DPad.Left == ButtonState.Pressed)
d.x--;
break;
case XBOX_DIRECTION.StickLeft:
d.x = pad.ThumbSticks.Left.X;
d.y = pad.ThumbSticks.Left.Y;
break;
case XBOX_DIRECTION.StickRight:
d.x = pad.ThumbSticks.Right.X;
d.y = pad.ThumbSticks.Right.Y;
break;
}
return d;
}
开发者ID:sylafrs,项目名称:rugby,代码行数:33,代码来源:XboxInputs.cs
示例3: MapPlayerInput
// TODO: Maybe reduce it to only the inputs actually used in the game?
private void MapPlayerInput(InputMapper inputMapper, GamePadState state, GamePadState previousState)
{
foreach (int axisInt in InputMapperAsset.GetMappedXboxAxis())
{
MapXboxAxis(axisInt, inputMapper, state);
}
foreach (int buttonInt in InputMapperAsset.GetMappedXboxButtons())
{
MapXboxButton(buttonInt, inputMapper, state, previousState);
}
// TODO: Put the following code into another class, so we can have 2 distinct XboxManager and KeyboardManager classes
// We map only the keyboard keys that are going to be used in the game
foreach (int key in InputMapperAsset.GetMappedKeyboardKeys())
{
inputMapper.SetRawButtonState(100 + key, Input.GetKey((KeyCode)key), Input.GetKey((KeyCode)key) && !Input.GetKeyDown((KeyCode)key));
}
foreach (int key in InputMapperAsset.GetMappedKeyboardKeysAxis())
{
float value = Input.GetKey((KeyCode)key) ? 1f : 0f;
inputMapper.SetRawAxisValue(100 + key, value);
}
}
开发者ID:ConjureETS,项目名称:OuijaMTLGJ2016,代码行数:29,代码来源:ControllerManager.cs
示例4: StateChanged
bool StateChanged (GamePadState s1, GamePadState s2)
{
bool changed = false;
changed |= s1.Buttons.A != s2.Buttons.A;
changed |= s1.Buttons.B != s2.Buttons.B;
changed |= s1.Buttons.X != s2.Buttons.X;
changed |= s1.Buttons.Y != s2.Buttons.Y;
changed |= s1.Buttons.Start != s2.Buttons.Start;
changed |= s1.Buttons.Back != s2.Buttons.Back;
changed |= s1.Buttons.LeftShoulder != s2.Buttons.LeftShoulder;
changed |= s1.Buttons.RightShoulder != s2.Buttons.RightShoulder;
changed |= s1.Buttons.LeftStick != s2.Buttons.LeftStick;
changed |= s1.Buttons.RightStick != s2.Buttons.RightStick;
changed |= s1.DPad.Up != s2.DPad.Up;
changed |= s1.DPad.Down != s2.DPad.Down;
changed |= s1.DPad.Left != s2.DPad.Left;
changed |= s1.DPad.Right != s2.DPad.Right;
changed |= Mathf.Abs (s1.Triggers.Left - s2.Triggers.Left) / Time.deltaTime > thresholdVelocity;
changed |= Mathf.Abs (s1.Triggers.Right - s2.Triggers.Right) / Time.deltaTime > thresholdVelocity;
changed |= Mathf.Abs (s1.ThumbSticks.Left.X - s2.ThumbSticks.Left.X) / Time.deltaTime > thresholdVelocity;
changed |= Mathf.Abs (s1.ThumbSticks.Left.Y - s2.ThumbSticks.Left.Y) / Time.deltaTime > thresholdVelocity;
changed |= Mathf.Abs (s1.ThumbSticks.Right.X - s2.ThumbSticks.Right.X) / Time.deltaTime > thresholdVelocity;
changed |= Mathf.Abs (s1.ThumbSticks.Right.Y - s2.ThumbSticks.Right.Y) / Time.deltaTime > thresholdVelocity;
return changed;
}
开发者ID:fatsopanda,项目名称:morning_coffee_ggj,代码行数:26,代码来源:XGamepadDevice.cs
示例5: CheckGamePad
private void CheckGamePad()
{
if (!playerIndexSet && !prevState.IsConnected)
{
for (int i = 0; i < 4; ++i)
{
PlayerIndex testPlayerIndex = (PlayerIndex)i;
GamePadState testState = GamePad.GetState(testPlayerIndex, GamePadDeadZone.None);
if (testState.IsConnected)
{
Debug.Log(string.Format("GamePad found {0}", testPlayerIndex));
playerIndex = testPlayerIndex;
playerIndexSet = true;
// Set vibration according to triggers
GamePad.SetVibration(playerIndex, state.Triggers.Left, state.Triggers.Right);
}
}
}
prevState = state;
state = GamePad.GetState(playerIndex);
}
开发者ID:SaverioDiLazzaro,项目名称:TheGGJGame,代码行数:25,代码来源:InputManager.cs
示例6: CallVote
public void CallVote(GamePadState state)
{
if (votesLeft > 0)
{
if (state.Buttons.B == ButtonState.Pressed)
{
FindObjectOfType<Vote>().voteNow();
votesLeft--;
}
}
}
开发者ID:IanHolstead,项目名称:GGJ2016,代码行数:11,代码来源:PlayerVote.cs
示例7: InputGetAxisState
private static float InputGetAxisState(ref GamePadState state, GmpdAxis gAxis) {
switch (gAxis) {
case (GmpdAxis.LStickX): return state.ThumbSticks.Left.X; break;
case (GmpdAxis.LStickY): return state.ThumbSticks.Left.Y; break;
case (GmpdAxis.RStickX): return state.ThumbSticks.Right.X; break;
case (GmpdAxis.RStickY): return state.ThumbSticks.Right.Y; break;
case (GmpdAxis.LTrigger): return state.Triggers.Left; break;
case (GmpdAxis.RTrigger): return state.Triggers.Right; break;
}
return 0;
}
开发者ID:Smoreley,项目名称:Unity-Revamped,代码行数:12,代码来源:GamepadInput.cs
示例8: UpdateAxisStates
private void UpdateAxisStates(ref InputForm inptForm, GamePadState gmpdState, GmpdAxis[] axsCodes) {
inptForm.m_axis = new float[axsCodes.Length];
// Get axises
for (int j = 0; j < axsCodes.Length; j++) {
if(IsDPad(axsCodes[j])) {
inptForm.m_axis[j] = InputGetDPadAxisState(gmpdState.DPad, axsCodes[j]);
} else {
inptForm.m_axis[j] = InputGetAxisState(ref gmpdState, axsCodes[j]);
}
}
}
开发者ID:Smoreley,项目名称:Unity-Revamped,代码行数:12,代码来源:GamepadInput.cs
示例9: UpdateButtonStates
private void UpdateButtonStates(ref InputForm inptForm, GamePadState gmpdState, GmpdButton[] bttnCodes) {
// Get buttons
for (int i = 0; i < bttnCodes.Length; i++) {
if (IsDPad(bttnCodes[i])) {
if (InputGetDPadButtonState(gmpdState.DPad, bttnCodes[i]))
inptForm.m_button |= (GenericButtonID)((int)1 << i);
} else {
if (InputGetButtonState(gmpdState.Buttons, bttnCodes[i]))
inptForm.m_button |= (GenericButtonID)((int)1 << i);
}
}
}
开发者ID:Smoreley,项目名称:Unity-Revamped,代码行数:13,代码来源:GamepadInput.cs
示例10: ActionReleased
public static bool ActionReleased(int playerIndex, GamePadState prevState, GamePadState state)
{
//if player index is divisible by 2 I'm left hand side of the controller
if (playerIndex % 2 == 0)
{
//if button has been pressed return true else false
return (prevState.Buttons.LeftShoulder == ButtonState.Pressed && state.Buttons.LeftShoulder == ButtonState.Released);
}
else
{
return (prevState.Buttons.RightShoulder == ButtonState.Pressed && state.Buttons.RightShoulder == ButtonState.Released);
}
}
开发者ID:Dunnings,项目名称:CGD_Qix,代码行数:13,代码来源:InputManager.cs
示例11: Use
public void Use(GamePadState gamePadState)
{
if (gamePadState.Buttons.X == ButtonState.Pressed)
{
if (useableObject != null)
{
if (useableObject.Use(this))
{
useableObject = null;
}
}
}
}
开发者ID:IanHolstead,项目名称:GGJ2016,代码行数:13,代码来源:PlayerOrb.cs
示例12: processActions
/// <summary>
/// Process every command that is not movement
/// </summary>
/// <param name="state">GamePadState</param>
protected void processActions(GamePadState state)
{
if (state.Buttons.A == ButtonState.Pressed)
OnTakeoff();
if (state.Buttons.A == ButtonState.Pressed)
OnLand();
if (state.Buttons.B == ButtonState.Pressed)
OnEmergency();
if (state.Buttons.Y == ButtonState.Pressed)
OnFlatTrim();
}
开发者ID:Awoyixiasigema,项目名称:MyoPilot,代码行数:18,代码来源:XBoxInput.cs
示例13: FixedUpdate
void FixedUpdate()
{
state = GamePad.GetState(playerIndexNum);
Vector3 pos = poi.position;
if(state.Buttons.Y == ButtonState.Pressed)
pos -= poi.forward * -distance;
else
pos -= poi.forward * distance;
pos += poi.up * height;
Vector3 rot = poi.localEulerAngles;
Vector3 pos2 = (1 - u) * transform.position + u * pos;
//Vector3 rot2 = (1 - v) * transform.localEulerAngles + v * rot;
//rot2.y = poi.transform.localEulerAngles.y;
if (shake) {
pos2.x += Random.value * shakeIntensity * Random .Range(-1, 1);
pos2.y += Random.value * shakeIntensity * Random .Range(-1, 1);
pos2.z += Random.value * shakeIntensity * Random .Range(-1, 1);
}
transform.position = pos2;
transform.rotation = Quaternion.Slerp(camTarget.rotation, transform.rotation, 2f * Time.fixedDeltaTime);
//transform.localEulerAngles = rot2;
}
开发者ID:kkalina,项目名称:CyborgKatz,代码行数:32,代码来源:ThirdPersonCamera.cs
示例14: Update
// Update is called once per frame
void Update()
{
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
#region Update Controller State
prevState_p1 = state_p1;
state_p1 = GamePad.GetState(pad_PlayerOne);
#endregion
if( Input.GetKeyDown(KeyCode.Space) ||
Input.GetKeyDown(KeyCode.Escape) ||
state_p1.Buttons.A == ButtonState.Pressed ||
state_p1.Buttons.Start == ButtonState.Pressed ||
state_p1.Buttons.Back == ButtonState.Pressed)
{
f_LevelTimer = f_LevelTimer_Max + 1f;
}
UpdateLerpTimer();
// Lerp from the previous graphic's alpha value to its new alpha
if(go_Graphic != null)
{
Color clr_Curr = go_Graphic.GetComponent<Image>().color;
clr_Curr.a = f_LerpPerc;
go_Graphic.GetComponent<Image>().color = clr_Curr;
}
}
开发者ID:ChrisCrossed,项目名称:CodeExamples,代码行数:30,代码来源:Cs_IntroScreenLogic.cs
示例15: Update
override protected void Update()
{
GPState = GamePad.GetState(PlayerIndex.One);
m_TargetVelocity = (Vector3.forward * GPState.ThumbSticks.Left.Y +
Vector3.right * GPState.ThumbSticks.Left.X).normalized * Time.deltaTime;
m_TargetVelocity = m_SpeedIsCapped ? m_TargetVelocity * m_ReducedSpeed : m_TargetVelocity * m_Speed;
m_Velocity = Vector3.Lerp(m_Velocity, m_TargetVelocity, m_DampingFactor);
BoundZVelocity();
if (m_Velocity != Vector3.zero)
{
m_Animator.SetBool("Walking", true);
m_Animator.SetFloat("WalkingMultiplier", m_SpeedIsCapped ? m_ReducedSpeed / m_Speed : 1f);
}
else
{
m_Animator.SetBool("Walking", false);
}
UpdatePose();
float X = m_Velocity.x;
float Y = m_Velocity.z;
float deltaAngle = (X / m_DistanceToCenter) * Mathf.Rad2Deg;
m_Angle += deltaAngle;
m_DistanceToCenter -= Y;
BoundDistanceToCenter();
base.Update();
}
开发者ID:JabberSnatch,项目名称:GGJ2016,代码行数:32,代码来源:RotatingPlayerController.cs
示例16: Update
// Update is called once per frame
void Update()
{
prevState = state;
state = GamePad.GetState(playerIndex);
if (InputEnabled) {
// axis crontrols for horizontal movement
if (Mathf.Abs(state.ThumbSticks.Left.X) > .5f || Mathf.Abs(state.ThumbSticks.Left.Y) > .5f){
CurrentRot = Quaternion.Euler(new Vector3(0 ,0 ,Mathf.Atan2(-state.ThumbSticks.Left.X, state.ThumbSticks.Left.Y)* Mathf.Rad2Deg));
StickPosSnap.x = state.ThumbSticks.Left.X;
StickPosSnap.y = state.ThumbSticks.Left.Y;
}
transform.rotation = CurrentRot;
// player thrust control
if (state.Triggers.Right > .05f){
RB.AddForce(new Vector2(StickPosSnap.x * Speed * state.Triggers.Right, StickPosSnap.y * Speed * state.Triggers.Right));
if (ThrusterSprite.activeSelf == false){
ThrusterSprite.SetActive(true);
}
}else {
if (ThrusterSprite.activeSelf == true){
ThrusterSprite.SetActive(false);
}
}
// menu control
if (state.Buttons.Start == ButtonState.Pressed && prevState.Buttons.Start == ButtonState.Released && Time.timeScale == 1) {
//InputEnabled = false;
//Time.timeScale = 0;
}
}
}
开发者ID:NIUGameDesignClub,项目名称:Arc-Lightning-Game,代码行数:35,代码来源:PlayerControlScript.cs
示例17: Update
// Update is called once per frame
protected virtual void Update()
{
// if we haven't gotten the correct player number yet
if (!gotNumber)
{
playerIndex = (PlayerIndex)GetComponentInParent<PlayerController>().playerNumber;
gotNumber = true;
}
prevState = state;
state = GamePad.GetState(playerIndex);
// short out if input's disabled
if (!inputEnabled)
return;
// if the right bumper is being pressed
if (prevState.Buttons.RightShoulder == ButtonState.Released && state.Buttons.RightShoulder == ButtonState.Pressed)
{
// and we have enough resources
if (plCont.currCharge >= reqCharge)
{
// do whatever our special is
Fire();
}
}
}
开发者ID:izzy-sabur,项目名称:polish_proj,代码行数:28,代码来源:BaseSpecial.cs
示例18: Convert
public override SF4InputState Convert()
{
SF4InputState outputState = new SF4InputState();
gamePadState = GamePad.GetState(playerIndex);
//Options
outputState.Options.Back = gamePadState.Buttons.Back == ButtonState.Pressed;
outputState.Options.Start = gamePadState.Buttons.Start == ButtonState.Pressed;
//Punches
outputState.Punches.Light = gamePadState.Buttons.X == ButtonState.Pressed;
outputState.Punches.Medium = gamePadState.Buttons.Y == ButtonState.Pressed;
outputState.Punches.Hard = gamePadState.Buttons.RightShoulder == ButtonState.Pressed;
//Kicks
outputState.Kicks.Light = gamePadState.Buttons.A == ButtonState.Pressed;
outputState.Kicks.Medium = gamePadState.Buttons.B == ButtonState.Pressed;
outputState.Kicks.Hard = gamePadState.Triggers.Right > 0.25f;
//Determine if Dpad has any input
outputState.Directions.Right = (gamePadState.DPad.Right == ButtonState.Pressed || gamePadState.ThumbSticks.Left.X > 0.25f);
outputState.Directions.Left = (gamePadState.DPad.Left == ButtonState.Pressed || -gamePadState.ThumbSticks.Left.X > 0.25f);
outputState.Directions.Up = (gamePadState.DPad.Up == ButtonState.Pressed || gamePadState.ThumbSticks.Left.Y > 0.25f);
outputState.Directions.Down = (gamePadState.DPad.Down == ButtonState.Pressed || -gamePadState.ThumbSticks.Left.Y > 0.25f);
return outputState;
}
开发者ID:jeremyschultz,项目名称:SF4ComboTrainer,代码行数:31,代码来源:XInputConverter.cs
示例19: Update
// Update is called once per frame
void Update()
{
currentState = GamePad.GetState(pIndex);
if(currentState.ThumbSticks.Right.X < 0)
{
pTran.Translate(Vector3.left*Time.deltaTime*9, Space.World);
//pTran.rotation = Quaternion.Lerp(pTran.rotation, rotLeft, Time.deltaTime*50);
}
else if(currentState.ThumbSticks.Right.X > 0)
{
pTran.Translate(Vector3.right*Time.deltaTime*9, Space.World);
//pTran.rotation = Quaternion.Lerp(pTran.rotation, rotRight, Time.deltaTime*50);
}
if(currentState.ThumbSticks.Right.Y < 0)
{
pTran.Translate(Vector3.down*Time.deltaTime*9, Space.World);
//pTran.rotation = Quaternion.Lerp(pTran.rotation, rotLeft, Time.deltaTime*50);
}
else if(currentState.ThumbSticks.Right.Y > 0)
{
pTran.Translate(Vector3.up*Time.deltaTime*9, Space.World);
//pTran.rotation = Quaternion.Lerp(pTran.rotation, rotRight, Time.deltaTime*50);
}
}
开发者ID:Wikzo,项目名称:P6_CouchGaming,代码行数:27,代码来源:EyeMove.cs
示例20: Update
// Update is called once per frame
void Update ()
{
Timer += Time.deltaTime;
if (Timer >= SwapTime && CanTimer)
{
Timer = 0;
NextCanvas += 1;
ChangeSlide(NextCanvas);
}
prevState = state;
state = GamePad.GetState(playerIndex);
if (Cooldown <= 0 && prevState.IsConnected)
{
state = GamePad.GetState(playerIndex);
CheckControllers();
}
else
{
Cooldown -= Time.deltaTime;
}
}
开发者ID:ChrisCrossed,项目名称:SpaceTube,代码行数:27,代码来源:CreditsHandler.cs
注:本文中的XInputDotNetPure.GamePadState类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论