コード例 #1
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;
                    }
                }
            }
        }
コード例 #3
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;
                    }
                }
            }
        }
コード例 #4
0
        public IEnumerator StartTracker(TrackerConfig config, string backupFilename, IBridge bridge = null)
        {
            trackerConfig = config;
            string domain = "";
            int    port   = 80;
            bool   secure = false;

            Debug.Log("[ANALYTICS] Setting up tracker...");
            try
            {
                if (config.getHost() != "")
                {
                    string[] splitted = config.getHost().Split('/');

                    if (splitted.Length > 1)
                    {
                        string[] host_splitted = splitted[2].Split(':');
                        if (host_splitted.Length > 0)
                        {
                            domain = host_splitted[0];
                            port   = (host_splitted.Length > 1) ? int.Parse(host_splitted[1]) : (splitted[0] == "https:" ? 443 : 80);
                            secure = splitted[0] == "https:";
                        }
                    }
                }
                else
                {
                    config.setHost("localhost");
                }
                Debug.Log("[ANALYTICS] Config: " + JsonConvert.SerializeObject(config));
            }
            catch (System.Exception e)
            {
                Debug.Log("Tracker error: Host bad format");
            }

            TrackerAsset.TraceFormats format;
            switch (config.getTraceFormat())
            {
            case TrackerConfig.TraceFormat.XAPI:
                format = TrackerAsset.TraceFormats.xapi;
                break;

            default:
                format = TrackerAsset.TraceFormats.csv;
                break;
            }
            Debug.Log("[ANALYTICS] Format: " + format);

            TrackerAsset.StorageTypes storage;
            switch (config.getStorageType())
            {
            case TrackerConfig.StorageType.NET:
                storage = TrackerAsset.StorageTypes.net;
                break;

            default:
                storage = TrackerAsset.StorageTypes.local;
                break;
            }
            Debug.Log("[ANALYTICS] Storage: " + storage);

            TrackerAssetSettings tracker_settings = new TrackerAssetSettings()
            {
                Host                     = domain,
                TrackingCode             = config.getTrackingCode(),
                BasePath                 = trackerConfig.getBasePath() ?? "/api",
                LoginEndpoint            = trackerConfig.getLoginEndpoint() ?? "login",
                StartEndpoint            = trackerConfig.getStartEndpoint() ?? "proxy/gleaner/collector/start/{0}",
                TrackEndpoint            = trackerConfig.getStartEndpoint() ?? "proxy/gleaner/collector/track",
                Port                     = port,
                Secure                   = secure,
                StorageType              = storage,
                TraceFormat              = format,
                BackupStorage            = config.getRawCopy(),
                UseBearerOnTrackEndpoint = trackerConfig.getUseBearerOnTrackEndpoint()
            };

            if (!string.IsNullOrEmpty(backupFilename))
            {
                tracker_settings.BackupFile = backupFilename;
            }

            Debug.Log("[ANALYTICS] Settings: " + JsonConvert.SerializeObject(tracker_settings));
            TrackerAsset.Instance.StrictMode = false;
            TrackerAsset.Instance.Bridge     = bridge ?? new UnityBridge();
            TrackerAsset.Instance.Settings   = tracker_settings;
            TrackerAsset.Instance.StrictMode = false;

            var done = false;

            Debug.Log("[ANALYTICS] Starting tracker without login...");
            TrackerAsset.Instance.StartAsync(() => done = true);

            this.nextFlush = config.getFlushInterval();

            Debug.Log("[ANALYTICS] Waiting until start");
            yield return(new WaitUntil(() => done));

            Debug.Log("[ANALYTICS] Start done, result: " + TrackerAsset.Instance.Started);
        }
コード例 #5
0
ファイル: Game.cs プロジェクト: dotlive/uAdventure
        private void PrepareTracker(TrackerConfig config)
        {
            string domain = "";
            int    port   = 80;
            bool   secure = false;

            try
            {
                if (config.getHost() != "")
                {
                    string[] splitted = config.getHost().Split('/');

                    if (splitted.Length > 1)
                    {
                        string[] host_splitted = splitted[2].Split(':');
                        if (host_splitted.Length > 0)
                        {
                            domain = host_splitted[0];
                            port   = (host_splitted.Length > 1) ? int.Parse(host_splitted[1]) : (splitted[0] == "https:" ? 443 : 80);
                            secure = splitted[0] == "https:";
                        }
                    }
                }
                else
                {
                    config.setHost("localhost");
                }
            }
            catch (System.Exception e)
            {
                Debug.Log("Tracker error: Host bad format");
            }

            TrackerAsset.TraceFormats format;
            switch (config.getTraceFormat())
            {
            case TrackerConfig.TraceFormat.XAPI:
                format = TrackerAsset.TraceFormats.xapi;
                break;

            default:
                format = TrackerAsset.TraceFormats.csv;
                break;
            }

            TrackerAsset.StorageTypes storage;
            switch (config.getStorageType())
            {
            case TrackerConfig.StorageType.NET:
                storage = TrackerAsset.StorageTypes.net;
                break;

            default:
                storage = TrackerAsset.StorageTypes.local;
                break;
            }

            TrackerAssetSettings tracker_settings = new TrackerAssetSettings()
            {
                Host          = domain,
                TrackingCode  = config.getTrackingCode(),
                BasePath      = "/api",
                Port          = port,
                Secure        = secure,
                StorageType   = storage,
                TraceFormat   = format,
                BackupStorage = config.getRawCopy()
            };

            TrackerAsset.Instance.Bridge   = new UnityBridge();
            TrackerAsset.Instance.Settings = tracker_settings;

            /* TODO: login disabled
             * if (!String.IsNullOrEmpty(username))
             *  TrackerAsset.Instance.Login(username, password);
             */

            TrackerAsset.Instance.Start();
            this.nextFlush = config.getFlushInterval();
        }