Exemple #1
0
    void OnTriggerEnter2D(Collider2D other)
    {
        ShipMovement ship = other.gameObject.GetComponent <ShipMovement>();

        if (ship)
        {
            if (ship.GetComponent <ShipHealth>().GetHealth() == 0)
            {
                if (!win)
                {
                    FindObjectOfType <StageManager>().GetComponent <StageManager>().ChangeScene(_cena);
                }
                else
                {
                    if (fim)
                    {
                        FindObjectOfType <StageManager>().GetComponent <StageManager>().ChangeScene("Fim");
                    }
                    else
                    {
                        FindObjectOfType <StageManager>().GetComponent <StageManager>().ChangeScene(_cenaWin);
                    }
                }
            }
            else
            {
                ship.GetComponent <ShipHealth>().Damage(_damage);
                ship.GetComponent <Rigidbody2D>().AddForce(Vector2.up * _force, ForceMode2D.Impulse);
            }
        }
    }
    void OnCollisionEnter2D(Collision2D other)
    {
        ShipMovement ship = other.gameObject.GetComponent <ShipMovement>();

        if (ship)
        {
            ship.GetComponent <ShipHealth>().Damage(_damage);
            // spawna particula explosao.
            Destroy(gameObject);
        }
    }
Exemple #3
0
    void OnTriggerEnter2D(Collider2D other)
    {
        ShipMovement ship = other.gameObject.GetComponent <ShipMovement>();

        if (ship)
        {
            if (!_done)
            {
                Vector2 direction = (ship.gameObject.transform.position - transform.position);
                ship.GetComponent <Rigidbody2D>().AddForce(direction.normalized * _pushForce, ForceMode2D.Impulse);
                _done = true;
            }
        }
    }
Exemple #4
0
 void Update()
 {
     this.gameObject.GetComponent <TMPro.TextMeshProUGUI>().text = (Mathf.FloorToInt(Mathf.Abs(movement.GetComponent <Rigidbody>().velocity.z)) * 10).ToString();
 }