本文整理汇总了C#中InputState.Get方法的典型用法代码示例。如果您正苦于以下问题:C# InputState.Get方法的具体用法?C# InputState.Get怎么用?C# InputState.Get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类InputState
的用法示例。
在下文中一共展示了InputState.Get方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Input
/// <summary>User input.</summary>
/// <param name="realm">Realm.</param>
/// <param name="user">User.</param>
/// <param name="state">Input state.</param>
public override void Input(IRealm realm, User user, InputState state)
{
var player = (Player)user["player"];
player.VectorX = (state.Get<bool>("right") ? 1 : state.Get<bool>("left") ? -1 : 0) * 20;
player.VectorY = (state.Get<bool>("up") ? 1 : state.Get<bool>("down") ? -1 : 0) * 80;
player.AimAngle = state.Get<float>("aimAngle");
}
示例2: Input
/// <summary>User input.</summary>
/// <param name="realm">Realm.</param>
/// <param name="user">User.</param>
/// <param name="state">Keys.</param>
public override void Input(IRealm realm, User user, InputState state)
{
var player = (Player)user["player"];
var aimAngle = state.Get<float>("aimAngle");
var kickBall = state.Get<bool>("kick");
var aimAngleRad = aimAngle / 180.0f * Math.PI;
//
if (kickBall) {
foreach (var ball in realm.Entities.OfType<Ball>()) {
ball.VectorX = (float)Math.Cos(aimAngleRad) * 25000;
ball.VectorY = (float)Math.Sin(aimAngleRad) * 25000;
}
}
}
示例3: Input
/// <summary>User input.</summary>
/// <param name="realm">Realm.</param>
/// <param name="user">User.</param>
/// <param name="state">Keys.</param>
public override void Input(IRealm realm, User user, InputState state)
{
var player = (Player)user["player"];
var aimAngle = state.Get<float>("aimAngle");
var fire = state.Get<bool>("fire");
var aimAngleRad = aimAngle / 180.0f * Math.PI;
if (fire) {
var vectorX = (float)Math.Cos(aimAngleRad);
var vectorY = (float)Math.Sin(aimAngleRad);
var bullet = new Bullet {
X = player.X + vectorX * 25, Y = player.Y + vectorY * 25,
VectorX = vectorX * 50,
VectorY = vectorY * 50
};
realm.AddEntity(bullet);
}
}