Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
 public virtual void ResetAnimation()
 {
     Pk1Obj.transform.position = Pos1;
     Pk2Obj.transform.position = Pos2;
     JhFunc.AddDepthForWidget(Pk1Obj.GetComponent <UIWidget>(), -30);
     JhFunc.AddDepthForWidget(Pk2Obj.GetComponent <UIWidget>(), -30);
     Pk1.SetActive(false);
     Pk2.SetActive(false);
     Animation.SetActive(false);
     Gzyz.SetActive(false);
 }
Ejemplo n.º 3
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();
            }
        }
Ejemplo n.º 4
0
        public void OnCurPlayer(ISFSObject response)
        {
            LastTime = JhFunc.GetTimeStamp(false);

            CurrenPlayer = response.GetInt("p");
            CurRound     = response.GetInt("round");
            CdTime       = response.GetInt("cd");
            SingleBet    = response.GetInt("minGold");

            if (response.ContainsKey("look"))
            {
                IsCanLook = response.GetBool("look");
            }
            if (response.ContainsKey("compare"))
            {
                IsCanCompare = response.GetBool("compare");
            }
            if (response.ContainsKey("giveup"))
            {
                IsCanGiveUp = response.GetBool("giveup");
            }

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

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

            ISFSObject sendObj = SFSObject.NewInstance();

            sendObj.PutInt("Chair", GetLocalSeat(CurrenPlayer));
            SetSfsUserContrl(sendObj);
            sendObj.PutDouble("CdTime", CdTime);
            sendObj.PutInt("SingleBet", SingleBet);
            if (CurrenPlayer == SelfSeat)
            {
                if (!curUser.IsGzyz && IsAutoFollow)
                {
                    sendObj.PutDouble("CdTime", 2.0f);
                }
            }

            SetCurrenPlayerBeatMinAndMax(curUser, sendObj);

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


            sendObj.PutInt("MaxLun", maxRound);
            sendObj.PutInt("CurLun", CurRound);
            EventObj.SendEvent("TableViewEvent", "CurrPlayer", sendObj);
        }
Ejemplo n.º 5
0
 void Update()
 {
     if (StartTimer)
     {
         long time = (HupTime - (JhFunc.GetTimeStamp() - StartTime));
         if (time <= 0)
         {
             time       = 0;
             StartTimer = false;
         }
         LeaveTime.text = "" + time;
     }
 }
Ejemplo n.º 6
0
        public virtual void OnPk(GameObject pk1Obj, GameObject pk2Obj, bool isWin, EventDelegate delDelegate)
        {
            Pos1   = pk1Obj.transform.position;
            Pos2   = pk2Obj.transform.position;
            Pk1Obj = pk1Obj;
            Pk2Obj = pk2Obj;


            JhFunc.AddDepthForWidget(pk1Obj.GetComponent <UIWidget>(), 30);
            JhFunc.AddDepthForWidget(pk2Obj.GetComponent <UIWidget>(), 30);

            PkAnm = StartCoroutine(PkAniamtion(isWin, delDelegate));
        }
Ejemplo n.º 7
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));
        }
Ejemplo n.º 8
0
        public void OnFapai(ISFSObject data)
        {
            RStatus = RoomStatus.FaPai;

            SingleBet = AnteRate[0];

            LastTime = JhFunc.GetTimeStamp(false);

            BankerSeat = data.GetInt(JhRequestConstKey.KeyBanker);
            int[] playing = data.GetIntArray(JhRequestConstKey.KeyPlayings);

            int[] playingChair = new int[playing.Length];
            for (int i = 0; i < playing.Length; i++)
            {
                playingChair[i] = GetLocalSeat(playing[i]);
                JhUserInfo uInfo = GetPlayerInfo <JhUserInfo>(playing[i], true);
                uInfo.IsPlayingGame = true;
                uInfo.CoinA        -= SingleBet;
                TotalBet           += SingleBet;
                uInfo.AllBeat      += SingleBet;
            }


            ISFSObject sendObj = SFSObject.NewInstance();

            sendObj.PutInt("Banker", GetLocalSeat(BankerSeat));
            sendObj.PutIntArray("Playing", playingChair);
            sendObj.PutInt("ChipValue", SingleBet);
            sendObj.PutInt("ChipIndex", AnteRate.IndexOf(SingleBet));
            sendObj.PutInt("SingleBet", SingleBet);
            EventObj.SendEvent("PlayersViewEvent", "Fapai", sendObj);

            SendGameStatusToTableView();

            EventObj.SendEvent("SoundEvent", "PlayerEffect", new JhSound.SoundData(JhSound.EnAudio.Card));
        }
Ejemplo n.º 9
0
        protected void OnHupUp(object data)
        {
            View.SetActive(true);

            ISFSObject obj     = (ISFSObject)data;
            ISFSArray  arr     = obj.GetSFSArray("Users");
            string     hupName = "";

            for (int i = 0; i < arr.Size(); i++)
            {
                ISFSObject arrObj = arr.GetSFSObject(i);
                int        status = arrObj.GetInt("Status");

                JhHupUpItem item;
                if (ItemList.Count > i)
                {
                    item = ItemList[i];
                    item.SetIcon(status);
                }
                else
                {
                    GameObject gobj = Instantiate(Prefce);
                    gobj.SetActive(true);
                    Grid.AddChild(gobj.transform);
                    gobj.transform.localScale = Vector3.one;
                    item = gobj.GetComponent <JhHupUpItem>();

                    string uname = arrObj.GetUtfString("Name");
                    int    sex   = arrObj.GetInt("Sex");
                    string head  = arrObj.GetUtfString("Head");
                    item.SetInfo(head, uname, sex, status);
                    ItemList.Add(item);
                }

                if (status == 2)
                {
                    hupName = arrObj.GetUtfString("Name");
                }
            }


            if (obj.ContainsKey("HupTime"))
            {
                StartTime = obj.GetLong("StartTime");
                HupTime   = obj.GetInt("HupTime");

                if (TotalTime != null)
                {
                    TotalTime.text = string.Format("(超过{0}秒未做选着,则默认同意。)", HupTime);
                }
                if (LeaveTime != null)
                {
                    LeaveTime.text = "" + (HupTime - (JhFunc.GetTimeStamp() - StartTime));
                }
                if (PlayerName != null)
                {
                    PlayerName.text = string.Format("玩家 {0} 申请解散房间,请等待其他玩家选着。", hupName);
                }
            }

            bool isShowBtn = !obj.GetBool("SelfChoose");

            Btns.SetActive(isShowBtn);


            if (!StartTimer)
            {
                StartTimer = true;
            }
        }
Ejemplo n.º 10
0
        protected void OnGameStatus(object data)
        {
            ISFSObject obj       = (ISFSObject)data;
            bool       isPlaying = obj.GetBool("IsPlaying");

            Reset(isPlaying || !DonotResetOnGameResult);
            //初始化 加注
            int[] antes = obj.GetIntArray("Antes");

            AddBeat.SetBeatInfo(antes);
            int  singleBet  = obj.GetInt("SingleBet");
            long playerGold = obj.GetLong("PlayerGold");

            AddBeat.SetBetShow(singleBet, playerGold);

            _showTimeTip = obj.GetBool("isShowTimeTip");

            if (isPlaying)
            {
                int banker = obj.GetInt("Banker");
                SetBanker(banker);

                int    curChair = obj.GetInt("CurChair");
                long   lastTime = obj.GetLong("LastTime");
                double cdTime   = obj.GetDouble("CdTime");
                double passTime = (int)(JhFunc.GetTimeStamp(false) - lastTime);
                if (passTime / 1000.0f >= cdTime)
                {
                    passTime = 0;
                }

                bool isGzyz       = obj.ContainsKey("IsGzyz") && obj.GetBool("IsGzyz");
                bool isAutoFollow = obj.ContainsKey("IsAutoFollow") && obj.GetBool("IsAutoFollow");

                SetCurrChair(curChair, cdTime, passTime / 1000.0f, !isGzyz && isAutoFollow);

                SetUserContrl(curChair, obj);

                //chip pool
                if (obj.ContainsKey("ChipList"))
                {
                    ISFSArray chips = obj.GetSFSArray("ChipList");
                    for (int i = 0; i < chips.Count; i++)
                    {
                        ISFSObject arrItem   = chips.GetSFSObject(i);
                        int        chipValue = arrItem.GetInt("ChipValue");
                        int        chipIndex = arrItem.GetInt("ChipIndex");
                        int        chipCnt   = arrItem.GetInt("ChipCnt");

                        for (int j = 0; j < chipCnt; j++)
                        {
                            BeatPool.Beat(chipIndex, chipValue);
                        }
                    }
                }
            }
            else
            {
                UserContrl.QiPaiShow();
            }



            //玩家信息
            ISFSArray array = obj.GetSFSArray("Players");

            foreach (ISFSObject arrItem  in array)
            {
                int chair = arrItem.GetInt("Chair");

                Players[chair].SetReady(arrItem.ContainsKey("IsReady") && arrItem.GetBool("IsReady"));

                if (arrItem.ContainsKey("IsPlaying") && arrItem.GetBool("IsPlaying"))
                {
                    Players[chair].ShowCardsBack();

                    if (arrItem.ContainsKey("Cards"))
                    {
                        Players[chair].SetPlayerCards(arrItem.GetIntArray("Cards"));
                    }

                    if (arrItem.ContainsKey("IsLook"))
                    {
                        if (arrItem.GetBool("IsLook"))
                        {
                            Players[chair].SetPlayerCardsStatus(JhCardGroup.GroupStatus.Look);
                        }
                    }
                    if (arrItem.ContainsKey("IsGiveUp"))
                    {
                        if (arrItem.GetBool("IsGiveUp"))
                        {
                            Players[chair].SetPlayerCardsStatus(JhCardGroup.GroupStatus.GiveUp);
                            Players[chair].ShowCardsGray();
                        }
                    }
                    if (arrItem.ContainsKey("IsFail"))
                    {
                        if (arrItem.GetBool("IsFail"))
                        {
                            Players[chair].SetPlayerCardsStatus(JhCardGroup.GroupStatus.CompareOut);
                            Players[chair].ShowCardsGray();
                        }
                    }
                    if (arrItem.ContainsKey("AllBeat"))
                    {
                        Players[chair].SetBeat(arrItem.GetInt("AllBeat"));
                    }
                }
            }
        }