public static void Setup( bool enable, Dictionary<string, string> parameters ) {
			if(initialized) {
				return;
			}

			initialized = true;

			if(enable == false) {
				return;
			}

			//start the SDK
			try {
				ga = GoogleAnalyticsV3.getInstance( );
				ga.StartSession( );
			}
			catch(System.Exception e) {
				UnityEngine.Debug.LogError( "Error at setup google analytics" + e );
				return;
			};

			enabled = true;
			//attach to the main events catcher for the entire session
			Analytics.trackEventListeners += TrackEvent;
			Analytics.trackScreenListeners += TrackScreen;

			//make sure the Google Analytics Class Instance is not
			//destroyed when the scene is changed.
			MonoBehaviour.DontDestroyOnLoad( ga.gameObject );
		}
    private string AddCustomVariables <T>(HitBuilder <T> builder)
    {
        if (!trackingCodeSet)
        {
            return("");
        }
        String url = "";

        foreach (KeyValuePair <int, string> entry in builder.GetCustomDimensions())
        {
            if (entry.Value != null)
            {
                url += Fields.CUSTOM_DIMENSION.ToString() + entry.Key + "=" +
                       WWW.EscapeURL(entry.Value.ToString());
            }
        }
        foreach (KeyValuePair <int, string> entry in builder.GetCustomMetrics())
        {
            if (entry.Value != null)
            {
                url += Fields.CUSTOM_METRIC.ToString() + entry.Key + "=" +
                       WWW.EscapeURL(entry.Value.ToString());
            }
        }

        if (!String.IsNullOrEmpty(url))
        {
            if (GoogleAnalyticsV3.belowThreshold(logLevel, GoogleAnalyticsV3.DebugMode.VERBOSE))
            {
                //Debug.Log("Added custom variables to hit.");
            }
        }
        return(url);
    }
Exemplo n.º 3
0
    void Start()
    {
        GoogleAnalyticsV3.getInstance().LogScreen("Failed");
        GoogleAnalyticsV3.getInstance().LogEvent("Failed", "Day" + DataPlayer.pthis.iStage, "", 1);

        StartCoroutine(OpenPage());
        // 天數.
        pLb[0].text = DataPlayer.pthis.iStage.ToString();
        // 關卡時間.
        pLb[1].text = string.Format("{0:00}:{1:00}:{2:00}", DataPlayer.pthis.iPlayTime / 3600, (DataPlayer.pthis.iPlayTime / 60) % 60, DataPlayer.pthis.iPlayTime % 60);
        // 殺怪數.
        pLb[2].text = DataPlayer.pthis.iEnemyKill.ToString();

        AudioCtrl.pthis.pMusic.volume = 0.5f;
        NGUITools.PlaySound(Resources.Load("Sound/FX/Fail") as AudioClip);

        // 比較紀錄.
        ObjRecord.SetActive(DataRecord.pthis.RecordNow());

        // 重設存檔與遊戲檔案.
        DataPlayer.pthis.Clear();
        DataGame.pthis.Clear();
        DataPickup.pthis.Clear();

        // 設為新遊戲.
        SysMain.pthis.NewRoleData();

        SysMain.pthis.SaveGame();
    }
Exemplo n.º 4
0
    // ------------------------------------------------------------------
    IEnumerator FlyToPos()
    {
        int   iCount = 1;
        float fFrame = 1;

        while (iCount <= 9)
        {
            pSprite.transform.Rotate(0, 0, -10);
            pSprite.transform.localScale = new Vector3(pSprite.transform.localScale.x + (0.01f * iCount), pSprite.transform.localScale.y + (0.01f * iCount), 1);
            iCount++;
            yield return(new WaitForEndOfFrame());
        }

        yield return(new WaitForSeconds(0.8f));

        while (Vector2.Distance(pSprite.transform.position, P_UI.pthis.ObjAmmoHeavy.transform.position) > 0.03f)
        {
            yield return(new WaitForEndOfFrame());

            ToolKit.MoveTo(gameObject, P_UI.pthis.ObjAmmoHeavy.transform.position - pSprite.transform.position, 0.8f * fFrame);
            fFrame += 0.05f;
        }

        DataPickup.pthis.Data[iItemID].bPickup = true;
        Rule.HeavyAmmoAdd(DataPickup.pthis.Data[iItemID].iCount);
        P_UI.pthis.UpdateResource();

        SysAchieve.pthis.Add(ENUM_Achievement.Total_HeavyAmmo, DataPickup.pthis.Data[iItemID].iCount);
        GoogleAnalyticsV3.getInstance().LogEvent("Count", "Pickup HeavyAmmo", "", 0);

        Destroy(gameObject);
    }
    /*
     * Make request using yield and coroutine to prevent lock up waiting on request to return.
     */
    public IEnumerator HandleWWW(WWW request)
    {
        while (!request.isDone)
        {
            yield return(request);

            if (request.responseHeaders.ContainsKey("STATUS"))
            {
                if (request.responseHeaders["STATUS"].Contains("200 OK"))
                {
                    if (GoogleAnalyticsV3.belowThreshold(logLevel, GoogleAnalyticsV3.DebugMode.INFO))
                    {
                        //Debug.Log("Successfully sent Google Analytics hit.");
                    }
                }
                else
                {
                    if (GoogleAnalyticsV3.belowThreshold(logLevel, GoogleAnalyticsV3.DebugMode.WARNING))
                    {
                        Debug.LogWarning("Google Analytics hit request rejected with " +
                                         "status code " + request.responseHeaders["STATUS"]);
                    }
                }
            }
            else
            {
                if (GoogleAnalyticsV3.belowThreshold(logLevel, GoogleAnalyticsV3.DebugMode.WARNING))
                {
                    Debug.LogWarning("Google Analytics hit request failed with error "
                                     + request.error);
                }
            }
        }
    }
    private string AddCampaignParameters <T>(HitBuilder <T> builder)
    {
        if (!trackingCodeSet)
        {
            return("");
        }
        String url = "";

        url += AddOptionalMPParameter(Fields.CAMPAIGN_NAME, builder.GetCampaignName());
        url += AddOptionalMPParameter(Fields.CAMPAIGN_SOURCE, builder.GetCampaignSource());
        url += AddOptionalMPParameter(Fields.CAMPAIGN_MEDIUM, builder.GetCampaignMedium());
        url += AddOptionalMPParameter(Fields.CAMPAIGN_KEYWORD, builder.GetCampaignKeyword());
        url += AddOptionalMPParameter(Fields.CAMPAIGN_CONTENT, builder.GetCampaignContent());
        url += AddOptionalMPParameter(Fields.CAMPAIGN_ID, builder.GetCampaignID());
        url += AddOptionalMPParameter(Fields.GCLID, builder.GetGclid());
        url += AddOptionalMPParameter(Fields.DCLID, builder.GetDclid());

        if (!String.IsNullOrEmpty(url))
        {
            if (GoogleAnalyticsV3.belowThreshold(logLevel, GoogleAnalyticsV3.DebugMode.VERBOSE))
            {
                //Debug.Log("Added campaign parameters to hit. url:" + url);
            }
        }
        return(url);
    }
Exemplo n.º 7
0
    void Awake()
    {
        googleAnalytics = GameObject.Find("GAv3").GetComponent <GoogleAnalyticsV3>();

        CM  = GameObject.Find("Manager").GetComponent <CameraManager>();
        SAM = GameObject.Find("SharkModel").GetComponent <SharkAnimManager>();
        TAM = GameObject.Find("TurtleModel").GetComponent <TurtleAnimManager>();
        FM  = GameObject.Find("Manager").GetComponent <FactManager>();
        SMC = GameObject.Find("AnimalParent").GetComponent <SharkMovementController>();

        Screen_Main       = GameObject.Find("Panel 1");
        Screen_Experience = GameObject.Find("Panel 2");

        SharkModel  = GameObject.Find("SharkModel");
        TurtleModel = GameObject.Find("TurtleModel");

        TrackingHint      = GameObject.Find("TrackingHint");
        Button_Back       = GameObject.Find("Back_Btn");
        Button_FactFinder = GameObject.Find("FactStart_Btn");
        Title_Hotspot     = GameObject.Find("Title_Hotspot");
        Button_Menu       = GameObject.Find("Menu_Btn");
        Popup_Fact        = GameObject.Find("FactPanel");

        SharkHotspots  = GameObject.Find("SharkHotSpots");
        TurtleHotspots = GameObject.Find("TurtleHotSpots");

        animalName_Lbl = GameObject.Find("AnimalName_Lbl").GetComponent <UILabel>();

        screenTween1           = Screen_Main.GetComponent <Animation>();
        screenTween2           = Screen_Experience.GetComponent <Animation>();
        dropdownmenuTween      = GameObject.Find("Dropdown").GetComponent <Animation>();
        dropdownmenu_mainTween = GameObject.Find("Main_Dropdown").GetComponent <Animation>();
        factPanelTween         = Popup_Fact.GetComponent <Animation>();
        animalSwapTween        = GameObject.Find("CharacterSelect").GetComponent <Animation>();
    }
Exemplo n.º 8
0
    // ------------------------------------------------------------------
    IEnumerator FlyToPos()
    {
        //轉加放大
        int iCount = 1;

        while (iCount <= 9)
        {
            pSprite.transform.localScale = new Vector3(pSprite.transform.localScale.x + (0.01f * iCount), pSprite.transform.localScale.y + (0.01f * iCount), 1);
            iCount++;
            yield return(new WaitForEndOfFrame());
        }
        P_UI.pthis.ShowCrystal();
        yield return(new WaitForSeconds(0.8f));

        Vector3 VecPos = P_UI.pthis.ObjCrystal.transform.position;

        float fFrame = 1;

        while (Vector2.Distance(pSprite.transform.position, VecPos) > 0.03f)
        {
            yield return(new WaitForEndOfFrame());

            ToolKit.MoveTo(gameObject, VecPos - pSprite.transform.position, 0.82f * fFrame);
            fFrame += 0.05f;
        }

        DataPickup.pthis.Data[iItemID].bPickup = true;
        P_UI.pthis.AddCrystal(DataPickup.pthis.Data[iItemID].iCount);

        SysAchieve.pthis.Add(ENUM_Achievement.Total_Crystal, DataPickup.pthis.Data[iItemID].iCount);
        GoogleAnalyticsV3.getInstance().LogEvent("Count", "Pickup Crystal", "", 0);

        Destroy(gameObject);
    }
    private void SendGaHitWithMeasurementProtocol(string url)
    {
        if (dryRun || optOut)
        {
            if (GoogleAnalyticsV3.belowThreshold(logLevel, GoogleAnalyticsV3.DebugMode.WARNING))
            {
                Debug.Log("Dry run or opt out enabled - hits will not be sent.");
            }
            return;
        }
        if (startSessionOnNextHit)
        {
            url += AddOptionalMPParameter(Fields.SESSION_CONTROL, "start");
            startSessionOnNextHit = false;
        }
        else if (endSessionOnNextHit)
        {
            url += AddOptionalMPParameter(Fields.SESSION_CONTROL, "end");
            endSessionOnNextHit = false;
        }
        // Add random z to avoid caching
        string newUrl = url + "&z=" + UnityEngine.Random.Range(0, 500);

        if (GoogleAnalyticsV3.belowThreshold(logLevel, GoogleAnalyticsV3.DebugMode.VERBOSE))
        {
            Debug.Log(newUrl);
        }
        WWW request = new WWW(newUrl);

        while (!request.isDone)
        {
        }
        if (request.responseHeaders.ContainsKey("STATUS"))
        {
            if (request.responseHeaders["STATUS"] == "HTTP/1.1 200 OK")
            {
                if (GoogleAnalyticsV3.belowThreshold(logLevel, GoogleAnalyticsV3.DebugMode.INFO))
                {
                    Debug.Log("Successfully sent Google Analytics hit.");
                }
            }
            else
            {
                if (GoogleAnalyticsV3.belowThreshold(logLevel, GoogleAnalyticsV3.DebugMode.WARNING))
                {
                    Debug.LogWarning("Google Analytics hit request rejected with" +
                                     "status code " + request.responseHeaders["STATUS"]);
                }
            }
        }
        else
        {
            if (GoogleAnalyticsV3.belowThreshold(logLevel, GoogleAnalyticsV3.DebugMode.WARNING))
            {
                Debug.LogWarning("Google Analytics hit request failed with error "
                                 + request.error);
            }
        }
    }
Exemplo n.º 10
0
 void Start()
 {
     googleAnalytics = GameObject.FindGameObjectWithTag("GoogleAnalyticsObject").GetComponent<GoogleAnalyticsV3>();
     string screenName = gameObject.name;
     if(screenName.IndexOf("(Clone)") > 0 ) screenName = screenName.Substring(0, screenName.IndexOf("(Clone)"));
     googleAnalytics.LogScreen(new AppViewHitBuilder().SetScreenName(screenName));
     GameObject.Find("GM").GetComponent<SoundControl>().CheckSoundState();
 }
Exemplo n.º 11
0
    void Start()
    {
        GoogleAnalyticsV3.getInstance().LogScreen("Stage");

        GoogleAnalyticsV3.getInstance().LogEvent("Play", "Day" + DataPlayer.pthis.iStage, "", 1);
        LbDay.text = "Day [e92121]" + DataPlayer.pthis.iStage;

        if (Rule.AppearBossStage())
        {
            pAni.Play("ShowDayBoss");
        }
    }
Exemplo n.º 12
0
 // Use this for initialization
 void Start()
 {
     if (isAnalyticsEnabled && googleAnalytics != null)
     {
         googleAnalytics.DispatchHits();
         googleAnalytics.StartSession();
     }
     else
     {
         googleAnalytics = null;
     }
 }
Exemplo n.º 13
0
 // Use this for initialization
 void Start()
 {
     if (isAnalyticsEnabled && googleAnalytics != null)
     {
         googleAnalytics.DispatchHits();
         googleAnalytics.StartSession();
     }
     else
     {
         googleAnalytics = null;
     }
 }
    public void InitializeTracker()
    {
        if (String.IsNullOrEmpty(trackingCode))
        {
            //Debug.Log("No tracking code set for 'Other' platforms - hits will not be set");
            trackingCodeSet = false;
            return;
        }
        if (GoogleAnalyticsV3.belowThreshold(logLevel, GoogleAnalyticsV3.DebugMode.INFO))
        {
            //Debug.Log("Platform is not Android or iOS - " +
            //    "hits will be sent using measurement protocol.");
        }
        screenRes = Screen.width + "x" + Screen.height;
        clientId  = SystemInfo.deviceUniqueIdentifier;
        string language = Application.systemLanguage.ToString();

        optOut = false;
#if !UNITY_WP8
        CultureInfo[] cultureInfos = CultureInfo.GetCultures(CultureTypes.AllCultures);
        foreach (CultureInfo info in cultureInfos)
        {
            if (info.EnglishName == Application.systemLanguage.ToString())
            {
                language = info.Name;
            }
        }
#endif
        try {
            url = "https://www.google-analytics.com/collect?v=1"
                  + AddRequiredMPParameter(Fields.LANGUAGE, language)
                  + AddRequiredMPParameter(Fields.SCREEN_RESOLUTION, screenRes)
                  + AddRequiredMPParameter(Fields.APP_NAME, appName)
                  + AddRequiredMPParameter(Fields.TRACKING_ID, trackingCode)
                  + AddRequiredMPParameter(Fields.APP_ID, bundleIdentifier)
                  + AddRequiredMPParameter(Fields.CLIENT_ID, clientId)
                  + AddRequiredMPParameter(Fields.APP_VERSION, appVersion);
            if (anonymizeIP)
            {
                url += AddOptionalMPParameter(Fields.ANONYMIZE_IP, 1);
            }
            if (GoogleAnalyticsV3.belowThreshold(logLevel, GoogleAnalyticsV3.DebugMode.VERBOSE))
            {
                //Debug.Log("Base URL for hits: " + url);
            }
        } catch (Exception) {
            if (GoogleAnalyticsV3.belowThreshold(logLevel, GoogleAnalyticsV3.DebugMode.WARNING))
            {
                //Debug.Log("Error building url.");
            }
        }
    }
Exemplo n.º 15
0
    void Start()
    {
        GoogleAnalyticsV3.getInstance().LogScreen("Login");
        // 選音樂.
        AudioCtrl.pthis.PlayMusic("Start", 0.9f);

        // 預先載入地圖物件.
        UITool.pthis.PreLoadMapObj(DataPlayer.pthis.iStyle);

        // 建立地圖物件.
        MapCreater.pthis.Show(0);
        // 開始行走
        CameraCtrl.pthis.LoginMove();
    }
Exemplo n.º 16
0
 private string AddRequiredMPParameter(Field parameter, string value)
 {
     if (value == null)
     {
         if (GoogleAnalyticsV3.belowThreshold(logLevel, GoogleAnalyticsV3.DebugMode.WARNING))
         {
             Debug.LogWarning("Value was null for required parameter " + parameter + ". Hit cannot be sent");
         }
         throw new ArgumentNullException();
     }
     else
     {
         return(parameter + "=" + WWW.EscapeURL(value));
     }
 }
Exemplo n.º 17
0
 void Start()
 {
     currentScore = 0f;
     text = textObject.GetComponent<Text>();
     highScore = PlayerPrefs.GetFloat("High Score", 0);
     highScoreText = highScoreTextObject.GetComponent<Text>();
     googleAnalytics = GameObject.FindGameObjectWithTag("GoogleAnalyticsObject").GetComponent<GoogleAnalyticsV3>();
     if(highScore > 0f)
     {
         Social.ReportScore((long)highScore, "CgkIsa-15KkVEAIQAQ", (bool success) =>
         {
             // handle success or failure
         });
     }
 }
Exemplo n.º 18
0
    // ------------------------------------------------------------------
    void OnClick()
    {
        // 檢查金錢是否足夠.
        if (DataPlayer.pthis.iCurrency < GameDefine.iPriceLayoff)
        {
            return;
        }

        GoogleAnalyticsV3.getInstance().LogEvent("Count", "Layoff", "", 0);

        DataPlayer.pthis.iCurrency -= GameDefine.iPriceLayoff;
        pData.pData.Layoff();

        P_UI.pthis.UpdateCurrency();
        DataPlayer.pthis.Save();
    }
Exemplo n.º 19
0
    // ------------------------------------------------------------------
    public void ChangePage(int iPage)
    {
        ObjPage[iPage].SetActive(false);
        ObjPage[iPage + 1].SetActive(true);

        if (ObjPage[iPage + 1] && ObjPage[iPage + 1].GetComponent <G_Feature>())
        {
            ObjPage[iPage + 1].GetComponent <G_Feature>().OpenPage();
        }

        if (iPage + 1 == 2)
        {
            GoogleAnalyticsV3.getInstance().LogScreen("Shop");
            ObjCrystalShop = SysUI.pthis.CreatePanel("Prefab/P_CrystalMan");
        }
    }
 private void SetLogLevel(GoogleAnalyticsV3.DebugMode logLevel) {
   switch(logLevel)
   {
     case GoogleAnalyticsV3.DebugMode.ERROR:
       handler._setLogLevel(1);
       break;
     case GoogleAnalyticsV3.DebugMode.VERBOSE:
       handler._setLogLevel(4);
       break;
     case GoogleAnalyticsV3.DebugMode.INFO:
       handler._setLogLevel(3);
       break;
     default:
       handler._setLogLevel(2);
       break;
   }
 }
Exemplo n.º 21
0
    // TODO: Error checking on initialization parameters
    private void InitializeTracker()
    {
        if (!initialized)
        {
            instance = this;

            DontDestroyOnLoad(instance);

            //Debug.Log("Initializing Google Analytics 0.1.");
#if UNITY_ANDROID && !UNITY_EDITOR
            androidTracker.SetTrackingCode(androidTrackingCode);
            androidTracker.SetAppName(productName);
            androidTracker.SetBundleIdentifier(bundleIdentifier);
            androidTracker.SetAppVersion(bundleVersion);
            androidTracker.SetDispatchPeriod(dispatchPeriod);
            androidTracker.SetSampleFrequency(sampleFrequency);
            androidTracker.SetLogLevelValue(logLevel);
            androidTracker.SetAnonymizeIP(anonymizeIP);
            androidTracker.SetDryRun(dryRun);
            androidTracker.InitializeTracker();
#elif UNITY_IPHONE && !UNITY_EDITOR
            iosTracker.SetTrackingCode(IOSTrackingCode);
            iosTracker.SetAppName(productName);
            iosTracker.SetBundleIdentifier(bundleIdentifier);
            iosTracker.SetAppVersion(bundleVersion);
            iosTracker.SetDispatchPeriod(dispatchPeriod);
            iosTracker.SetSampleFrequency(sampleFrequency);
            iosTracker.SetLogLevelValue(logLevel);
            iosTracker.SetAnonymizeIP(anonymizeIP);
            iosTracker.SetDryRun(dryRun);
            iosTracker.InitializeTracker();
#else
            mpTracker.SetTrackingCode(otherTrackingCode);
            mpTracker.SetBundleIdentifier(bundleIdentifier);
            mpTracker.SetAppName(productName);
            mpTracker.SetAppVersion(bundleVersion);
            mpTracker.SetLogLevelValue(logLevel);
            mpTracker.SetAnonymizeIP(anonymizeIP);
            mpTracker.SetDryRun(dryRun);
            mpTracker.InitializeTracker();
#endif
            initialized = true;
            SetOnTracker(Fields.DEVELOPER_ID, "GbOCSs");
        }
    }
Exemplo n.º 22
0
 // ------------------------------------------------------------------
 void OnPress(bool bIsPress)
 {
     if (bIsPress)
     {
         NGUITools.PlaySound(Resources.Load("Sound/FX/SaveRole") as AudioClip);
         if (pPlayer.iTied <= 0)
         {
             PlayerCreater.pthis.SaveRole(pPlayer.gameObject);
             Statistics.pthis.RecordResource(ENUM_Pickup.Member, 1);
             GoogleAnalyticsV3.getInstance().LogEvent("Count", "Save Member", "", 0);
             if (DataPickup.pthis.Data[iItemID] != null)
             {
                 DataPickup.pthis.Data[iItemID].bPickup = true;
             }
         }
         Destroy(gameObject);
     }
 }
Exemplo n.º 23
0
    void Awake()
    {
        InitializeTracker();

        if (sendLaunchEvent)
        {
            LogEvent("Google Analytics", "Auto Instrumentation", "Game Launch", 0);
        }

        if (UncaughtExceptionReporting)
        {
            Application.RegisterLogCallback(HandleException);
            if (GoogleAnalyticsV3.belowThreshold(logLevel, GoogleAnalyticsV3.DebugMode.VERBOSE))
            {
                Debug.Log("Enabling uncaught exception reporting.");
            }
        }
    }
Exemplo n.º 24
0
    void OnClick()
    {
        // 檢查金錢是否足夠.
        if (DataPlayer.pthis.iCurrency < GameDefine.iLightAmmoCost)
        {
            // 錢不夠要表演叭叭.
            GetComponent <Animator>().Play("CantBuy");
            return;
        }

        GoogleAnalyticsV3.getInstance().LogEvent("Count", "Buy LightAmmo", "", 0);

        NGUITools.PlaySound(P_Victory.pthis.Clip_Buy);
        DataPlayer.pthis.iCurrency -= GameDefine.iLightAmmoCost;
        Rule.LightAmmoAdd(GameDefine.iLightAmmoCount);
        P_UI.pthis.UpdateCurrency();
        P_UI.pthis.UpdateResource();
        DataPlayer.pthis.Save();
    }
Exemplo n.º 25
0
    // ------------------------------------------------------------------
    void StartBomb()
    {
        if (fCoolDown > Time.time || DataPlayer.pthis.iBomb <= 0)
        {
            return;
        }

        pBtn.isEnabled = false;

        // 播放大絕.
        SysBomb.pthis.StartBomb();

        // 計算冷卻.
        fCoolDown = Time.time + 3;

        GoogleAnalyticsV3.getInstance().LogEvent("Count", "Use Bomb", "", 0);

        StartCoroutine(CoolDown());
    }
Exemplo n.º 26
0
  void Awake() {
    if (tm != null && tm != this) {
      Destroy(gameObject);
      return;
    }

    DontDestroyOnLoad(gameObject);
    DontDestroyOnLoad(GetComponentInChildren<AppsFlyerTrackerCallbacks>());
    tm = this;

#if !UNITY_EDITOR
    googleAnalyticsV3 = GetComponent<GoogleAnalyticsV3>();
    if (!googleAnalyticsV3.isActiveAndEnabled)
      initGoogleAnalytics();

    initAppsFlyer();

#endif
  }
Exemplo n.º 27
0
    public void LogTiming(TimingHitBuilder builder)
    {
        InitializeTracker();
        if (builder.Validate() == null)
        {
            return;
        }
        if (GoogleAnalyticsV3.belowThreshold(logLevel, GoogleAnalyticsV3.DebugMode.VERBOSE))
        {
            Debug.Log("Logging timing.");
        }
#if UNITY_ANDROID && !UNITY_EDITOR
        androidTracker.LogTiming(builder);
#elif UNITY_IPHONE && !UNITY_EDITOR
        iosTracker.LogTiming(builder);
#else
        mpTracker.LogTiming(builder);
#endif
    }
Exemplo n.º 28
0
    // ------------------------------------------------------------------
    void OnClick()
    {
        // 檢查金錢是否足夠.
        if (DataPlayer.pthis.iCurrency < Rule.DmgLvMoney())
        {
            // 錢不夠要表演叭叭.
            GetComponent <Animator>().Play("CantBuy");
            return;
        }

        GoogleAnalyticsV3.getInstance().LogEvent("Count", "Buy AddDmg", "", 0);

        NGUITools.PlaySound(P_Victory.pthis.Clip_Buy);
        DataPlayer.pthis.iCurrency -= Rule.DmgLvMoney();
        DataPlayer.pthis.iDamageLv++;
        P_UI.pthis.UpdateCurrency();
        DataPlayer.pthis.Save();
        // 更新價格.
        LbMoney.text = Rule.DmgLvMoney().ToString();
    }
Exemplo n.º 29
0
    // ------------------------------------------------------------------
    void OnPress(bool bIsPress)
    {
        if (bIsPress)
        {
            NGUITools.PlaySound(Resources.Load("Sound/FX/SaveRole") as AudioClip);

            pPlayer.iTied--;
            if (pPlayer.iTied <= 0)
            {
                // 加回被抓機率.
                if (ToolKit.CatchRole.ContainsKey(pPlayer.gameObject))
                {
                    ToolKit.CatchRole[pPlayer.gameObject] += 20;
                }

                GoogleAnalyticsV3.getInstance().LogEvent("Count", "Untied Member", "", 0);
            }
            Destroy(gameObject);
        }
    }
    private void SendGaHitWithMeasurementProtocol(string url)
    {
        if (optOut)
        {
            return;
        }
        if (String.IsNullOrEmpty(url))
        {
            if (GoogleAnalyticsV3.belowThreshold(logLevel, GoogleAnalyticsV3.DebugMode.WARNING))
            {
                Debug.Log("No tracking code set for 'Other' platforms - hit will not be sent.");
            }
            return;
        }
        if (dryRun)
        {
            if (GoogleAnalyticsV3.belowThreshold(logLevel, GoogleAnalyticsV3.DebugMode.VERBOSE))
            {
                Debug.Log("Dry run or opt out enabled - hits will not be sent.");
            }
            return;
        }
        if (startSessionOnNextHit)
        {
            url += AddOptionalMPParameter(Fields.SESSION_CONTROL, "start");
            startSessionOnNextHit = false;
        }
        else if (endSessionOnNextHit)
        {
            url += AddOptionalMPParameter(Fields.SESSION_CONTROL, "end");
            endSessionOnNextHit = false;
        }
        // Add random z to avoid caching
        string newUrl = url + "&z=" + UnityEngine.Random.Range(0, 500);

        if (GoogleAnalyticsV3.belowThreshold(logLevel, GoogleAnalyticsV3.DebugMode.VERBOSE))
        {
            Debug.Log(newUrl);
        }
        GoogleAnalyticsV3.getInstance().StartCoroutine(this.HandleWWW(new WWW(newUrl)));
    }
Exemplo n.º 31
0
    // ------------------------------------------------------------------
    void Start()
    {
        GoogleAnalyticsV3.getInstance().LogScreen("Victory");

        GoogleAnalyticsV3.getInstance().LogEvent("PlayTime", "Day" + DataPlayer.pthis.iStage, "", DataGame.pthis.iStageTime);
        GoogleAnalyticsV3.getInstance().LogEvent("Victory", "Day" + DataPlayer.pthis.iStage, "", 1);

        // 天數.
        pLb[0].text = DataPlayer.pthis.iStage.ToString();
        // 關卡時間.
        pLb[1].text = string.Format("{0:00}:{1:00}:{2:00}", DataGame.pthis.iStageTime / 3600, (DataGame.pthis.iStageTime / 60) % 60, DataGame.pthis.iStageTime % 60);
        // 殺怪數.
        pLb[2].text = DataGame.pthis.iKill.ToString();
        // 殘餘人數.
        pLb[3].text = DataPlayer.pthis.MemberParty.Count.ToString();
        // 死亡人數.
        pLb[4].text = DataGame.pthis.iDead.ToString();

        AudioCtrl.pthis.PlayMusic("BG_Victory", 0.55f);
        NGUITools.PlaySound(Resources.Load("Sound/FX/Victory") as AudioClip);
    }
    public GoogleAnalyticsAdaptor()
    {
        var config = Config.Find<GoogleAnalyticsConfig>();
        if(config == null)
        {
            EngineRoot.Instance.RemoveModule(this);
            return;
        }

        ga = UnityRoot.Instance.gameObject.AddComponent<GoogleAnalyticsV3>();

        ga.IOSTrackingCode = config.IOSTrackingCode;
        ga.androidTrackingCode = config.androidTrackingCode;
        ga.otherTrackingCode = config.otherTrackingCode;
        ga.productName = config.productName;
        ga.bundleIdentifier = config.bundleIdentifier;
        ga.bundleVersion = config.bundleVersion;
        ga.sendLaunchEvent = config.sendLaunchEvent;
        ga.logLevel = GoogleAnalyticsV3.DebugMode.VERBOSE;
        ga.sendLaunchEvent = true;

        ga.StartSession();
    }
Exemplo n.º 33
0
    // ------------------------------------------------------------------
    public void OpenPage()
    {
        GoogleAnalyticsV3.getInstance().LogScreen("Member List");

        iFeature = new int[DataPlayer.pthis.MemberParty.Count];
        iEquip   = new int[DataPlayer.pthis.MemberParty.Count];

        // 有幾個人建幾個人.
        for (int i = 0; i < DataPlayer.pthis.MemberParty.Count; i++)
        {
            // 建立群組.
            ObjGroup[i]      = UITool.pthis.CreateUI(ObjGrid, "Prefab/G_ListRole");
            ObjGroup[i].name = string.Format("Role{0:000}", i);
            ObjGroup[i].GetComponent <G_ListRole>().pInfo     = pInfo;
            ObjGroup[i].GetComponent <G_ListRole>().iPlayerID = i;

            if (!DataGame.pthis.bVictory)
            {
                // 升級.
                DataPlayer.pthis.MemberParty[i].iLiveStage++;
                iFeature[i] = Rule.GainFeature(i);
                iEquip[i]   = Rule.GainEquip(i);
            }
        }

        RefreshMember();

        ObjGrid.GetComponent <UIGrid>().Reposition();

        DataGame.pthis.bVictory = true;

        Rule.AddDamageReset();
        Rule.CriticalStrikeReset();
        SysMain.pthis.SaveGame();

        StartCoroutine(StartGain());
    }
Exemplo n.º 34
0
 void Start()
 {
     I = GetComponent<GoogleAnalyticsV3>();
 }
    AddCustomVariablesAndCampaignParameters <T>(HitBuilder <T> builder)
    {
        Dictionary <AndroidJavaObject, string> parameters =
            new Dictionary <AndroidJavaObject, string>();
        AndroidJavaObject fieldName;

        foreach (KeyValuePair <int, string> entry in builder.GetCustomDimensions())
        {
            fieldName = analyticsTrackingFields.CallStatic <AndroidJavaObject>(
                "customDimension", entry.Key);
            parameters.Add(fieldName, entry.Value);
        }
        foreach (KeyValuePair <int, string> entry in builder.GetCustomMetrics())
        {
            fieldName = analyticsTrackingFields.CallStatic <AndroidJavaObject>(
                "customMetric", entry.Key);
            parameters.Add(fieldName, entry.Value);
        }

        if (parameters.Keys.Count > 0)
        {
            if (GoogleAnalyticsV3.belowThreshold(logLevel, GoogleAnalyticsV3.DebugMode.VERBOSE))
            {
                Debug.Log("Added custom variables to hit.");
            }
        }

        if (!String.IsNullOrEmpty(builder.GetCampaignSource()))
        {
            fieldName = analyticsTrackingFields.
                        GetStatic <AndroidJavaObject>("CAMPAIGN_SOURCE");
            parameters.Add(fieldName, builder.GetCampaignSource());
            fieldName = analyticsTrackingFields.
                        GetStatic <AndroidJavaObject>("CAMPAIGN_MEDIUM");
            parameters.Add(fieldName, builder.GetCampaignMedium());
            fieldName = analyticsTrackingFields.
                        GetStatic <AndroidJavaObject>("CAMPAIGN_NAME");
            parameters.Add(fieldName, builder.GetCampaignName());
            fieldName = analyticsTrackingFields.
                        GetStatic <AndroidJavaObject>("CAMPAIGN_CONTENT");
            parameters.Add(fieldName, builder.GetCampaignContent());
            fieldName = analyticsTrackingFields.
                        GetStatic <AndroidJavaObject>("CAMPAIGN_KEYWORD");
            parameters.Add(fieldName, builder.GetCampaignKeyword());
            fieldName = analyticsTrackingFields.
                        GetStatic <AndroidJavaObject>("CAMPAIGN_ID");
            parameters.Add(fieldName, builder.GetCampaignID());
            fieldName = analyticsTrackingFields.
                        GetStatic <AndroidJavaObject>("GCLID");
            parameters.Add(fieldName, builder.GetGclid());
            fieldName = analyticsTrackingFields.
                        GetStatic <AndroidJavaObject>("DCLID");
            parameters.Add(fieldName, builder.GetDclid());
            if (GoogleAnalyticsV3.belowThreshold(logLevel, GoogleAnalyticsV3.DebugMode.VERBOSE))
            {
                Debug.Log("Added campaign parameters to hit.");
            }
        }

        if (parameters.Keys.Count > 0)
        {
            return(parameters);
        }
        return(null);
    }
Exemplo n.º 36
0
 public void ShowAd()
 {
     UnityAdsHelper.ShowAd(zoneID, RewardUser);
     GoogleAnalyticsV3.getInstance().LogEvent("Count", "WatchAD", "", 0);
 }
Exemplo n.º 37
0
 void Awake()
 {
     Application.RegisterLogCallback(HandleException);
     googleAnalytics = GameObject.FindGameObjectWithTag("GoogleAnalyticsObject").GetComponent<GoogleAnalyticsV3>();
 }
Exemplo n.º 38
0
 public void InitAnalytics(GoogleAnalyticsV3 ga)
 {
     m_ga = ga;
 }
 public void SetLogLevelValue(GoogleAnalyticsV3.DebugMode logLevel)
 {
     this.logLevel = logLevel;
 }
Exemplo n.º 40
0
 // TODO: Error checking on initialization parameters
 private void InitializeTracker()
 {
     if (!initialized) {
       instance = this;
       Debug.Log("Initializing Google Analytics 0.1.");
     #if UNITY_ANDROID && !UNITY_EDITOR
       androidTracker.SetTrackingCode(androidTrackingCode);
       androidTracker.SetAppName(productName);
       androidTracker.SetBundleIdentifier(bundleIdentifier);
       androidTracker.SetAppVersion(bundleVersion);
       androidTracker.SetDispatchPeriod(dispatchPeriod);
       androidTracker.SetSampleFrequency(sampleFrequency);
       androidTracker.SetLogLevelValue(logLevel);
       androidTracker.SetAnonymizeIP(anonymizeIP);
       androidTracker.SetDryRun(dryRun);
       androidTracker.InitializeTracker();
     #elif UNITY_IPHONE && !UNITY_EDITOR
       iosTracker.SetTrackingCode(IOSTrackingCode);
       iosTracker.SetAppName(productName);
       iosTracker.SetBundleIdentifier(bundleIdentifier);
       iosTracker.SetAppVersion(bundleVersion);
       iosTracker.SetDispatchPeriod(dispatchPeriod);
       iosTracker.SetSampleFrequency(sampleFrequency);
       iosTracker.SetLogLevelValue(logLevel);
       iosTracker.SetAnonymizeIP(anonymizeIP);
       iosTracker.SetDryRun(dryRun);
       iosTracker.InitializeTracker();
     #else
       mpTracker.SetTrackingCode(otherTrackingCode);
       mpTracker.SetBundleIdentifier(bundleIdentifier);
       mpTracker.SetAppName(productName);
       mpTracker.SetAppVersion(bundleVersion);
       mpTracker.SetLogLevelValue(logLevel);
       mpTracker.SetAnonymizeIP(anonymizeIP);
       mpTracker.SetDryRun(dryRun);
       mpTracker.InitializeTracker();
     #endif
       initialized = true;
       SetOnTracker(Fields.DEVELOPER_ID, "GbOCSs");
     }
 }
Exemplo n.º 41
0
 public static bool belowThreshold(GoogleAnalyticsV3.DebugMode userLogLevel,
   GoogleAnalyticsV3.DebugMode comparelogLevel)
 {
     if (comparelogLevel == userLogLevel) {
       return true;
     } else if (userLogLevel == GoogleAnalyticsV3.DebugMode.ERROR) {
       return false;
     } else if (userLogLevel == GoogleAnalyticsV3.DebugMode.VERBOSE) {
       return true;
     } else if (userLogLevel == GoogleAnalyticsV3.DebugMode.WARNING &&
       (comparelogLevel == GoogleAnalyticsV3.DebugMode.INFO ||
       comparelogLevel == GoogleAnalyticsV3.DebugMode.VERBOSE)) {
       return false;
     } else if (userLogLevel == GoogleAnalyticsV3.DebugMode.INFO &&
       (comparelogLevel == GoogleAnalyticsV3.DebugMode.VERBOSE)) {
       return false;
     }
     return true;
 }
Exemplo n.º 42
0
 // ------------------------------------------------------------------
 void Start()
 {
     GoogleAnalyticsV3.getInstance().LogScreen("AddMember");
     UpdateCurrency();
 }
Exemplo n.º 43
0
 void Start()
 {
     GoogleAnalyticsV3.getInstance().LogScreen("Copyright");
     SysMain.pthis.ReadyStart();
 }
Exemplo n.º 44
0
    void Start()
    {
        aSources = gameObject.GetComponents<AudioSource>();
        aliveScript = gameObject.GetComponent<AliveScript>();
        animator = gameObject.GetComponent<Animator>();
        spriteRenderer = gameObject.GetComponent<SpriteRenderer>();
        if (playerSpeed != startPlayerSpeed) playerSpeed = startPlayerSpeed;

        spriteRenderer.color = new Color(0.6f, 0.6f, 0.6f, 1f);
        DrawLives();
        lifeIcons = GameObject.FindGameObjectsWithTag("LifeIcon");
        googleAnalytics = GameObject.FindGameObjectWithTag("GoogleAnalyticsObject").GetComponent<GoogleAnalyticsV3>();
        googleAnalytics.LogEvent(new EventHitBuilder().SetEventCategory("Level Start").SetEventAction("Level Started"));
        timeFromStart = Time.time;
    }
 private void SetLogLevel(GoogleAnalyticsV3.DebugMode logLevel)
 {
     using (logger = googleAnalyticsSingleton.
     Call<AndroidJavaObject>("getLogger"))
     using (AndroidJavaClass log = new AndroidJavaClass(
     "com.google.analytics.tracking.android.Logger$LogLevel")) {
       switch(logLevel)
       {
     case GoogleAnalyticsV3.DebugMode.ERROR:
       using (AndroidJavaObject level =
           log.GetStatic<AndroidJavaObject>("ERROR")){
         logger.Call("setLogLevel", level);
       }
       break;
     case GoogleAnalyticsV3.DebugMode.VERBOSE:
       using (AndroidJavaObject level =
           log.GetStatic<AndroidJavaObject>("VERBOSE")){
         logger.Call("setLogLevel", level);
       }
       break;
     case GoogleAnalyticsV3.DebugMode.INFO:
       using (AndroidJavaObject level =
           log.GetStatic<AndroidJavaObject>("INFO")){
         logger.Call("setLogLevel", level);
       }
       break;
     default:
       using (AndroidJavaObject level =
           log.GetStatic<AndroidJavaObject>("WARNING")){
         logger.Call("setLogLevel", level);
       }
       break;
       }
     }
 }
Exemplo n.º 46
0
    public void Init()
    {
        sessionId = guid();

        PLAYER_FILE = Application.persistentDataPath + Path.DirectorySeparatorChar + "User";
        TUTORIAL_ONE_FILE = Application.persistentDataPath + Path.DirectorySeparatorChar + "Tut1";
        TUTORIAL_ONE_REPEAT_FILE = Application.persistentDataPath + Path.DirectorySeparatorChar + "Tut1Repeat";
        TUTORIAL_TWO_FILE = Application.persistentDataPath + Path.DirectorySeparatorChar + "Tut2";
        FEEDBACK_FILE = Application.persistentDataPath + Path.DirectorySeparatorChar + "Fdbk";
        VIEW_COUNT_FILE = Application.persistentDataPath + Path.DirectorySeparatorChar + "VC";

        try {
            gav3 = GetComponent<GoogleAnalyticsV3> ();

            if (Application.isEditor) {
                gav3.androidTrackingCode = gav3.otherTrackingCode = preProdTrackingCode;
            }
        } catch (System.Exception e) {
            LogException("Error setting up gav3", false);
        }

        // check and register repeat user
        if (File.Exists(PLAYER_FILE)) {
            try {
                var sr = new StreamReader(PLAYER_FILE);
                userId = sr.ReadLine();
                if (userId != null && !userId.Trim().Equals("")) {
                    sessionCount = int.Parse(sr.ReadLine());
                }
                sessionCount++;
                sr.Close();
            } catch (System.Exception e) {
                LogException("Error reading player file", false);
            }

            try {
                var sw = new StreamWriter(PLAYER_FILE);
                sw.Write(userId + "\n" + sessionCount);
                sw.Close();
            } catch (System.Exception e) {
                LogException("Error writing player file for new user", false);
            }

            LogEvent("Application", "ReturnUser");
        //			LogEvent("Application", "SessionCount:" + sessionCount);
            gav3.LogEvent( new EventHitBuilder().SetEventCategory("Application:"+sessionId).SetEventAction("SessionCount:" + sessionCount) );
        } else {
            firstTimeUser = true;
        }

        // else assign userId (even if file is corrupted)
        if (userId == null || userId.Trim().Equals("")) {
            userId = "U" + guid();
            sessionCount = 1;

            try {
                var sw = new StreamWriter(PLAYER_FILE);
                sw.Write(userId + "\n" + sessionCount);
                sw.Close();
            } catch (System.Exception e) {
                LogException("Error writing player file for new/null user", false);
            }
            firstTimeUser = true;
        }

        tutorialOneFinished = File.Exists (TUTORIAL_ONE_FILE);
        tutorialOneRepeatFinished = File.Exists (TUTORIAL_ONE_REPEAT_FILE);
        tutorialTwoFinished = File.Exists (TUTORIAL_TWO_FILE);
        feedbackFinished = File.Exists (FEEDBACK_FILE);

        if (File.Exists (VIEW_COUNT_FILE)) {
            try {
                var sr = new StreamReader(VIEW_COUNT_FILE);
                monoViewCount = int.Parse(sr.ReadLine());
                string svc = sr.ReadLine();
                stereoViewCount = (svc != null && !svc.Trim().Equals("") ? int.Parse(svc) : 0);
                string sivc = sr.ReadLine();
                stereoImgViewCount = (sivc != null && !sivc.Trim().Equals("") ? int.Parse(sivc) : 0);
                sr.Close();
            } catch (System.Exception e) {
                LogException("Error reading view count file", false);
            }
        }

        // register session with timestamp
        System.TimeSpan t = System.DateTime.UtcNow - new System.DateTime(1970, 1, 1);
        double secondsSinceEpoch = t.TotalSeconds;
        if (gav3) {
            gav3.LogEvent( new EventHitBuilder().SetEventCategory("UserSessions").SetEventAction(userId).SetEventValue(1) );
            gav3.LogEvent( new EventHitBuilder().SetEventCategory("Sessions").SetEventAction(secondsSinceEpoch + ":" + gav3.bundleVersion + ":" + userId + ":" + sessionId) );
        }
        LogEvent("Application", "Platform-" + Application.platform);

        ready = true;
    }