Example #1
0
        public void joinServer(IPAddress[] ip, int port)
        {
            TcpClient tcpClient = new TcpClient();
            try {
                Console.WriteLine("before tcpClient.connect");
                tcpClient.Connect(ip, port);
                Console.WriteLine("after tcpClient.connect");
                serverConnection = new ServerConnection(this, tcpClient);

                PacketVerifyClient p = new PacketVerifyClient(uniqueUsername);
                p.writePacket(serverConnection.stream);

            }catch(SocketException){
                if (serverConnection != null) serverConnection = null;
                currentGui = new GuiMainMenu(this);
            }
            camera.reset();
        }
Example #2
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            stopwatch = System.Diagnostics.Stopwatch.StartNew();

            //Set Working Directory to Source Directory
            if (System.IO.Directory.GetFiles(System.IO.Directory.GetCurrentDirectory(), "textures.png").Length==0) {
                System.IO.Directory.SetCurrentDirectory(System.IO.Directory.GetCurrentDirectory() + "\\..\\..\\");
            }
            Console.WriteLine(System.IO.Directory.GetCurrentDirectory() + "");

            texturesId = loadTexture("textures.png");

            initShaders();

            modelMatrixLocation = GL.GetUniformLocation(glProgram, "modelMatrix");
            perspectiveMatrixLocation = GL.GetUniformLocation(glProgram, "perspectiveMatrix");

            //world = new World(this);
            //inGame = true;

            currentGui = new GuiMainMenu(this);

            inputControl.init();

            StreamData.init();

            Wall.init(this);
            FrameManager.initFrames(this);
            loadDone = true;

            uniqueUsername += "-"+(rand.Next() % 100);
        }