当前位置: 首页>>代码示例>>C#>>正文


C# InputState.Get方法代码示例

本文整理汇总了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");
 }
开发者ID:brainster-one,项目名称:uberball,代码行数:11,代码来源:PlayerControlRealmBehavior.cs

示例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;
                }
            }
        }
开发者ID:brainster-one,项目名称:uberball,代码行数:19,代码来源:PlayerKickBallControlRealmBehavior.cs

示例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);
            }
        }
开发者ID:brainster-one,项目名称:uberball,代码行数:22,代码来源:PlayerFireControlRealmBehavior.cs


注:本文中的InputState.Get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。