コード例 #1
0
    public void uploadMap(Text FileName)
    {
        int fileSize;

        uploadMapName = FileName.text;

        Debug.Log("Upload " + uploadMapName);

        Zip(uploadMapName);

        bool connectSuccess = false;

        tcpClient      = new TCP_Client(serverIP, serverPort);
        connectSuccess = tcpClient.ClientConnect();

        if (!connectSuccess)
        {
            return;
        }

        tcpClient.WriteString("Upload " + uploadMapName);

        fileSize = tcpClient.SendFile(Application.persistentDataPath + "/" + uploadMapName + ".zip");

        tcpClient.CloseClient();

        //debugFileSizeText.text = fileSize.ToString();

        //System.Diagnostics.Process.Start(Application.persistentDataPath);
    }
コード例 #2
0
    public void createMapList()
    {
        bool connectSuccess = false;

        mapNameList.Clear();
        mapListDropDown.ClearOptions();

        tcpClient      = new TCP_Client(serverIP, serverPort);
        connectSuccess = tcpClient.ClientConnect();

        if (!connectSuccess)
        {
            return;
        }

        tcpClient.WriteString("List");

        string mapListString = tcpClient.ReadString();

        Debug.Log(mapListString);

        tcpClient.CloseClient();

        // 產生 Map List
        mapNameList.Clear();
        foreach (string mapName in mapListString.Split(' '))
        {
            mapNameList.Add(mapName);
        }

        if (!(selectMapName != mapNameList[0] && mapNameList.Contains(selectMapName)))
        {
            selectMapName = mapNameList[0];
        }

        // 建立 mapListDropDown
        mapListDropDown.AddOptions(mapNameList);
    }
コード例 #3
0
    public void downloadMap()
    {
        int fileSize;

        bool connectSuccess = false;

        tcpClient      = new TCP_Client(serverIP, serverPort);
        connectSuccess = tcpClient.ClientConnect();

        if (!connectSuccess)
        {
            return;
        }

        tcpClient.WriteString("Download " + selectMapName);
        fileSize = tcpClient.ReceiveFile(Application.persistentDataPath + "/" + selectMapName + ".zip");

        tcpClient.CloseClient();

        //debugFileSizeText.text = fileSize.ToString();

        Unzip();
        StartCoroutine(ShowAndHide(GameObject.Find("MenuMap"), 3.0f));   // 1 second
    }