Пример #1
0
        private void ProcessNewGame(CreateGamePacket cgp, NetPeer p)
        {
            LCRLobby g = new LCRLobby(cgp.Id, cgp.Playernum);

            GameList.Add(g);
            cgp.Success = true;
            Console.WriteLine($"{ServerSignature} game created! ID:{cgp.Id} Players:{cgp.Playernum}");
            _netPacketProcessor.SendNetSerializable(p, cgp, DeliveryMethod.ReliableOrdered);
        }
Пример #2
0
        void HandleInputs(ref SimulationStep step)
        {
            m_Poller.OnInput(out step.input);

            SimulateTick(ref step);

            m_Input.SetInput(Time.time, m_ClientLastTick, m_ClientPredictedTick, m_Simulation);

            m_PacketProcessor.SendNetSerializable(ClientNetPeer, m_Input, DeliveryMethod.Unreliable);
        }
Пример #3
0
        void HandleNetwork()
        {
            while (m_Inputs.Count > 0)
            {
                if (Time.time >= m_Inputs.First.DeliveryTime)
                {
                    InputMessage m_InputMessage = m_Inputs.First;
                    m_Inputs.RemoveFirst();

                    if ((m_InputMessage.LastAckTick + m_InputMessage.Inputs.Count - 1) >= m_ServerTick)
                    {
                        for (int i = m_ServerTick > m_InputMessage.LastAckTick ? (m_ServerTick - m_InputMessage.LastAckTick) : 0; i < m_InputMessage.Inputs.Count; ++i)
                        {
                            m_ServerSharedPlayer.HandlePlayer(m_InputMessage.Inputs[i]);
                            m_ServerSimulation.Simulate(Constants.SNAPSHOT_INTERVAL);

                            ++m_ServerTick;

                            Snapshot m_Snapshot = new Snapshot
                            {
                                DeliveryTime = Time.time,
                                Tick         = m_ServerTick,
                                States       = new EntityState[]
                                {
                                    new EntityState
                                    {
                                        Id       = 0,
                                        Position = m_ServerSharedPlayer.transform.position,
                                        Rotation = m_ServerSharedPlayer.transform.rotation,
                                        Yaw      = m_ServerSharedPlayer.Yaw,
                                        Pitch    = m_ServerSharedPlayer.Pitch
                                    }
                                }
                            };

                            foreach (NetPeer peer in m_Manager.ConnectedPeerList)
                            {
                                m_PacketProcessor.SendNetSerializable(peer, m_Snapshot, DeliveryMethod.Unreliable);
                            }
                        }
                    }
                    else
                    {
                        m_Inputs.RemoveFirst();
                    }
                }
            }
        }
Пример #4
0
 public void SendCreateGameRequest(CreateGamePacket cgp)
 {
     Console.WriteLine($"{ClientSignature} creating game: ID:{cgp.Id}  Players:{cgp.Playernum}");
     _netPacketProcessor.SendNetSerializable <CreateGamePacket>(Server, cgp, DeliveryMethod.ReliableOrdered);
 }
Пример #5
0
    public void SendNSCommand <T>(NetPeer peer, T command) where T : INetSerializable, new()
    {
        var deliveryMethod = NetCommand.Metadata.DeliveryType[typeof(T)];

        netPacketProcessor.SendNetSerializable(peer, command, deliveryMethod);
    }