Exemple #1
0
        void OnCollisionEnter2D(Collision2D col)
        {
            if (PongGame.Instance.IsClient)
            {
                return;
            }

            Racket racket = col.gameObject.GetComponent <Racket>();

            if (racket != null)
            {
                float sumX = 0;
                for (int i = 0; i < col.contactCount; i++)
                {
                    sumX += col.GetContact(i).point.x;
                }

                float forceX = sumX / col.contactCount - racket.transform.position.x;
                float forceY = CurrentFieldSide == PongGame.Side.A ? 1 : -1;

                if (Mathf.Abs(CachedTransform.position.y) > Mathf.Abs(racket.transform.position.y))
                {
                    forceY *= -1;
                }
                racket.OnBallHit();
                SetVelocity(new Vector2(forceX, forceY));
            }
        }
Exemple #2
0
 public PlayerAI(Racket racket, Difficulty dif) : base(racket)
 {
     m_dif            = dif;
     m_racketMaxSpeed = dif == Difficulty.Unreal ? AI_SPEED * 2 : AI_SPEED;
     m_accel          = dif == Difficulty.Unreal ? AI_ACCEL * 2 : AI_ACCEL;
     m_curSpeed       = 0;
     GenereateNewShift();
 }
Exemple #3
0
 public PlayerBase(Racket racket)
 {
     m_racket       = racket;
     m_racket.Owner = this;
     Score          = 0;
 }
Exemple #4
0
 public PlayerLocal(Racket racket) : base(racket)
 {
 }
Exemple #5
0
 public PlayerInterpolated(Racket racket) : base(racket)
 {
     InterpHelper = new InterpolatingHelper();
 }
Exemple #6
0
 public PlayerRemote(Racket racket) : base(racket)
 {
 }