Exemple #1
0
 private void RpcReceiveInput(BoatInput input)
 {
     if (!isLocalPlayer)
     {
         KeysDown = input;
     }
 }
Exemple #2
0
    //Get input for player
    void Update()
    {
        if (isLocalPlayer)
        {
            oldKeysDown            = KeysDown;
            KeysDown.forward       = InputWrapper.GetKey(forwardKey);
            KeysDown.backwards     = InputWrapper.GetKey(backwardsKey);
            KeysDown.left          = InputWrapper.GetKey(leftKey);
            KeysDown.right         = InputWrapper.GetKey(rightKey);
            KeysDown.fireCannon    = InputWrapper.GetKey(cannonFireKey);
            KeysDown.fireSwivelGun = InputWrapper.GetKey(swivelGunFireKey);

            //detect meaningful change in input to send to server
            if (oldKeysDown.forward != KeysDown.forward ||
                oldKeysDown.backwards != KeysDown.backwards ||
                oldKeysDown.left != KeysDown.left ||
                oldKeysDown.right != KeysDown.right)
            {
                CmdBounceInput(KeysDown); //just a struct of 6 bools, shouldn't be weighty at all
            }

            if (KeysDown.fireSwivelGun)
            {
                foreach (SwivelGun sScript in swivelGunScripts)
                {
                    if (sScript.CanFire())
                    {
                        //Pass information to server and spawn cannonball on all cients
                        CmdFire(sScript.GetCannonBallPosition(), sScript.GetCannonBallVelocity());
                    }
                }
            }

            if (KeysDown.fireCannon || InputWrapper.GetMouseButtonDown(0))
            {
                foreach (BroadsideCannonFireNetworked cScript in cannonScripts)
                {
                    if (cScript.CanFire())
                    {
                        //Pass information to server and spawn cannonball on all cients
                        CmdFire(cScript.GetCannonBallPosition(), cScript.GetCannonBallVelocity() * cannonBallSpeedScale);
                        cScript.ResetFireTimer();
                    }
                }
            }

            boatCam.gameIsPaused = gameIsPaused;             //assign game is paused value to boat cam
        }
        // Boat speed is visible for testing purposes
        speed = this.GetComponent <Rigidbody>().velocity.magnitude;
    }
Exemple #3
0
 private void CmdBounceInput(BoatInput input)
 {
     RpcReceiveInput(input);
 }