Esempio n. 1
0
    public override void ExecuteCommand(Command command, bool resetState)
    {
        TicTacCommand cmd = (TicTacCommand)command;

        if (resetState)
        {
            // we got a correction from the server, reset (this only runs on the client)
            _motor.SetState(cmd.Result.Position, cmd.Result.Velocity, cmd.Result.Grounded, cmd.Result.JumpFrames);
        }
        else
        {
            // apply movement (this runs on both server and client)
            PlayerMotor.State motorState = _motor.Move(cmd.Input.Forward, cmd.Input.Backward, cmd.Input.Left, cmd.Input.Right, cmd.Input.Jump, cmd.Input.Yaw);

            // copy the motor state to the commands result (this gets sent back to the client)
            cmd.Result.Position   = motorState.position;
            cmd.Result.Velocity   = motorState.velocity;
            cmd.Result.Grounded   = motorState.isGrounded;
            cmd.Result.JumpFrames = motorState.jumpFrames;

            if (cmd.IsFirstExecution)
            {
                //AnimatePlayer(cmd);

                // set state pitch
                state.Pitch = cmd.Input.Pitch;

                // check if we should try to fire our weapon
                if (cmd.Input.Aiming && cmd.Input.Fire)
                {
                    FireWeapon(cmd);
                }
            }
        }
    }
Esempio n. 2
0
 void FireWeapon(TicTacCommand cmd)
 {
     if (weapons[0].FireFrame + weapons[0].FireInterval <= BoltNetwork.ServerFrame)
     {
         weapons[0].FireFrame = BoltNetwork.ServerFrame;
         state.Fire();
     }
 }
Esempio n. 3
0
    public override void SimulateController()
    {
        PollKeys(false);

        ITicTacCommandInput input = TicTacCommand.Create();

        input.Forward  = _forward;
        input.Backward = _backward;
        input.Left     = _left;
        input.Right    = _right;
        input.Jump     = _jump;
        input.Yaw      = _yaw;
        input.Pitch    = _pitch;

        // new lines
        input.Aiming = _aiming;
        input.Fire   = _fire;

        entity.QueueInput(input);
    }
Esempio n. 4
0
 public virtual void HitDetection(TicTacCommand cmd, BoltEntity entity)
 {
 }