本文整理汇总了C#中InputState类的典型用法代码示例。如果您正苦于以下问题:C# InputState类的具体用法?C# InputState怎么用?C# InputState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
InputState类属于命名空间,在下文中一共展示了InputState类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Start
void Start () {
//body2D = GetComponent<Rigidbody2D> ();
player = gameObject.GetComponent<Transform> ();
player.position = setPosition ((int)Positions.TOP);
inputState = GetComponent<InputState>();
}
示例2: DirectionalIndicator
public DirectionalIndicator(
ContentUtil content,
InputState.Move move,
float beatTimeInMs,
float travelSpeed)
{
this.recordings = new List<RecordedStart>();
this.color = Color.White;
this.move = move;
this.beatTimeInMs = beatTimeInMs;
this.travelSpeed = travelSpeed;
String texName = "hud/arrow_" + move.ToString().ToLower();
this.texture = new ScaledTexture(
content.load<Texture2D>(texName), TEXTURE_SCALE);
switch (move) {
case InputState.Move.UP:
this.direction = new Vector2(0, 1);
break;
case InputState.Move.DOWN:
this.direction = new Vector2(0, -1);
break;
case InputState.Move.LEFT:
this.direction = new Vector2(1, 0);
break;
case InputState.Move.RIGHT:
this.direction = new Vector2(-1, 0);
break;
}
this.isMoving = false;
}
示例3: UpdatePlayerActionInput
/// <summary>
/// This is how we hook keyboard/other input.
/// </summary>
/// <param name="input"></param>
/// <param name="allowFull"></param>
/// <returns></returns>
public override bool UpdatePlayerActionInput(InputState input, bool allowFull)
{
// this is a simple, hard coded example to handle input from a player
// we can probably add some kind of modifier key here for doing something else cool
if (input.IsKeyReleased(Keys.OemPlus))
{
bool canAutoTarget = false;
bool canTargetSpace = false;
bool isAutoTarget;
bool isTargetBlocked;
// find something to kill
ITarget targetHere = this._world.Cursor.GetTargetHere(canAutoTarget, canTargetSpace, out isAutoTarget, out isTargetBlocked);
if (null != targetHere)
{
// output some data to the debug log
DebugLog.Write("Terminating target: {0}", targetHere.DisplayName);
// kill it
Damage.ApplyDamage(targetHere, targetHere.Health);
}
}
return base.UpdatePlayerActionInput(input, allowFull);
}
示例4: UpdateEmpty
void UpdateEmpty()
{
var chrono = FindObjectOfType<Chrono>();
var disco = FindObjectOfType<Disco>();
var collider = GetComponent<SphereCollider>();
var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
var info = new RaycastHit();
var hit = Physics.Raycast(ray, out info);
if (!hit)
return;
var obj = info.collider.gameObject;
if (!obj)
return;
if (obj.CompareTag("Bouncer"))
{
hover_object = obj;
hover_object.GetComponent<Renderer>().material.color = Color.green;
state = InputState.Hover;
return;
}
if (obj.CompareTag("Palette"))
{
hover_object = obj;
hover_object.GetComponent<Renderer>().material.color = Color.green;
state = InputState.Hover;
return;
}
}
示例5: OnPlayerInput
//Oxide Hook
void OnPlayerInput(BasePlayer player, InputState input)
{
if (this.allowAdminRotate && player.IsAdmin() && player.GetActiveItem() != null && player.GetActiveItem().info.shortname.Equals("hammer"))
{
if (input.WasJustPressed(BUTTON.FIRE_PRIMARY))
{
RaycastHit hit;
if (Physics.Raycast(player.eyes.position, (player.eyes.rotation * Vector3.forward), out hit, 2f, Layers.Server.Buildings))
{
BaseEntity baseEntity = hit.collider.gameObject.ToBaseEntity();
if (baseEntity != null)
{
BuildingBlock block = baseEntity.GetComponent<BuildingBlock>();
if (block != null && block.blockDefinition.canRotate && !this.instanceIDs.Contains(block.GetInstanceID()))
{
block.SetFlag(BaseEntity.Flags.Reserved1, true);
addBlockToLists(block.GetInstanceID(), DateTime.Now.AddMinutes(-this.amountOfMinutesAfterUpgrade).ToString());
int remainingSeconds = timerInterval - DateTime.Now.Subtract(lastTimerTick).Seconds;
SendReply(player, "<color=green>You can now rotate this " + block.blockDefinition.info.name.english + " for " + remainingSeconds + " seconds.</color>");
}
}
}
}
}
}
示例6: ProcessKey
protected override void ProcessKey(ConsoleKeyInfo consoleKey, InputState inputState)
{
switch(consoleKey.Key)
{
case ConsoleKey.Backspace:
if(inputState.CarrageIndex > 0)
{
inputState.Line.Remove(inputState.CarrageIndex - 1, 1);
inputState.CarrageIndex--;
Console.Write("\b");
inputState.RefreshTail(1);
}
break;
case ConsoleKey.Delete:
if(inputState.CarrageIndex < inputState.Line.Length)
{
inputState.Line.Remove(inputState.CarrageIndex, 1);
inputState.RefreshTail(1);
}
break;
default:
base.ProcessKey(consoleKey, inputState);
break;
}
}
示例7: HandleInput
protected override void HandleInput(UserInput button, InputState state)
{
//First we need to define if we are inside the ingame screen
if (state == InputState.Ingame)
{
//If the pressed button equals Start we open the menu screen and disable ingame input
if (button == UserInput.Start)
{
StopAllCoroutines();
StartCoroutine(OpenPauseMenu());
}
}
//If we are not then maybe we are inside the menus screen?
else if (state == InputState.PauseMenu)
{
switch (button)
{
case UserInput.Start:
StopAllCoroutines();
StartCoroutine(ClosePauseMenu());
break;
case UserInput.Up:
Up();
break;
case UserInput.Down:
Down();
break;
case UserInput.A:
selectedButton.Invoke();
break;
}
}
}
示例8: HandleInput
public override void HandleInput(GameTime gameTime, InputState input)
{
if (input == null)
throw new ArgumentNullException("input");
GamePadState gamePadState = input.CurrentGamePadState;
if (pauseAction.Evaluate(input))
{
ScreenManager.AddScreen(new PauseScreen());
}
else
{
Vector2 movement = Vector2.Zero;
if (input.touchState.Count > 0)
{
Vector2 touchPosition = input.touchState[0].Position;
Vector2 direction = touchPosition - playerPosition;
direction.Normalize();
movement += direction;
}
if (movement.Length() > 1)
movement.Normalize();
playerPosition += movement * 8f;
}
}
示例9: Evaluate
/// <summary>
/// Evaluates the action against a given InputState.
/// </summary>
/// <param name="state">The InputState to test for the action.</param>
/// <param name="controllingPlayer">The player to test, or null to allow any player.</param>
/// <param name="player">If controllingPlayer is null, this is the player that performed the action.</param>
/// <returns>True if the action occurred, false otherwise.</returns>
public bool Evaluate(InputState state, PlayerIndex? controllingPlayer, out PlayerIndex player)
{
// Figure out which delegate methods to map from the state which takes care of our "newPressOnly" logic
ButtonPress buttonTest;
KeyPress keyTest;
if (newPressOnly)
{
buttonTest = state.IsNewButtonPress;
keyTest = state.IsNewKeyPress;
}
else
{
buttonTest = state.IsButtonPressed;
keyTest = state.IsKeyPressed;
}
// Now we simply need to invoke the appropriate methods for each button and key in our collections
foreach (Buttons button in buttons)
{
if (buttonTest(button, controllingPlayer, out player))
return true;
}
foreach (Keys key in keys)
{
if (keyTest(key, controllingPlayer, out player))
return true;
}
// If we got here, the action is not matched
player = PlayerIndex.One;
return false;
}
示例10: HandleLeftMoveRightAttack
void HandleLeftMoveRightAttack(InputState state,Vector3 acc)
{
var player = MyPlayerController.Instance;
Vector3 weapon = new Vector3(Mathf.Clamp(EulerAsin(-acc.z), -45f, 30f), 0, 0); // 視線
const float DUMP = 0.4f; // 減衰
if(state == InputState.NONE)
{
player.ActAttackEnd();
if (acc.x > 0) player.TurnRight(acc.x); else player.TurnLeft(-acc.x);
}
else if(state == InputState.MOVE)
{
player.ActAttackEnd();
if (acc.z < 0) player.MoveForward(-acc.z); else player.MoveBack(acc.z);
if (acc.x > 0) player.MoveRight(acc.x); else player.MoveLeft(-acc.x);
weapon = Vector3.zero;
}
else if(state == InputState.ATTACK)
{
player.ActAttackStart();
if (acc.x > 0) player.TurnRight(acc.x); else player.TurnLeft(-acc.x);
}
else if(state == InputState.ATTACK_AND_MOVE)
{
player.ActAttackStart();
if (acc.x > 0) player.TurnRight(acc.x * DUMP); else player.TurnLeft(-acc.x * DUMP);
if (acc.x > 0) player.MoveRight(acc.x * DUMP); else player.MoveLeft(-acc.x * DUMP);
if (acc.z < 0) player.MoveForward(-acc.z * DUMP); else player.MoveBack(acc.z * DUMP);
}
// 視線
_BufferWeaponAngle = _BufferWeaponAngle * 0.9f + weapon * 0.1f;
player.WeaponAngle = _BufferWeaponAngle;
}
示例11: Awake
void Awake () {
inputState = GetComponent<InputState> ();
walkBehaviour = GetComponent<Walk> ();
duckBehaviour = GetComponent<Duck> ();
animator = GetComponent<Animator> ();
collisionState = GetComponent<CollisionState> ();
}
示例12: DoResize
public override void DoResize(DiagramView view, RectangleF origRect, PointF newPoint, int whichHandle, InputState evttype, SizeF min, SizeF max)
{
INodeIconConstraint constraint1 = this.Constraint;
SizeF ef1 = constraint1.MinimumIconSize;
SizeF ef2 = constraint1.MaximumIconSize;
base.DoResize(view, origRect, newPoint, whichHandle, evttype, ef1, ef2);
}
示例13: UniversalDetector
public UniversalDetector(int languageFilter) {
this.start = true;
this.inputState = InputState.PureASCII;
this.lastChar = 0x00;
this.bestGuess = -1;
this.languageFilter = languageFilter;
}
示例14: Update
/// <summary>
/// Allows the game component to update itself.
/// </summary>
/// <param name="gameTime">Provides a snapshot of timing values.</param>
public override void Update(GameTime gameTime)
{
if (!Game.IsActive)
return;
input = new InputState();
WiimoteLib.PointF ws = wm.WiimoteState.IRState.Midpoint;
input.Position.X = GameEngine.WIDTH * (1 - ws.X);
input.Position.Y = GameEngine.HEIGHT * ws.Y;
float time = gameTime.ElapsedGameTime.Milliseconds; // time elapsed since last update
Vector2 posDiff = input.Position - buffer.CurrentPosition;
input.Velocity = posDiff / time;
WiimoteLib.Point3F acc = wm.WiimoteState.AccelState.Values;
input.Acceleration = new Vector2(acc.X, acc.Y);
input.Pause = wm.WiimoteState.ButtonState.Home;
input.Confirm = wm.WiimoteState.ButtonState.A;
if (ws.X == 0.0f && ws.Y == 0.0f) // sensor bar out of range
{
input.Position = lastPosition;
posDiff = new Vector2();
}
else
{
lastPosition = input.Position;
}
if (Math.Abs(posDiff.X) > POS_DIFF_THRESHOLD || Math.Abs(posDiff.Y) > POS_DIFF_THRESHOLD) // add only only if the baton has moved at least a decent amount of distance
{
buffer.Add(input);
}
base.Update(gameTime);
}
示例15: HandleInput
/// <summary>
/// Lets the game respond to player input. Unlike the Update method,
/// this will only be called when the gameplay screen is active.
/// </summary>
public override void HandleInput(InputState input)
{
if (input == null)
{
return;
}
// Look up inputs for the active player profile.
if (ControllingPlayer == null)
{
Debug.WriteLine("ControllingPlayer is null...");
return;
}
var playerIndex = (int)ControllingPlayer.Value;
var keyboardState = input.CurrentKeyboardStates[playerIndex];
var gamePadState = input.CurrentGamePadStates[playerIndex];
// The game pauses either if the user presses the pause button, or if
// they unplug the active gamepad. This requires us to keep track of
// whether a gamepad was ever plugged in, because we don't want to pause
// on PC if they are playing with a keyboard and have no gamepad at all!
var gamePadDisconnected = !gamePadState.IsConnected &&
input.GamePadWasConnected[playerIndex];
if (input.IsPauseGame(ControllingPlayer) || gamePadDisconnected)
{
const string message = "Pause. Do you really want to exit game?";
var confirmExit = new DecisionScreen(message);
confirmExit.Accepted += ConfirmExitGameAccepted;
ScreenManager.AddScreen(confirmExit, ControllingPlayer);
}
}