Exemple #1
0
        public void SendGeneralPacket(bool players, bool spectators)
        {
            var mobiles = GetInGameMobiles(players, spectators);

            if (mobiles.Count == 0)
            {
                return;
            }

            Span <byte> generalInfo = stackalloc byte[MahjongPackets.MahjongGeneralInfoPacketLength].InitializePacket();

            foreach (var mobile in mobiles)
            {
                MahjongPackets.CreateMahjongGeneralInfo(generalInfo, Game);
                mobile.NetState?.Send(generalInfo);
            }
        }
Exemple #2
0
        public void SendRelievePacket(bool players, bool spectators)
        {
            var mobiles = GetInGameMobiles(players, spectators);

            if (mobiles.Count == 0)
            {
                return;
            }

            Span <byte> relievePacket = stackalloc byte[MahjongPackets.MahjongRelievePacketLength].InitializePacket();

            foreach (var mobile in mobiles)
            {
                MahjongPackets.CreateMahjongRelieve(relievePacket, Game.Serial);
                mobile.NetState?.Send(relievePacket);
            }
        }
Exemple #3
0
        public void CheckPlayers()
        {
            var removed = false;

            Span <byte> relievePacket = stackalloc byte[MahjongPackets.MahjongRelievePacketLength].InitializePacket();

            for (var i = 0; i < m_Players.Length; i++)
            {
                var player = m_Players[i];

                if (player == null)
                {
                    continue;
                }

                if (player.Deleted)
                {
                    m_Players[i] = null;

                    SendPlayerExitMessage(player);
                    UpdateDealer(true);

                    removed = true;
                }
                else if (m_InGame[i])
                {
                    if (player.NetState == null)
                    {
                        m_InGame[i] = false;

                        SendPlayerExitMessage(player);
                        UpdateDealer(true);

                        removed = true;
                    }
                    else if (!Game.IsAccessibleTo(player) || player.Map != Game.Map ||
                             !player.InRange(Game.GetWorldLocation(), 5))
                    {
                        m_InGame[i] = false;

                        MahjongPackets.CreateMahjongRelieve(relievePacket, Game.Serial);
                        player.NetState?.Send(relievePacket);

                        SendPlayerExitMessage(player);
                        UpdateDealer(true);

                        removed = true;
                    }
                }
            }

            for (var i = 0; i < m_Spectators.Count;)
            {
                var mobile = m_Spectators[i];

                if (mobile.NetState == null || mobile.Deleted)
                {
                    m_Spectators.RemoveAt(i);
                }
                else if (!Game.IsAccessibleTo(mobile) || mobile.Map != Game.Map ||
                         !mobile.InRange(Game.GetWorldLocation(), 5))
                {
                    m_Spectators.RemoveAt(i);

                    MahjongPackets.CreateMahjongRelieve(relievePacket, Game.Serial);
                    mobile.NetState?.Send(relievePacket);
                }
                else
                {
                    i++;
                }
            }

            if (removed && !UpdateSpectators())
            {
                SendPlayersPacket(true, true);
            }
        }