Example #1
0
 public void SavePlayBackData(string objName, string describe)
 {
     if (PlayBackController.Instance.dicPlaybackData.ContainsKey(deduceTime))
     {
         List <PlayBackData> dataList = new List <PlayBackData>();
         PlayBackData        data     = new PlayBackData();
         //if (PlayBackController.Instance.dicCommandDescribe[deduceTime].ContainsKey(data.JzjName))
         //{
         //    PlayBackController.Instance.dicCommandDescribe[deduceTime][data.JzjName].Add(data);
         //}
         //else
         //{
         //    dataList.Add(data);
         //    PlayBackController.Instance.dicCommandDescribe[deduceTime].Add(data.JzjName, dataList);
         //}
     }
     else
     {
         Dictionary <string, List <PlayBackData> > dicData = new Dictionary <string, List <PlayBackData> >();
         List <PlayBackData> dataList = new List <PlayBackData>();
         PlayBackData        data     = new PlayBackData();
         data.describe = describe;
         //if (dicData.ContainsKey(data.JzjName))
         //{
         //    dicData[data.JzjName].Add(data);
         //}
         //else
         //{
         //    dataList.Add(data);
         //    dicData.Add(data.JzjName, dataList);
         //}
         PlayBackController.Instance.dicPlaybackData.Add(deduceTime, dicData);
     }
 }
Example #2
0
    public static void Load(string filepath, string readName)
    {
        if (File.Exists(filepath))
        {
            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.Load(filepath);
            XmlNode     nodeName     = xmlDoc.FirstChild;
            XmlNodeList nodeNameList = nodeName.ChildNodes;

            foreach (XmlElement node in nodeNameList)
            {
                if (node.GetAttribute("name") == readName)
                {
                    XmlNodeList playBackList = node.ChildNodes;
                    foreach (XmlElement xe in playBackList)
                    {
                        PlayBackData data = new PlayBackData();
                        data.time     = DateTime.Parse(xe.GetAttribute("time"));
                        data.describe = xe.GetAttribute("describe");
                        XmlNodeList playBackAttributeList = xe.ChildNodes;
                        foreach (XmlElement x in playBackAttributeList)
                        {
                            XmlAttributeCollection col = x.Attributes;
                            if (x.Name == "state")
                            {
                                XmlAttribute stateAttribute = col["value"];
                                data.state = int.Parse(stateAttribute.Value);
                            }
                        }
                        if (PlayBackController.Instance.dicPlaybackData.Count > 0)
                        {
                            PlayBackController.Instance.dicPlaybackData.Clear();
                        }
                        if (PlayBackController.Instance.dicPlayBack.ContainsKey(data.time))
                        {
                            PlayBackController.Instance.dicPlayBack[data.time].Add(data);
                        }
                        else
                        {
                            List <PlayBackData> ls = new List <PlayBackData>();
                            ls.Add(data);
                            PlayBackController.Instance.dicPlayBack.Add(data.time, ls);
                        }
                    }
                }
            }
        }
    }
Example #3
0
    public static PlayBackData GetPlayBackData(string text)
    {
        if (text.Length == 0 || text == null)
        {
            return(null);
        }
        PlayBackData             backData        = JsonMapper.ToObject <PlayBackData>(text);
        string                   fingtingLogData = backData.fightingLog;
        JsonData                 fightData       = JsonMapper.ToObject(fingtingLogData);
        List <PlayBackFightData> listFight       = new List <PlayBackFightData>();

        for (int i = 0; i < fightData.Count; i++)
        {
            string each = fightData[i].ToJson();
            listFight.Add(JsonMapper.ToObject <PlayBackFightData>(each));
        }
        backData.fightingLog        = null;
        backData.fightingPutoutlist = listFight;
        return(backData);
    }
Example #4
0
        /// <summary>
        /// 获取玩家的回放数据
        /// </summary>
        /// <param name="json"></param>
        /// <param name="status"></param>
        void GetPlayerPlayBackData(string json, int status)
        {
            PlayBackData        pbd  = GameData.Instance.PlayBackData;
            PlayBackMessageData data = new PlayBackMessageData();

            data = JsonBase.DeserializeFromJson <PlayBackMessageData>(json.ToString());
            if (data.lsPlayBackMessageData[0].status != 1)
            {
                Debug.LogError("获取网页json数据状态错误,status:" + data.lsPlayBackMessageData[0].status);
                UIMgr.GetInstance().GetUIMessageView().Show("您的回放数据版本过低,无法查看!");
                return;
            }

            //将数据保存到list中
            for (int i = 0; i < data.lsPlayBackMessageData.Count; i++)
            {
                //庄家座位号赋值
                pbd.byDealerSeat = Convert.ToInt32(data.lsPlayBackMessageData[i].dealer);

                //昵称赋值
                pbd.sName[0] = data.lsPlayBackMessageData[i].nick1;
                pbd.sName[1] = data.lsPlayBackMessageData[i].nick2;
                pbd.sName[2] = data.lsPlayBackMessageData[i].nick3;
                pbd.sName[3] = data.lsPlayBackMessageData[i].nick4;

                //头像赋值
                pbd.sHeadUrl[0] = data.lsPlayBackMessageData[i].head1;
                pbd.sHeadUrl[1] = data.lsPlayBackMessageData[i].head2;
                pbd.sHeadUrl[2] = data.lsPlayBackMessageData[i].head3;
                pbd.sHeadUrl[3] = data.lsPlayBackMessageData[i].head4;

                //性别赋值
                pbd.sex[0] = Convert.ToInt32(data.lsPlayBackMessageData[i].sex1);
                pbd.sex[1] = Convert.ToInt32(data.lsPlayBackMessageData[i].sex2);
                pbd.sex[2] = Convert.ToInt32(data.lsPlayBackMessageData[i].sex3);
                pbd.sex[3] = Convert.ToInt32(data.lsPlayBackMessageData[i].sex4);

                //玩家id赋值
                pbd.iUserId[0] = Convert.ToInt32(data.lsPlayBackMessageData[i].uid1);
                pbd.iUserId[1] = Convert.ToInt32(data.lsPlayBackMessageData[i].uid2);
                pbd.iUserId[2] = Convert.ToInt32(data.lsPlayBackMessageData[i].uid3);
                pbd.iUserId[3] = Convert.ToInt32(data.lsPlayBackMessageData[i].uid4);

                //添加房间号,玩法id
                pbd.sRoomId         = String.Format("{0:000000}", data.lsPlayBackMessageData[i].roomNum);
                pbd.iMethodId       = Convert.ToInt16(data.lsPlayBackMessageData[i].playing_method);
                pbd.iCurrentGameNum = data.lsPlayBackMessageData[i].roomProgress;

                //  Debug.LogError("玩家的第一视角座位号:" + Convert.ToInt32(data.lsPlayBackMessageData[i].seatIndex));

                pbd.ShowSeatNum = Convert.ToInt32(data.lsPlayBackMessageData[i].seatIndex) + 1;

                //改变第一视角的座位号
                for (int j = 0; j < pbd.iUserId.Length; j++)
                {
                    if (GameData.Instance.PlayerNodeDef.iUserId == pbd.iUserId[j])
                    {
                        pbd.ShowSeatNum = j + 1;
                    }
                }

                //确定玩家的操作步数
                pbd.iAllDealNum = data.lsPlayBackMessageData[i].replay.Split(',').Length;

                //解析版本号
                pbd.iPlayBackVersion = Convert.ToInt32(data.lsPlayBackMessageData[i].replay.Split('>')[0]);
                if (pbd.iPlayBackVersion < pbd.iPbVersion_Old)
                {
                    UIMgr.GetInstance().GetUIMessageView().Show("您的回放数据版本过低,无法查看!");
                    SDKManager.Instance.gameObject.GetComponent <anhui.CameControler>().PostMsg("uloading");
                    return;
                }

                //解析玩法配置回应消息(直接调用的消息结构体,后面有补位“0”)
                string message = data.lsPlayBackMessageData[i].replay.Split('>')[1] + "000000";
                int    ioffset = 0;


                //如果是版本2则,读取最新的消息
                if (pbd.iPlayBackVersion == pbd.iPbVersion_New)
                {
                    MahjongGame_AH.Network.Message.NetMsg.ClientPlayingMethodConfRes msg = new MahjongGame_AH.Network.Message.NetMsg.ClientPlayingMethodConfRes();
                    ioffset = msg.parseBytes(pbd.GetByteToString(message, 48), ioffset);
                    pbd.playingMethodConf = msg.playingMethodConf;


                    //解析玩家的初试分数
                    string[] sPoint = data.lsPlayBackMessageData[i].replay.Split('>')[2].Split(',');
                    for (int k = 0; k < 4; k++)
                    {
                        pbd.iPoint[k]     = Convert.ToInt16(sPoint[k]);
                        pbd.iPointInit[k] = Convert.ToInt16(sPoint[k]);
                    }
                    //解析回放数据
                    pbd.sPlayBackMessageData = new string[pbd.iAllDealNum];
                    pbd.sPlayBackMessageData = data.lsPlayBackMessageData[i].replay.Split('>')[3].Split(',');
                }
                //如果是版本1,则读取上个版本的消息
                else if (pbd.iPlayBackVersion == pbd.iPbVersion_Old)
                {
                    MahjongGame_AH.Network.Message.NetMsg.ClientPlayingMethodConfRes_2 msg = new MahjongGame_AH.Network.Message.NetMsg.ClientPlayingMethodConfRes_2();
                    ioffset = msg.parseBytes(pbd.GetByteToString(message, 20), ioffset);
                    pbd.playingMethodConf_2 = msg.playingMethodConf;
                    //解析回放数据
                    pbd.sPlayBackMessageData = new string[pbd.iAllDealNum];
                    pbd.sPlayBackMessageData = data.lsPlayBackMessageData[i].replay.Split('>')[3].Split(',');
                }

                //解析玩法参数
                string[] str = data.lsPlayBackMessageData[i].param.Split(',');
                for (int j = 0; j < str.Length; j++)
                {
                    pbd.iPlayMethodParam[j] = Convert.ToUInt32(str[j]);
                }

                //Debug.LogError("回放数据:" + data.lsPlayBackMessageData[i].replay);

                //开放参数赋值
                if (!data.lsPlayBackMessageData[i].param.Contains(","))
                {
                    //跳转场景
                    anhui.MahjongCommonMethod.Instance.SkipPlayBack_();
                    //pbd.OpenPlayBackScene();
                    //UnityEngine.SceneManagement.SceneManager.LoadScene("GradePlayBack", UnityEngine.SceneManagement.LoadSceneMode.Additive);
                    //Application.LoadLevelAdditiveAsync("GradePlayBack");
                    return;
                }

                string[] param = data.lsPlayBackMessageData[i].param.Split(',');
                for (int k = 0; k < param.Length; k++)
                {
                    pbd.iOpenRoomParam[i] = Convert.ToUInt32(param[k]);
                }
            }

            //跳转场景
            anhui.MahjongCommonMethod.Instance.SkipPlayBack_();
            //pbd.OpenPlayBackScene();
            //UnityEngine.SceneManagement.SceneManager.LoadScene("GradePlayBack", UnityEngine.SceneManagement.LoadSceneMode.Additive);
            //Application.LoadLevelAdditiveAsync("GradePlayBack");
        }