void FixedUpdate() { if (transform.localPosition.y + boxCollider.size.y >= stageSize.y || transform.localPosition.y - boxCollider.size.y <= -stageSize.y) { Vector2 normal = new Vector2(0.0f, -Mathf.Sign(transform.localPosition.y)); this.y = Mathf.Sign(transform.localPosition.y) * (stageSize.y - boxCollider.size.y - 0.1f); this.reflectMovement(normal); if (OnBallCollided != null) { OnBallCollided.Invoke(); } } if (transform.localPosition.x + boxCollider.size.x >= stageSize.x) { if (OnPlayerScored != null) { OnPlayerScored.Invoke(); } ResetBall(); } else if (transform.localPosition.x - boxCollider.size.x <= -stageSize.x) { if (OnAIScored != null) { OnAIScored.Invoke(); } ResetBall(); } body.velocity = getVelocityVector(); }
private void OnTriggerEnter(Collider other) { if (other.GetComponent <Hoop>() != null) { if (!ignoredColliders.Contains(other.gameObject) && other.isTrigger) { #if UNITY_EDITOR Debug.Log("Someone scored!"); #endif PlayerScored?.Invoke(other.GetComponent <Hoop>()); DisablePlayerCollider(other); } } }
public void CheckIfCollisionWithPlayer(DrawableObject item) { Player player = item as Player; if (!IsOccupied) { if (base.CheckIfCollisionWith(item)) { IsOccupied = true; IsVisible = false; OccupiedPods++; PlayerScored?.Invoke(player); if (OccupiedPods == CreatedPods) { AllPodsOccupied?.Invoke(); } } } }
private void OnPlayerScored() { PlayerScored?.Invoke(this, new EventArgs()); }