示例#1
0
    /// <summary>
    /// 本地添加一条订单记录, 防止漏单
    /// </summary>
    /// <param name="userID"></param>
    /// <param name="payLoad"></param>
    public void AddItemIAPTransaction(string userID, string transactionID, string payLoad, string price)
    {
        string logStr = "";

        if (userID == null || userID == "" || transactionID == null || transactionID == "" || payLoad == null || payLoad == "" || price == null || price == "")
        {
            logStr = "数据错误,无法添加订单记录: 用户ID:" + userID + ", 订单ID:" + transactionID + ", 收据:" + payLoad + ", 价钱:" + price;
            //if (Manager) Manager.log(logStr);
            LogManager.Log(logStr);
            return;
        }
        IAPVerifyTempItem Transaction = new IAPVerifyTempItem();

        Transaction.userID        = userID;
        Transaction.transactionID = transactionID;
        Transaction.payLoad       = payLoad;
        Transaction.price         = price;
        TransactionTemp.Add(Transaction);

        SaveDataUtils.Save <IAPVerifyProxy>();

        logStr = "本地添加一条订单记录, 防止漏单: 用户ID:" + userID + ", 订单ID:" + transactionID + ", 当前有" + TransactionTemp.Count + "条待处理订单(漏单)";
        //if (Manager) Manager.log(logStr);
        LogManager.Log(logStr);
    }
示例#2
0
        /// <summary>
        /// Login by browser auth
        /// </summary>
        /// <returns>Task</returns>
        static async UniTask _Login(LoginCallbackInfo authRes)
        {
            var auth = EOS.auth;
            var con  = EOS.connect;

            var token = auth.CopyUserAuthToken(authRes.LocalUserId);

            if (token == null)
            {
                return;
            }

            var conRes = await con.Login(token.AccessToken, Epic.OnlineServices.Connect.ExternalCredentialType.Epic);

            if (conRes == null)
            {
                return;
            }

            SaveDataUtils.SaveString(Defines.KEY_REFRESH_TOKEN, token.RefreshToken);
            var playerId = conRes.LocalUserId;

            Ctrl.GeneratePlayer(playerId);

            // Set request callback
            _ins._SetRequestCallback();

            await _ins._JoinLobby();
        }
示例#3
0
 private void OnClickCloseCallBack()
 {
     //print("OK");
     GetComponent <DOTweenAnimation>().DOPlayBackwards();
     SaveDataUtils.Save <SelfPlayerRoleTitleData>();
     DancingWordAPI.Instance.UpDateServerRoleTitleInfo(SelfPlayerRoleTitleData.RoleTitleList);
 }
    public static void SaveToLocal(int new_score, float accuracy, int combo, int life, float readAccuracy, float wordAccuracy, string processData)
    {
        new_score                = Mathf.Clamp(new_score, 0, 999999999);
        ScoreIncrement           = new_score - MaxScore;
        TempScore                = new_score;
        TempAccuracy             = accuracy;
        TempMaxCombo             = combo;
        TempLeftLife             = life;
        TempReadAccuracy         = readAccuracy;
        TempWordAccuracy         = wordAccuracy;
        TempSelfLevelProcessData = processData;
        if (ScoreIncrement <= 0 || life == -1)
        {
            ScoreIncrement = 0;
            //return;
        }

        // 解锁关卡
        if (SelfPlayerData.Instance.GetLevelStatusByLevelId(StaticData.LevelID + 1).isPay&& !SelfPlayerData.Instance.GetLevelStatusByLevelId(StaticData.LevelID + 1).isUnLock)
        {
            SelfPlayerData.Instance.SetLevelStatus(StaticData.LevelID);
            LogManager.Log(" 解锁关卡 = ", StaticData.LevelID);
        }
        CurInfo.maxScore     = new_score;
        CurInfo.accuracy     = accuracy;
        CurInfo.maxCombo     = combo;
        CurInfo.leftLife     = life;
        CurInfo.readAccuracy = readAccuracy;
        CurInfo.wordAccuracy = wordAccuracy;
        CurInfo.rank         = -1;
        SaveDataUtils.Save <SelfPlayerData> ();
    }
示例#5
0
        /// <summary>
        /// 获取当前用户的所有关卡的状态信息
        /// </summary>
        public static void GetCourseFormServer()
        {
            SaveDataUtils.Load <SelfPlayerRoleTitleData> ();
            JsonData data = new JsonData();

            data["userID"] = SelfPlayerData.Uuid;
            DancingWordAPI.Instance.RequestCourseFromServer(data, (string result) => {
                LogManager.Log(result);
                JsonData resultData           = JsonMapper.ToObject(result);
                JsonData courseData           = resultData["data"];
                List <CourseData> courseDatas = new List <CourseData> ();
                for (int i = 0; i < courseData.Count; i++)
                {
                    courseDatas.Add(new CourseData()
                    {
                        m_CourseID = int.Parse(courseData[i].TryGetString("courseID")),
                        m_Progress = int.Parse(courseData[i].TryGetString("progress")),
                        m_IsPay    = bool.Parse(courseData[i].TryGetString("isPay"))
                    });
                }
                SelfPlayerData.CourseData = courseDatas;
                SaveDataUtils.Save <SelfPlayerData> ();
                SelfPlayerData.LevelStatus = SelfPlayerData.Instance.CreateLevelStatusDic();
                //测试
                //LevelStatus dic = SelfPlayerData.Instance.GetLevelStatusByLevelId(1003);
                //print(dic.isPay + "=====" + dic.isLock);
                //SelfPlayerData.Instance.SetLevelStatus(1002);
            }, () => {
                ///print("GetCourse");
                SaveDataUtils.Load <SelfPlayerData> ();
                SelfPlayerData.LevelStatus = SelfPlayerData.Instance.CreateLevelStatusDic();
            });
        }
示例#6
0
    /// <summary>
    /// 从服务器获取当前用户的所有称号数据并保存到本地
    /// </summary>
    private void GetRoleTitleDataFromServer()
    {
        JsonData data = new JsonData();

        data["userID"] = SelfPlayerData.Uuid;
        DancingWordAPI.Instance.RequestRoleTitleFromServer(data, (string result) =>
        {
            //print(result);
            JsonData jsonResult = JsonMapper.ToObject(result)["data"];
            roleTitleObjectList = new List <RoleTitleItemObject>();
            for (int i = 0; i < jsonResult.Count; i++)
            {
                RoleTitleItemObject roleTitleItemObject = new RoleTitleItemObject();
                roleTitleItemObject.roletitleId         = int.Parse(jsonResult[i].TryGetString("titleID"));
                roleTitleItemObject.roletitleCount      = int.Parse(jsonResult[i].TryGetString("progress"));
                roleTitleItemObject.roleTitleStatus     = bool.Parse(jsonResult[i].TryGetString("isUsed")) != true ? RoleTitleStatus.NotWear : RoleTitleStatus.Weared;
                roleTitleObjectList.Add(roleTitleItemObject);
            }
            roleTitleObjectList.Sort();
            SelfPlayerRoleTitleData.RoleTitleList = roleTitleObjectList;
            SaveDataUtils.Save <SelfPlayerRoleTitleData>();
            CreateRoleTitleItem();
        }, () =>
        {
            SaveDataUtils.Load <SelfPlayerRoleTitleData>();
            SelfPlayerRoleTitleData.RoleTitleList.Sort();
            roleTitleObjectList = SelfPlayerRoleTitleData.RoleTitleList;
            if (roleTitleObjectList != null)
            {
                CreateRoleTitleItem();
            }
        });
    }
示例#7
0
    protected override void Init()
    {
        base.Init();

        var obj = new GameObject();

        obj.name = "BackgroundSound";
        obj.transform.SetParent(transform);
        GameObject lyricObj = new GameObject();

        lyricObj.name = "LyricSound";
        lyricObj.transform.SetParent(transform);

        _bgmSource             = obj.AddComponent <AudioSource>();
        _bgmSource.playOnAwake = false;
        _sfxSource             = GetComponent <AudioSource>();
        _sfxSource.playOnAwake = false;

        _lyricsSource             = lyricObj.AddComponent <AudioSource>();
        _lyricsSource.playOnAwake = false;
        _mute = false;
        //InitBtnClick();

        SaveDataUtils.LoadTo(this);
    }
示例#8
0
 /// <summary>
 /// First frame
 /// </summary>
 void Start()
 {
     btnAuthLogin.SetOnClick(() => EOSP2P.LoginAuth().Forget());
     btnDeleteAuth.SetOnClick(() => SaveDataUtils.DeleteKey(Defines.KEY_REFRESH_TOKEN));
     btnDevLogin.SetOnClick(() => EOSP2P.LoginDev(inptDevPort.text.ToInt(), inptDevName.text).Forget());
     btnGithub.SetOnClick(() => Application.OpenURL("https://github.com/okamototomoyuki/unity_eos_fps"));
 }
 public void RefreshDownloadStatus(int status, bool refreshVersion = false)
 {
     DownloadStatus = status;
     if (refreshVersion)
     {
         CurrentDownloadVersion = MiscUtils.GetVersion();
     }
     SaveDataUtils.Save <AssetBundleSaveData>();
 }
示例#10
0
    protected override void Init()
    {
        base.Init();

        SaveDataUtils.LoadTo(this);

        _upkFolder    = Application.persistentDataPath + "/AssetBundle/";
        _upkPath      = _upkFolder + MiscUtils.GetCurrentPlatform() + ".upk";
        _bundleFolder = _upkFolder + MiscUtils.GetCurrentPlatform() + "/";
    }
示例#11
0
    void ChangeStatus(Status status)
    {
        var old = _currentStatus;

        _currentStatus = status;
        if (old != _currentStatus)
        {
            SaveDataUtils.SaveFrom(this);
        }
        _needAction = true;
    }
        private async Task ImportInternal()
        {
            DecorationsSaveSlotInfo selected = await SaveDataUtils.GetDecorationsSaveSlot(saveSlotInfoSelector);

            if (selected == null)
            {
                return;
            }

            ApplySaveDataDecorations(selected);
        }
示例#13
0
    void Awake()
    {
        GameSettings.BGMVolumeChanged += BGMVolumeChanged;
        GameSettings.SEVolumeChanged  += SEVolumeChanged;

        OnMusic = SaveDataUtils.GetBoolUserDefault(DataDefine.Music, true);
        OnSound = SaveDataUtils.GetBoolUserDefault(DataDefine.Sound, true);

        UpdateMusic();
        UpdateSound();
    }
示例#14
0
    private void SaveRoleInforToLocal(string nickName, string modelId, string emotionId)
    {
        SelfPlayerData.Nickname  = nickName;
        SelfPlayerData.ModelId   = modelId;
        SelfPlayerData.EmotionId = emotionId;
        SaveDataUtils.Save <SelfPlayerData> ();
        //这时结束玩家第一次进游戏流程
        PlayerPrefs.SetString("isFirst", "True");

        AnalysisManager.Instance.OnEvent("enterTasteLevel", null);
        LoadSceneManager.Instance.LoadPlayScene(LevelConfig.AllLevelDic[1001]);
    }
示例#15
0
    void OnClickYes()
    {
        SelfPlayerData.Nickname  = text_name.text;
        SelfPlayerData.AvatarUrl = image_self.sprite.name.Replace("(Clone)", "");
        SelfPlayerLevelData.Instance.changeNameEvent.Invoke();

        SaveDataUtils.Save <SelfPlayerData>();
        if (MiscUtils.IsOnline() && !string.IsNullOrEmpty(SelfPlayerData.Uuid))
        {
            HttpHandler.UploadUser();
        }
        //node_scoreListNode.text_playerName.text = text_name.text;
        Close();
    }
示例#16
0
    /// 存入 SelfPlayerLevelData
    public static void UploadScore(Action callback          = null,
                                   bool successNeedCallback = true,
                                   bool failNeedCallback    = true)
    {
        string uuid = SelfPlayerData.Uuid;

        if (SelfPlayerLevelData.MaxScore <= 0 || string.IsNullOrEmpty(uuid))
        {
            return;
        }

        //string url = "api/game_app/v1/level_scores";
        JsonData data    = new JsonData();
        int      levelID = StaticData.LevelID;

        data["levelID"]      = levelID;
        data["accuracy"]     = SelfPlayerLevelData.TempAccuracy;
        data["score"]        = SelfPlayerLevelData.TempScore;
        data["uid"]          = uuid;
        data["maxCombo"]     = SelfPlayerLevelData.TempMaxCombo;
        data["finalHP"]      = SelfPlayerLevelData.TempLeftLife;
        data["readAccuracy"] = SelfPlayerLevelData.TempReadAccuracy;
        data["wordAccuracy"] = SelfPlayerLevelData.TempWordAccuracy;
        data["processData"]  = SelfPlayerLevelData.TempSelfLevelProcessData;
        //byte[] Data = System.Text.Encoding.UTF8.GetBytes(data.ToJson());
        SelfPlayerData.PlayerLevelData = SelfPlayerLevelData.Instance;
        SaveDataUtils.Save <SelfPlayerData>();

        SelfPlayerLevelData.Reset();



        SnapAppApi.UploadGameScores(data, (SnapRpcDataVO vo) =>
        {
            //LogManager.Log("wangji",vo.ToString());
            //LogManager.Log(" UploadScore.收到 = " , jsonString);
            JsonData json = vo.data;            //JsonMapper.ToObject(jsonString);
            LogManager.Log("上传分数成功之后:", json.ToJson());
            SelfPlayerLevelData.Instance.AddLevelData(levelID);
            SelfPlayerLevelData.LevelDic[levelID].rank    = int.Parse(json.TryGetString("rank", "0"));
            SelfPlayerLevelData.TempHistoryId             = json["enemy"].TryGetString("historyID");
            SelfPlayerLevelData.TempOtherLevelProcessData = json["enemy"].TryGetString("TargetUsers");
            SaveDataUtils.Save <SelfPlayerData>();
            if (callback != null && successNeedCallback)
            {
                callback.Invoke();
            }
        });
    }
示例#17
0
 void CGFinishCallback()
 {
     if (m_Status == Status.FirstTimeCG || m_Status == Status.BossAppearCG)
     {
         if (!SelfPlayerData.FirstTimeBossCG)
         {
             SelfPlayerData.FirstTimeBossCG = true;
             SaveDataUtils.Save <SelfPlayerData>();
         }
         m_SentenceCheckResult = RuntimeConst.BossWarLose;
         PlaySong();
         StartCoungting();
         //StartReadCurSentence();
     }
 }
示例#18
0
 private void Skip(AudioObject audioObject)
 {
     obj_hand.SetActive(false);
     if (m_Tap != null)
     {
         m_Tap.Delete();
     }
     SelfPlayerData.NewPlayer = false;
     VoiceController.instance.Restart();
     SaveDataUtils.Save <SelfPlayerData>();
     AudioController.StopCategory("Other");
     XunFeiSRManager.Instance.StopListen();
     MicManager.Instance.StopRecord();
     Instance = null;
     Destroy(transform.gameObject);
 }
示例#19
0
    public void Refresh(string uuid, string nickname, int level = 0, int energy = 0, int experience = 0)
    {
        if (!string.IsNullOrEmpty(uuid))
        {
            _uuid = uuid;
        }
        if (!string.IsNullOrEmpty(nickname))
        {
            _nickname = nickname;
        }
        _level      = level;
        _energy     = energy;
        _experience = experience;

        SaveDataUtils.Save <SelfPlayerData> ();
    }
示例#20
0
    /// <summary>
    /// 更新课程中关卡的状态
    /// </summary>
    /// <param name="levelId">Level identifier.</param>
    public void SetLevelStatus(int levelId)
    {
        LogManager.Log("更新关卡的状态:", levelId, CourseConfig.Instance);
        int courseId = CourseConfig.Instance.GetCourseIdFromLevelId(levelId);
        List <CourseData> courses = SelfPlayerData.CourseData;

        for (int i = 0; i < courses.Count; i++)
        {
            if (courses[i].m_CourseID == courseId)
            {
                courses[i].m_Progress++;
                SaveDataUtils.Save <SelfPlayerData> ();
                UpdateCourse(courses[i]);
                break;
            }
        }
    }
示例#21
0
    /// <summary>
    /// 保存游戏数据到本地
    /// </summary>
    /// <param name="user"></param>
    public static void SaveGameUser(JsonData user)
    {
        SelfPlayerData.PlayerLevelData = new SelfPlayerLevelData();
        //首先加载UserData,判断缓存里面是否有数据
        SaveDataUtils.Load <SelfPlayerData>();

        SelfPlayerData.DeviceID = user["deviceID"].ToString();
        SelfPlayerData.Uuid     = user["id"].ToString();

        SelfPlayerData.AppUID    = user["appUID"].ToString();
        SelfPlayerData.AvatarUrl = user["avatar"].ToString();
        SelfPlayerData.Sex       = int.Parse(user["sex"].ToString());
        SelfPlayerData.Age       = int.Parse(user["age"].ToString());
        SelfPlayerData.Country   = int.Parse(user["country"].ToString());
        SelfPlayerData.Nickname  = user["nickname"].ToString();
        SelfPlayerData.Profile   = user["profile"].ToString();

        int server_lv         = int.Parse(user["level"].ToString());
        int server_energy     = int.Parse(user["energy"].ToString());
        int server_experience = int.Parse(user["experience"].ToString());

        //暂时以本地的数据为基准
        //SelfPlayerData.Level = server_lv;
        //SelfPlayerData.Energy = server_energy;
        //SelfPlayerData.Experience = server_experience;

        if (SelfPlayerData.Level <= server_lv)
        {
            SelfPlayerData.Level = server_lv;
        }
        if (SelfPlayerData.Energy <= server_energy)
        {
            SelfPlayerData.Energy = server_energy;
        }
        if (SelfPlayerData.Experience <= server_experience)
        {
            SelfPlayerData.Experience = server_experience;
        }

        SelfPlayerLevelData.Instance = SelfPlayerData.PlayerLevelData;
        SaveDataUtils.Save <SelfPlayerData>();
        GlobalConst.Player_IDTemp = SelfPlayerData.Uuid;

        InitBuyly();
        UploadUserScore();
    }
示例#22
0
    /// <summary>
    /// 订单(漏单)处理完成, 清除记录
    /// </summary>
    /// <param name="userID"></param>
    /// <param name="payLoad"></param>
    public void RemoveItemIAPTransaction(string userID, string transactionID)
    {
        for (int i = 0; i < TransactionTemp.Count; i++)
        {
            if (TransactionTemp[i].userID == userID && TransactionTemp[i].transactionID == transactionID)
            {
                TransactionTemp.RemoveAt(i);
            }
        }

        SaveDataUtils.Save <IAPVerifyProxy>();

        string logStr = "单条订单(漏单)处理完成, 清除记录: 用户ID:" + userID + ", 订单ID:" + transactionID;

        //if (Manager) Manager.log(logStr);
        LogManager.Log(logStr);
    }
示例#23
0
        /// <summary>
        /// Every frame
        /// </summary>
        void Update()
        {
            if (PlayerCtrl.userId == null)
            {
                btnDeleteAuth.gameObject.SetActive(SaveDataUtils.HasKey(Defines.KEY_REFRESH_TOKEN));

                loginRoot.SetActive(true);
                inGameRoot.SetActive(false);
                Cursor.lockState = CursorLockMode.None;
                Cursor.visible   = true;
            }
            else
            {
                loginRoot.SetActive(false);
                inGameRoot.SetActive(true);

                var numDot      = DateTime.Now.Second % 3;
                var lobbyIdText = EOS.lobbyId == null ? "Connecting." + new string('.', numDot) : EOS.lobbyId;
                lblLobbyId.text   = $"Lobby Id : {lobbyIdText}";
                lblUserCount.text = $"User Count : {Ctrl.idToCtrl.Keys.Count}";
                lblHp.text        = $"HP : {PlayerCtrl.hp}/{PlayerCtrl.MAX_HP}";

                loginRoot.SetActive(false);

                if (Input.GetKeyDown(KeyCode.Escape))
                {
                    isLockMouse = false;
                }
                else if (Input.GetMouseButtonDown(0))
                {
                    isLockMouse = true;
                }

                if (isLockMouse)
                {
                    Cursor.lockState = CursorLockMode.Confined;
                    Cursor.visible   = false;
                }
                else
                {
                    Cursor.lockState = CursorLockMode.None;
                    Cursor.visible   = true;
                }
            }
        }
示例#24
0
    void onClickLoginHandle()
    {
        Regex Reg_Phone = new Regex(@"^1[2|3|4|5|6|7|8|9][0-9]\d{4,8}$");

        if (Input_pwd.text.Length < 11 || Reg_Phone.IsMatch(Input_pwd.text) == false)
        {
            ImgInputTelOK.transform.gameObject.SetActive(false);
            ImgInputTelError.transform.gameObject.SetActive(true);
            PromptManager.Instance.MessageBox(PromptManager.Type.FloatingTip, "手机号输入有误,请重新输入");
            return;
        }
        SelfPlayerData.TelphoneNum = Input_pwd.text;
        SaveDataUtils.Save <SelfPlayerData>();
        LoginRpcProxy.getInstance().ShareWeChatGameByLevelID();
        PageManager.Instance.CurrentPage.GetNode <ShareActivityNode>().Close(false);
        PageManager.Instance.CurrentPage.GetNode <WinNode>().Open();
        Close(true);
    }
示例#25
0
 void LoginDelegateHandler()
 {
     login_app.loginDelegate -= LoginDelegateHandler;
     clicked = true;
     if (GlobalConst.LoginToApp == false)
     {
         LogManager.Log(" 未登陆app需要走这段逻辑 ");
         LoadUserData();
     }
     if (!AudioController.IsPlaying("Click"))
     {
         AudioController.Play("Click");
     }
     AudioController.StopMusic();
     //print("okokookokokokok");
     //LoadSceneManager.Instance.LoadNormalScene(LoadSceneManager.BookSceneName);
     LogManager.Log("登录成功");
     SaveDataUtils.Load <IAPVerifyProxy>();
 }
示例#26
0
    public void Refresh(string uuid, string username, string nickname, string server, int level = 0, int energy = 0, int experience = 0)
    {
        bool save = false;

        if (!string.IsNullOrEmpty(uuid))
        {
            Uuid = uuid;
            save = true;
        }
        if (!string.IsNullOrEmpty(nickname))
        {
            Nickname = nickname;
            save     = true;
        }

        if (save)
        {
            SaveDataUtils.Save <PlayerInfo>();
        }
    }
        private async Task ImportInternal()
        {
            if (gameEquipments == null)
            {
                gameEquipments = LoadGameEquipments();
                if (gameEquipments == null)
                {
                    return;
                }
            }

            EquipmentSaveSlotInfo selected = await SaveDataUtils.GetEquipmentSaveSlot(saveSlotInfoSelector);

            if (selected == null)
            {
                return;
            }

            ApplySaveDataEquipments(selected);
        }
示例#28
0
    /// <summary>
    /// 上传游戏用户信息
    /// </summary>
    public void UploadGameUserInfo(Action action = null)
    {
        JsonData data = new JsonData();

        data["uid"]        = SelfPlayerData.Uuid;
        data["nickname"]   = SelfPlayerData.Nickname;
        data["level"]      = SelfPlayerData.Level;
        data["energy"]     = SelfPlayerData.Energy;
        data["experience"] = SelfPlayerData.Experience;
        data["avatar"]     = SelfPlayerData.AvatarUrl;

        //上传数据的时候做次缓存
        SaveDataUtils.Save <SelfPlayerData> ();
        SnapAppApi.Request_SnapAppApi(SnapAppApiInterface.Request_UploadGameInfo, SnapHttpConfig.NET_REQUEST_PUT, data, (SnapRpcDataVO rpcData) => {
            if (action != null)
            {
                action.Invoke();
            }
        });
    }
示例#29
0
        /// <summary>
        /// Login by browser auth
        /// </summary>
        /// <returns>Task</returns>
        public static async UniTask LoginAuth()
        {
            var auth = EOS.auth;

            var refreshToken          = SaveDataUtils.GetString(Defines.KEY_REFRESH_TOKEN);
            LoginCallbackInfo authRes = null;

            if (refreshToken.NotEmpty())
            {
                authRes = await auth.Login(LoginCredentialType.RefreshToken, string.Empty, refreshToken);
            }

            if (authRes == null)
            {
                authRes = await auth.Login(LoginCredentialType.AccountPortal, string.Empty, string.Empty);

                if (authRes == null)
                {
                    return;
                }
            }

            await _Login(authRes);
        }
示例#30
0
 private void getUserInfoFromCache()
 {
     SaveDataUtils.Load <SelfPlayerData>();
     Input_account.text = PlayerPrefs.GetString("user_cache_name");
     Input_pwd.text     = PlayerPrefs.GetString("user_cache_pwd");
 }