Esempio n. 1
0
    void Update()
    {
        if (!startedCheering)
        {
            return;
        }

        backgroundCheering.UpdateLoop();
    }
    public override void AfterFixed()
    {
        //Update running sound.

        if (!StateMachine.WithinError(Owner.Velocity.x, 0.0f, WorldConstants.MinMovementSpeed))
        {
            runningNoise.StartLoop();
        }
        else
        {
            runningNoise.EndLoop();
        }

        if (runningNoise.Running)
        {
            runningNoise.UpdateLoop();
        }


        //Check current wall collisions.

        if (Owner.ColManager.WallSides[ColType.Top].Count == 0)
        {
            Owner.ChangeState(ScriptableObject.CreateInstance <InAirState>(), false);
        }

        if (Owner.ColManager.WallSides[ColType.Left].Count > 0)
        {
            dontPlayEffects = true;
            HitSide(Owner.ColManager.WallSides[ColType.Left][0], ColType.Left);
            dontPlayEffects = false;
        }

        if (Owner.ColManager.WallSides[ColType.Right].Count > 0)
        {
            dontPlayEffects = true;
            HitSide(Owner.ColManager.WallSides[ColType.Right][0], ColType.Right);
            dontPlayEffects = false;
        }


        //Update the correct timing stat.
        Owner.OwnerStats.TimeOnGround += Time.fixedDeltaTime;
    }
    public override void AfterFixed()
    {
        //Update sliding noise. The faster the player, the higher his volume.
        slidingNoise.UpdateLoop();
        if (useSlidingNoise)
        {
            slidingNoise.SetMaxVolume(Mathf.Lerp(0.0f, slidingNoiseMaxVolume,
                                                 Mathf.Abs(Owner.Velocity.x) / Owner.PlayerProps.MaxSpeeds.x));
        }

        //Update the correct timed stat.
        Owner.OwnerStats.TimeOnCeiling += Time.fixedDeltaTime;

        //Update the projected y speed.
        currentSimulatedYSpeed += SimulatedGravity * Time.fixedDeltaTime;

        //Let the player fall if he ran out of time, isn't in contact with a ceiling anymore, or hit a wall.
        if (currentSimulatedYSpeed <= targetYSpeed ||
            Owner.ColManager.WallSides[ColType.Bottom].Count == 0 ||
            Owner.ColManager.WallSides[ColType.Left].Count != 0 ||
            Owner.ColManager.WallSides[ColType.Right].Count != 0)
        {
            Owner.transform.position += new Vector3(0.0f, -Owner.PlayerProps.CeilingPushOffOffset, 0.0f);

            Owner.ChangeState(ScriptableObject.CreateInstance <InAirState>(), true);
            return;
        }

        //Check to see if he hit a wall.
        if (Owner.ColManager.WallSides[ColType.Left].Count > 0)
        {
            HitSide(Owner.ColManager.WallSides[ColType.Left][0], ColType.Left);
        }
        if (Owner.ColManager.WallSides[ColType.Right].Count > 0)
        {
            HitSide(Owner.ColManager.WallSides[ColType.Right][0], ColType.Right);
        }
    }