Пример #1
0
    public static PlayerOperationData GetDataFromJson(string json)
    {
        PlayerOperationData data = new PlayerOperationData();

        JsonData jsonData = JsonMapper.ToObject(json);

        data.clickAccuracy = float.Parse(jsonData.TryGetString("clickAccuracy"));
        data.clickScore    = int.Parse(jsonData.TryGetString("clickScore"));
        data.clickNumber   = int.Parse(jsonData.TryGetString("clickNumber"));
        data.clickAccuracy = int.Parse(jsonData.TryGetString("rightNumber"));
        data.wrongNumber   = int.Parse(jsonData.TryGetString("wrongNumber"));
        data.wholeScore    = int.Parse(jsonData.TryGetString("wholeScore"));

        JsonData readingData = jsonData["readingData"];

        for (int i = 0; i < readingData.Count; i++)
        {
            data.m_ReadingData.Add(PlayerReadingData.GetReadingDataFromJsonData(readingData[i]));
        }

        return(data);
    }
Пример #2
0
    public void GameFinish()
    {
        m_Status = GameStatus.Finish;
        AudioController.Play("applause");

        if (m_WrongNum == 0)
        {
            AudioController.Play("combo_perfect");
        }
        if (m_Life > 0)
        {
            AnalysisManager.Instance.OnEvent("100002", null, StaticData.LevelID.ToString(), "完成游戏");
            AnalysisManager.Instance.OnEvent("100001", null, StaticData.LevelID.ToString(), m_Life.ToString());
            AnalysisManager.Instance.OnLevelCompleted(StaticData.LevelID.ToString());
        }
        else
        {
            AnalysisManager.Instance.OnEvent("100002", null, StaticData.LevelID.ToString(), "完成游戏");
            AnalysisManager.Instance.OnEvent("100001", null, StaticData.LevelID.ToString(), "空血通关");
            AnalysisManager.Instance.OnLevelFailed(StaticData.LevelID.ToString(), "没血通关");
        }
        // 记录成绩
        SelfPlayerLevelData.TempRankIncrement = SelfPlayerLevelData.CurRank;
        Debug.LogWarning("  记录成绩 = " + SelfPlayerLevelData.TempRankIncrement);
        Debug.Log("<======记录舞蹈数据 boss战舞蹈数据为空 ======>");
        // 打开UI
        if (CorePlayData.BossLife > 0)
        {
            m_ProcessData = null;
            SelfPlayerRoleTitleData.Instance.UpdateRoleTitleCount(50002);
        }
        else
        {
            SelfPlayerRoleTitleData.Instance.UpdateRoleTitleCount(50001);
            PlayerOperationData operData = new PlayerOperationData();
            operData.wholeScore    = m_Score;
            operData.clickAccuracy = (float)m_CorrectNum / m_AllWordNum;
            operData.clickNumber   = m_AllWordNum;
            operData.clickScore    = m_Score - (int)(m_SumVoiceScore * CorePlaySettings.Instance.m_VoiceRightPoint);
            operData.wrongNumber   = m_WrongNum;
            operData.rightNumber   = m_CorrectNum;
            operData.m_ReadingData = CorePlayData.PlayerReadingData;

            //临时测试上传操作过程数据
            m_ProcessData = operData.GetJson();
        }
        SaveDataUtils.Save <SelfPlayerRoleTitleData>();
        DancingWordAPI.Instance.UpDateServerRoleTitleInfo(SelfPlayerRoleTitleData.RoleTitleList);
        SaveResultToLocal(m_Life);
        int grade = SetLevel.setLevel(SelfPlayerLevelData.CurAccuracy);

        SelfPlayerData.Instance.AddExpAndSaveToLocal(grade);
        // 关录音
        XunFeiSRManager.Instance.StopListen();
        MicManager.Instance.StopRecord();
        LoginRpcProxy.getInstance().SaveLevelVoices(MicManager.Instance.voiceDic);

        PageManager.Instance.CurrentPage.GetComponent <CorePlayPage>().HidePauseButton();
        if (CorePlayData.BossLife > 0)
        {
            PageManager.Instance.CurrentPage.GetNode <WinNode>().Open();
        }
        else
        {
            HttpHandler.UploadScore(ServerDataCallback, true);
            m_AlreadyRuning = false;
            LoadStage();
        }
    }
Пример #3
0
    void ServerDataCallback()
    {
        OnReceive_ScoreData();
        if (!m_AlreadyRuning)
        {
            StopCoroutine(LoadStageData());

            m_AlreadyRuning = true;
            //从服务器获取的真实数据


            int songMax  = m_SongMaxScoreInfo.MaxScore;
            int clickMax = (int)(m_SongMaxScoreInfo.MaxScore * m_SongMaxScoreInfo.ClickScorePercent);
            int voiceMax = (int)(m_SongMaxScoreInfo.MaxScore * m_SongMaxScoreInfo.VoiceScorePercent);

            DancerInfo left  = new DancerInfo();
            DancerInfo right = new DancerInfo();

            if (!string.IsNullOrEmpty(SelfPlayerLevelData.TempOtherLevelProcessData))
            {
                JsonData otherPlayers = JsonMapper.ToObject(SelfPlayerLevelData.TempOtherLevelProcessData);

                JsonData leftJson  = otherPlayers[0];
                JsonData rightJson = otherPlayers[1];

                if (int.Parse(leftJson.TryGetString("Country")) == China)
                {
                    left.m_Country = DancerInfo.Country.China;
                }
                else
                {
                    left.m_Country = DancerInfo.Country.America;
                }

                left.ModelID  = RoleModelConfig.Instance.GetNameById(int.Parse(leftJson.TryGetString("ModelId")));
                left.Name     = leftJson.TryGetString("UserName");
                left.FaceID   = RoleEmotionConfig.Instance.GetNameById(int.Parse(leftJson.TryGetString("EmotionId")));
                left.PlayerID = leftJson.TryGetString("uid");

                PlayerOperationData leftOperation = PlayerOperationData.GetDataFromJson(leftJson.TryGetString("Process"));

                left.WholeScore = leftOperation.wholeScore;
                left.ClickScore = leftOperation.clickScore;
                left.VoiceScore = left.WholeScore - left.ClickScore;

                left.WholeRankingPercent = (float)left.WholeScore / songMax;
                left.ClickScorePercent   = (float)left.ClickScore / clickMax;
                left.VoiceScorePercent   = (float)left.VoiceScore / voiceMax;

                if (int.Parse(rightJson.TryGetString("Country")) == China)
                {
                    right.m_Country = DancerInfo.Country.China;
                }
                else
                {
                    right.m_Country = DancerInfo.Country.America;
                }

                right.ModelID  = RoleModelConfig.Instance.GetNameById(int.Parse(rightJson.TryGetString("ModelId")));
                right.Name     = leftJson.TryGetString("UserName");
                right.FaceID   = RoleEmotionConfig.Instance.GetNameById(int.Parse(rightJson.TryGetString("EmotionId")));
                right.PlayerID = rightJson.TryGetString("uid");

                PlayerOperationData rightOperation = PlayerOperationData.GetDataFromJson(rightJson.TryGetString("Process"));

                right.WholeScore = rightOperation.wholeScore;
                right.ClickScore = rightOperation.clickScore;
                right.VoiceScore = right.WholeScore - right.ClickScore;

                right.WholeRankingPercent = (float)right.WholeScore / songMax;
                right.ClickScorePercent   = (float)right.ClickScore / clickMax;
                right.VoiceScorePercent   = (float)right.VoiceScore / voiceMax;
            }
            else
            {
                if (m_SelfWinner)
                {
                    left  = GetNPCDancer(false, m_Score, DancerInfo.Country.China, DancerInfo.Sex.Female, songMax, clickMax, m_TempTypeCache);
                    right = GetNPCDancer(false, m_Score, DancerInfo.Country.America, DancerInfo.Sex.Male, songMax, clickMax, m_TempTypeCache);
                }
                else
                {
                    int temp = UnityEngine.Random.Range(0, 2);
                    if (temp == 0)
                    {
                        left  = GetNPCDancer(true, m_Score, DancerInfo.Country.China, DancerInfo.Sex.Female, songMax, clickMax, m_TempTypeCache);
                        right = GetNPCDancer(false, m_Score, DancerInfo.Country.America, DancerInfo.Sex.Male, songMax, clickMax, m_TempTypeCache);
                    }
                    else
                    {
                        left  = GetNPCDancer(false, m_Score, DancerInfo.Country.China, DancerInfo.Sex.Female, songMax, clickMax, m_TempTypeCache);
                        right = GetNPCDancer(true, m_Score, DancerInfo.Country.America, DancerInfo.Sex.Male, songMax, clickMax, m_TempTypeCache);
                    }
                }
            }

            stageManager.CreateDancer(left, StageManager.DancerPos.Left);
            stageManager.CreateDancer(right, StageManager.DancerPos.Right);
            stageManager.CreateDancerActionData();
        }
    }