Esempio n. 1
0
 private void OnBallVollied(PlayerEvents.BallVolliedEvent e)
 {
     //if (e.PlayerID == PlayerManager.Instance.GetPlayerID(this.gameObject))
     //{
     _canMove = true;
     //}
 }
Esempio n. 2
0
 private void OnBallLaunched(PlayerEvents.BallVolliedEvent e)
 {
     if (_currentState == eGameState.Serve)
     {
         SetState(eGameState.Play);
     }
 }
Esempio n. 3
0
    //private void OnPlayerHit(GameEvents.BallTouchPlayerEvent e)
    //{
    //    _rigidbody.velocity *= _playerHitDampenFactor;

    //    // update trajectory
    //    UpdateTrajectory(e.RelativeVelocity.normalized, _rigidbody.velocity.magnitude, 1f, Color.green);
    //}

    private void OnBallVollied(PlayerEvents.BallVolliedEvent e)
    {
        // effects
        if (e.Spike)
        {
            _spikeParticles.Play();
            _trail.time = _spikeTrailTime;

            SetTrailColor(_spikeColor);
        }
        else
        {
            _spikeParticles.Stop();
            _trail.time = _defaultTrailTime;

            SetTrailColor(Settings.Instance.GetPlayerColor(e.PlayerID));
        }

        // stop all momentum, so that the shots are accurate to their aim locations
        _rigidbody.velocity        = Vector2.zero;
        _rigidbody.angularVelocity = 0f;

        //HoldBall(false);
        _rigidbody.AddForce(e.Direction * e.Power);

        // spin
        _spinValues   = e.Spins;
        _spinModifier = e.SpinModifier;
        _spin         = _spinValues.x + _spinValues.y;
        _rigidbody.AddTorque(_spin * _spinModifier * Mathf.Sign(Vector2.Dot(Vector2.right, e.Direction)));

        // predict trajectory
        float ballTravelDirection    = Mathf.Sign(_rigidbody.velocity.x);
        float magicalTrajectoryValue = BaseTrajectoryModifier;
        Color debugColor             = Color.red;

        if (_spin * ballTravelDirection > 0f)
        {
            float delta = BackwardSpinTrajectoryModifier - BaseTrajectoryModifier;
            magicalTrajectoryValue = BaseTrajectoryModifier + delta * _spin;
            debugColor             = Color.green;
        }
        else if (_spin * ballTravelDirection < 0f)
        {
            float delta = ForwardSpinTrajectoryModifier - BaseTrajectoryModifier;
            magicalTrajectoryValue = BaseTrajectoryModifier - delta * _spin;
            debugColor             = Color.blue;
        }

        UpdateTrajectory(e.Direction, magicalTrajectoryValue, debugColor);

        _trail.enabled = true;
    }
Esempio n. 4
0
 private void OnBallVollied(PlayerEvents.BallVolliedEvent e)
 {
     SetIsKinematic(false);
 }
Esempio n. 5
0
 private void OnBallVollied(PlayerEvents.BallVolliedEvent e)
 {
     Reset();
 }