Ejemplo n.º 1
0
 private void OnScore(int player)
 {
     PlacarTracker.AddScore(player);
     PlacarTracker.GameStarted = false;
     PlacarTracker.ResetIterated();
     Debug.Log(PlacarTracker.TimesIterated);
     _vel            = VelInit;
     body2d.position = Vector2.zero;
     Direction       = new Vector2(-1, Random.Range(-1f, 1f));
 }
Ejemplo n.º 2
0
    private void OnCollisionEnter2D(Collision2D other)
    {
        var otherbody = other.gameObject.GetComponent <Rigidbody2D>();

        var otherpos = otherbody.position.y;

        var relativePosition = Mathf.Abs(body2d.position.y) -
                               Mathf.Abs(otherbody.position.y);
        float abs;

        if (otherpos > 0)
        {
            abs = Mathf.Abs(relativePosition) / relativePosition;
        }
        else if (otherpos < 0)
        {
            abs = -1 * Mathf.Abs(relativePosition) / relativePosition;
        }
        else
        {
            abs = 1;
        }


        relativePosition = Mathf.Abs(relativePosition);

        var newAngle = (float)(relativePosition * Math.PI / 3);


        if (other.gameObject.CompareTag("PlayerBar"))
        {
            Direction.x *= -1;
            Direction.y  = Mathf.Tan(newAngle) * abs;
            PlacarTracker.AddIteration();
            _vel += (PlacarTracker.TimesIterated / 3f);
        }

        if (other.gameObject.CompareTag("Debug"))
        {
            Direction.x *= -1;
            Direction.y  = 0;
        }
    }
Ejemplo n.º 3
0
 private void Start()
 {
     _text.text = PlacarTracker.GetPlacar() + "\nGame Over!";
 }
Ejemplo n.º 4
0
 // Update is called once per frame
 void Update()
 {
     _text.text = PlacarTracker.GetPlacar();
 }