private void OnTriggerEnter2D(Collider2D otherCollider) { GameObject otherObj = otherCollider.gameObject; int layer = 1 << otherObj.layer; if ((layer & paddle) != 0) { currentSpeed += speedIncreasePerHit; Vector2 directionToPaddleCenter = otherObj.transform.position - transform.position; float signedAngle = Vector2.SignedAngle(Vector2.up, -directionToPaddleCenter); float sign = Mathf.Sign(signedAngle); float angle = Vector2.Angle(Vector2.up, -directionToPaddleCenter); float clampedAngle = Mathf.Clamp(angle, 90f - paddleReboundAngleLimit, 90f + paddleReboundAngleLimit); float finalAngle = clampedAngle * -sign * Mathf.Deg2Rad; Vector2 newDirection = new Vector2(Mathf.Sin(finalAngle), Mathf.Cos(finalAngle)); newDirection = ScaleToXSpeed(newDirection, currentSpeed); rb.velocity = newDirection; } if ((layer & playerSideGoal) != 0) { enemyScore.IncrementScore(); audio.PlayOneShot(hitPlayerSideGoal); Reset(); } if ((layer & enemySideGoal) != 0) { playerScore.IncrementScore(); audio.PlayOneShot(hitEnemySideGoal); Reset(); } }
public virtual void NotifyPlayerDeath(GameEventPlayerDeath _e) { int eliminatorId = killTracker.ProcessPlayerDeath(_e); if (eliminatorId != -1) { scoreTracker.IncrementScore(eliminatorId, 1); } else { scoreTracker.IncrementScore(_e.receiverId, -1); } UpdateDisplay(); GameManager.Instance.GetPlayer(_e.receiverId).Respawn(); }
public void IncrementScore() { ScoreTracker.IncrementScore(0); }