Exemple #1
0
        public override void SimulateController()
        {
            // If player is "dead" ignore inputs
            if (state.Health <= 0)
            {
                return;
            }

            var cmd = MoveAndShootMoveCommand.Create();

            cmd.Direction = _input.Dir;
            cmd.Yaw       = _input.Angle;

            entity.QueueInput(cmd);

            if (_input.Fired.HasValue)
            {
                var fireCommandInput = MoveAndShootFireCommand.Create();
                fireCommandInput.Type = _input.Fired.Value;

                entity.QueueInput(fireCommandInput);

                // reset fire input
                _input.Fired = null;
            }
        }
Exemple #2
0
        private void HandleMoveCommand(MoveAndShootMoveCommand cmd, bool reset)
        {
            if (reset)
            {
                SetState(cmd.Result.Position, cmd.Result.Velocity, cmd.Result.Yaw);
            }
            else
            {
                Vector3 resultPosition;
                Vector3 resultVelocity;
                float   resultYaw;

                Move(cmd.Input.Direction, cmd.Input.Yaw, out resultPosition, out resultVelocity, out resultYaw);

                cmd.Result.Position = resultPosition;
                cmd.Result.Velocity = resultVelocity;
                cmd.Result.Yaw      = resultYaw;
            }
        }