本文整理汇总了C#中PlayerInput类的典型用法代码示例。如果您正苦于以下问题:C# PlayerInput类的具体用法?C# PlayerInput怎么用?C# PlayerInput使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PlayerInput类属于命名空间,在下文中一共展示了PlayerInput类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MoveCarWithIA
public void MoveCarWithIA(PlayerInput playerInput)
{
if (playerInput._keyCodes.Contains(_inputBrakeCar))
{
carRigid.velocity = carRigid.velocity * 0.9f;
}
else if (playerInput._keyCodes.Contains(_inputForwardCar))
{
carRigid.AddForce(carTransform.forward * 18 * 1.5f, ForceMode.Acceleration);
}
if (carRigid.velocity.magnitude > _maxVelocity)
{
carRigid.velocity = carRigid.velocity.normalized * _maxVelocity;
}
if ( (playerInput._axeHorizontal <= 1.0f && playerInput._axeHorizontal > 0.40f) || (playerInput._axeHorizontal < -0.40f && playerInput._axeHorizontal >= -1.0f) ) // peut etre zone morte a ajouter entre 0.1 et -0.1
{
carTransform.Rotate(new Vector3(0, playerInput._axeHorizontal * 2, 0));
if (carRigid.velocity.magnitude > _maxVelocity * 0.8f)
{
carRigid.velocity = carRigid.velocity * 0.95f;
}
}
if (playerInput._keyCodes.Contains(_inputResetCar))
{
Debug.Log("ResetCar");
carRigid.velocity = new Vector3(0, 0, 0);
carTransform.position = new Vector3(aiScript._previousCheckPoint.transform.position.x, 0.3f, aiScript._previousCheckPoint.transform.position.z);
carTransform.LookAt(aiScript._currentCheckPoint.transform);
StartCoroutine(ResetCar());
}
}
示例2: Awake
void Awake()
{
_recipeManager = FindObjectOfType<RecipeManager>();
_musicManager = FindObjectOfType<MusicManager>();
_rigidbody = GetComponent<Rigidbody2D>();
_collider = GetComponent<Collider2D>();
_animator = GetComponent<Animator> ();
_initPos = transform.position;
if(GameManager.Instance.playerDevices.Count > playerNum - 1)
{
//Take the controller assigned on the menu
_playerInput = new PlayerInput(true);
_playerInput.Device = InputManager.Devices[GameManager.Instance.playerDevices[playerNum - 1]];
Debug.Log(playerNum + " " + _playerInput.Device.Name);
}
else
{
//Test only
Debug.Log("Controllers " + InputManager.Devices.Count);
if(InputManager.Devices.Count > playerNum - 1)
{
_playerInput = new PlayerInput(true);
_playerInput.Device = InputManager.Devices[playerNum - 1];
}
else if(playerNum == 4)
_playerInput = new PlayerInput(false);
Debug.LogWarning("No input for player " + playerNum);
}
FindObjectOfType<GameOverManager>().OnGameOver += HandleGameOver;
}
示例3: Start
void Start()
{
m_Count = 0;
board = GameObject.Find ("Board").GetComponent<Board> ();
player = GameObject.Find ("PlayerInput").GetComponent<PlayerInput>();
gameInfo = GameObject.Find ("GameInfo").GetComponent<GameInfo>();
}
示例4: Awake
// ******************************************** START/ UPDATE ********************************************
void Awake()
{
// find components:
tform = transform;
compoMain = Camera.main.GetComponent<Main>();
compoInput = GetComponent<PlayerInput>();
}
示例5: Awake
void Awake()
{
previousInput = new PlayerInput(0, 0);
// Get all input sources that are defined
sources = Reflector.InstantiateAll<PlayerInputSource>();
}
示例6: Update
// Update is called once per frame
void Update()
{
// Retrieve our current WASD or Arrow Key input
// Using GetAxisRaw removes any kind of gravity or filtering being applied to the input
// Ensuring that we are getting either -1, 0 or 1
Vector3 moveInput = new Vector3 (Input.GetAxisRaw ("Horizontal"), 0, Input.GetAxisRaw ("Vertical"));
Vector2 mouseInput = new Vector2(Input.GetAxis("Mouse X"), Input.GetAxis("Mouse Y"));
Vector2 rightStickInput = new Vector2 (Input.GetAxisRaw ("RightH"), Input.GetAxisRaw ("RightV"));
// pass rightStick values in place of mouse when non-zero
mouseInput.x = rightStickInput.x != 0 ? rightStickInput.x * RightStickMultiplier.x : mouseInput.x;
mouseInput.y = rightStickInput.y != 0 ? rightStickInput.y * RightStickMultiplier.y : mouseInput.y;
float zoomInput = Input.GetAxisRaw("Mouse ScrollWheel");
bool jumpInput = Input.GetButtonDown("Jump");
bool shootInput = Input.GetButtonDown ("Shoot");
Current = new PlayerInput()
{
MoveInput = moveInput,
MouseInput = mouseInput,
ZoomInput = zoomInput,
JumpInput = jumpInput,
ShootInput = shootInput
};
}
示例7: use
public override void use(PlayerInput usedBy = PlayerInput.None)
{
GameData.Instance.Brightness = Mathf.Clamp(GameData.Instance.Brightness + m_Increment,
Constants.BRIGHTNESS_MIN,
Constants.BRIGHTNESS_MAX);
i_Slider.Value = GameData.Instance.Brightness;
}
示例8: OnEnable
///onEnable looks for inputs for camera and button
void OnEnable(){
enemy = GameObject.Find("Enemy").GetComponent<PlayerHealth> ();
playerInput = GameObject.Find ("Main Camera").GetComponent<PlayerInput>();
trapAudio = GetComponent <AudioSource> ();
StartCoroutine("TrapActivate");
}
示例9: InputSelectV2
//constructor to initialize the class
public InputSelectV2(Transform mountPoint, GameObject model, PlayerInput inputType)
{
m_MountPoint = mountPoint;
m_OriginalMountPoint = mountPoint;
m_Model = model;
m_InputType = inputType;
}
示例10: Start
// Use this for initialization
void Start()
{
_ui = GameObject.Find("Keys");
_input = new PlayerInput();
_input.Reset ();
_controller = this.GetComponent<PlayerPhysics>();
}
示例11: Update
// Update is called once per frame
void Update()
{
if ((Input.GetKey(KeyCode.P)) && (_actionsLaunched == false))
{
Debug.Log("Make Action");
MakePlayerActions();
}
if (_nbInputsToDo > 0)
{
_currentPlayerInput = _playerInputs[_currentInputToDo];
++_currentInputToDo;
--_nbInputsToDo;
if (_currentPlayerInput != null)
_moveScript.makeMove(_currentPlayerInput);
if (_nbInputsToDo <= 0)
{
_currentInputToDo = 0;
_actionsLaunched = false;
_moveScript._playerMove = true;
Debug.Log("----- End -----");
}
}
}
示例12: Awake
void Awake()
{
capsule = GetComponent<CapsuleCollider>();
grabTriggerCol = GetComponent<BoxCollider>();
anim = GetComponent<Animator> ();
_charStatus = GetComponent<CharacterStatus> ();
_charAttacking = GetComponent<CharacterAttacking> ();
_charAI = GetComponent<CharacterAI> ();
if (!IsEnemy)
{
_playerInput = GetComponent<PlayerInput>();
//_playerInputMobile = GetComponent<PlayerInputMobile>();
}
// I use these since when we have low health, we will move a bit slower.
// When we get more than 25% health again, we will go back to our
// default speeds for these.
defaultAirSpeed = airSpeed;
m_Loco_0Id = Animator.StringToHash ("Base Layer.Locomotion");
m_Loco_1Id = Animator.StringToHash ("LowHealth.Locomotion");
myRigidbody = GetComponent<Rigidbody> ();
if (!grabTriggerCol)
Debug.LogWarning("PLEASE ASSIGN YOUR Player's GRAB TRIGGER COLLIDER");
else
grabTriggerCol.enabled = false;
}
示例13: CanEnterState
public override bool CanEnterState()
{
float minDistance = m_AttackRange;
m_TargettedPlayer = null;
foreach(PlayerInput player in m_Players)
{
if(!LayerMask.LayerToName(player.gameObject.layer).Contains (NameConstants.DEAD_LAYER))
{
Vector3 playerPosition = player.transform.position;
playerPosition.y = transform.position.y;
float distance = Vector3.Distance(playerPosition, transform.position);
if(distance <= minDistance)
{
minDistance = distance;
m_TargettedPlayer = player;
}
}
}
return m_TargettedPlayer != null;
}
示例14: Awake
void Awake()
{
//getting all the required components
_rigidbody = GetComponent<Rigidbody2D>();
_touchDetector = GetComponent<TouchDetector2D>();
_playerInput = GetComponent<PlayerInput>();
}
示例15: Start
// Use this for initialization
protected virtual void Start()
{
centerOffset = transform.position - target.position;
originalcenterOffset = centerOffset;
playerActor = target.root.GetComponent<PlayerActor>();
playerInput = target.root.GetComponent<PlayerInput>();
}