Exemplo n.º 1
0
 private void Awake()
 {
     gameOverEvent      = new GameOverEvent();
     addScoreEvent      = new AddScoreEvent();
     powerPickupEvent   = new PowerPickupEvent();
     stickToPaddleEvent = new StickToPaddleEvent();
     coinPickUpEvent    = new CoinPickUpEvent();
     explodeEvent       = new ExplodeEvent();
     ballHitEvent       = new BallHitEvent();
     brickDamageEvent   = new BrickDamageEvent();
 }
Exemplo n.º 2
0
    private void Update()
    {
        // Works with mobile as well
        if (Input.GetMouseButtonDown(0))
        {
            RaycastHit2D hit = Physics2D.Raycast(cam.ScreenToWorldPoint(Input.mousePosition), Vector2.zero);
            if (hit.collider != null)
            {
                Ball ball = hit.collider.GetComponent <Ball>();
                if (ball)
                {
                    // Get direction from hit point to ball
                    Vector2 direction = ((Vector2)ball.transform.position - hit.point).normalized;

                    ball.AddForce(direction * force, ForceMode2D.Impulse);
                    ball.AddTorque(Random.Range(-torque, torque));

                    BallHitEvent?.Invoke(hit.point);
                }
            }
        }
    }
Exemplo n.º 3
0
    private void GenBallHitEvent(string _paddleID_)
    {
        BallHitEvent e = new BallHitEvent(_paddleID_);

        eventLog.AddEvent(e.type, JsonConvert.SerializeObject(e, Formatting.Indented, GeneralUtils.jss));
    }