コード例 #1
0
 // Update is called once per frame
 void Update()
 {
     if (!gameStart)
     {
         if (Input.GetMouseButtonDown(0))
         {
             AVAnalytics.StartEvent("OneGame", new Dictionary <string, object>
             {
                 { "startSilgelGameTime", DateTime.UtcNow.ToString() }
             });//记录玩家点击屏幕游戏开始的时间。
             gameStart = true;
             totalGames++;
         }
     }
     if (gameStart)
     {
         if (Input.GetKeyUp(KeyCode.Escape))
         {
             AVAnalytics.TrackEvent("QuitGame", new Dictionary <string, object>
             {
                 { "totalGames", totalGames }
             });
             Application.Quit();
         }
     }
 }
コード例 #2
0
ファイル: bird.cs プロジェクト: YJEngr/unity-sdk-demos
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.gameObject.tag == "scoreMaker")
        {
            GameManager.score += 1;
            Destroy(other.gameObject);
        }
        else
        {
            AVAnalytics.StopEvent("OneGame");//本局结束,只要调用一下事件终止方法,SDK会自动计算开始到结束之间的间隔发送到服务端。

            #region 把这次的分数记录到AVOS Cloud的服务端

            AVObject gameScore = new AVObject("GameScore");
            gameScore["score"]      = GameManager.score;
            gameScore["playerName"] = "DemoUser";
            gameScore["deviceID"]   = SystemInfo.deviceUniqueIdentifier;
            gameScore.SaveAsync();

            #endregion

            gameObject.collider2D.isTrigger = false;
            AudioSource.PlayClipAtPoint(hit, Camera.main.transform.position);
            if (GameManager.score > PlayerPrefs.GetInt("highscore"))
            {
                guiManager.medal = true;
            }
            GameManager.gameOver = true;
        }
    }
コード例 #3
0
        public Task TestSendAnalyticsData()
        {
            return(AVAnalytics.InitAsync(new PC()).ContinueWith(t =>
            {
                AVAnalytics.Current.TrackAppOpened();
                AVAnalytics.Current.TrackAppOpenedWithPush();
                var pageId = AVAnalytics.Current.BeginPage("LogInPage");
                AVAnalytics.Current.TrackEvent("LogIn_Button_Clicked");
                AVAnalytics.Current.TrackEvent("Gesture_Flick");

                var inputEventId = AVAnalytics.Current.BeginEvent("Input", "SignUpAction", new Dictionary <string, object>()
                {
                    { "age", 27 },
                    { "gender", "female" },
                });

                var orderEventId = AVAnalytics.Current.BeginEvent("Order", "OrderAction", new Dictionary <string, object>()
                {
                    { "clicked_ads", "left" }, //用户点击了左边栏的广告
                    { "scorll_down", true },   //用户拉到了页面底部
                });
                AVAnalytics.Current.EndEvent(inputEventId);
                AVAnalytics.Current.EndPage(pageId);
                AVAnalytics.Current.CloseSession();
                return Task.FromResult(0);
            }));
        }
コード例 #4
0
ファイル: bird.cs プロジェクト: YJEngr/unity-sdk-demos
    // Update is called once per frame
    void Update()
    {
        if (!GameManager.gameStart)
        {
            rigidbody2D.gravityScale = 0f;
        }
        else
        {
            rigidbody2D.gravityScale = 0.5f;
        }
        var pos = new Vector3(birdPos.x, transform.position.y, transform.position.z);

        transform.position = pos;
        if ((Input.GetKeyDown(KeyCode.Space) || Input.GetMouseButtonDown(0)) && !GameManager.gameOver && GameManager.gameStart)
        {
            AVAnalytics.TrackEvent("Tap");
            rigidbody2D.velocity = new Vector2(0f, upForce);
        }
        if (rigidbody2D.velocity.y < upForce - some && transform.rotation.y > -90 && GameManager.gameStart)
        {
            rotz = Mathf.Lerp(rotz, -90f, Time.deltaTime);
            var rot = Quaternion.Euler(0, 0, rotz);
            transform.rotation = rot;
        }
        else
        {
            if (!GameManager.gameOver && GameManager.gameStart)
            {
                rotz = Mathf.Lerp(rotz, 25f, Time.deltaTime * 6);
                var rot = Quaternion.Euler(0, 0, rotz);
                transform.rotation = rot;
            }
        }

        if (!GameManager.gameStart)
        {
            Vector3 temp = new Vector3(transform.position.x, 0.9118328f, transform.position.z);
            transform.position = temp;
        }

        if (transform.position.y < -2.72)
        {
            Vector3 temp    = new Vector3(transform.position.x, -2.72f, transform.position.z);
            var     tempRot = Quaternion.Euler(0, 0, -90f);
            transform.position = temp;
            transform.rotation = tempRot;
        }

        if (rigidbody2D.velocity.y < downVel)
        {
            Vector3 tempVel = new Vector3(0f, downVel, 0f);
            rigidbody2D.velocity = tempVel;
        }
    }