Exemplo n.º 1
0
        // Start is called before the first frame update
        void Awake()
        {
            rigidbody      = GetComponent <Rigidbody2D>();
            renderer       = GetComponent <Renderer>();
            spriteRenderer = GetComponent <SpriteRenderer>();
            BallPrefab.transform.position = Evolution.GetRandomPosition();
            ballInitialPosition           = BallPrefab.transform.position;
            ball               = Instantiate(BallPrefab);
            ballRigidbody      = ball.GetComponent <Rigidbody2D>();
            ballCollider       = ball.GetComponent <Collider2D>();
            ballRenderer       = ball.GetComponent <Renderer>();
            ballSpriteRenderer = ball.GetComponent <SpriteRenderer>();

            playerActions = new PlayerInputActions();
            playerActions.Player.Move.performed += Move_performed;
            playerActions.Player.Move.Enable();
            playerActions.Player.Shoot.performed += Shoot_performed;
            playerActions.Player.Shoot.Enable();

            ball.OnRightGoalCollisionEnter += Ball_OnRightGoalCollisionEnter;
            ball.OnRightGoalCollisionStay  += Ball_OnRightGoalCollisionStay;
        }
Exemplo n.º 2
0
 // We want to reuse this object instead of creating new ones each generation.
 public void Reset(Vector2 playerPos)
 {
     transform.position = playerPos;
     ballRigidbody.transform.position = Evolution.GetRandomPosition();
     ballInitialPosition = ballRigidbody.transform.position;
 }