Esempio n. 1
0
        void DoNetworkDestroy(NetworkView view, byte reasonCode)
        {
            m_Actors.Remove(view);

            //if we don't do it now, it'll just get cleared once gamestate leaves the delegate call
            GameObject.Destroy(view.gameObject);

            NetworkView.RemoveView(view);

            //send a destruction message to everyone, just in case.
            var connections = new List <NetConnection>(players.Count);

            for (int i = 0; i < players.Count; i++)
            {
                connections.Add(players[i].connection);
            }
            if (connections.Count == 0)
            {
                return;
            }

            var msg = PNetServer.peer.CreateMessage(3);

            msg.Write(RPCUtils.Remove);
            msg.Write(view.viewID.guid);
            msg.Write(reasonCode);
            PNetServer.peer.SendMessage(msg, connections, NetDeliveryMethod.ReliableOrdered, Channels.STATIC_UTILS);
        }
Esempio n. 2
0
        /// <summary>
        /// Close the room
        /// </summary>
        /// <param name="roomToChangeLeftoverPlayersTo"></param>
        public void Close(Room roomToChangeLeftoverPlayersTo)
        {
            try
            {
                for (int i = 0; i < _roomBehaviours.Count; ++i)
                {
                    _roomBehaviours[i].Closing();
                }
            }
            catch (Exception e)
            {
                Debug.LogError("[Room Closing] {0}: {1}", Name, e);
            }

            if (roomToChangeLeftoverPlayersTo == null)
            {
                foreach (var player in players)
                {
                    player.Disconnect("Room closing");
                }
            }
            else
            {
                foreach (var player in players)
                {
                    player.ChangeRoom(roomToChangeLeftoverPlayersTo);
                }
            }

            foreach (var act in m_Actors)
            {
                NetworkView.RemoveView(act);
                GameObject.Destroy(act.gameObject);
            }
            m_Actors = null;

            foreach (var gobj in roomObjects)
            {
                GameObject.Destroy(gobj.Value.gameObject);
            }

            roomObjects = null;
            m_Players   = null;
            phases      = null;

            GC.Collect();
        }
Esempio n. 3
0
        void DoNetworkDestroy(NetworkView view)
        {
            m_Actors.Remove(view);

            //if we don't do it now, it'll just get cleared once gamestate leaves the delegate call
            GameObject.DestroyNow(view.gameObject);

            var msg = PNetServer.peer.CreateMessage(3);

            msg.Write(RPCUtils.Remove);
            msg.Write(view.viewID.guid);

            NetworkView.RemoveView(view);

            //send a destruction message to everyone, just in case.
            var connections = players.Select(p => p.connection).ToList();

            if (connections.Count == 0)
            {
                return;
            }
            PNetServer.peer.SendMessage(msg, connections, NetDeliveryMethod.ReliableOrdered, Channels.STATIC_UTILS);
        }