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)); } }
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(); }
public PlayerBase(Racket racket) { m_racket = racket; m_racket.Owner = this; Score = 0; }
public PlayerLocal(Racket racket) : base(racket) { }
public PlayerInterpolated(Racket racket) : base(racket) { InterpHelper = new InterpolatingHelper(); }
public PlayerRemote(Racket racket) : base(racket) { }