private void OnCollisionEnter(Collision collision)
    {
        Rigidbody     rb = collision.rigidbody;
        MissileEngine me = rb.GetComponent <MissileEngine>();

        if (me == null)
        {
            return;
        }
        Destroy(collision.gameObject);
    }
Beispiel #2
0
    void OnCollisionEnter(Collision collision)
    {
        if (collision.rigidbody == null)
        {
            return;
        }

        Rigidbody     rb = collision.rigidbody;
        MissileEngine me = rb.GetComponent <MissileEngine>();

        if (me == null)
        {
            return;
        }
        Application.LoadLevel(Application.loadedLevelName);
        Destroy(this.gameObject);
    }
    // Update is called once per frame
    void Update()
    {
        if (Time.time - lastSpawn > mSpawnerRate_sec && target != null)
        {
            MissileEngine me = Instantiate <MissileEngine>(missilePrefab);
            me.transform.position = mSpawnOrigin.position +
                                    Random.Range(-1.0f, 1.0f) * mSpawnRadius * mSpawnOrigin.right +
                                    Random.Range(-1.0f, 1.0f) * mSpawnRadius * mSpawnOrigin.forward;
            Rigidbody rb = me.GetComponent <Rigidbody>();
            if (target != null)
            {
                rb.velocity = (target.position - me.transform.position).normalized * mSpeed;
            }
            lastSpawn = Time.time;
        }

        if (Time.time - startTime > 10)
        {
            mSpeed           = 2;
            mSpawnerRate_sec = 5;
        }

        if (Time.time - startTime > 20)
        {
            mSpeed           = 3;
            mSpawnerRate_sec = 3;
        }

        if (Time.time - startTime > 30)
        {
            mSpeed           = 4;
            mSpawnerRate_sec = 1;
        }

        if (Time.time - startTime > 60)
        {
            mSpeed           = 5;
            mSpawnerRate_sec = 1;
        }
    }