コード例 #1
0
        protected void OnAutoFollow()
        {
            IsAutoFollow = !IsAutoFollow;
            ISFSObject sendObj = SFSObject.NewInstance();

            if (IsAutoFollow)
            {
                //判断当前用户是否是自己
                if (CurrenPlayer == SelfSeat)
                {
                    EventObj.SendEvent("ServerEvent", "FollowReq", null);
                }
            }
            else
            {
                if (CurrenPlayer == SelfSeat)
                {
                    sendObj.PutDouble("CdTime", CdTime - (double)(JhFunc.GetTimeStamp(false) - LastTime) / 1000.0f);
                }
            }
            sendObj.PutBool("IsCurrPlayer", CurrenPlayer == SelfSeat);
            sendObj.PutBool("IsAutoFollow", IsAutoFollow);
            SetSfsUserContrl(sendObj);
            EventObj.SendEvent("PlayersViewEvent", "AutoFollow", sendObj);
        }
コード例 #2
0
        protected void SendGameStatusToTableView()
        {
            ISFSObject sendObj = SFSObject.NewInstance();

            sendObj.PutInt("SingleBet", SingleBet);
            JhUserInfo user = GetPlayerInfo <JhUserInfo>();

            if (RStatus <= RoomStatus.CanStart)
            {
                if (user.IsReady == false)
                {
                    sendObj.PutInt("ShowReady", 1);
                }
#if UNITY_IPHONE || UNITY_ANDROID
                if (IsCreatRoom && CreateRoomInfo.CurRound <= 0)
                {
                    sendObj.PutInt("ShowWx", 1);
                }
#endif
            }
            else
            {
                sendObj.PutInt("TotalBeat", TotalBet);
            }

            sendObj.PutBool("IsFangKa", IsCreatRoom);
            if (IsCreatRoom)
            {
                if (BankerSeat == SelfSeat)
                {
                    if (RStatus != RoomStatus.CanStart)
                    {
                        sendObj.PutBool("ShowStart", false);
                    }
                    else
                    {
                        sendObj.PutBool("ShowStart", true);
                    }
                }
                sendObj.PutInt("RoomId", CreateRoomInfo.RoomId);
                sendObj.PutInt("MaxJu", CreateRoomInfo.MaxRound);
                sendObj.PutInt("CurJu", CreateRoomInfo.CurRound);
                sendObj.PutInt("Ante", AnteRate[0]);
            }

            sendObj.PutInt("MaxLun", maxRound);
            sendObj.PutInt("CurLun", CurRound);

            if (RStatus > RoomStatus.CanStart)
            {
                sendObj.PutBool("HideReadyTip", true);
            }

            EventObj.SendEvent("TableViewEvent", "Status", sendObj);
        }
コード例 #3
0
        private void OnAutoRequest(KeyValuePair <int, bool> autoStateChange)
        {
            ISFSObject iobj = GameTools.getSFSObject((int)EnumRequest.Auto);

            iobj.PutBool(RequestKey.KeyAuto, autoStateChange.Value);
            SendGameRequest(iobj);
        }
コード例 #4
0
        // Request
        private static bool SFOnDataWritePatch(ref IMessage __0)
        {
            ISFSObject raw = __0.Content;
            bool       log = true;

            // System
            if (raw.GetByte("c") == 0)
            {
            }
            // Game
            else if (raw.GetByte("c") == 1)
            {
                ISFSObject p = raw.GetSFSObject("p");
                // Player movements
                string c = p.GetUtfString("c");
                if (c == "spawnMonster")
                {
                    ISFSObject p2 = p.GetSFSObject("p");
                    p2.PutBool("sp", true);
                }
                if (c == "UPP" || c == "playerAction.CM")
                {
                    log = false;
                }
            }
            if (log)
            {
                Logger.LogLine($"Sending request (ID {Convert.ToInt32(raw.GetShort("a"))}):\n{raw.GetDump()}", ConsoleColor.Green);
            }
            return(true);
        }
コード例 #5
0
ファイル: ProductScreen.cs プロジェクト: shldn/mdons
    public void UpdateServerRefreshMe()
    {
        ISFSObject productUpdateObj = CreateProductUpdateMessageWithID();

        productUpdateObj.PutBool("rp", true); // refresh product
        CommunicationManager.SendObjectMsg(productUpdateObj);
    }
コード例 #6
0
        public void OnResult(ISFSObject response)
        {
            RStatus = RoomStatus.Over;
            int[]      cards = response.GetIntArray("cards");
            JhUserInfo self  = GetPlayerInfo <JhUserInfo>();

            self.Cards = cards;
            ISFSArray users = response.GetSFSArray("users");

            for (int i = 0; i < users.Count; i++)
            {
                ISFSObject itemData = users.GetSFSObject(i);
                int        seat     = itemData.GetInt("seat");
                JhUserInfo user     = GetPlayerInfo <JhUserInfo>(seat, true);
                user.SetResult(itemData);
            }

            if (response.ContainsKey("compare"))
            {
                ISFSArray arr = response.GetSFSArray("compare");
                for (int i = 0; i < arr.Size(); i++)
                {
                    ISFSObject obj   = arr.GetSFSObject(i);
                    int        seat  = obj.GetInt("seat");
                    JhUserInfo uInfo = GetPlayerInfo <JhUserInfo>(seat, true);
                    uInfo.Cards = obj.GetIntArray("cards");
                    int[] cards1 = obj.GetIntArray("cards");
                    Debug.LogError(" result cards " + uInfo.NickM + "  " + cards1[0] + " " + cards1[1] + " " + cards1[2]);
                }
            }


            bool isWinner = false;

            ResultSfs = SFSArray.NewInstance();
            foreach (var useinfo in UserInfoDict)
            {
                if (useinfo.Value.IsPlayingGame)
                {
                    JhUserInfo jhUserInfo = ((JhUserInfo)useinfo.Value);
                    ISFSObject obj        = jhUserInfo.GetResultSfsObject();
                    obj.PutInt("Chair", useinfo.Key);

                    if (useinfo.Key == 0 && jhUserInfo.IsWinner)
                    {
                        isWinner = true;
                    }
                    obj.PutBool("IsWinner", isWinner);
                    ResultSfs.AddSFSObject(obj);
                }
            }

            EventObj.SendEvent("PlayersViewEvent", "Result", ResultSfs);

            ResultDelay = StartCoroutine(SendToResultView(ResultSfs));

            EventObj.SendEvent("SoundEvent", "PlayerEffect", new JhSound.SoundData(isWinner ? JhSound.EnAudio.Win : JhSound.EnAudio.Lost));
        }
コード例 #7
0
        public void OnGameInfo(ISFSObject data)
        {
            if (data.ContainsKey("tptime"))
            {
                HupTime = data.GetInt("tptime");
            }

            string hupInfo;

            if (data.ContainsKey("hup"))
            {
                hupInfo = data.GetUtfString("hup");
            }
            else
            {
                return;
            }
            //接收重连解散信息
            if (!string.IsNullOrEmpty(hupInfo))
            {
                IsNotFirstTime = true;
                StartTime      = data.ContainsKey("hupstart") ? data.GetLong("hupstart") : 0;
                string[] ids = hupInfo.Split(',');

                for (int i = 0; i < ids.Length; i++)
                {
                    for (int j = 0, max = UserHupUp.Count; j < max; j++)
                    {
                        var id = int.Parse(ids[i]);
                        if (id.Equals(int.Parse(UserHupUp[j].UserInfo.UserId)))
                        {
                            //2发起投票 3同意 -1拒绝
                            UserHupUp[j].Status = i == 0 ? HupType.Start : HupType.TongYi;
                            if (id.Equals(int.Parse(SelfID)))
                            {
                                SelfChoose = true;
                            }
                        }
                    }
                }

                ISFSObject sendObj = SFSObject.NewInstance();
                ISFSArray  arr     = SFSArray.NewInstance();
                foreach (HupUp hupUp in UserHupUp)
                {
                    arr.AddSFSObject(hupUp.GetSfsObject());
                }
                sendObj.PutSFSArray("Users", arr);
                sendObj.PutInt("HupTime", HupTime);
                sendObj.PutLong("StartTime", StartTime);
                sendObj.PutBool("SelfChoose", SelfChoose);
                //发送投票view
                EventObj.SendEvent("HupUpViewEvent", "HupUp", sendObj);
            }
        }
コード例 #8
0
 public void PutBool(ISFSObject data, string key, bool item)
 {
     if (sendEncrypted)
     {
         data.PutByteArray(key, provider.EncryptBool(item));
     }
     else
     {
         data.PutBool(key, item);
     }
 }
コード例 #9
0
 public void PutBool(ISFSObject data, string key, bool item)
 {
     if (sendEncrypted)
     {
         data.PutByteArray(key, provider.EncryptBool(item));
     }
     else
     {
         data.PutBool(key, item);
     }
 }
コード例 #10
0
        protected void OnHupUpResponse(object data)
        {
            ISFSObject obj    = (ISFSObject)data;
            int        id     = obj.GetInt(RequestKey.KeyId);
            int        starus = obj.GetInt(RequestKey.KeyType);

            if (starus == 2)
            {
                SelfChoose = false;
                foreach (HupUp hupUp in UserHupUp)
                {
                    hupUp.Status = 0;
                }
            }
            foreach (HupUp hupUp in UserHupUp)
            {
                if (hupUp.UserInfo.UserId.Equals(id.ToString()))
                {
                    hupUp.Status = (HupType)starus;
                }
            }
            if (id.Equals(int.Parse(SelfID)))
            {
                SelfChoose = true;
            }

            ISFSObject sendObj = SFSObject.NewInstance();

            if (!IsNotFirstTime)
            {
                StartTime      = JhFunc.GetTimeStamp();
                IsNotFirstTime = true;
                sendObj.PutInt("HupTime", HupTime);
                sendObj.PutLong("StartTime", StartTime);
            }

            ISFSArray arr = SFSArray.NewInstance();

            foreach (HupUp hupUp in UserHupUp)
            {
                arr.AddSFSObject(hupUp.GetSfsObject());
            }
            sendObj.PutSFSArray("Users", arr);
            sendObj.PutBool("SelfChoose", SelfChoose);
            //发送投票view
            EventObj.SendEvent("HupUpViewEvent", "HupUp", sendObj);

            if (starus == -1)
            {
                CloseHup();
                Reset();
            }
        }
コード例 #11
0
            public ISFSObject GetSfsObj()
            {
                ISFSObject obj = SFSObject.NewInstance();

                obj.PutUtfString("Name", Name);
                obj.PutUtfString("Avatar", Avatar);
                obj.PutInt("Sex", Sex);
                obj.PutInt("WinCnt", WinCnt);
                obj.PutInt("LostCnt", LostCnt);
                obj.PutInt("BipaiCnt", BipaiCnt);
                obj.PutInt("Gold", Gold);
                obj.PutBool("IsBigWinner", IsBigWinner);
                obj.PutInt("UID", UId);
                return(obj);
            }
コード例 #12
0
        public override void UserIdle(int localSeat, ISFSObject responseData)
        {
            if (_onUserIdle == null)
            {
                return;
            }

            ISFSObject data = responseData;

            data.PutInt(RequestKey.KeySeat, data.GetInt(RequestKey.KeySeat));
            data.PutBool(NewRequestKey.KeyUserIdle, true);
            var eventArgs = new DdzbaseEventArgs(data);

            _onUserIdle(this, eventArgs);
        }
コード例 #13
0
        /****
         * 公共 sfs 组合
         */
        protected void SetSfsUserContrl(ISFSObject sendObj)
        {
            JhUserInfo userInfo = GetPlayerInfo <JhUserInfo>();

            sendObj.PutBool("IsCanLook", IsCanLook && !userInfo.IsLook);
            sendObj.PutBool("IsCanGiveup", IsCanGiveUp && (!userInfo.IsGiveUp || userInfo.IsFail));
            //如果是开发 不用在意金币
            bool compare = IsCanCompare && (IsCreatRoom || (userInfo.IsLook ? SingleBet * 2 * BiPaiBeiShu : SingleBet * BiPaiBeiShu) < userInfo.CoinA);

            sendObj.PutBool("IsCanCompare", compare);
            sendObj.PutBool("IsUserPlaying", userInfo.IsPlaying());
            sendObj.PutBool("ShowCard", userInfo.ShowCards());
            sendObj.PutBool("IsGzyz", userInfo.IsGzyz);
            sendObj.PutBool("IsAutoFollow", IsAutoFollow);
        }
コード例 #14
0
        public void OnLookCards(ISFSObject response)
        {
            LastTime = JhFunc.GetTimeStamp(false);

            int        seat  = response.GetInt("seat");
            JhUserInfo uinfo = GetPlayerInfo <JhUserInfo>(seat, true);

            uinfo.IsLook = true;
            if (SelfSeat == seat)
            {
                uinfo.Cards = response.GetIntArray("cards");
            }

            if (response.ContainsKey("gzyz"))
            {
                uinfo.IsGzyz = response.GetBool("gzyz");
            }

            ISFSObject sendObj = SFSObject.NewInstance();

            sendObj.PutInt("LookChair", GetLocalSeat(seat));

            if (SelfSeat == seat)
            {
                sendObj.PutIntArray("Cards", uinfo.Cards);
            }

            if (SelfSeat == seat && SelfSeat == CurrenPlayer)
            {
                sendObj.PutBool("IsCurPlayer", true);
                SetSfsUserContrl(sendObj);
            }

            EventObj.SendEvent("PlayersViewEvent", "Look", sendObj);

            EventObj.SendEvent("SoundEvent", "PersonSound", new JhSound.SoundData(JhSound.EnAudio.Look, uinfo.SexI));
        }
コード例 #15
0
        public ISFSObject GetSfsObject(RoomStatus status)
        {
            ISFSObject obj = SFSObject.NewInstance();

            if (status <= RoomStatus.CanStart)
            {
                obj.PutBool("IsReady", IsReady);
            }
            else
            {
                obj.PutBool("IsLook", IsLook);
                obj.PutBool("IsGiveUp", IsGiveUp);
                obj.PutBool("IsFail", IsFail);
                obj.PutBool("IsPlaying", IsPlayingGame);
                obj.PutBool("IsGzyz", IsGzyz);
                if ((IsLook || IsShowCards) && Cards != null)
                {
                    obj.PutIntArray("Cards", Cards);
                }
                obj.PutInt("AllBeat", AllBeat);
            }

            return(obj);
        }
コード例 #16
0
        public void OnGuZhuYiZhi(ISFSObject response)
        {
            int  gold  = response.GetInt("goldinc");
            bool isWin = response.GetBool("result");

            JhUserInfo biUser = GetPlayerInfo <JhUserInfo>(CurrenPlayer, true);

            biUser.CoinA -= gold;
            TotalBet     += gold;
            biUser.IsGzyz = false;
            List <int> lostList = new List <int>();

            if (isWin)
            {
                foreach (var userInfo in UserInfoDict)
                {
                    JhUserInfo jhUser = (JhUserInfo)userInfo.Value;
                    if (jhUser != biUser)
                    {
                        jhUser.IsFail = true;
                        lostList.Add(GetLocalSeat(jhUser.Seat));
                    }
                }
            }
            else
            {
                biUser.IsFail = true;
                lostList.Add(GetLocalSeat(CurrenPlayer));
            }

            if (response.ContainsKey("fancha"))
            {
                ISFSArray arr = response.GetSFSArray("fancha");
                for (int i = 0; i < arr.Count; i++)
                {
                    ISFSObject obj     = arr.GetSFSObject(i);
                    int        seat    = obj.GetInt("seat");
                    int        fancha  = obj.GetInt("gold");
                    JhUserInfo fanUser = GetPlayerInfo <JhUserInfo>(seat, true);
                    fanUser.CoinA += fancha;
                }
            }

            ISFSObject sendObj = SFSObject.NewInstance();

            sendObj.PutInt("Chair", GetLocalSeat(CurrenPlayer));
            sendObj.PutInt("Gold", gold);
            sendObj.PutBool("isWin", isWin);
            sendObj.PutUtfString("Name", biUser.Name);
            sendObj.PutIntArray("LostList", lostList.ToArray());
            //如果存在 反差值的情况 刷新金币
            if (response.ContainsKey("fancha"))
            {
                //刷新金币
                ISFSArray arr = SFSArray.NewInstance();
                foreach (var info in UserInfoDict)
                {
                    JhUserInfo jhInfo = (JhUserInfo)info.Value;
                    if (jhInfo.IsPlaying())
                    {
                        ISFSObject obj = SFSObject.NewInstance();
                        obj.PutInt("Chair", GetLocalSeat(jhInfo.Seat));
                        obj.PutLong("Gold", jhInfo.CoinA);
                        arr.AddSFSObject(obj);
                    }
                }
                sendObj.PutSFSArray("FanCha", arr);
            }

            EventObj.SendEvent("PlayersViewEvent", "GZYZ", sendObj);

            EventObj.SendEvent("SoundEvent", "PlayerEffect", new JhSound.SoundData(JhSound.EnAudio.CompareAnimate));

            EventObj.SendEvent("TableViewEvent", "Bet", TotalBet);
        }
コード例 #17
0
        protected void SendGameStatusToPlayerView()
        {
            ISFSObject sendObj   = SFSObject.NewInstance();
            ISFSArray  sendArray = SFSArray.NewInstance();

            foreach (var info in UserInfoDict)
            {
                JhUserInfo userInfo = (JhUserInfo)info.Value;
                if (userInfo != null)
                {
                    ISFSObject obj = userInfo.GetSfsObject(RStatus);
                    obj.PutInt("Chair", GetLocalSeat(userInfo.Seat));
                    sendArray.AddSFSObject(obj);
                }
            }
            sendObj.PutBool("isShowTimeTip", CoustemTime > 0);

            if (RStatus > RoomStatus.CanStart)
            {
                sendObj.PutInt("CurChair", GetLocalSeat(CurrenPlayer));
                sendObj.PutDouble("CdTime", CdTime);
                sendObj.PutLong("LastTime", LastTime);

                if (CurrenPlayer == SelfSeat)
                {
                    JhUserInfo curUser = GetPlayerInfo <JhUserInfo>(CurrenPlayer, true);
                    if (!curUser.IsGzyz && IsAutoFollow)
                    {
                        sendObj.PutDouble("CdTime", 2.0f);
                    }
                }

                JhUserInfo currP = GetPlayerInfo <JhUserInfo>(CurrenPlayer, true);
                SetCurrenPlayerBeatMinAndMax(currP, sendObj);

                sendObj.PutInt("Banker", GetLocalSeat(BankerSeat));

                if (TotalBet != 0)
                {
                    ISFSArray betArray = SFSArray.NewInstance();
                    int       ttBet    = TotalBet;
                    for (int i = AnteRate.Count - 1; i >= 0; i--)
                    {
                        if (ttBet >= AnteRate[i])
                        {
                            ISFSObject arrO = SFSObject.NewInstance();
                            arrO.PutInt("ChipValue", AnteRate[i]);
                            arrO.PutInt("ChipIndex", i);
                            arrO.PutInt("ChipCnt", ttBet / AnteRate[i]);
                            betArray.AddSFSObject(arrO);
                            ttBet = ttBet % AnteRate[i];
                        }
                    }
                    sendObj.PutSFSArray("ChipList", betArray);
                }
            }

            sendObj.PutSFSArray("Players", sendArray);
            sendObj.PutIntArray("Antes", AnteRate.ToArray());
            sendObj.PutInt("SingleBet", SingleBet);
            sendObj.PutBool("IsPlaying", RStatus > RoomStatus.CanStart && RStatus != RoomStatus.Over);

            SetSfsUserContrl(sendObj);

            EventObj.SendEvent("PlayersViewEvent", "Status", sendObj);
        }