Example #1
0
    // Use this for initialization
    void Start()
    {
        if (readFromFile)
        {
            server_ipaddr = System.IO.File.ReadAllText("ipAddr.txt");
        }
        udp       = new UDP(15001);
        udpListen = new UDP(15000);
        udp.StartUDP();
        udpListen.StartUDP();

        UnityHandler.player = playerPosition;

        client = new Client(server_ipaddr, playerRotation, cam, udp, udpListen);
        udp.Send(UDP.GetLocalIPAddress().ToString(), server_ipaddr);
    }
Example #2
0
 public void SendClassData(String classPath, int[] abilityIds)
 {
     udp.Send(DataParserAndFormatter.GetClassPathAndAbilityIdsFormatted(classPath, abilityIds, UDP.GetLocalIPAddress()), serverIP);
 }
Example #3
0
    public void SendPlayerData()
    {
        string keysPressed = "";

        for (int i = 33; i <= 122; i++)
        {
            if (Input.GetKey(((char)i).ToString().ToLower() + ""))
            {
                string input = ((char)i).ToString().ToLower();
                if (!keysPressed.Contains(input))
                {
                    keysPressed += input;
                }
            }
        }
        if (Input.GetKey(KeyCode.Space))
        {
            keysPressed += " ";
        }

        string clientData = DataParserAndFormatter.GetClientInputFormatted(keysPressed, Input.GetMouseButtonDown(0), Input.GetMouseButtonDown(1), player.transform.rotation, camera.transform.rotation, camera.transform.position, UDP.GetLocalIPAddress());

        udp.Send(clientData, serverIP); //send position and orientation and ipaddr of client to server for update
    }