Beispiel #1
0
    IEnumerator lightTimer(float time)
    {
        while (!isDone)
        {
            yield return(new WaitForSeconds(time));

            isLightsOn     = !isLightsOn;
            lights.enabled = isLightsOn;

            if (!task && transform.GetChild(0).gameObject.activeSelf)
            {
                task = Instantiate(roomTemplates.GetTask(), new Vector3(transform.position.x, transform.position.y, transform.position.z), Quaternion.identity);
                task.transform.SetParent(transform);
                task.SetActive(false);
            }
            if (task)
            {
                if (task.GetComponent <Collider>().isTrigger)
                {
                    roomTemplates.finishedTasks++;
                    RoomTemplates.taskToBeFinish = roomTemplates.totalTasks - roomTemplates.finishedTasks;
                    changeState();
                    Destroy(task);

                    Destroy(tracker);
                    lights.color   = Color.green;
                    lights.enabled = true;
                    isDone         = true;

                    if (roomTemplates.finishedTasks == roomTemplates.totalTasks)
                    {
                        roomTemplates.win = true;
                        endingScript.showExit();
                    }
                }
            }
        }
    }