コード例 #1
0
        /* Loads a game setup with the given id and starts the first task from it */
        public void startGame(int id)
        {
            Debug.Log("Start game");
            regularCamera.SetActive(false);
            this.setup           = null;
            currentTask          = null;
            connectedPartsMax    = 0;
            currentSetupFinished = false;
            arCamera.SetActive(false);
            currentGameSetup = false;

            foreach (Part p in parts)
            {
                p.gameObject.SetActive(true);
            }

            var rendererComponents = GetComponentsInChildren <Renderer>(true);
            var colliderComponents = GetComponentsInChildren <Collider>(true);
            var canvasComponents   = GetComponentsInChildren <Canvas>(true);

            // Enable rendering:
            foreach (var component in rendererComponents)
            {
                component.enabled = false;
            }

            // Enable colliders:
            foreach (var component in colliderComponents)
            {
                component.enabled = false;
            }

            // Enable canvas':
            foreach (var component in canvasComponents)
            {
                component.enabled = false;
            }

            foreach (Settings.GameSetup s in Settings.Instance.setups)
            {
                if (s.id == id)
                {
                    this.setup = s;
                }
            }

            if (this.setup == null)
            {
                Debug.Log("Could not find game setup with id " + id);
                return;
            }

            Debug.Log(setup.ToString() + " now runnung");


            finishedTasks = 0;
            liloJump.Play(0);
            example = PrepareScene();
            StartCoroutine(example);
        }
コード例 #2
0
        /* Starts the next unfinished task from the current setup */
        private void nextTask()
        {
            connectedPartsMax = 0;
            if (setup.tasks.Count > finishedTasks)
            {
                currentTask = setup.tasks[finishedTasks];
                Debug.Log("Next task: " + (finishedTasks + 1) + " / " + setup.tasks.Count);

                // Disable all Vuforia datasets except the one needed for the current task
                string        dataset      = currentTask.dataset;
                ObjectTracker imageTracker = TrackerManager.Instance.GetTracker <ObjectTracker>();
                foreach (DataSet ds in imageTracker.GetDataSets())
                {
                    // determine whether the dataset is alreay active
                    bool isActive = false;
                    foreach (DataSet other in imageTracker.GetActiveDataSets())
                    {
                        if (ds.Equals(other))
                        {
                            isActive = true;
                        }
                    }

                    if (ds.Path.Contains(dataset) && !isActive)
                    {
                        imageTracker.ActivateDataSet(ds);
                        Debug.Log(ds.Path + " activated");
                    }
                    else if (!ds.Path.Contains(dataset) && isActive)
                    {
                        imageTracker.DeactivateDataSet(ds);
                        Debug.Log(ds.Path + " deactivated");
                    }
                }

                SoundManager.Instance.playFile("Sounds/Tasks/" + currentTask.audio);

                Debug.Log("Next Task: " + currentTask.ToString());
                Debug.Log(parts.Length + " active parts");
                connectionStateChanged();
            }
            else
            {
                currentSetupFinished = true;
                setupFinished        = SetupFinished();
                StartCoroutine(setupFinished);
            }
        }