コード例 #1
0
 public bool validateInput(Client.Input input)
 {
     if (Math.Abs(input.press_time.TotalMilliseconds) > 1 / 40)
     {
         return(false);
     }
     return(true);
 }
コード例 #2
0
            public void processInputs()
            {
                // Process all pending messages from clients.
                while (true)
                {
                    LagNetwork.IMessage message = this.network.receive();
                    if (message == null)
                    {
                        break;
                    }
                    Client.Input input = ((LagNetwork.ClientMessage)message).input;

                    // Update the state of the entity, based on its input.
                    // We just ignore inputs that don't look valid; this is what prevents clients from cheating.
                    Console.WriteLine(input.press_time.TotalMilliseconds);
                    if (true || validateInput(input))
                    {
                        int id = input.entity_id;
                        entities[id].applyInput(input);
                        last_processed_input[id] = input.input_sequence_number;
                    }
                }
            }
コード例 #3
0
            public Slider ui_slider;                    // Appended

            public void applyInput(Client.Input input)
            {
                x += input.press_time.TotalSeconds * speed;
            }