Esempio n. 1
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKey(KeyCode.Escape))
        {
    #if UNITY_EDITOR
            //Application.Quit();  doesnt work in the editor so
            //UnityEditor.EditorApplication.isPlaying need to be set to  flase

            UnityEditor.EditorApplication.isPlaying = false;
    #else
            Application.Quit();
    #endif
        }

        if (numberofPlanes < maxPlanes)
        {
            //Bounds myBound = GetComponent <Renderer>().bounds;
            CameraSupport s = Camera.main.GetComponent <CameraSupport>();
            GameObject    e = Instantiate(Resources.Load("Prefabs/Enemy") as GameObject);
            Vector3       pos;
            pos.x = s.GetWorldBounds().min.x + Random.value * s.GetWorldBounds().size.x;
            pos.y = s.GetWorldBounds().min.y + Random.value * s.GetWorldBounds().size.y;
            pos.z = 0;
            e.transform.localPosition = pos;
            ++numberofPlanes;
        }
    }
Esempio n. 2
0
    void Update()
    {
        // Travel
        transform.position += transform.up * (eggSpeed * Time.smoothDeltaTime);

        // If outside the game window: kill itself
        Vector3 pos = transform.position;

        if (!s.GetWorldBounds().Contains(pos))
        {
            Destroy(transform.gameObject);
            gameCon.EggDestroyed();
        }
    }