Пример #1
0
 private void CmdUploadGrindInput(GrindInputState grindInputState)
 {
     // server recieves inputs from client
     masterComp.inputCont.shipInputs.grind = grindInputState.grind;
     Debug.Log("grind cmd recieved");
 }
Пример #2
0
    // Update is called once per frame
    void Update()
    {
        if (grindLockers.IsLocked())
        {
            return;
        }

        // get all of the gravity rails in range
        float grabDist = maxGrabDist;//!masterComp.steeringCont.IsStunned() ? maxGrabDist : maxGrabDist * 0.75f;
        List <GravityRail.RailInfo> railsInRange = track.GetRailInfoWithinDist(transform.position, grabDist);

        // see if grind is released
        if (masterComp.inputCont.shipInputs.grind.wasReleased)
        {
            grindReleased  = true;
            grabFramesLeft = 0;

            if (currentRailInfo != null)
            {
                // launch the player off the rail and detach
                LaunchOffRail();
                // start rail jump slow timer
                railJumpTimer.Activate();
            }
        }
        else
        {
            // set grab frames left to 0 if stunned to make it harder to grab when stunned
            //if (masterComp.steeringCont.IsStunned()) { grabFramesLeft = 0; }

            // grab is pressed if block is entered

            /*
             * Attempt to grab a rail if:
             * 1. No currently attached to a rail
             * 2.  - Grab is not on cooldown and grind was released last frame
             *  - There are grab frames left from attempting to grab in prev frame
             */
            if (currentRailInfo == null &&
                ((!grabCoolDown.isActive && grindReleased) || grabFramesLeft > 0))
            {
                AttemptToGrabRail(railsInRange);
            }

            // set grab on cooldown if just pressed
            if (grindReleased && !grabCoolDown.isActive)
            {
                grabCoolDown.Activate();
            }

            // save that grind has been pressed
            grindReleased = false;
        }

        // save whether not in range of any tracks
        noRailsInRange = railsInRange.Count == 0;
        if (noRailsInRange)
        {
            canGetGrabBonus = true;
        }

        // tick grab cooldown
        grabCoolDown.Update(Time.deltaTime);

        // update jump cooldown
        if (railJumpTimer.isActive)
        {
            if (railJumpTimer.Update(Time.deltaTime))
            {
                masterComp.speedCont.maxSpeedAdjustors.RemoveAdjustor(JUMP_SPEED_ADJUSTER_NAME);
            }
        }

        // if grind changed, send a new grind input command
        if (prevGrindButton != masterComp.inputCont.shipInputs.grind)
        {
            GrindInputState grindInputState = new GrindInputState();
            grindInputState.grind = masterComp.inputCont.shipInputs.grind;
            int index = clientGrindInputCmdID % clientCmdHistorySize;
            grindInputState.id        = clientGrindInputCmdID++;
            grindInputState.timeStamp = GameMode.singleton.gameTime;

            clientGrindHistory[index] = grindInputState;

            //CmdUploadGrindInput(grindInputState);
        }

        prevGrindButton = masterComp.inputCont.shipInputs.grind;
    }