aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Assets/Scripts/Controllers/Ball.cs
blob: b09b1be5452d4832f9c0d3186e721e97e8cc0370 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
using System;
using UnityEngine;

namespace Controllers
{
  [RequireComponent(typeof(Rigidbody2D))]
  [RequireComponent(typeof(CircleCollider2D))]
  public class Ball : MonoBehaviour
  {
    internal GameController controller;

    [SerializeField] private float shotForce;
    
    private void OnCollisionEnter2D(Collision2D other)
    {
      controller.BallDropped();
    }

    public void Shoot(Transform playerTransform)
    {
      GetComponent<Rigidbody2D>().AddForce((Vector2)(playerTransform.right + playerTransform.up) * shotForce);
    }
  }
}