예제 #1
0
    void Start()
    {
        currentScene = SceneManager.GetActiveScene();
        sceneName    = currentScene.name;

        follow = GetComponent <TigerPathFollow> ();
        pursue = GetComponent <TigerPursue> ();

        follow.enabled = true;
        pursue.enabled = false;
    }
예제 #2
0
    // Update is called once per frame
    void Update()
    {
        if (sceneName == "MainScene")
        {
            isCoroutineStarted = false;
            //check if the GameObject is loaded.
            if (a == null)
            {
                a  = GameObject.FindWithTag("LeaderZebra");
                fc = a.GetComponent <ZebraMainFlockController>();
            }
            //check distance between the gO and the endpoint
            distance1 = fc.distance;
            // Debug.Log("distance "+distance);

            //trigger to initiate scene change
            if (distance1 <= 3 && distance1 >= 1)
            {
                if (!isCoroutineStarted)
                {
                    Debug.Log("Next Scene Coroutine Started");
                    StartCoroutine(Fading());
                }
            }
        }
        else if (sceneName == "Hunt")
        {
            if (b == null)
            {
                b  = GameObject.FindWithTag("Tiget");
                tp = b.GetComponent <TigerPursue>();
            }
            //check distance between the gO and the target
            distance2 = tp.direction.magnitude;
            // Debug.Log("distance "+tp.direction);

            //trigger to initiate scene change
            if (distance2 <= 10)
            {
                if (!isCoroutineStarted)
                {
                    Debug.Log("Next Scene Coroutine Started");
                    //	StartCoroutine(Fading());
                }
            }
        }
        else if (sceneName == "BirdView")
        {
            isCoroutineStarted = false;
            //check if birds have reacher the last checkpoint then
            if (c == null)
            {
                c   = GameObject.FindWithTag("Birds");
                bpf = c.GetComponent <BirdsPathFollow>();
            }
            //check distance between the gO and the target
            int i = bpf.index;
            // Debug.Log("distance "+distance);

            //trigger to initiate scene change
            if (i == 3)
            {
                if (!isCoroutineStarted)
                {
                    Debug.Log("Next Scene Coroutine Started");
                    StartCoroutine(Fading());
                }
            }
        }
    }