Data object representing an analytics event. Useful for bundling data to be passed to an IEventReporter.
示例#1
0
            public static void TrackUserActionAsync( AnalyticsEvent action )
            {
                if ( IsEnabled && UserActionTrackingHandler != null )
                {
#if FX40
                System.Threading.Tasks.Task.Factory.StartNew( () =>
                {
                    UserActionTrackingHandler( action );
                } );
#else
                    UserActionTrackingHandler.BeginInvoke( action, new AsyncCallback( r => { } ), null );
#endif
                }
            }
示例#2
0
		public void TrackEvent(ActionValue actionValue, string name, int value = 0)
		{
			//if (!_init)
			//{
			//    _collector.Initialize(_dictionary);
			//    _init = true;
			//}

			var analyticsEvent = new AnalyticsEvent()
			{
				Category = Category.AppEvents.ToString(),
				ActionValue = actionValue.ToString(),
				Name = name,
				Value = value,
				ObjectType = GetType().Name
			};

			this.Log(analyticsEvent);
			//_collector.Log(analyticsEvent);

			// AppName
			//ClipContext Clip
			// ContentId
			//Uri DocumentUri
			//Collection<PropertyValue> EventArgs
			//HitType HitType
			//InstallState InstallState
			//bool IsFullScreen
			// Language
			//Uri MediaSource
			//MediaStreamType? MediaStreamType
			//TimeSpan MediaTimeCode
			// NavigationState
			// ObjectName
			// ObjectType
			// Referrer
			//Size Resolution
			// SilverlightVersion
			// StateName
			//TimeSpan TimeCode
			//DateTimeOffset Timestamp
			//TrackInfo Track
			// UserAgent
			// Version
			//double ZoomFactor
		}
示例#3
0
        private void ProcessQueryString(string querystring)
        {
            // Parse the query string variables into a NameValueCollection.
            var qscoll = HttpUtility.ParseQueryString(querystring);

            var sessionId = qscoll["ssid"];
            qscoll.Remove("ssid");

            var list = new SortedSet<AnalyticsEvent>();
            for (var i = 0; i < qscoll.Count; i += 3)
            {
                var analyticsEvent = new AnalyticsEvent(qscoll[i], qscoll[i + 1], qscoll[i + 2]);
                list.Add(analyticsEvent);
            }

            Console.WriteLine(_i++);
            //            Console.WriteLine(sessionId);
            var ruleEngineInput = new RuleEngineInput("TODO", sessionId, list);
            _ruleEngine.ProcessAnalyticsEvents(ruleEngineInput);
        }
示例#4
0
 public void ShopTriggered()
 {
     AnalyticsEvent.ScreenVisit("Shop");
     gameState.cameraView = GameStateScriptableObject.CameraView.Shop;
 }
示例#5
0
        private void TrackPreferenceInternal(string name, string stringValue, int?metricValue)
        {
            var e = AnalyticsEvent.Create(Categories.Preferences.ToString(), name, stringValue, metricValue);

            e.Track();
        }
 public void TutorialStep(int aStepIndex, string aTutorialId, IDictionary <string, object> aDictionary = null)
 {
     AnalyticsEvent.TutorialStep(aStepIndex, aTutorialId, aDictionary ?? new Dictionary <string, object>());
 }
    public IEnumerator Begin()
    {
        if (!m_Rerun)
        {
            firstObstacle       = true;
            m_CameraOriginalPos = Camera.main.transform.position;

            if (m_TrackSeed != -1)
            {
                Random.InitState(m_TrackSeed);
            }
            else
            {
                Random.InitState((int)System.DateTime.Now.Ticks);
            }

            // Since this is not a rerun, init the whole system (on rerun we want to keep the states we had on death)
            m_CurrentSegmentDistance = k_StartingSegmentDistance;
            m_TotalWorldDistance     = 0.0f;

            characterController.gameObject.SetActive(true);

            //Addressables 1.0.1-preview
            // Spawn the player
            var op = Addressables.InstantiateAsync(PlayerData.instance.characters[PlayerData.instance.usedCharacter],
                                                   Vector3.zero,
                                                   Quaternion.identity);
            yield return(op);

            if (op.Result == null || !(op.Result is GameObject))
            {
                Debug.LogWarning(string.Format("Unable to load character {0}.", PlayerData.instance.characters[PlayerData.instance.usedCharacter]));
                yield break;
            }
            Character player = op.Result.GetComponent <Character>();

            player.SetupAccesory(PlayerData.instance.usedAccessory);

            characterController.character    = player;
            characterController.trackManager = this;

            characterController.Init();
            characterController.CheatInvincible(invincible);

            //Instantiate(CharacterDatabase.GetCharacter(PlayerData.instance.characters[PlayerData.instance.usedCharacter]), Vector3.zero, Quaternion.identity);
            player.transform.SetParent(characterController.characterCollider.transform, false);
            Camera.main.transform.SetParent(characterController.transform, true);

            if (m_IsTutorial)
            {
                m_CurrentThemeData = tutorialThemeData;
            }
            else
            {
                m_CurrentThemeData = ThemeDatabase.GetThemeData(PlayerData.instance.themes[PlayerData.instance.usedTheme]);
            }

            m_CurrentZone         = 0;
            m_CurrentZoneDistance = 0;

            skyMeshFilter.sharedMesh = m_CurrentThemeData.skyMesh;
            RenderSettings.fogColor  = m_CurrentThemeData.fogColor;
            RenderSettings.fog       = true;

            gameObject.SetActive(true);
            characterController.gameObject.SetActive(true);
            characterController.coins   = 0;
            characterController.premium = 0;

            m_Score      = 0;
            m_ScoreAccum = 0;

            m_SafeSegementLeft = m_IsTutorial ? 0 : k_StartingSafeSegments;

            Coin.coinPool = new Pooler(currentTheme.collectiblePrefab, k_StartingCoinPoolSize);

            PlayerData.instance.StartRunMissions(this);

#if UNITY_ANALYTICS
            AnalyticsEvent.GameStart(new Dictionary <string, object>
            {
                { "theme", m_CurrentThemeData.themeName },
                { "character", player.characterName },
                { "accessory", PlayerData.instance.usedAccessory >= 0 ? player.accessories[PlayerData.instance.usedAccessory].accessoryName : "none" }
            });
#endif
        }

        characterController.Begin();
        StartCoroutine(WaitToStart());
        isLoaded = true;
    }
示例#8
0
    public override void Tick()
    {
        if (m_Finished)
        {
            //游戏结束,检查广告是否播放完毕,如果广告还没播放完毕,允许显示关闭广告按钮
#if UNITY_ADS
            if (!m_AdsInitialised && Advertisement.IsReady(adsPlacementId))
            {
                adsForLifeButton.SetActive(true);
                m_AdsInitialised = true;
#if UNITY_ANALYTICS
                AnalyticsEvent.AdOffer(adsRewarded, adsNetwork, adsPlacementId, new Dictionary <string, object>
                {
                    { "level_index", PlayerData.instance.rank },
                    { "distance", TrackManager.instance == null ? 0 : TrackManager.instance.worldDistance },
                });
#endif
            }
            else if (!m_AdsInitialised)
            {
                adsForLifeButton.SetActive(false);
            }
#else
            adsForLifeButton.SetActive(false); //Ads is disabled
#endif

            return;
        }

        CharacterInputController chrCtrl = trackManager.characterController;

        m_TimeSinceStart += Time.deltaTime;

        if (chrCtrl.currentLife <= 0)
        {
            pauseButton.gameObject.SetActive(false);
            chrCtrl.CleanConsumable();
            chrCtrl.character.animator.SetBool(s_DeadHash, true);
            chrCtrl.characterCollider.koParticle.gameObject.SetActive(true);
            StartCoroutine(WaitForGameOver());
        }

        // 消耗品计时和生命管理
        List <Consumable>  toRemove     = new List <Consumable>();
        List <PowerupIcon> toRemoveIcon = new List <PowerupIcon>();

        for (int i = 0; i < chrCtrl.consumables.Count; ++i)
        {
            PowerupIcon icon = null;
            for (int j = 0; j < m_PowerupIcons.Count; ++j)
            {
                if (m_PowerupIcons[j].linkedConsumable == chrCtrl.consumables[i])
                {
                    icon = m_PowerupIcons[j];
                    break;
                }
            }

            chrCtrl.consumables[i].Tick(chrCtrl);
            if (!chrCtrl.consumables[i].active)
            {
                toRemove.Add(chrCtrl.consumables[i]);
                toRemoveIcon.Add(icon);
            }
            else if (icon == null)
            {
                // 如果没有可以用的消耗品prefabs则创建它
                GameObject o = Instantiate(PowerupIconPrefab);
                icon = o.GetComponent <PowerupIcon>();

                icon.linkedConsumable = chrCtrl.consumables[i];
                icon.transform.SetParent(powerupZone, false);

                m_PowerupIcons.Add(icon);
            }
        }

        for (int i = 0; i < toRemove.Count; ++i)
        {
            toRemove[i].Ended(trackManager.characterController);

            Destroy(toRemove[i].gameObject);
            if (toRemoveIcon[i] != null)
            {
                Destroy(toRemoveIcon[i].gameObject);
            }

            chrCtrl.consumables.Remove(toRemove[i]);
            m_PowerupIcons.Remove(toRemoveIcon[i]);
        }

        UpdateUI();

        currentModifier.OnRunTick(this);
    }
示例#9
0
        private object TriggerReceiver(VideoOS.Platform.Messaging.Message message, FQID dest, FQID sender)
        {
            try
            {
                if (dest != null && dest.Kind == _kind)
                {
                    string userSID = "";
                    if (sender != null && sender.Kind == Kind.User)
                    {
                        userSID = sender.ObjectIdString;                                                        // Get hold of the user executing the command
                    }
                    String command = message.Data as String;
                    Item   item    = GetItem(dest);

                    if (command != null && item != null)
                    {
                        // We have selected to use the "Manage" tick-mark for these operations:  ("Manage" is stored as "GENERIC_WRITE")
                        if (userSID == null)
                        {
                            SecurityAccess.CheckPermission(item, "GENERIC_WRITE");
                        }
                        else
                        {
                            SecurityAccess.CheckPermission(item, "GENERIC_WRITE", userSID);
                        }

                        if (command == "ACTIVATESENSOR")
                        {
                            EnvironmentManager.Instance.Log(false, "SensorMonitor", "Activate sensor" + command, null);
                            SensorItem.SensorActiveState[item.FQID.ObjectId] = true;
                            EventServerControl.Instance.ItemStatusChanged(item);

                            FQID cameraFQID = null;
                            if (item.Properties.ContainsKey("RelatedFQID"))
                            {
                                cameraFQID = new FQID(item.Properties["RelatedFQID"]);
                            }
                            EventHeader eventHeader = new EventHeader()
                            {
                                ID        = Guid.NewGuid(),
                                Class     = "Operational",
                                Type      = "SensorState",
                                Timestamp = DateTime.Now,
                                Message   = SensorMonitorControllerItemManager.SensorActiveMessage,
                                Name      = item.Name,
                                Source    = new EventSource {
                                    FQID = item.FQID, Name = item.Name
                                },
                                CustomTag = "<My><MiniXml>Sensor info</MiniXml></My>"
                            };
                            AnalyticsEvent eventData = new AnalyticsEvent
                            {
                                EventHeader = eventHeader,
                            };
                            if (cameraFQID != null)
                            {
                                eventData.ReferenceList = new ReferenceList();
                                eventData.ReferenceList.Add(new Reference()
                                {
                                    FQID = cameraFQID
                                });                                                                             // Ensure that camera will be presented in the preview
                            }
                            EnvironmentManager.Instance.SendMessage(new VideoOS.Platform.Messaging.Message(MessageId.Server.NewEventCommand)
                            {
                                Data = eventData, RelatedFQID = cameraFQID
                            });
                        }
                        if (command == "DEACTIVATESENSOR")
                        {
                            EnvironmentManager.Instance.Log(false, "SensorMonitor", "Deactive sensor " + command, null);
                            SensorItem.SensorActiveState[item.FQID.ObjectId] = false;
                            EventServerControl.Instance.ItemStatusChanged(item);

                            FQID cameraFQID = null;
                            if (item.Properties.ContainsKey("RelatedFQID"))
                            {
                                cameraFQID = new FQID(item.Properties["RelatedFQID"]);
                            }
                            EventHeader eventHeader = new EventHeader()
                            {
                                ID        = Guid.NewGuid(),
                                Class     = "Operational",
                                Type      = "SensorState",
                                Timestamp = DateTime.Now,
                                Message   = SensorMonitorControllerItemManager.SensorPassiveMessage,
                                Name      = item.Name,
                                Source    = new EventSource {
                                    FQID = item.FQID, Name = item.Name
                                },
                                CustomTag = "<My><MiniXml>Some other info</MiniXml></My>"
                            };
                            AnalyticsEvent eventData = new AnalyticsEvent
                            {
                                EventHeader = eventHeader,
                            };
                            if (cameraFQID != null)
                            {
                                eventData.ReferenceList = new ReferenceList();
                                eventData.ReferenceList.Add(new Reference()
                                {
                                    FQID = cameraFQID
                                });                                                                             // Ensure that camera will be presented in the preview
                            }
                            EnvironmentManager.Instance.SendMessage(new VideoOS.Platform.Messaging.Message(MessageId.Server.NewEventCommand)
                            {
                                Data = eventData, RelatedFQID = cameraFQID
                            });
                        }
                    }
                }
            }
            catch (NotAuthorizedMIPException)
            {
                throw;
            }
            catch (Exception ex)
            {
                EnvironmentManager.Instance.Log(false, "SensorMonitor", "SensorMonitor-9 " + ex.Message, new[] { ex });
                //User not authorized to perform the action
            }
            return(null);
        }
        public virtual void LogEventLocally(AnalyticsEvent _event)
        {
            if (!CollectAnalytics || !LogAnalyticsLocally)
            {
                return;
            }
            if (!Directory.Exists(localLogFolderPath))
            {
                Directory.CreateDirectory(localLogFolderPath);
            }
            currentLogFilePath = localLogFolderPath + Path.DirectorySeparatorChar + "Analytics " + SessionNumber + ".txt";
            string[]     currentLogFileLines = new string[1];
            string       dataColumn;
            StreamWriter writer = null;

            if (File.Exists(currentLogFilePath))
            {
                currentLogFileLines = File.ReadAllLines(currentLogFilePath);
                File.Delete(currentLogFilePath);
                writer = File.CreateText(currentLogFilePath);
                string currentLogFileLine = "";
                string dataValue;
                for (int i = 0; i < dataColumns.Length; i++)
                {
                    dataColumn = dataColumns[i].name;
                    columnData.TryGetValue(dataColumn, out dataValue);
                    if (dataValue == null)
                    {
                        dataValue = "";
                    }
                    else
                    {
                        currentLogFileLine += dataValue;
                    }
                    for (int i2 = dataValue.Length; i2 < MAX_STRING_LENGTH; i2++)
                    {
                        currentLogFileLine += FILLER_CHARACTER;
                    }
                    currentLogFileLine += VALUE_SEPERATOR;
                }
                currentLogFileLines = currentLogFileLines.Add(currentLogFileLine);
                foreach (string line in currentLogFileLines)
                {
                    writer.Write("\n" + line);
                }
            }
            else
            {
                writer = File.CreateText(currentLogFilePath);
                for (int i = 0; i < dataColumns.Length; i++)
                {
                    dataColumn              = dataColumns[i].name;
                    currentLogFileLines[0] += dataColumn;
                    for (int i2 = dataColumn.Length; i2 < MAX_STRING_LENGTH; i2++)
                    {
                        currentLogFileLines[0] += FILLER_CHARACTER;
                    }
                    currentLogFileLines[0] += VALUE_SEPERATOR;
                }
                writer.Write(currentLogFileLines[0]);
            }
            writer.Close();
            writer.Dispose();
        }
示例#11
0
 public void IAPTransaction(string aTransactionContext, string aCurrency, int aPriceInt, float aPriceFloat, string aItemId)
 {
     AnalyticsEvent.IAPTransaction(aTransactionContext, aPriceFloat, aItemId);
     GameAnalytics.NewBusinessEventGooglePlay(aCurrency, aPriceInt, "shop_item", aItemId, aTransactionContext, null, null);
 }
示例#12
0
 public AnalyticsEventDomain ToDomain(AnalyticsEvent analyticsEvent)
 {
     return(_mapper.Map <AnalyticsEventDomain>(analyticsEvent));
 }
示例#13
0
 public void AdComplete(bool aIsRewarded, string aNetwork)
 {
     AnalyticsEvent.AdComplete(aIsRewarded, aNetwork);
 }
示例#14
0
 public void AdStart(bool aIsRewarded, string aNetwork)
 {
     AnalyticsEvent.AdStart(aIsRewarded, aNetwork);
 }
示例#15
0
 public void TutorialSkip(string aTutorialId, IDictionary <string, object> aDictionary = null)
 {
     AnalyticsEvent.TutorialSkip(aTutorialId, aDictionary ?? new Dictionary <string, object>());
 }
示例#16
0
    private void OnEnable()
    {
#if UNITY_ANALYTICS
        AnalyticsEvent.StoreOpened(StoreType.Premium);
#endif
    }
示例#17
0
    public void Die()
    {
        if (GetComponent <GameManager>().player.started)
        {
            dead = true;

            deathCount++;
            if (score >= ChangeBgEvery)
            {
                GetComponent <GameManager>().player.rb.gameObject.GetComponent <Collider2D>().isTrigger = true;
            }
            PlayerPrefs.SetInt("deathCount", deathCount);

            //Platforms[] all_platforms = FindObjectsOfType<Platforms>();
            foreach (Platforms plat in all_platforms)
            {
                if (plat != null)
                {
                    plat.gameObject.SetActive(true);
                    //Destroy(plat);
                }
            }
            BoxCollider2D[] Colliders = FindObjectsOfType <BoxCollider2D>();
            foreach (BoxCollider2D col in Colliders)
            {
                if (col.gameObject.name == "Platform" || col.gameObject.name == "Right" || col.gameObject.name == "Left")
                {
                    col.isTrigger = true;
                }
            }
            GetComponent <GameManager>().player.rb.constraints = RigidbodyConstraints2D.None;
            //player.rb.gameObject.transform.rotation = Quaternion.RotateTowards(player.rb.gameObject.transform.rotation,Quaternion.Euler(new Vector3(0,0,-99)), 500 * Time.deltaTime);
            GetComponent <GameManager>().player.rb.AddTorque(diePower, ForceMode2D.Impulse);
            GetComponent <GameManager>().EndScreen.SetActive(true);
            GetComponent <GameManager>().GameScreen.SetActive(false);
            GetComponent <GameManager>().EndScoreText.text = score.ToString();

            if (PlayerPrefs.GetInt("HScore", 0) < score)
            {
                PlayerPrefs.SetInt("HScore", score);
                GetComponent <GameManager>().BestScoreText.text = "new best";
                AnalyticsEvent.Custom("new_best", new Dictionary <string, object>
                {
                    { "score_id", "score" },
                    { "value", score }
                });
                HighScoreBeaten();
            }
            else
            {
                GetComponent <GameManager>().BestScoreText.text = "best score: " + PlayerPrefs.GetInt("HScore", 0);
            }
            GetComponent <GameManager>().you_died.OpenCloseObjectAnimation();
            GetComponent <GameManager>().restart_btn.OpenCloseObjectAnimation();
            GetComponent <GameManager>().new_best.OpenCloseObjectAnimation();
            //#if UNITY_IPHONE

            /*if (Social.localUser.authenticated && authenticated) {
             *  GetComponent<GameManager>().leaderboardBtn.SetActive(true);
             * }*/
            //#endif
            flash = true;
            GetComponent <GameManager>().myCG.alpha = 1;
            if (deathCount != 0 && deathCount % 3 == 0)
            {
                GetComponent <AdManager>().ShowInterstitial();
                Debug.Log("Interstial Now");
            }
            StartCoroutine(ShareScreenshot());
        }
    }
示例#18
0
 void Start()
 {
     if (NPC1.GetComponent <NPCScript>().playingLevel < 30)
     {
         AnalyticsEvent.LevelStart("level_index", NPC1.GetComponent <NPCScript>().playingLevel + 1);
     }
     timeStart = Time.fixedTime;
     Paused    = true;
     Source.Stop();
     if (PlayerPrefs.GetInt("Language") == 0)
     {
         continueP.text  = "Continuar";
         menuP.text      = "Menú";
         restartP.text   = "Reiniciar";
         exitP.text      = "Salir";
         menuE.text      = "Menú";
         restartE.text   = "Reiniciar";
         exitE.text      = "Salir";
         nextLevelE.text = "Siguiente nivel";
         loadingM.text   = "Cargando...";
         if (NPC1.GetComponent <NPCScript>().playingLevel == 31)
         {
             Hcongrats.text = "Has conseguido entrar en el top 10. \n¡Felicidades!";
             Hinitials.text = "3 iniciales";
             Hsave.text     = "Guardar";
         }
     }
     else if (PlayerPrefs.GetInt("Language") == 1)
     {
         continueP.text  = "Continue";
         menuP.text      = "Menu";
         restartP.text   = "Restart";
         exitP.text      = "Exit";
         menuE.text      = "Menu";
         restartE.text   = "Restart";
         exitE.text      = "Exit";
         nextLevelE.text = "Next level";
         loadingM.text   = "Loading...";
         if (NPC1.GetComponent <NPCScript>().playingLevel == 31)
         {
             Hcongrats.text = "You entered the top 10. \nCongratulations!";
             Hinitials.text = "3 initials";
             Hsave.text     = "Save";
         }
     }
     else if (PlayerPrefs.GetInt("Language") == 2)
     {
         continueP.text  = "Jarraitu";
         menuP.text      = "Menua";
         restartP.text   = "Berrabiatu";
         exitP.text      = "Irten";
         menuE.text      = "Menua";
         restartE.text   = "Berrabiatu";
         exitE.text      = "Irten";
         nextLevelE.text = "Hurrengo nibela";
         loadingM.text   = "Kargatzen...";
         if (NPC1.GetComponent <NPCScript>().playingLevel == 31)
         {
             Hcongrats.text = "Top 10ean sartzea lortu duzu. \nZorionak!";
             Hinitials.text = "3 inizial";
             Hsave.text     = "Gorde";
         }
     }
 }
    private void InitBlocks()
    {
        int           currentLevelNumber = levelLoader.GetCurrentLevelNumber();
        List <string> blockTexts         = new List <string>();
        List <string> blockTypes         = new List <string>();

        SetBoardType(currentLevelNumber);
        CreateBlocks();
        AnalyticsEvent.LevelStart(currentLevelNumber);
        if (StorageController.IsBlocksSaved(currentLevelNumber) && levelLoader.GetCurrentSceneName() != Constants.SCENE_NAME.TUTORIAL)
        {
            speicalBlockController.SetSpeicialBlocks(speicalBlocks, false);
            blockTexts = StorageController.LoadBlocksText(currentLevelNumber);
            blockTypes = StorageController.LoadBlocksType(currentLevelNumber);

            for (int i = 0; i < blocks.Count; i++)
            {
                GameObject clonedBlock = blocks[i];
                Block      tmpBlock    = clonedBlock.GetComponent <Block>();

                string blockType = "";
                if (i < blockTypes.Count)
                {
                    blockType = blockTypes[i];
                }

                if (i == 0)
                {
                    tmpBlock.isClickable = true;
                }

                if (blockType != string.Empty)
                {
                    tmpBlock.SetBlockType(blockTypes[i]);
                    tmpBlock.SetTooltipInfo();
                }

                if (i < blockTexts.Count)
                {
                    tmpBlock.blockText.text = blockTexts[i];
                    // tmpBlock.SetBlocksValue(false);
                }
            }

            SetBlocksValue(false);
        }
        else
        {
            Debug.Log("Save");
            SetBlocksValue(true);
            foreach (GameObject clonedBlock in blocks)
            {
                Block tmpBlock = clonedBlock.GetComponent <Block>();
                // tmpBlock.SetBlocksValue();
            }
            speicalBlockController.SetSpeicialBlocks(speicalBlocks);

            foreach (GameObject clonedBlock in blocks)
            {
                Block tmpBlock = clonedBlock.GetComponent <Block>();
                blockTypes.Add(tmpBlock.blocksType);
                blockTexts.Add(tmpBlock.blockText.text);
            }

            StorageController.SaveBlocksType(currentLevelNumber, blockTypes);
            StorageController.SaveBlocksText(currentLevelNumber, blockTexts);
        }
    }
示例#20
0
    public void Begin()
    {
        if (!m_Rerun)
        {
            if (m_TrackSeed != -1)
            {
                Random.InitState(m_TrackSeed);
            }
            else
            {
                Random.InitState((int)System.DateTime.Now.Ticks);
            }

            // Since this is not a rerun, init the whole system (on rerun we want to keep the states we had on death)
            m_CurrentSegmentDistance = k_StartingSegmentDistance;
            m_TotalWorldDistance     = 0.0f;

            characterController.gameObject.SetActive(true);

            // Spawn the player
            Character player = Instantiate(CharacterDatabase.GetCharacter(PlayerData.instance.characters[PlayerData.instance.usedCharacter]), Vector3.zero, Quaternion.identity);
            var       mesh   = player.GetComponentInChildren <SkinnedMeshRenderer>();
            Instantiate(ElonPrefab, mesh.transform);
            mesh.enabled = false;

            player.transform.SetParent(characterController.characterCollider.transform, false);
            Camera.main.transform.SetParent(characterController.transform, true);


            player.SetupAccesory(PlayerData.instance.usedAccessory);

            characterController.character    = player;
            characterController.trackManager = this;

            characterController.Init();
            characterController.CheatInvincible(invincible);

            m_CurrentThemeData    = ThemeDatabase.GetThemeData(PlayerData.instance.themes[PlayerData.instance.usedTheme]);
            m_CurrentZone         = 0;
            m_CurrentZoneDistance = 0;

            skyMeshFilter.sharedMesh = m_CurrentThemeData.skyMesh;
            RenderSettings.fogColor  = m_CurrentThemeData.fogColor;
            RenderSettings.fog       = true;

            gameObject.SetActive(true);
            characterController.gameObject.SetActive(true);
            characterController.coins   = 0;
            characterController.premium = 0;

            m_Score      = 0;
            m_ScoreAccum = 0;

            m_SafeSegementLeft = k_StartingSafeSegments;

            foreach (var collectibleType in currentTheme.collectiblePrefabs)
            {
                Coin.coinPools.Add(new Pooler(collectibleType, k_StartingCoinPoolSize));
            }

            PlayerData.instance.StartRunMissions(this);

#if UNITY_ANALYTICS
            AnalyticsEvent.GameStart(new Dictionary <string, object>
            {
                { "theme", m_CurrentThemeData.themeName },
                { "character", player.characterName },
                { "accessory", PlayerData.instance.usedAccessory >= 0 ? player.accessories[PlayerData.instance.usedAccessory].accessoryName : "none" }
            });
#endif
        }

        characterController.Begin();
        StartCoroutine(WaitToStart());
    }
示例#21
0
 void IAnalyticsInterchange.SendEvent(AnalyticsEvent targetEvent)
 {
     Mixpanel.SendEvent(targetEvent.ID, targetEvent.Properties);
 }
    void Update()
    {
        while (_spawnedSegments < (m_IsTutorial ? 4 : k_DesiredSegmentCount))
        {
            StartCoroutine(SpawnNewSegment());
            _spawnedSegments++;
        }

        if (parallaxRoot != null && currentTheme.cloudPrefabs.Length > 0)
        {
            while (_parallaxRootChildren < currentTheme.cloudNumber)
            {
                float lastZ = parallaxRoot.childCount == 0 ? 0 : parallaxRoot.GetChild(parallaxRoot.childCount - 1).position.z + currentTheme.cloudMinimumDistance.z;

                GameObject cloud = currentTheme.cloudPrefabs[Random.Range(0, currentTheme.cloudPrefabs.Length)];
                if (cloud != null)
                {
                    GameObject obj = Instantiate(cloud);
                    obj.transform.SetParent(parallaxRoot, false);

                    obj.transform.localPosition =
                        Vector3.up * (currentTheme.cloudMinimumDistance.y +
                                      (Random.value - 0.5f) * currentTheme.cloudSpread.y)
                        + Vector3.forward * (lastZ + (Random.value - 0.5f) * currentTheme.cloudSpread.z)
                        + Vector3.right * (currentTheme.cloudMinimumDistance.x +
                                           (Random.value - 0.5f) * currentTheme.cloudSpread.x);

                    obj.transform.localScale    = obj.transform.localScale * (1.0f + (Random.value - 0.5f) * 0.5f);
                    obj.transform.localRotation = Quaternion.AngleAxis(Random.value * 360.0f, Vector3.up);
                    _parallaxRootChildren++;
                }
            }
        }

        if (!m_IsMoving)
        {
            return;
        }

        float scaledSpeed = m_Speed * Time.deltaTime;

        m_ScoreAccum          += scaledSpeed;
        m_CurrentZoneDistance += scaledSpeed;

        int intScore = Mathf.FloorToInt(m_ScoreAccum);

        if (intScore != 0)
        {
            AddScore(intScore);
        }
        m_ScoreAccum -= intScore;

        m_TotalWorldDistance     += scaledSpeed;
        m_CurrentSegmentDistance += scaledSpeed;

        if (m_CurrentSegmentDistance > m_Segments[0].worldLength)
        {
            m_CurrentSegmentDistance -= m_Segments[0].worldLength;

            // m_PastSegments are segment we already passed, we keep them to move them and destroy them later
            // but they aren't part of the game anymore
            m_PastSegments.Add(m_Segments[0]);
            m_Segments.RemoveAt(0);
            _spawnedSegments--;

            if (currentSegementChanged != null)
            {
                currentSegementChanged.Invoke(m_Segments[0]);
            }
        }

        Vector3    currentPos;
        Quaternion currentRot;
        Transform  characterTransform = characterController.transform;

        m_Segments[0].GetPointAtInWorldUnit(m_CurrentSegmentDistance, out currentPos, out currentRot);


        // Floating origin implementation
        // Move the whole world back to 0,0,0 when we get too far away.
        bool needRecenter = currentPos.sqrMagnitude > k_FloatingOriginThreshold;

        // Parallax Handling
        if (parallaxRoot != null)
        {
            Vector3 difference = (currentPos - characterTransform.position) * parallaxRatio;;
            int     count      = parallaxRoot.childCount;
            for (int i = 0; i < count; i++)
            {
                Transform cloud = parallaxRoot.GetChild(i);
                cloud.position += difference - (needRecenter ? currentPos : Vector3.zero);
            }
        }

        if (needRecenter)
        {
            int count = m_Segments.Count;
            for (int i = 0; i < count; i++)
            {
                m_Segments[i].transform.position -= currentPos;
            }

            count = m_PastSegments.Count;
            for (int i = 0; i < count; i++)
            {
                m_PastSegments[i].transform.position -= currentPos;
            }

            // Recalculate current world position based on the moved world
            m_Segments[0].GetPointAtInWorldUnit(m_CurrentSegmentDistance, out currentPos, out currentRot);
        }

        characterTransform.rotation = currentRot;
        characterTransform.position = currentPos;

        if (parallaxRoot != null && currentTheme.cloudPrefabs.Length > 0)
        {
            for (int i = 0; i < parallaxRoot.childCount; ++i)
            {
                Transform child = parallaxRoot.GetChild(i);

                // Destroy unneeded clouds
                if ((child.localPosition - currentPos).z < -50)
                {
                    _parallaxRootChildren--;
                    Destroy(child.gameObject);
                }
            }
        }

        // Still move past segment until they aren't visible anymore.
        for (int i = 0; i < m_PastSegments.Count; ++i)
        {
            if ((m_PastSegments[i].transform.position - currentPos).z < k_SegmentRemovalDistance)
            {
                m_PastSegments[i].Cleanup();
                m_PastSegments.RemoveAt(i);
                i--;
            }
        }

        PowerupSpawnUpdate();

        if (!m_IsTutorial)
        {
            if (m_Speed < maxSpeed)
            {
                m_Speed += k_Acceleration * Time.deltaTime;
            }
            else
            {
                m_Speed = maxSpeed;
            }
        }

        if (Time.frameCount % 30 == 0)
        {
            GameSensor.instance.SendEvent("speed", m_Speed);
        }

        m_Multiplier = 1 + Mathf.FloorToInt((m_Speed - minSpeed) / (maxSpeed - minSpeed) * speedStep);

        if (modifyMultiply != null)
        {
            foreach (MultiplierModifier part in modifyMultiply.GetInvocationList())
            {
                m_Multiplier = part(m_Multiplier);
            }
        }

        if (!m_IsTutorial)
        {
            //check for next rank achieved
            int currentTarget = (PlayerData.instance.rank + 1) * 300;
            if (m_TotalWorldDistance > currentTarget)
            {
                PlayerData.instance.rank += 1;
                PlayerData.instance.Save();
#if UNITY_ANALYTICS
//"level" in our game are milestone the player have to reach : one every 300m
                AnalyticsEvent.LevelUp(PlayerData.instance.rank);
#endif
            }

            PlayerData.instance.UpdateMissions(this);
        }

        MusicPlayer.instance.UpdateVolumes(speedRatio);
    }
示例#23
0
 public void LogScreenVisited(string name)
 {
     AnalyticsEvent.ScreenVisit(name);
 }
示例#24
0
 public void LogScreen(string title)
 {
     Debug.Log("=== Log screen = " + title);
     _googleAnalytics.LogScreen(title);
     AnalyticsEvent.ScreenVisit(title);
 }
示例#25
0
 public void LogGameEnded()
 {
     AnalyticsEvent.GameOver();
 }
 /// <summary>
 /// Ova funkcija se zove sa custom argumentom eventData i name. U eventData smestiti
 /// sve podatke koji su nam zanimljivi za event
 /// </summary>
 public void CustomEvent(string name, IDictionary <string, object> eventData)
 {
     AnalyticsEvent.Custom(name, eventData);
 }
示例#27
0
 public void LevelComplete(string aName, IDictionary <string, object> aDictionary = null)
 {
     AnalyticsEvent.LevelComplete(aName, aDictionary ?? new Dictionary <string, object>());
     GameAnalytics.NewProgressionEvent(GAProgressionStatus.Complete, aName);
 }
示例#28
0
 public void LogGameStarted()
 {
     AnalyticsEvent.GameStart();
 }
示例#29
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.CompareTag("HealthPotion"))
        {
            AudioManager.instance.PlayPotionGet();
            HP++;
            UIController.Instance.RefreshInfo(HP, BombCount, SwordCount, MoneyCount, GemCount);
        }

        if (other.CompareTag("BombPotion"))
        {
            AudioManager.instance.PlayPotionGet();
            BombCount++;
            UIController.Instance.RefreshInfo(HP, BombCount, SwordCount, MoneyCount, GemCount);
        }

        if (other.CompareTag("Key"))
        {
            AudioManager.instance.PlayCoinGet();
            UIController.Instance.DisplayKey();
            hasKey = true;
        }

        if (hasKey && other.CompareTag("Box"))
        {
            AudioManager.instance.PlayOpenBox();
            hasKey = false;
        }

        if (other.CompareTag("Gem"))
        {
            GemCount++;
            AudioManager.instance.PlayCoinGet();
            UIController.Instance.RefreshInfo(HP, BombCount, SwordCount, MoneyCount, GemCount);
        }

        if (other.CompareTag("Bow"))
        {
            AudioManager.instance.PlayBowGet();
            explodeRange = explodeRange + 2.0f;
        }

        if (other.CompareTag("Money"))
        {
            AudioManager.instance.PlayCoinGet();
            MoneyCount += 2;
            UIController.Instance.RefreshInfo(HP, BombCount, SwordCount, MoneyCount, GemCount);
        }

        if (isEnemy(other) || isBomb(other))
        {
            // safe time
            if (SwordCount == 0 && SafeFlag)
            {
                return;
            }

            if (HP > 0)
            {
                if (isEnemy(other) && SwordCount > 0)
                {
                    SwordCount = SwordCount - 1;
                    StartCoroutine(BackToPlayer());
                }
                else
                {
                    HP--;
                    AudioManager.instance.PlayTouch();
                    SafeFlag = true;
                    StartCoroutine(GraceTime(SafeTime));
                }
            }

            UIController.Instance.RefreshInfo(HP, BombCount, SwordCount, MoneyCount, GemCount);

            if (HP == 0)
            {
                UIController.Instance.ShowGameOver();
                Destroy(gameObject);
            }
        }

        if (other.CompareTag("Sword"))
        {
            SwordCount++;
            AudioManager.instance.PlaySwordGet();
            UIController.Instance.RefreshInfo(HP, BombCount, SwordCount, MoneyCount, GemCount);
            // gameObject.tag = "Killer";
        }

        if (other.CompareTag("Door_sample"))
        {
            SceneManager.LoadScene("Start");
        }

        if (other.CompareTag("Door_level1"))
        {
            Dictionary <string, object> customParams = new Dictionary <string, object>();
            customParams.Add("bombs_remain", UIController.Instance.GetBombCount());
            customParams.Add("life_remain", UIController.Instance.GetHP());

            hasKey = UIController.Instance.KeyAvailable();

            AnalyticsEvent.LevelComplete(thisScene.name, thisScene.buildIndex, customParams);
            SceneManager.LoadScene("Store");
        }

        if (other.CompareTag("Door_level2"))
        {
            Dictionary <string, object> customParams = new Dictionary <string, object>();
            customParams.Add("bombs_remain", UIController.Instance.GetBombCount());
            customParams.Add("life_remain", UIController.Instance.GetHP());

            hasKey = UIController.Instance.KeyAvailable();

            AnalyticsEvent.LevelComplete(thisScene.name, thisScene.buildIndex, customParams);
            SceneManager.LoadScene("Store");
        }

        if (other.CompareTag("Door_level3"))
        {
            Dictionary <string, object> customParams = new Dictionary <string, object>();
            customParams.Add("bombs_remain", UIController.Instance.GetBombCount());
            customParams.Add("life_remain", UIController.Instance.GetHP());

            hasKey = UIController.Instance.KeyAvailable();

            AnalyticsEvent.LevelComplete(thisScene.name, thisScene.buildIndex, customParams);
            SceneManager.LoadScene("Congratulation");
        }
        // touchMusic.Play();
    }
示例#30
0
 public void LogRoundStarted(string name)
 {
     AnalyticsEvent.LevelStart(name);
 }
示例#31
0
    void Awake()
    {
        _MenuAnimator = _MenuButton.GetComponentInChildren <Animator>();
        _MainManager  = GetComponent <MainManager>();
        _Backend      = GetComponent <Backeend>();
        EventManager.AddListener <InitButtonEvent>(Init);

        //Main Menu Handler
        _MainMenuPlayButton.AddComponent <Button>().onClick.AddListener(delegate {
            EventManager.TriggerEvent(new SFXPlayEvent(SfxType.TAP, true));
            EventManager.TriggerEvent(new MainMenuButtonEvent(MainMenuButtonType.START_GAME));

            AnalyticsEvent.Custom("Start Button");

            _MenuAnimator.CrossFade("FALSE", 0);
            _IsMenu = false;
        });

        _HighscoreButton.AddComponent <Button>().onClick.AddListener(delegate {
            EventManager.TriggerEvent(new SFXPlayEvent(SfxType.TAP, false));
            EventManager.TriggerEvent(new ShowLeaderboardEvent());

            AnalyticsEvent.Custom("Highscore Button");
        });

        _AchievementButton.AddComponent <Button>().onClick.AddListener(delegate {
            EventManager.TriggerEvent(new SFXPlayEvent(SfxType.TAP, false));
            EventManager.TriggerEvent(new MainMenuButtonEvent(MainMenuButtonType.CHALLENGE));
            //Diubah jadi challenge button
            //EventManager.TriggerEvent(new ShowAchievementEvent());

            AnalyticsEvent.Custom("Challenge Button");
        });

        _MainMenuExitButton.AddComponent <Button>().onClick.AddListener(delegate {
            EventManager.TriggerEvent(new SFXPlayEvent(SfxType.TAP_BACK, false));
            ExitButton();

            AnalyticsEvent.Custom("Quit Button");
        });

        //MENU BUTTON
        _MenuButton.AddComponent <Button>().onClick.AddListener(delegate {
            if (!_IsMenu)
            {
                EventManager.TriggerEvent(new SFXPlayEvent(SfxType.TAP, false));
                _MenuAnimator.CrossFade("TRUE", 0);
                _IsMenu = true;
            }
            else
            {
                EventManager.TriggerEvent(new SFXPlayEvent(SfxType.TAP_BACK, false));
                _MenuAnimator.CrossFade("FALSE", 0);
                _IsMenu = false;
            }
        });

        _CreditButton.AddComponent <Button>().onClick.AddListener(delegate {
            EventManager.TriggerEvent(new SFXPlayEvent(SfxType.TAP, false));
            _CreditObject.SetActive(true);
        });
        _CreditBackButton.AddComponent <Button>().onClick.AddListener(delegate {
            EventManager.TriggerEvent(new SFXPlayEvent(SfxType.TAP_BACK, false));
            _CreditObject.SetActive(false);
        });

        //BENTUK SEDERHANA LEVEL HANDLER
        foreach (LevelSelectData data in _LevelSelectData)
        {
            data.Object.AddComponent <Button>().onClick.AddListener(delegate
            {
                ButtonAction(data);
            });
        }

        //BENTUK SEDERHANA CGALLENGE HANDLER
        foreach (ChallengeSelectData data in _ChallengeSelectData)
        {
            data.Object.AddComponent <Button>().onClick.AddListener(delegate
            {
                ButtonAction2(data);
            });
        }
    }
示例#32
0
        internal void CreateSampleAnalyticsByMonth(int month)
        {
            var smapleProductSkus = new List <string>
            {
                "SAMPLE001",
                "SAMPLE002",
                "SAMPLE003",
                "SAMPLE004",
                "SAMPLE005",
                "SAMPLE006"
            };
            var products = CatalogServices.Products.FindManySkus(smapleProductSkus);

            var productsCount = products.Count;

            var storeId = Context.CurrentStore.Id;

            var todaysDate = DateTime.UtcNow;
            var startDate  = todaysDate.AddMonths(-month);

            EventLog.LogEvent("SampleData", "Creating Analytics info for " + startDate.ToString("Y"),
                              EventLogSeverity.Information);

            var endDate = startDate.AddMonths(-1);

            var index    = 0;
            var currDate = startDate;

            var sessionGuid         = Guid.NewGuid();
            var analyticsEventsList = new List <AnalyticsEvent>();
            var analyticsEventTypes = new[] { ActionTypes.ProductViewed, ActionTypes.ProductAddedToCart };

            while (currDate > endDate)
            {
                if (currDate != todaysDate)
                {
                    foreach (var product in products)
                    {
                        for (var i = 0; i < currDate.Month + currDate.Year % 2 + index % 6; i++)
                        {
                            var analyticsEvent = new AnalyticsEvent
                            {
                                SessionGuid         = sessionGuid,
                                ShoppingSessionGuid = sessionGuid,
                                StoreId             = storeId,
                                Action   = analyticsEventTypes[i % 2],
                                ObjectId = DataTypeHelper.BvinToGuid(product.Bvin),
                                DateTime = currDate
                            };
                            analyticsEventsList.Add(analyticsEvent);

                            sessionGuid = Guid.NewGuid();
                        }

                        index++;
                    }
                }
                currDate = currDate.AddDays(-1);
            }

            var analyticsEventsRepository = Factory.CreateRepo <AnalyticsEventsRepository>();

            analyticsEventsRepository.BatchCreate(analyticsEventsList);

            index    = 0;
            currDate = startDate;

            var ordersList = new List <Order>();
            var address    = new Address
            {
                FirstName   = "Ryan",
                LastName    = "Morgan",
                Line1       = "319 CLEMATIS ST",
                Line2       = "Suite 500",
                City        = "WEST PALM BCH",
                RegionBvin  = "FL",
                PostalCode  = "44301",
                CountryBvin = Country.UnitedStatesCountryBvin,
                Phone       = "(561) 714-7926"
            };

            while (currDate > endDate)
            {
                if (currDate != todaysDate)
                {
                    foreach (var product in products)
                    {
                        var order = new Order
                        {
                            bvin                        = Guid.NewGuid().ToString(),
                            StoreId                     = storeId,
                            BillingAddress              = address,
                            ShippingAddress             = address,
                            UserID                      = "1",
                            UserEmail                   = "*****@*****.**",
                            OrderNumber                 = "Sample Order",
                            ShippingMethodId            = "TOBEDETERMINED",
                            ShippingProviderId          = string.Empty,
                            ShippingProviderServiceCode = string.Empty,
                            ShippingMethodDisplayName   = "To Be Determined. Contact Store for Details",
                            PaymentStatus               = OrderPaymentStatus.Paid,
                            ShippingStatus              = OrderShippingStatus.Unshipped,
                            StatusCode                  = "F37EC405-1EC6-4a91-9AC4-6836215FBBBC",
                            StatusName                  = "Received",
                            IsPlaced                    = true,
                            IsAbandonedEmailSent        = true,
                            UserDeviceType              = (DeviceType)(index % 3),
                            LastUpdatedUtc              = currDate,
                            TimeOfOrderUtc              = currDate
                        };
                        var qty      = (currDate.Month + 4 + currDate.Year % 2 + index % 6) % 12 + 4;
                        var lineItem = new LineItem
                        {
                            StoreId              = storeId,
                            OrderBvin            = order.bvin,
                            ProductId            = product.Bvin,
                            ProductSku           = product.Sku,
                            ProductName          = product.ProductName,
                            Quantity             = qty,
                            BasePricePerItem     = product.SitePrice,
                            AdjustedPricePerItem = product.SitePrice,
                            LineTotal            = product.SitePrice * qty,
                            ShipFromMode         = ShippingMode.ShipFromSite,
                            LastUpdatedUtc       = currDate
                        };
                        order.Items.Add(lineItem);
                        ordersList.Add(order);

                        index++;

                        var order2 = new Order
                        {
                            bvin                        = Guid.NewGuid().ToString(),
                            StoreId                     = storeId,
                            BillingAddress              = address,
                            ShippingAddress             = address,
                            UserID                      = "1",
                            UserEmail                   = "*****@*****.**",
                            OrderNumber                 = "Sample Order",
                            ShippingMethodId            = "TOBEDETERMINED",
                            ShippingProviderId          = string.Empty,
                            ShippingProviderServiceCode = string.Empty,
                            ShippingMethodDisplayName   = "To Be Determined. Contact Store for Details",
                            PaymentStatus               = OrderPaymentStatus.Paid,
                            ShippingStatus              = OrderShippingStatus.Unshipped,
                            StatusCode                  = OrderStatusCode.Received,
                            StatusName                  = "Received",
                            IsPlaced                    = false,
                            IsAbandonedEmailSent        = true,
                            UserDeviceType              = (DeviceType)(index % 3),
                            LastUpdatedUtc              = currDate,
                            TimeOfOrderUtc              = currDate
                        };
                        var qty2      = (currDate.Month + 8 + currDate.Year % 2 + index % 6) % 12 + 2;
                        var lineItem2 = new LineItem
                        {
                            StoreId              = storeId,
                            OrderBvin            = order2.bvin,
                            ProductId            = product.Bvin,
                            ProductSku           = product.Sku,
                            ProductName          = product.ProductName,
                            Quantity             = qty2,
                            BasePricePerItem     = product.SitePrice,
                            AdjustedPricePerItem = product.SitePrice,
                            LineTotal            = product.SitePrice * qty2,
                            ShipFromMode         = ShippingMode.ShipFromSite,
                            LastUpdatedUtc       = currDate
                        };
                        order2.Items.Add(lineItem2);
                        ordersList.Add(order2);

                        index++;
                    }
                }

                currDate = currDate.AddDays(-1);
            }
            var orderRepository = Factory.CreateRepo <OrderRepository>();

            orderRepository.BatchCreate(ordersList, false);

            var lineItemList       = ordersList.SelectMany(o => o.Items).ToList();
            var lineItemRepository = Factory.CreateRepo <LineItemRepository>();

            lineItemRepository.BatchCreate(lineItemList);


            var orderTransactionList = new List <OrderTransaction>();

            foreach (var order in ordersList)
            {
                if (!order.IsPlaced)
                {
                    continue;
                }

                var orderTransaction = new OrderTransaction
                {
                    StoreId      = storeId,
                    OrderId      = order.bvin,
                    OrderNumber  = "Sample Order",
                    TimeStampUtc = order.TimeOfOrderUtc,
                    Action       = ActionType.CashReceived,
                    Amount       = order.TotalGrand,
                    Success      = true
                };
                orderTransactionList.Add(orderTransaction);
            }
            var orderTransactionRepository = Factory.CreateRepo <OrderTransactionRepository>();

            orderTransactionRepository.BatchCreate(orderTransactionList);
        }
 public void ChatMessageSent_NoArgsTest()
 {
     Assert.DoesNotThrow(() => m_Result = AnalyticsEvent.ChatMessageSent());
     EvaluateAnalyticsResult(m_Result);
 }