Example #1
0
    public void EventLog(string eventName, AnalyticsEventParam analyticsEventParam)
    {
        // Log an event with an int parameter.
        if (_app != null)
        {
            if (eventName.Length > 0 && analyticsEventParam.ParamDic.Count > 0)
            {
                Parameter[] LevelUpParameters = new Parameter[analyticsEventParam.ParamDic.Count];
                int         index             = 0;
                foreach (string paramName in analyticsEventParam.ParamDic.Keys)
                {
                    object paramValueObject = analyticsEventParam.ParamDic[paramName];
                    if (paramValueObject is int)
                    {
                        LevelUpParameters[index] = new Firebase.Analytics.Parameter(paramName, (int)paramValueObject);
                        index++;
                    }
                    else if (paramValueObject is float)
                    {
                        LevelUpParameters[index] = new Firebase.Analytics.Parameter(paramName, (float)paramValueObject);
                        index++;
                    }
                    else if (paramValueObject is string)
                    {
                        LevelUpParameters[index] = new Firebase.Analytics.Parameter(paramName, (string)paramValueObject);
                        index++;
                    }
                }

                Firebase.Analytics.FirebaseAnalytics.LogEvent(eventName, LevelUpParameters);
            }
        }
    }
Example #2
0
    public void SaveGameResult(int updateScore, int getCoin, int[] useItems)
    {
        _userData.AddCoin(getCoin);
        if (_userData.UpdateScore(updateScore))
        {
            //Upload Score rank.
            NetworkManager.Instance.SetScoreToLeaderBorad(updateScore);
        }

        ItemUseCountInfo    itemUseCountInfo    = ItemUseCountInfo.GetInstance(useItems);
        AnalyticsEventParam analyticsEventParam = new AnalyticsEventParam()
                                                  .AddParam("Score", updateScore)
                                                  .AddParam("Coin", getCoin)
                                                  .AddParam("Item_Recycle", itemUseCountInfo.GetCount(ItemType.TRASH))
                                                  .AddParam("Item_Hammer", itemUseCountInfo.GetCount(ItemType.BREAK))
                                                  .AddParam("Item_Rewind", itemUseCountInfo.GetCount(ItemType.UNDO));;

        AnalyticsManager.Instance.EventLog(GameConstants.EVENTLOG_BASICMODE_RESULT, analyticsEventParam);

        DeletePlayData();
        SaveUserDataFile();
    }