Пример #1
0
    private void __PassReady()
    {
        MahjongClientPlayer player = localPlayer as MahjongClientPlayer;

        if (player != null)
        {
            player.Ready(255);
        }

        __ClearReady();
    }
Пример #2
0
    private void __OnReadyHand(NetworkMessage message)
    {
        MahjongReadyHandMessage readyHandMessage = message == null ? null : message.ReadMessage <MahjongReadyHandMessage>();

        if (readyHandMessage == null)
        {
            return;
        }

        MahjongClientRoom room = MahjongClientRoom.instance;

        if (room == null)
        {
            return;
        }

        GameObject gameObject = room.pass.gameObject;

        if (gameObject != null)
        {
            gameObject.SetActive(true);
        }

        Button.ButtonClickedEvent buttonClickedEvent = new Button.ButtonClickedEvent();
        room.pass.onClick = buttonClickedEvent;
        buttonClickedEvent.AddListener(__PassReady);

        if (room.show != null)
        {
            gameObject = room.show.gameObject;
            if (gameObject != null)
            {
                gameObject.SetActive(true);
            }

            int count = readyHandMessage.indices == null ? 0 : readyHandMessage.indices.Count;
            buttonClickedEvent = new Button.ButtonClickedEvent();
            room.show.onClick  = buttonClickedEvent;
            UnityAction handler = delegate()
            {
                MahjongClientPlayer player = localPlayer as MahjongClientPlayer;
                for (int i = 0; i < count; ++i)
                {
                    int index = i;
                    player.Select(readyHandMessage.indices[i], delegate()
                    {
                        player.Ready((byte)((index << 2) | (int)MahjongReadyType.Show));

                        __ClearReady();
                    });
                }
            };

            buttonClickedEvent.AddListener(handler);
        }

        if (room.hide != null)
        {
            gameObject = room.hide.gameObject;
            if (gameObject != null)
            {
                gameObject.SetActive(true);
            }

            int count = readyHandMessage.indices == null ? 0 : readyHandMessage.indices.Count;
            buttonClickedEvent = new Button.ButtonClickedEvent();
            room.hide.onClick  = buttonClickedEvent;
            UnityAction handler = delegate()
            {
                MahjongClientPlayer player = localPlayer as MahjongClientPlayer;
                for (int i = 0; i < count; ++i)
                {
                    int index = i;
                    player.Select(readyHandMessage.indices[i], delegate()
                    {
                        player.Ready((byte)((index << 2) | (int)MahjongReadyType.Hide));

                        __ClearReady();
                    });
                }
            };

            buttonClickedEvent.AddListener(handler);
        }


        Invoke("__ClearReady", readyTime);
    }