Beispiel #1
0
        private bool __NotReady(short index, bool isRpc)
        {
            Network.Node player = Get(index);

            Lobby.Node temp = player as Lobby.Node;
            if (temp != null)
            {
                if (temp._count < 1)
                {
                    return(false);
                }

                --temp._count;

                if (temp._onNotReady != null)
                {
                    temp._onNotReady();
                }
            }

            Node node;

            if (GetNode(index, out node))
            {
                Room room;
                if (__rooms.TryGetValue(node.roomIndex, out room) && room != null)
                {
                    int count = room.count - 1;
                    if (room.NotReady(node.playerIndex))
                    {
                        if (isRpc)
                        {
                            if (player != null)
                            {
                                player.Rpc((short)HostMessageHandle.NotReady, new NotReadyMessage());
                            }
                        }
                        else
                        {
                            SendToOthers(index, (short)HostMessageHandle.NotReady, new NotReadyMessage());
                        }

                        if (count == room.count)
                        {
                            if (onNotReady != null)
                            {
                                onNotReady(node.roomIndex, count);
                            }
                        }
                    }
                    else
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
Beispiel #2
0
        public void Ready(short index)
        {
            Network.Node player = Get(index);

            Node node;

            if (GetNode(index, out node))
            {
                Room room;
                if (__rooms.TryGetValue(node.roomIndex, out room) && room != null)
                {
                    int count = room.count + 1;
                    if (room.Ready(node.playerIndex))
                    {
                        if (player != null)
                        {
                            player.Rpc((short)HostMessageHandle.Ready, new ReadyMessage());
                        }

                        if (count == room.count)
                        {
                            if (onReady != null)
                            {
                                onReady(node.roomIndex, count);
                            }
                        }
                    }
                    else
                    {
                        Debug.LogError("Ready Fail:" + index);

                        return;
                    }
                }
            }

            Lobby.Node temp = player as Lobby.Node;
            if (temp != null)
            {
                ++temp._count;

                if (temp._onReady != null)
                {
                    temp._onReady();
                }
            }
        }