Exemple #1
0
    void OnCollisionEnter(Collision collide)
    {
        Destroy(obj);

        if (!ws.IsGameOver())
        {
            ws.GameOver();
            Instantiate(prompt,
                        new Vector3(0, 6.1f, 24.81724f),
                        Quaternion.identity);
        }

        var temp = Instantiate(explode,
                               obj.gameObject.transform.position,
                               Quaternion.identity);

        Destroy(temp, 0.6f);
    }
    // Update is called once per frame
    void Update()
    {
        if (ws.GetLevel() >= 3)
        {
            time = Time.timeSinceLevelLoad;
            if (time > nextFire)
            {
                nextFire = nextFire + Random.Range(time, time + 20);

                Instantiate(bullet,
                            trans.position + new Vector3(0, -1f, 0),
                            Quaternion.identity);
            }
        }

        if (trans.position.y < -0.5f)
        {
            Debug.Log(trans.position.y);
            if (!ws.IsGameOver())
            {
                ws.GameOver();
                Instantiate(prompt,
                            new Vector3(0, 6.1f, 24.81724f),
                            Quaternion.identity);

                GameObject ship = GameObject.FindGameObjectWithTag("Ship");

                Destroy(GameObject.FindGameObjectWithTag("Ship"));

                var temp = Instantiate(explode,
                                       ship.transform.position,
                                       Quaternion.identity);

                Destroy(temp, 0.6f);
            }
        }
    }