Beispiel #1
0
        ///<summary>
        ///Process a thrust event
        ///</summary>
        ///<param name="eventName"></param>
        ///<param name="thrustData"></param>
        protected virtual void OnThrustEvent(
            string eventName, ThrustData thrustData)
        {
            if (thrustData.Id != SceneObject.ObjectId)
                return;

            ForwardThrust = thrustData.ForwardThrust;
            ReverseThrust = thrustData.ReverseThrust;
            LateralThrust = thrustData.LateralThrust;
            Braking = thrustData.Braking;
            AngularThrust = thrustData.AngularThrust;
        }
        ///<summary>
        ///Called each tick
        ///</summary>
        ///<param name="move"></param>
        ///<param name="dt">
        ///The amount of elapsed time since the last call, in seconds.
        ///</param>
        public virtual void ProcessTick(Move move, float dt)
        {
            if (Program.GamePaused)
                return;

            if (move == null)
                return;

            ThrustData td = new ThrustData();
            td.Id = SceneObject.ObjectId;
            td.AngularThrust = move.Sticks[0].X;
            td.ForwardThrust =
                MathHelper.Max(
                    MathHelper.Clamp(move.Sticks[0].Y, 0, 1),
                    move.Triggers[0].Value);
            td.Braking = move.Buttons[0].Pushed ? 1.0f : 0.0f;
            td.ReverseThrust =
                MathHelper.Max(
                    -MathHelper.Clamp(move.Sticks[0].Y, -1, 0),
                    move.Triggers[1].Value);
            td.LateralThrust = move.Sticks[1].X;
            TorqueEventManager.Instance.MgrPostEvent(_thrustEvent, td);
        }