예제 #1
0
    public void Execute()
    {
        if (_address != null)
        {
            _connection.Send(_message, _address);
        }
        else
        {
            _connection.Send(_message);
        }

        onFinish?.Invoke();
    }
예제 #2
0
    void Update()
    {
        if (send)
        {
            send = false;
            udp.Send("SAYY:" + tosend + ";");
        }

        if (join)
        {
            join = false;
            udp.Send("JOIN:" + id + ";");
        }
    }
예제 #3
0
    void Update()
    {
        float neardist = float.PositiveInfinity;

        foreach (Pickup p in nearPickups)
        {
            float dist = Vector3.Distance(playerPosition.position, p.transform.position);
            if (dist < neardist)
            {
                neardist = dist;
                if (chosenPickup)
                {
                    chosenPickup.UnChosen();
                }
                p.Chosen();
                chosenPickup = p;
            }
        }


        if (Input.GetKeyDown(KeyCode.F))
        {
            if (chosenPickup)
            {
                Debug.Log("picked up " + chosenPickup.ToString());
                connection.Send("PCKUP:" + chosenPickup.PickupID + ";");
            }
        }
    }
예제 #4
0
 void Update()
 {
     if (!isInGame)
     {
         if ((Time.time - lastTryTime) > tryInterval)
         {
             connection.ResetAdress();
             connection.Send("MATCH;");
             lastTryTime = Time.time;
         }
     }
     else
     {
         if (Time.time - pingo.lastHeardFromServer > pingInterval)
         {
             if (Time.time - pingo.lastHeardFromServer > pingTimeout)
             {
                 exittListener.ExitGame();
             }
             else
             {
                 pingo.SendPingo();
             }
         }
     }
 }
예제 #5
0
 void Update()
 {
     if (Input.GetKeyDown("p"))
     {
         UDPConnection.Send(new Ping());
     }
 }
예제 #6
0
    IEnumerator Auth()
    {
        yield return(new WaitUntil(() => UDPConnection.init));

        string playerName = NameGenerator.GenerateName(4, 10);

        UDPConnection.Send(new AuthMessage(playerName));
    }
예제 #7
0
    void Start()
    {
        //Give Random PlayerID
        //PlayerID.Variable.SetValue(Random.Range (int.MinValue, int.MaxValue));

        connection.Send("CNNRQ;");

        player.SetActive(true);
    }
예제 #8
0
    public override void OnEventInvoked(object eventData)
    {
        string[] args = (string[])eventData;

        connection.ChangeAdress(args [0]);
        connection.ChangePort(int.Parse(args [1]));

        connection.Send("CNNRQ;");

        playerObject.SetActive(true);

        autoConnector.isInGame = true;
    }
    public void SendString(string message)
    {
        var serializer = new MessageSerializer();
        //var debug = new DebugLogMessage
        //{
        //    Message = message
        //};

        var welcome = new WelcomeMessage();
        var bytes   = serializer.SerializeMessage(welcome);

        _connection.Send(new IPEndPoint(IPAddress.Broadcast, serverPort), bytes);
    }
예제 #10
0
    public void ExitGame()
    {
        connection.Send("EXITT;");

        player.SetActive(false);

        connection.ResetAdress();

        bulletOrchestrator.Cleanup();
        rivalOrchestrator.Cleanup();
        propOrchestrator.Cleanup();
        pickupOrchestrator.Cleanup();

        autoConnector.isInGame = false;
    }
예제 #11
0
    //Send Server events
    void Tick()
    {
        //We will send current position to server every tick
        pkgid++;

        string tosend = "MOVER:"
                        + pkgid + ","
                        + my_transform.position.x + ","
                        + my_transform.position.y + ","
                        + my_transform.localEulerAngles.z + ";";

        if (shootCommand)
        {
            shootCommand = false;
            tosend      += "SHOOT;";
        }

        connection.Send(tosend);
    }
예제 #12
0
    void FixedUpdate()
    {
        if (!networkEntity.isAuth)
        {
            return;
        }

        TransformMessage transformMessage = new TransformMessage(
            positionTransform.position.x,
            positionTransform.position.y,
            positionTransform.position.z,
            rotationTransform.localEulerAngles.x,
            positionTransform.eulerAngles.y,
            0
            );

        if (Time.time > nextActionTime)
        {
            nextActionTime += period;
            UDPConnection.Send(transformMessage);
        }
    }
 public void SendUDP(byte[] data)
 {
     udpConnection.Send(data);
 }
예제 #14
0
 public void Execute()
 {
     _connection.Send(new ReadyNotification(), _address);
     onFinish?.Invoke();
 }
예제 #15
0
 public void SendPingo()
 {
     stopwatch.Reset();
     stopwatch.Start();
     Connection.Send("PINGO;");
 }
예제 #16
0
    public void RequestItemInfo(int playerID)
    {
        //Debug.Log (connection.ServerEndPoint.Address+":"+connection.ServerEndPoint.Port + ">" +"Requesting item info");

        connection.Send("PIREQ:" + playerID + ";");
    }
예제 #17
0
 public void ButtonPressed()
 {
     connection.ResetAdress();
     connection.Send("MATCH;");
     Invoke("ReenableButton", 5f);
 }
예제 #18
0
파일: FormMain.Udp.cs 프로젝트: yfyf510/GPS
 //发送信息
 public bool Send(UdpTerminal ut, String s)
 {
     return(udpConnection.Send(ut.Host, ut.Port, s));
 }