Пример #1
0
    public void Start()
    {
        if (MainMenu.firstLoad)
        {
            GameObject.DontDestroyOnLoad(this.skybox);
        }
        else
        {
            UnloadMemory();
        }

        EnvironmentVariablesCentral.Start();
        Configurations.LoadConfigFile();
        World.SetGameSceneFlag(false);

        MainMenu.firstLoad = false;
        this.worldsDir     = EnvironmentVariablesCentral.clientExeDir + "\\Worlds\\";

        CreateSinglePlayerNewMap();
        CreateMultiPlayerMap();
        OpenMainMenu();
    }
Пример #2
0
    public Client(ChunkLoader cl)
    {
        this.socket         = new Socket(SocketType.Stream, ProtocolType.Tcp);
        this.smoothMovement = new SmoothMovement(this.entityHandler);
        receiveBuffer       = new byte[receiveBufferSize];
        this.cl             = cl;

        // If game world is in client
        if (World.isClient)
        {
            // Unity edition only
                        #if UNITY_EDITOR
            // Startup local server
            this.lanServerProcess = new Process();
            this.lanServerProcess.StartInfo.Arguments = "-Local";

            if (!File.Exists(EnvironmentVariablesCentral.serverDir + invisLauncher))
            {
                EnvironmentVariablesCentral.WriteInvisLaunchScript();
            }

            if (File.Exists(EnvironmentVariablesCentral.serverDir + serverFile))
            {
                this.lanServerProcess.StartInfo.FileName = EnvironmentVariablesCentral.serverDir + serverFile;
            }
            else
            {
                Panic();
            }

            try{
                this.lanServerProcess.Start();
            }
            catch {
                Panic();
            }

            // Standalone edition
                        #else
            if (!File.Exists(EnvironmentVariablesCentral.serverDir + invisLauncher))
            {
                EnvironmentVariablesCentral.WriteInvisLaunchScript();
            }

            if (File.Exists(EnvironmentVariablesCentral.serverDir + serverFile))
            {
                Application.OpenURL(EnvironmentVariablesCentral.serverDir + invisLauncher);
            }
            else
            {
                Panic();
            }
                        #endif

            this.ip = new IPAddress(new byte[4] {
                127, 0, 0, 1
            });
        }

        // If game world is in server
        else
        {
            string[] segmentedIP  = World.IP.Split('.');
            byte[]   connectionIP = new byte[4];

            // If it's not a valid IPv4
            if (segmentedIP.Length != 4)
            {
                Panic();
            }
            // Tailors the IP
            else
            {
                for (int i = 0; i < 4; i++)
                {
                    try{
                        connectionIP[i] = (byte)Convert.ToInt16(segmentedIP[i]);
                    }
                    catch (Exception e) {
                        Debug.Log(e);
                        Panic();
                    }
                }

                this.ip = new IPAddress(connectionIP);
            }
        }

        this.Connect();
    }