Esempio n. 1
0
        public IEnumerator OnAfterGameLoad()
        {
            TrackerConfig defaultTrackerConfig = new TrackerConfig();

            defaultTrackerConfig.setStorageType(TrackerConfig.StorageType.LOCAL);
            defaultTrackerConfig.setTraceFormat(TrackerConfig.TraceFormat.XAPI);
            defaultTrackerConfig.setRawCopy(true);
            defaultTrackerConfig.setDebug(true);

            Debug.Log("[SIMVA] Starting...");
            if (SimvaConf.Local == null)
            {
                SimvaConf.Local = new SimvaConf();
                yield return(StartCoroutine(SimvaConf.Local.LoadAsync()));

                Debug.Log("[SIMVA] Conf Loaded...");
            }

            if (!IsEnabled)
            {
                Debug.Log("[SIMVA] Study is not set! Stopping...");
                yield return(StartTracker(defaultTrackerConfig, null));

                yield break;
            }
            else if (IsActive)
            {
                Debug.Log("[SIMVA] Simva is already started...");
                // No need to restart
                yield break;
            }
            else
            {
                Debug.Log("[SIMVA] Setting current target to Simva.Login...");
                savedGameTarget = SceneManager.GetActiveScene().name;
                LoadManager.Instance.AutoStart = false;
                yield return(RunTarget("Simva.Login"));

                yield return(OnGameReady());
            }
        }
Esempio n. 2
0
        public IEnumerator LaunchActivity(string activityId)
        {
            if (activityId == null)
            {
                if (backupOperation != null && !backupOperation.IsCompletedSuccessfully)
                {
                    Game.Instance.AbortQuit();
                    DisableAutoSave();
                    Game.Instance.RunTarget("Simva.Backup", null, false);
                }
                else
                {
                    DisableAutoSave();
                    Game.Instance.RunTarget("Simva.End", null, false);
                    schedule = null;
                }
            }
            else
            {
                Activity activity = GetActivity(activityId);

                if (activity != null)
                {
                    Game.Instance.AbortQuit();
                    Debug.Log("[SIMVA] Schedule: " + activity.Type + ". Name: " + activity.Name + " activityId " + activityId);
                    switch (activity.Type)
                    {
                    case "limesurvey":
                        Debug.Log("[SIMVA] Starting Survey...");
                        DisableAutoSave();
                        Game.Instance.RunTarget("Simva.Survey", null, false);
                        break;

                    case "gameplay":
                    default:
                        var trackerConfig = new TrackerConfig();

                        trackerConfig.setStorageType(TrackerConfig.StorageType.LOCAL);
                        trackerConfig.setTraceFormat(TrackerConfig.TraceFormat.XAPI);
                        trackerConfig.setRawCopy(true);
                        trackerConfig.setDebug(true);

                        if (ActivityHasDetails(activity, "realtime", "trace_storage"))
                        {
                            // Realtime
                            trackerConfig.setStorageType(TrackerConfig.StorageType.NET);
                            trackerConfig.setHost(simvaController.SimvaConf.URL);
                            trackerConfig.setBasePath("");
                            trackerConfig.setLoginEndpoint("/users/login");
                            trackerConfig.setStartEndpoint("/activities/{0}/result");
                            trackerConfig.setTrackEndpoint("/activities/{0}/result");
                            trackerConfig.setTrackingCode(activityId);
                            trackerConfig.setUseBearerOnTrackEndpoint(true);
                            Debug.Log("TrackingCode: " + activity.Id + " settings " + trackerConfig.getTrackingCode());
                        }

                        if (ActivityHasDetails(activity, "backup"))
                        {
                            // Local
                            trackerConfig.setRawCopy(true);
                        }

                        if (ActivityHasDetails(activity, "realtime", "trace_storage", "backup"))
                        {
                            SimvaBridge = new SimvaBridge(API.ApiClient);
                            Debug.Log("[SIMVA] Starting tracker...");
                            yield return(StartCoroutine(AnalyticsExtension.Instance.StartTracker(trackerConfig, auth.Username + "_" + activityId + "_backup.log", SimvaBridge)));
                        }

                        Debug.Log("[SIMVA] Starting Gameplay...");
                        RestoreAutoSave();
                        Game.Instance.RunTarget(savedGameTarget, this);
                        if (Game.Instance.GameState.CheckFlag("DisclaimerEnabled") == FlagCondition.FLAG_ACTIVE)
                        {
                            Game.Instance.GameState.SetFlag("SeeingDisclaimer", FlagCondition.FLAG_ACTIVE);
                        }
                        break;
                    }
                }
            }
        }
        public IEnumerator LaunchActivity(string activityId)
        {
            if (activityId == null)
            {
                Game.Instance.RunTarget("Simva.End", null, false);
            }
            else
            {
                Activity activity = GetActivity(activityId);

                if (activity != null)
                {
                    Debug.Log("[SIMVA] Schedule: " + activity.Type + ". Name: " + activity.Name + " activityId " + activityId);
                    switch (activity.Type)
                    {
                    case "limesurvey":
                        Debug.Log("[SIMVA] Starting Survey...");
                        Game.Instance.RunTarget("Simva.Survey", null, false);
                        break;

                    case "gameplay":
                    default:
                        var trackerConfig = new TrackerConfig();

                        trackerConfig.setStorageType(TrackerConfig.StorageType.LOCAL);
                        trackerConfig.setTraceFormat(TrackerConfig.TraceFormat.XAPI);
                        trackerConfig.setRawCopy(true);
                        trackerConfig.setDebug(true);

                        if (ActivityHasDetails(activity, "realtime", "trace_storage"))
                        {
                            // Realtime
                            trackerConfig.setStorageType(TrackerConfig.StorageType.NET);
                            trackerConfig.setHost(simvaController.SimvaConf.URL);
                            trackerConfig.setBasePath("");
                            trackerConfig.setLoginEndpoint("/users/login");
                            trackerConfig.setStartEndpoint("/activities/{0}/result");
                            trackerConfig.setTrackEndpoint("/activities/{0}/result");
                            trackerConfig.setTrackingCode(activityId);
                            trackerConfig.setUseBearerOnTrackEndpoint(true);
                            Debug.Log("TrackingCode: " + activity.Id + " settings " + trackerConfig.getTrackingCode());
                        }

                        if (ActivityHasDetails(activity, "backup"))
                        {
                            // Local
                            trackerConfig.setRawCopy(true);
                        }

                        if (ActivityHasDetails(activity, "realtime", "trace_storage", "backup"))
                        {
                            SimvaBridge = new SimvaBridge(API.ApiClient);
                            Debug.Log("[SIMVA] Starting tracker...");
                            yield return(StartCoroutine(AnalyticsExtension.Instance.StartTracker(trackerConfig, SimvaBridge)));
                        }

                        Debug.Log("[SIMVA] Starting Gameplay...");
                        Game.Instance.RunTarget(Game.Instance.GameState.InitialChapterTarget.getId(), this);
                        break;
                    }
                }
            }
        }
Esempio n. 4
0
        public IEnumerator LaunchActivity(string activityId)
        {
            if (activityId == null || gameplay)
            {
                if (backupOperation != null && !backupOperation.IsCompletedSuccessfully)
                {
                    AbortQuit();
                    yield return(RunTarget("Simva.Backup"));

                    yield return(new WaitUntil(() => afterBackup));
                }

                //yield return RunTarget("Simva.End");
                allowedToQuit = true;
                schedule      = null;
            }
            else
            {
                Activity activity = GetActivity(activityId);
                if (activity != null)
                {
                    AbortQuit();
                    Debug.Log("[SIMVA] Schedule: " + activity.Type + ". Name: " + activity.Name + " activityId " + activityId);
                    switch (activity.Type)
                    {
                    case "limesurvey":
                        Debug.Log("[SIMVA] Starting Survey...");
                        yield return(RunTarget("Simva.Survey"));

                        break;

                    case "gameplay":
                    default:
                        var trackerConfig = new TrackerConfig();

                        trackerConfig.setStorageType(TrackerConfig.StorageType.LOCAL);
                        trackerConfig.setTraceFormat(TrackerConfig.TraceFormat.XAPI);
                        trackerConfig.setRawCopy(true);
                        trackerConfig.setDebug(true);

                        gameplay = true;

                        if (ActivityHasDetails(activity, "realtime", "trace_storage"))
                        {
                            // Realtime
                            trackerConfig.setStorageType(TrackerConfig.StorageType.NET);
                            trackerConfig.setHost(simvaController.SimvaConf.URL);
                            trackerConfig.setBasePath("");
                            trackerConfig.setLoginEndpoint("/users/login");
                            trackerConfig.setStartEndpoint("/activities/{0}/result");
                            trackerConfig.setTrackEndpoint("/activities/{0}/result");
                            trackerConfig.setTrackingCode(activityId);
                            trackerConfig.setUseBearerOnTrackEndpoint(true);
                            Debug.Log("TrackingCode: " + activity.Id + " settings " + trackerConfig.getTrackingCode());
                        }

                        if (ActivityHasDetails(activity, "backup"))
                        {
                            // Local
                            trackerConfig.setRawCopy(true);
                        }

                        if (ActivityHasDetails(activity, "realtime", "trace_storage", "backup"))
                        {
                            SimvaBridge = new SimvaBridge(API.ApiClient);
                            Debug.Log("[SIMVA] Starting tracker...");
                            yield return(StartTracker(trackerConfig, auth.Username + "_" + activityId + "_backup.log", SimvaBridge));
                        }

                        DestroyImmediate(runner.gameObject);
                        SceneManager.UnloadSceneAsync("Simva");

                        Debug.Log("[SIMVA] Starting Gameplay...");
                        LoadManager.Instance.LoadScene("MenuScene");
                        break;
                    }
                }
            }
        }