Esempio n. 1
0
        /// <summary>
        /// Update position of the plane in the 3D environment
        /// </summary>
        /// <param name="plane"></param>
        public void Update(Plane plane)
        {
            //Try to connect to the server if not connected
            if (!_state.workSocket.Connected && _serverIP != "")
            {
                try
                {
                    _state.workSocket.Connect(_serverIP, 5447);
                    _state.workSocket.GetStream().BeginRead(_state.buffer, 0, StateObject.BufferSize, new AsyncCallback(ReadCallback), _state);
                    Console.WriteLine("Connection success");
                }
                catch (SocketException)
                {
                    Console.WriteLine("Connection faillure");
                }
            }

            //Send the position of the plane to the server
            Write(plane.Name + ":{X:" + (int)((plane.Position.X / _screenWidth) * 1000) + " " +
                "Y:" + (int)(((plane.Position.Y - _screenHeight / 2) / _screenHeight) * 1000) + " " +
                "a:" + (int)(plane.Rotation) + "}");

            Console.WriteLine(plane.Name + ":{X:" + (int)((plane.Position.X / _screenWidth) * 1000) + " " +
                "Y:" + (int)(((plane.Position.Y - _screenHeight / 2) / _screenHeight) * 1000) + " " +
                "a:" + (int)(plane.Rotation) + "}");
        }
Esempio n. 2
0
 /// <summary>
 /// Remove the plane of the 3D environment
 /// </summary>
 /// <param name="plane"></param>
 public void Remove(Plane plane)
 {
     Write(plane.Name + ":Remove");
     Console.WriteLine(plane.Name + ":Remove");
 }