public override void OnApplicationPause(bool bPause) { base.OnApplicationPause(bPause); if (bPause) { PlayerPrefs.SetFloat("PlayTime", GetPlayTime()); //暂停时保存游戏时间 #if UNITY_ANDROID || UNITY_IPHONE if (CapsConfig.EnableTalkingData) { TalkingDataPlugin.SessionStoped(); } #endif } else { m_playTime = PlayerPrefs.GetFloat("PlayTime"); //恢复时读取游戏时间 m_startAppTime = Time.realtimeSinceStartup; #if UNITY_ANDROID || UNITY_IPHONE if (CapsConfig.EnableTalkingData) { TalkingDataPlugin.SessionStarted("8F604653A8CC694E6954B51FE6D26127", "Test"); } #endif } }
private void Start() { string channelName = Singleton <NetworkManager> .Instance.channelConfig.ChannelName; TalkingDataPlugin.SetLogEnabled(true); TalkingDataPlugin.SetExceptionReportEnabled(true); TalkingDataPlugin.SessionStarted("A0F361D0ACD1B1846FCEE7327ADEF913", channelName); }
void Update() { if (Input.GetKey(KeyCode.Escape)) { Application.Quit(); } #if UNITY_IPHONE TalkingDataPlugin.SetDeviceToken(); TalkingDataPlugin.HandlePushMessage(); #endif }
public override void OnApplicationQuit() { base.OnApplicationQuit(); Application.Quit(); PlayerPrefs.SetFloat("PlayTime", GetPlayTime()); #if UNITY_ANDROID || UNITY_IPHONE if (CapsConfig.EnableTalkingData) { TalkingDataPlugin.SessionStoped(); } #endif }
void Start() { Debug.Log("start...!!!!!!!!!!"); TalkingDataPlugin.SetLogEnabled(true); TalkingDataPlugin.SetExceptionReportEnabled(true); TalkingDataPlugin.SessionStarted("E7538D90715219B3A2272A3E07E69C57", "your_channel_id"); TalkingDataEAuth.SuccessDelegate successMethod = new TalkingDataEAuth.SuccessDelegate(this.OnEAuthSuccess); TalkingDataEAuth.FailedDelegate failedMethod = new TalkingDataEAuth.FailedDelegate(this.OnEAuthFailed); TalkingDataEAuth.Init("506610b4d5a142809cca181e32d70e21", "7c1573fbd1cc33d336f01838dc2d606e", successMethod, failedMethod); #if UNITY_IPHONE #if UNITY_5 || UNITY_5_6_OR_NEWER UnityEngine.iOS.NotificationServices.RegisterForNotifications( UnityEngine.iOS.NotificationType.Alert | UnityEngine.iOS.NotificationType.Badge | UnityEngine.iOS.NotificationType.Sound); #else UnityEngine.iOS.NotificationServices.RegisterForNotifications( UnityEngine.iOS.NotificationType.Alert | UnityEngine.iOS.NotificationType.Badge | UnityEngine.iOS.NotificationType.Sound); #endif #endif }
public void OnApplicationQuit() { TalkingDataPlugin.SessionStoped(); }
protected override void DoInit() { //根据平台开关数据分析 if (Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.IPhonePlayer || Application.platform == RuntimePlatform.WP8Player) { CapsConfig.EnableGA = true; CapsConfig.EnableTalkingData = true; Resources.Load("GA_SystemTracker"); } else { CapsConfig.EnableGA = false; CapsConfig.EnableTalkingData = false; } #if UNITY_ANDROID || UNITY_IPHONE if (CapsConfig.EnableTalkingData) { TalkingDataPlugin.SessionStarted("8F604653A8CC694E6954B51FE6D26127", "Test"); } #endif m_startAppTime = Time.realtimeSinceStartup; m_playTime = PlayerPrefs.GetFloat("PlayTime"); if (!PlayerPrefs.HasKey("Music")) //第一次运行 { PlayerPrefs.SetInt("Music", 1); PlayerPrefs.SetInt("SFX", 1); GlobalVars.UseMusic = true; GlobalVars.UseSFX = true; } else { GlobalVars.UseMusic = (PlayerPrefs.GetInt("Music") == 1); GlobalVars.UseSFX = (PlayerPrefs.GetInt("SFX") == 1); } Application.targetFrameRate = 60; // if (Application.platform == RuntimePlatform.WindowsPlayer) { Screen.SetResolution(480, 800, false); } new CapsConfig(); new ResourceManager(); UIDrawer.Singleton.AddPrefab(ResourceManager.Singleton.GetUIPrefabByName("BaseTextLabel")); UIDrawer.Singleton.fontDefaultPrefabID = UIDrawer.Singleton.AddPrefab(ResourceManager.Singleton.GetUIPrefabByName("OutlineTextLabel")); UIDrawer.Singleton.AddPrefab(ResourceManager.Singleton.GetUIPrefabByName("ShadowTextLabel")); UIDrawer.Singleton.spriteDefaultPrefabID = UIDrawer.Singleton.AddPrefab(ResourceManager.Singleton.GetUIPrefabByName("BaseSpriteCommonAtlas")); UIDrawer.Singleton.numDefaultPrefabID = UIDrawer.Singleton.AddPrefab(ResourceManager.Singleton.GetUIPrefabByName("BaseNumber")); TextTable.Singleton.AddTextMap(@"baseText"); TextTable.Singleton.AddTextMap(@"errorcode"); ChangeState((int)StateEnum.Login); GlobalVars.TotalStageCount = CapsConfig.Instance.TotalStageCount; if (CapsConfig.Instance.MoveTime > 0) { GameLogic.MOVE_TIME = CapsConfig.Instance.MoveTime; } if (CapsConfig.Instance.EatTime > 0) { GameLogic.EATBLOCK_TIME = CapsConfig.Instance.EatTime; } if (CapsConfig.Instance.DropAcc > 0) { GameLogic.DROP_ACC = CapsConfig.Instance.DropAcc; } if (CapsConfig.Instance.DropSpeed > 0) { GameLogic.DROP_SPEED = CapsConfig.Instance.DropSpeed; } if (CapsConfig.Instance.SlideSpeed > 0) { GameLogic.SLIDE_SPEED = CapsConfig.Instance.SlideSpeed; } GlobalVars.ReadHeart(); UIWindowManager.Singleton.CreateWindow <UILogin>(); Timer.AddDelayFunc(0.3f, delegate() { UIWindowManager.Singleton.GetUIWindow <UILogin>().ShowWindow(delegate() { GameObject obj = GameObject.Find("FirstTimeBackground"); //为了让第一次进游戏的图平滑变化没有闪烁,先在场景里垫了一张图,现在用完了,把图删除 GameObject.Destroy(obj); }); }); Localization.instance.currentLanguage = "Chinese"; //中文版 //初始化支付插件 if (Application.platform != RuntimePlatform.WindowsPlayer) { Unibiller.onBillerReady += OnUniBillInitialised; Unibiller.Initialise(); } if (Application.platform != RuntimePlatform.WP8Player) { //第一次运行时,5月份之前,送点金币 if (System.DateTime.Today.Year == 2014 && System.DateTime.Today.Month <= 5 && !PlayerPrefs.HasKey("GiveFirstTimeMoney3")) { PlayerPrefs.SetInt("GiveFirstTimeMoney3", 1); Unibiller.CreditBalance("gold", 3000); //给3000金币 } } }
public void RefreshData() { if (GameLogic.Singleton.IsStageFinish() && GameLogic.Singleton.CheckGetEnoughScore()) //检查关卡是否结束 { m_bWin = true; } else { m_bWin = false; if (GlobalVars.CurStageData.Target == GameTarget.ClearJelly) { m_infoLabel.text = Localization.instance.Get("DidNotClearIce"); } else if (GlobalVars.CurStageData.Target == GameTarget.BringFruitDown) { m_infoLabel.text = Localization.instance.Get("DidNotBringNuts"); } else if (GlobalVars.CurStageData.Target == GameTarget.Collect) { m_infoLabel.text = Localization.instance.Get("DidNotCollectEnough"); } else if (GlobalVars.CurStageData.Target == GameTarget.GetScore) //分数要求的情况 { m_infoLabel.text = Localization.instance.Get("NotEnoughScore"); } else { m_infoLabel.text = Localization.instance.Get("EndGameByHimSelf"); } } if (m_bWin) { GlobalVars.AddHeart(1); //若关卡成功,需要把之前扣的心恢复回来 } if (m_bWin) { if (GlobalVars.AvailabeStageCount == GlobalVars.CurStageNum) { if (GlobalVars.AvailabeStageCount < GlobalVars.TotalStageCount) { ++GlobalVars.AvailabeStageCount; //开启下一关 } //UIWindowManager.Singleton.GetUIWindow<UIMap>().OpenNewButton(GlobalVars.AvailabeStageCount); } for (int i = 2; i >= 0; --i) { if (GameLogic.Singleton.GetProgress() >= GlobalVars.CurStageData.StarScore[i]) { m_starCount = i + 1; break; } } if (GlobalVars.StageStarArray[GlobalVars.CurStageNum] == 0) //if it's the first time of finishing the stage { float scorePercent = (float)GameLogic.Singleton.GetProgress() / GameLogic.Singleton.PlayingStageData.StarScore[0]; if (CapsConfig.EnableGA) //游戏过关后的记录 { GA.API.Design.NewEvent("Stage" + GlobalVars.CurStageNum + ":FirstSucceed:StepLeft", GameLogic.Singleton.m_stepCountWhenReachTarget); // GA.API.Design.NewEvent("Stage" + GlobalVars.CurStageNum + ":FirstSucceed:Score_Percent", scorePercent); //记录当前开始的关卡的百分比 GA.API.Design.NewEvent("Stage" + GlobalVars.CurStageNum + ":FirstSucceed:StarCount", m_starCount); GA.API.Design.NewEvent("Stage" + GlobalVars.CurStageNum + ":FirstSucceed:FailedTimes", GlobalVars.StageFailedArray[GlobalVars.CurStageNum]); GA.API.Design.NewEvent("Stage" + GlobalVars.CurStageNum + ":FirstSucceed:PlayTime", GameLogic.Singleton.GetStagePlayTime()); } #if UNITY_ANDROID || UNITY_IPHONE if (CapsConfig.EnableTalkingData) { Dictionary <string, object> param = new Dictionary <string, object>(); if (GameLogic.Singleton.m_stepCountWhenReachTarget > 10) { param["StepLeft"] = ">10"; } else if (GameLogic.Singleton.m_stepCountWhenReachTarget > 5) { param["StepLeft"] = ">5"; } else { param["StepLeft"] = GameLogic.Singleton.m_stepCountWhenReachTarget.ToString(); } param["StarCount"] = m_starCount.ToString(); if (scorePercent > 5) { param["ScorePercent"] = ">5"; } else if (scorePercent > 3) { param["ScorePercent"] = ">3"; } else if (scorePercent > 2) { param["ScorePercent"] = ">2"; } else if (scorePercent > 1.5) { param["ScorePercent"] = ">1.5"; } else { param["ScorePercent"] = ">1"; } float playTime = GameLogic.Singleton.GetStagePlayTime(); if (playTime > 600) { param["PlayTime"] = ">10min"; } else if (playTime > 60) { param["PlayTime"] = ((int)(playTime / 60)).ToString() + "min"; } else { param["PlayTime"] = "<1min"; } int failedTimes = GlobalVars.StageFailedArray[GlobalVars.CurStageNum]; if (failedTimes > 20) { param["FailedTime"] = ">20"; } else if (failedTimes > 10) { param["PlayTime"] = ">10"; } else if (failedTimes > 5) { param["PlayTime"] = ">5"; } else { param["PlayTime"] = failedTimes.ToString(); } TalkingDataPlugin.TrackEventWithParameters("Stage" + GlobalVars.CurStageNum + ":FirstSucceed", "", param); } #endif } PlayerPrefs.SetInt("StageAvailableCount", GlobalVars.AvailabeStageCount); //保存进度 if (m_starCount > GlobalVars.StageStarArray[GlobalVars.CurStageNum - 1]) { GlobalVars.StageStarArray[GlobalVars.CurStageNum - 1] = m_starCount; //保存星数 PlayerPrefsExtend.SetIntArray("StageStars", GlobalVars.StageStarArray); //保存进度 } if (GameLogic.Singleton.GetProgress() > GlobalVars.StageScoreArray[GlobalVars.CurStageNum - 1]) //记录分数记录 { GlobalVars.StageScoreArray[GlobalVars.CurStageNum - 1] = GameLogic.Singleton.GetProgress(); PlayerPrefsExtend.SetIntArray("StageScores", GlobalVars.StageScoreArray); } UIWindowManager.Singleton.GetUIWindow <UIMap>().RefreshButtonStar(GlobalVars.CurStageNum); //刷新当前关卡的星星 UIWindowManager.Singleton.GetUIWindow <UIMap>().RefreshButton(GlobalVars.CurStageNum - 1); //刷新当前关卡的星星 } else { GlobalVars.StageFailedArray[GlobalVars.CurStageNum]++; PlayerPrefsExtend.SetIntArray("StageFailed", GlobalVars.StageFailedArray); } m_levelLabel.SetNumberRapid(GlobalVars.CurStageNum); }
void OnGUI() { int i = 0; GUI.Box(new Rect(10, 10, Screen.width - 20, Screen.height - 20), "Demo Menu"); if (GUI.Button(new Rect(left, top + step * i++, width, height), "Apply Auth Code")) { TalkingDataEAuth.ApplyAuthCode("86", mobile, TalkingDataAuthCodeType.smsAuth, account, smsId); } if (GUI.Button(new Rect(left, top + step * i++, width, height), "Reapply Auth Code")) { TalkingDataEAuth.ReapplyAuthCode("86", mobile, TalkingDataAuthCodeType.voiceCallAuth, account, smsId, request_id); } if (GUI.Button(new Rect(left, top + step * i++, width, height), "Is Verify Account")) { TalkingDataEAuth.IsVerifyAccount(account); } if (GUI.Button(new Rect(left, top + step * i++, width, height), "Is Mobile Match Account")) { TalkingDataEAuth.IsMobileMatchAccount(account, "86", mobile); } if (GUI.Button(new Rect(left, top + step * i++, width, height), "Bind")) { TalkingDataEAuth.Bind("86", mobile, "001178", account); } if (GUI.Button(new Rect(left, top + step * i++, width, height), "Unbind")) { TalkingDataEAuth.Unbind("86", mobile, account); } if (GUI.Button(new Rect(left, top + step * i++, width, height), "OnRegister")) { TalkingDataPlugin.OnRegister("user01", TalkingDataAccountType.ANONYMOUS, "abc"); } if (GUI.Button(new Rect(left, top + step * i++, width, height), "OnLogin")) { TalkingDataPlugin.OnLogin("user01", TalkingDataAccountType.TYPE1, "abc"); } if (GUI.Button(new Rect(left, top + step * i++, width, height), "OnPlaceOrder")) { TalkingDataOrder order = TalkingDataOrder.CreateOrder("order01", 2466400, "CNY"); order.AddItem("A1660", "手机", "iPhone 7", 538800, 2); order.AddItem("MLH12CH", "电脑", "MacBook Pro", 1388800, 1); TalkingDataPlugin.OnPlaceOrder("user01", order); } if (GUI.Button(new Rect(left, top + step * i++, width, height), "OnOrderPaySucc")) { TalkingDataOrder order = TalkingDataOrder.CreateOrder("order01", 2466400, "CNY"); order.AddItem("A1660", "手机", "iPhone 7", 538800, 2); order.AddItem("MLH12CH", "电脑", "MacBook Pro", 1388800, 1); TalkingDataPlugin.OnOrderPaySucc("user01", "AliPay", order); } if (GUI.Button(new Rect(left, top + step * i++, width, height), "OnViewItem")) { TalkingDataPlugin.OnViewItem("A1660", "手机", "iPhone 7", 538800); } if (GUI.Button(new Rect(left, top + step * i++, width, height), "OnAddItemToShoppingCart")) { TalkingDataPlugin.OnAddItemToShoppingCart("MLH12CH", "电脑", "MacBook Pro", 1388800, 1); } if (GUI.Button(new Rect(left, top + step * i++, width, height), "OnViewShoppingCart")) { TalkingDataShoppingCart shoppingCart = TalkingDataShoppingCart.CreateShoppingCart(); if (shoppingCart != null) { shoppingCart.AddItem("A1660", "手机", "iPhone 7", 538800, 2); shoppingCart.AddItem("MLH12CH", "电脑", "MacBook Pro", 1388800, 1); TalkingDataPlugin.OnViewShoppingCart(shoppingCart); } } if (GUI.Button(new Rect(left, top + step * i++, width, height), "TrackPageBegin")) { TalkingDataPlugin.TrackPageBegin("page_name"); } if (GUI.Button(new Rect(left, top + step * i++, width, height), "TrackPageEnd")) { TalkingDataPlugin.TrackPageEnd("page_name"); } if (GUI.Button(new Rect(left, top + step * i++, width, height), "TrackEvent")) { TalkingDataPlugin.TrackEvent("action_id"); } if (GUI.Button(new Rect(left, top + step * i++, width, height), "TrackEventWithLabel")) { TalkingDataPlugin.TrackEventWithLabel("action_id", "action_label"); } if (GUI.Button(new Rect(left, top + step * i++, width, height), "TrackEventWithParameters")) { Dictionary <string, object> dic = new Dictionary <string, object>(); dic.Add("StartApp" + "StartAppTime", "startAppMac" + "#" + "02/01/2013 09:52:24"); dic.Add("IntValue", 1); TalkingDataPlugin.TrackEventWithParameters("action_id", "action_label", dic); } }
void OnDestroy() { TalkingDataPlugin.SessionStoped(); Debug.Log("onDestroy"); }