Exemple #1
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);
            }
        }
Exemple #2
0
 public void PutLong(ISFSObject data, string key, long item)
 {
     if (sendEncrypted)
     {
         data.PutByteArray(key, provider.EncryptLong(item));
     }
     else
     {
         data.PutLong(key, item);
     }
 }
Exemple #3
0
    private void OnRoomJoin(BaseEvent evt)
    {
        Room room = (Room)evt.Params["room"];

        // Clear chat (uless this is the first time a Room is joined - or the initial system message would be deleted)
        //if (!firstJoin)
        //chatText.text = "";

        firstJoin = false;

        // Show system message
        Debug.Log("\nYou joined room '" + room.Name + "'\n");

        // Enable chat controls
        //chatControls.interactable = true;

        // Populate users list
        //populateUserList(room.UserList);


        ISFSObject parameters = SFSObject.NewInstance();

        parameters.PutInt("0", 1);        // sit id
        parameters.PutLong("1", 1000000); // money on sit

        sfs.Send(new ExtensionRequest("sc", parameters));

        sitting = true;

        Debug.Log("SENDING Sit");

        ISFSObject parameters2 = SFSObject.NewInstance();

        parameters.PutLong("0", 100);  // bet amount
        parameters.PutInt("1", 10);    // number of lines
        parameters.PutInt("2", 0);     // seat number
        parameters.PutLong("3", 1000); // user money
        parameters.PutLong("4", 100);  // user experiance

        sfs.Send(new ExtensionRequest("sss", parameters2));
    }
Exemple #4
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();
            }
        }
Exemple #5
0
    private void OnExtensionResponse(BaseEvent evt)
    {
        Debug.Log("EXTENSION CALL RECIVED");


        if (sitting)
        {
            ISFSObject parameters = SFSObject.NewInstance();
            parameters.PutLong("0", 100);  // bet amount
            parameters.PutInt("1", 10);    // number of lines
            parameters.PutInt("2", 0);     // seat number
            parameters.PutLong("3", 1000); // user money
            parameters.PutLong("4", 100);  // user experiance

            sfs.Send(new ExtensionRequest("sss", parameters, sfs.LastJoinedRoom));
        }
        else
        {
            string    cmd        = (string)evt.Params["cmd"];
            SFSObject dataObject = (SFSObject)evt.Params["params"];

            Debug.Log(evt);
        }
    }
 public void PutLong(ISFSObject data, string key, long item)
 {
     if (sendEncrypted)
     {
         data.PutByteArray(key, provider.EncryptLong(item));
     }
     else
     {
         data.PutLong(key, item);
     }
 }
Exemple #7
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);
        }
Exemple #8
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);
        }