Ejemplo n.º 1
0
    void Update()
    {
        // Press Q to quit game application
        if (Input.GetKey(KeyCode.Q))
        {
#if UNITY_EDITOR
            UnityEditor.EditorApplication.isPlaying = false;
#else
            Application.Quit();
#endif
        }

        if (Input.GetKeyDown(KeyCode.J))
        {
            if (isRandom)
            {
                //Debug.Log("Random is off");
                waypoint.text = "Waypoints: Sequential";
                isRandom      = false;
            }

            else
            {
                //Debug.Log("Random is on");
                waypoint.text = "Waypoints: Random";
                isRandom      = true;
            }
        }

        // Create more planes to maintain maxPlanes in the world
        if (numberOfPlanes < maxPlanes)
        {
            // Create a plane
            GameObject e = Instantiate(Resources.Load("Prefabs/PlaneEnemy") as GameObject);

            // Spawn plane to random position within 90% of world boundaries
            Vector3 pos;
            pos.x = s.Get90Bounds().min.x + Random.value * s.Get90Bounds().size.x;
            pos.y = s.Get90Bounds().min.y + Random.value * s.Get90Bounds().size.y;
            pos.z = 0;

            e.transform.localPosition = pos;
            numberOfPlanes++; // Increase plane count
        }

        // Update the UI Text
        enemyText.text = "ENEMY: Count(" + numberOfPlanes +
                         ") Destroyed(" + planesDestroyed + ")";

        eggText.text = "EGG: OnScreen(" + numberOfEggs + ")";

        heroHits.text = "HERO: Hit(" + heroHit + ")";
    }