Exemplo n.º 1
0
    IEnumerator _exit(float delay)
    {
        while (syncQueue.Count > 0)
        {
            yield return(new WaitForEndOfFrame());
        }

        ReplayMgr rm   = ReplayMgr.GetInstance();
        GameMgr   gm   = GameMgr.GetInstance();
        RoomMgr   room = RoomMgr.GetInstance();

        ResourcesMgr.GetInstance().release();

        rm.clear();
        gm.Reset();
        room.reset();

        if (delay > 0)
        {
            PUtils.setTimeout(() => {
                LoadingScene.LoadNewScene("02.lobby");
            }, delay);
        }
        else
        {
            LoadingScene.LoadNewScene("02.lobby");
        }
    }
Exemplo n.º 2
0
    void UpdateHandCard(bool silent = false)
    {
        if (!silent)
        {
            AudioManager.GetInstance().PlayEffectAudio("sort");
        }

        HandCardItem item = null;

        for (int i = 0; i < _handCardList.Count; i++)
        {
            float x = _handCardList.Count / 2.0f - i;

            item = _handCardList[i];

            if (item.getLayer() == "ZhuoPai")
            {
                Debug.LogError("UpdateHandCard zhuopai");
                continue;
            }

            Transform tm = item.getObj().transform;
            tm.localPosition = Vector3.zero;
            tm.localRotation = Quaternion.Euler(Vector3.zero);
            tm.Translate(offSetX * x, 0, 0);
        }

        bool replay = ReplayMgr.GetInstance().isReplay();

        _MoHandPos.localPosition = !isMyself() && replay ? new Vector3(0, 0, 0.04f) : Vector3.zero;
        _MoHandPos.Translate(-(_handCardList.Count / 2.0f + 0.5f) * offSetX, 0, 0);
    }
Exemplo n.º 3
0
 public void updateProgress()
 {
     if (progress != null)
     {
         progress.text = ReplayMgr.GetInstance().getProgress() + "%";
     }
 }
Exemplo n.º 4
0
    public static ReplayMgr GetInstance()
    {
        if (mInstance == null)
        {
            mInstance = new ReplayMgr();
        }

        return(mInstance);
    }
Exemplo n.º 5
0
    public void onResume(JsonObject data)
    {
        //string sign = userMgr.sign;
        userMgr = JsonUtility.FromJson <UserMgr>(data.ToString());
        //userMgr.sign = sign;

        InitHandler();

        string roomid = userMgr.roomid;

        if (roomid != null && roomid.Length == 6)
        {
            enterRoom(roomid, code => {
                string content = "房间[" + roomid + "]已解散";

                if (code == 2224)
                {
                    content = "房间[" + roomid + "]已满";
                }
                else if (code == 2231)
                {
                    content = "您的IP和其他玩家相同";
                }
                else if (code == 2232)
                {
                    content = "您的位置和其他玩家太近";
                }
                else if (code == 2233)
                {
                    content = "您的定位信息无效,请检查是否开启定位";
                }

                if (code != 0)
                {
                    GameAlert.Show(content, () => {
                        if (SceneManager.GetActiveScene().name == "04.table3d")
                        {
                            GameManager.GetInstance().exit();
                        }
                    });
                }
            });

            userMgr.roomid = null;
        }
        else
        {
            if (SceneManager.GetActiveScene().name == "04.table3d" && !ReplayMgr.GetInstance().isReplay())
            {
                GameAlert.Show("房间已结束,点确定返回大厅", () => {
                    GameManager.GetInstance().exit();
                });
            }
        }
    }
Exemplo n.º 6
0
    void logout()
    {
        ReplayMgr rm   = ReplayMgr.GetInstance();
        GameMgr   gm   = GameMgr.GetInstance();
        RoomMgr   room = RoomMgr.GetInstance();

        ResourcesMgr.GetInstance().release();

        rm.clear();
        gm.Reset();
        room.reset();
        LoadingScene.LoadNewScene("01.login");
    }
Exemplo n.º 7
0
    void Start()
    {
        RoomMgr rm = RoomMgr.GetInstance();

        Transform Seats = transform.Find("Seats");

        for (int i = 0; i < Seats.childCount; i++)
        {
            Transform s = Seats.GetChild(i);
            seats.Add(s.gameObject);

            Transform icon = s.Find("bghead");
            int       j    = rm.getSeatIndexByLocal(i);
            PUtils.onClick(icon, () => {
                PlayerInfo p = RoomMgr.GetInstance().players[j];
                GetComponent <UserPanel>().show(p.userid);
            });
        }

        Transform gs = transform.Find("Game/seats");

        for (int i = 0; i < gs.childCount; i++)
        {
            gseats.Add(gs.GetChild(i).gameObject);
        }

        InitSeats();
        InitEventHandlers();

        bool replay = ReplayMgr.GetInstance().isReplay();

        GameObject entries = transform.Find("Entries").gameObject;

        entries.SetActive(!replay);

        prepare.gameObject.SetActive(!replay);

        if (replay)
        {
            return;
        }

        NetMgr nm     = NetMgr.GetInstance();
        bool   isIdle = 0 == rm.info.numofgames;

        if (!isIdle)
        {
            nm.send("ready");
        }
    }
Exemplo n.º 8
0
    void Start()
    {
        isReplay = ReplayMgr.GetInstance().isReplay();

        replay.SetActive(isReplay);
        refreshBtn();

        nextPlayTime = Time.time + 5.0f;

        if (isReplay)
        {
            PUtils.setTimeout(() => {
                ReplayMgr.GetInstance().sync();
            }, 2.0f);
        }
    }
Exemplo n.º 9
0
    public void Ting(bool silent = false)
    {
        bool      replay = ReplayMgr.GetInstance().isReplay();
        Transform tm     = _HandCardPlace.transform;

        if (!silent)
        {
            AudioManager.GetInstance().PlayEffectAudio("ting2");
        }

        if (!isMyself() && !replay)
        {
            tm.Translate(0, 0.0225f, 0);
            tm.Rotate(90, 0, 0);
        }

        setCigarette(true);
    }
Exemplo n.º 10
0
    public void onBtnPrev()
    {
        ReplayMgr rm  = ReplayMgr.GetInstance();
        bool      old = isPlaying;

        isPlaying = false;

        rm.prev(2);
        rm.sync();

        updateProgress();
        nextPlayTime = Time.time + 2.0f;
        isPlaying    = old;

        refreshBtn();

        lastClickTime = Time.time;
        setButton(false);
    }
Exemplo n.º 11
0
    void Awake()
    {
        PUtils ut = PUtils.GetInstance();

        Loom lm = Loom.Current;

        mNetMgr = NetMgr.GetInstance();
        mNetMgr.Init();

        mGameMgr = GameMgr.GetInstance();
        mGameMgr.Init();

        mRoomMgr = RoomMgr.GetInstance();
        mRoomMgr.Init();

        mVoiceMgr = VoiceMgr.GetInstance();
        mVoiceMgr.Init();

        mReplayMgr = ReplayMgr.GetInstance();
        mReplayMgr.Init();
    }
Exemplo n.º 12
0
    void refreshBtns()
    {
        RoomMgr    rm     = RoomMgr.GetInstance();
        NetMgr     nm     = NetMgr.GetInstance();
        bool       isIdle = rm.isIdle();
        PlayerInfo player = rm.getSelfPlayer();

        bool replay = ReplayMgr.GetInstance().isReplay();

        Transform  actions  = prepare.Find("actions");
        GameObject btnReady = actions.Find("btnReady").gameObject;
        GameObject waiting  = prepare.Find("waiting").gameObject;

        waiting.SetActive(!replay && isIdle);
        actions.gameObject.SetActive(!replay && isIdle);
        btnReady.SetActive(!replay && !player.ready);

        if (actions.gameObject.activeSelf)
        {
            actions.GetComponent <UIGrid>().Reposition();
        }
    }
Exemplo n.º 13
0
    void Update()
    {
        ReplayMgr rm = ReplayMgr.GetInstance();

        if (isPlaying && rm.isReplay() && nextPlayTime > 0 && nextPlayTime < Time.time)
        {
            float next = rm.takeAction(false);

            if (next == 0)
            {
                nextPlayTime = 0;
                return;
            }

            nextPlayTime = Time.time + next;
            updateProgress();
        }

        if (lastClickTime > 0 && lastClickTime + 0.5f < Time.time)
        {
            setButton(true);
            lastClickTime = 0;
        }
    }
Exemplo n.º 14
0
    void onBtnReplay(int id)
    {
        NetMgr  nm = NetMgr.GetInstance();
        RoomMgr rm = RoomMgr.GetInstance();

        nm.request_apis("get_detail_of_game", "id", id, data => {
            GetDetailOfGame ret = JsonUtility.FromJson <GetDetailOfGame> (data.ToString());
            if (ret.errcode != 0)
            {
                return;
            }

            Debug.Log("base_info: ");
            Debug.Log(ret.data.base_info);

            GameBaseInfo baseInfo    = JsonUtility.FromJson <GameBaseInfo> (ret.data.base_info);
            List <int> actionRecords = ret.data.action_records;

            rm.prepareReplay(mRoom, baseInfo);
            ReplayMgr.GetInstance().Setup(mRoom, baseInfo, actionRecords);

            LoadingScene.LoadNewScene("04.table3d");
        });
    }
Exemplo n.º 15
0
    IEnumerator _HuPai(HuPushInfo info, Action cb)
    {
        bool       myself = isMyself();
        bool       zimo   = info.iszimo;
        int        layer  = myself ? LayerMask.NameToLayer("Self") : LayerMask.NameToLayer("ZhuoPai");
        List <int> holds  = info.holds;

        holds.Sort((a, b) => a - b);

        if (!myself)
        {
            for (int i = 0; i < _handCardList.Count && i < holds.Count; i++)
            {
                HandCardItem item = _handCardList [i];

                int          id   = holds [i];
                GameObject   obj  = ResourcesMgr.GetInstance().LoadMJ(id);
                HandCardItem card = new HandCardItem(id, obj);
                obj.layer = layer;
                obj.tag   = tagValue;
                obj.transform.SetParent(_HandCardPlace);

                obj.transform.localRotation = item.getObj().transform.localRotation;
                obj.transform.localPosition = item.getObj().transform.localPosition;

                _handCardList [i] = card;
                item.destroy();
            }

            foreach (HandCardItem item in _handCardList)
            {
                item.setLayer("ZhuoPai");
            }
        }

        if (_MoHand != null)
        {
            _MoHand.destroy();
        }

        if (true)
        {
            int        id  = info.hupai;
            GameObject obj = ResourcesMgr.GetInstance().LoadMJ(id);
            _MoHand   = new HandCardItem(id, obj);
            obj.layer = layer;
            obj.tag   = tagValue;
            obj.transform.SetParent(_MoHandPos);
            obj.transform.rotation = _MoHandPos.rotation;
            obj.transform.position = _MoHandPos.TransformPoint(0.0731f * offSetX, 0, 0);
        }

        _MoHand.setInteractable(false, false);

        bool anim   = false;
        bool replay = ReplayMgr.GetInstance().isReplay();

        if (!myself && !replay)
        {
            _MoHandPos.transform.Translate(0, 0, 0.04f);
            _MoHandPos.transform.Rotate(-90, 0, 0);
            anim = true;
        }

        if (anim)
        {
            Transform  huHandSpawn = this.transform.parent.Find("HandSpawn");
            GameObject huHand      = ResourcesMgr.mInstance.InstantiateGameObjectWithType("HupaiHand", ResourceType.Hand);
            huHand.transform.rotation = huHandSpawn.rotation;
            huHand.transform.position = huHandSpawn.position;
            huHand.GetComponent <DHM_HandAnimationCtr> ().huPaiEvent += HuPaiEventHandle;
        }

        if (!zimo)
        {
            DHM_RecyleHandCardManager.playHu();
        }
        else
        {
            Transform trans = _MoHand.getObj().transform;

            if (!myself)
            {
                GameObject ob = Instantiate(Resources.Load("Prefab/Meishu/fx_hu"), trans) as GameObject;
                Transform  ts = ob.transform;
                ts.localPosition = new Vector3(0, 0.24f, 0.13f);
            }
        }

        _MoHand.setHu();
        yield return(new WaitForSeconds(1.0f));

/*
 *              if (huPaiSpawn == null)
 *          huPaiSpawn = this.transform.parent.Find("HuPaiSpwan");
 *
 *      GameObject effectObj = Instantiate(_huEffect);
 *      effectObj.SetActive(true);
 *      effectObj.transform.position = huPaiSpawn.position;
 *
 *              GameObject huCard = ResourcesMgr.GetInstance ().LoadMJ (id);
 *      huCard.transform.rotation = huPaiSpawn.rotation;
 *      huCard.transform.position = huPaiSpawn.position;
 *      huCard.transform.SetParent(huPaiSpawn);
 */

        AudioManager.GetInstance().PlayEffectAudio("hu");
        MainViewMgr mm = MainViewMgr.GetInstance();

        if (zimo)
        {
            mm.showAction(seatindex, "zimo");
        }
        else
        {
            mm.showAction(seatindex, "hu");
            if (info.target >= 0)
            {
                mm.showAction(info.target, "dianpao");
            }
        }

        yield return(new WaitForSeconds(4.0f));

        cb();
    }
Exemplo n.º 16
0
    public IEnumerator _Fapai()
    {
        AudioManager am = AudioManager.GetInstance();
        RoomMgr      rm = RoomMgr.GetInstance();

        ResetCards();

        SeatInfo seat  = rm.seats[seatindex];
        bool     valid = seat.isHoldsValid();

        List <int> holds = new List <int>(seat.holds);
        int        cnt   = seat.getHoldsLen();
        int        mopai = 0;

        if (!valid)
        {
            for (int i = 0; i < cnt; i++)
            {
                holds.Add(INVALID_ID);
            }
        }

        if (cnt % 3 == 2)
        {
            mopai = holds[cnt - 1];
            holds.RemoveAt(cnt - 1);
        }

        bool replay = ReplayMgr.GetInstance().isReplay();

        if (!isMyself() && replay)
        {
            _HandCardPlace.transform.Translate(0, 0, 0.04f);
            _HandCardPlace.transform.Rotate(-90, 0, 0);

            _MoHandPos.transform.Rotate(-90, 0, 0);
        }

        holds.Sort((a, b) => a - b);
        idArray = holds;

        for (int i = 0; i < holds.Count; i++)
        {
            int        id  = holds[i];
            float      x   = holds.Count / 2.0f - i;
            GameObject obj = ResourcesMgr.GetInstance().LoadMJ(id);
            Transform  tm  = obj.transform;

            obj.layer          = m_handCard_layer;
            obj.gameObject.tag = tagValue;
            tm.SetParent(_HandCardPlace);

            HandCardItem item = new HandCardItem(id, obj);

            item.setInteractable(false, false);
            _handCardList.Add(item);

            tm.localPosition = Vector3.zero;
            tm.localRotation = Quaternion.Euler(Vector3.zero);
            tm.Translate(offSetX * x, 0, 0);

            am.PlayEffectAudio("dice");

            yield return(new WaitForSeconds(0.05f));
        }

        _MoHandPos.localPosition = !isMyself() && replay ? new Vector3(0, 0, 0.04f) : Vector3.zero;
        _MoHandPos.Translate(-(holds.Count / 2.0f + 0.5f) * offSetX, 0, 0);

        if (mopai > 0)
        {
            SetMoHandCard(mopai);
            _MoHand.setInteractable(false, false);
        }

        Dance();
    }
Exemplo n.º 17
0
    public void sync()
    {
        RoomMgr rm = RoomMgr.GetInstance();

        ResetInfo();

        SeatInfo seat = rm.seats[seatindex];

        bool valid = seat.isHoldsValid();

        List <int> holds = new List <int>(seat.holds);
        int        cnt   = seat.getHoldsLen();
        int        mopai = 0;

        if (!valid)
        {
            for (int i = 0; i < cnt; i++)
            {
                holds.Add(INVALID_ID);
            }
        }

        if (cnt % 3 == 2)
        {
            mopai = holds[cnt - 1];
            holds.RemoveAt(cnt - 1);
        }

        bool replay = ReplayMgr.GetInstance().isReplay();

        if (!isMyself() && replay)
        {
            _HandCardPlace.transform.Translate(0, 0, 0.04f);
            _HandCardPlace.transform.Rotate(-90, 0, 0);

            _MoHandPos.transform.Rotate(-90, 0, 0);
        }

        holds.Sort((a, b) => a - b);
        idArray = holds;

        for (int i = 0; i < holds.Count; i++)
        {
            int        id  = holds[i];
            GameObject obj = ResourcesMgr.GetInstance().LoadMJ(id);

            obj.layer          = m_handCard_layer;
            obj.gameObject.tag = tagValue;
            obj.transform.SetParent(_HandCardPlace);
            obj.transform.Rotate(90, 0, 0);
            HandCardItem item = new HandCardItem(id, obj);
            _handCardList.Add(item);
        }

        UpdateHandCard(true);

        if (seat.tingpai)
        {
            Ting(true);
        }

        showFlowers();

        cnt = rm.seats[seatindex].getCPGCnt();
        m_pengOrGangMoveCount = cnt < 3 ? cnt : 3;
        if (cnt > 0)
        {
            _HandCardPlace.transform.Translate(-1.5f * cnt * offSetX, 0, 0);
            transform.Translate(-1.5f * cnt * offSetX, 0, 0);
        }

        if (mopai > 0)
        {
            SetMoHandCard(mopai);
        }
    }
Exemplo n.º 18
0
    void Update()
    {
        ReplayMgr replay = ReplayMgr.GetInstance();

        if (replay.isReplay() || !isMyself())
        {
            return;
        }

        if (Input.GetMouseButtonDown(0))
        {
            Ray        ray = camera_2D.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;
            if (Physics.Raycast(ray, out hit, m_handCard_layer))
            {
                GameObject ob = hit.collider.gameObject;

                if (ob.CompareTag(tagValue))
                {
                    onMJClicked(ob);

                    Vector3 pos = ob.transform.position;
                    moved          = false;
                    oldPosition    = pos;
                    screenPosition = camera_2D.WorldToScreenPoint(pos);
                    offset         = pos - camera_2D.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, screenPosition.z));

                    draging = true;
                }
            }
        }

        if (currentObj == null)
        {
            return;
        }

        Vector3 currentPos = currentObj.transform.position;

        if (Input.GetMouseButtonUp(0))
        {
            Vector3 off = currentPos - oldPosition;

            if (moved)
            {
                if (Math.Abs(off.x) > 0.017f || Math.Abs(off.y) > 0.025f)
                {
                    onMJClicked(currentObj);
                }
                else
                {
                    currentObj.transform.position = oldPosition;
                }
            }

            draging = false;
        }
        else if (draging)
        {
            Vector3 currentScreenSpace = new Vector3(Input.mousePosition.x, Input.mousePosition.y, screenPosition.z);
            Vector3 currentPosition    = camera_2D.ScreenToWorldPoint(currentScreenSpace) + offset;

            if (currentPosition != currentPos)
            {
                moved = true;

                Vector3 off = currentPosition - oldPosition;

                if (Math.Abs(off.x) > 0.017f || Math.Abs(off.y) > 0.025f)
                {
                    currentObj.transform.position = currentPosition + new Vector3(0, 0.04f, 0);
                }
                else
                {
                    currentObj.transform.position = currentPosition;
                }
            }
        }
    }
Exemplo n.º 19
0
    void Start()
    {
        bool replay = ReplayMgr.GetInstance().isReplay();

        gameObject.SetActive(!replay);
    }