コード例 #1
0
        public static JigsawPuzzleAsset GetNew()
        {
            Directory.CreateDirectory(AssetDirectory);
            JigsawPuzzleAsset instance = CreateInstance <JigsawPuzzleAsset>();

            AssetDatabase.CreateAsset(instance, instance.AssetFullName);
            return(instance);
        }
コード例 #2
0
        private void OnGUI()
        {
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("GetNew"))
            {
                Coroutine.Enqueue(() => JigsawPuzzleAsset.GetNew());
            }
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            GUILayout.Space(15f);
            GUILayout.BeginHorizontal();
            GUILayout.Label($"{nameof(EffectImage)} : {(EffectImage ? EffectImage.name : "null")}");
            if (GUILayout.Button(nameof(SetSelectedAsEffectImage)))
            {
                Coroutine.Enqueue(SetSelectedAsEffectImage);
            }
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            GUILayout.Space(15f);
            GUILayout.BeginHorizontal();
            if (GUILayout.Button(nameof(GetTaskMap)) &&
                Coroutine.Count == 0)
            {
                Coroutine.Enqueue(GetTaskMap);
            }
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
            if (FileMap != null && FileMap.Task != null)
            {
                GUILayout.Label($"{nameof(FileMap)} Length : {FileMap.Task.Length}");
                for (int index = 0; index < FileMap.Task.Length; index++)
                {
                    string serverTask = FileMap.Task[index];
                    GUILayout.BeginHorizontal();
                    GUILayout.Label($"Client : {FileMap.ClientTask?[index]}");
                    GUILayout.Label($"Server : {serverTask}");
                    if (GUILayout.Button(nameof(DownloadInfoData)))
                    {
                        Coroutine.Enqueue(() => DownloadInfoData(serverTask));
                    }
                    if (GUILayout.Button(nameof(JPTask.StartRemoteTask)))
                    {
                        Coroutine.Enqueue(() => JPTask.StartRemoteTask(Connector.Value, new string[] { $"Task/{serverTask}" }));
                    }
                    GUILayout.EndHorizontal();
                }
            }
        }
コード例 #3
0
        public static void OverrideInfoData(string name, byte[] binData)
        {
            Directory.CreateDirectory(AssetDirectory);
            if (binData is null)
            {
                return;
            }
            File.WriteAllBytes($"{AssetDirectory}/{name}.json", binData);
            JigsawPuzzleAsset    asset    = AssetDatabase.LoadAssetAtPath <JigsawPuzzleAsset>($"{AssetDirectory}/{name}.asset");
            JigsawPuzzleInfoData infoData = JsonFuck.FromJsonToObject <JigsawPuzzleInfoData>(Encoding.UTF8.GetString(binData));

            asset.InfoData = infoData;
            EditorUtility.SetDirty(asset);
        }
コード例 #4
0
 private void DownloadInfoData(string task)
 {
     Connector.Value.PostForm("SelectFiles", "Explorer",
                              new Dictionary <string, object>()
     {
         { "File", new string[] { $"Task/{task}" } },
     })
     ?.Result.Get("DownloadFile", "Explorer",
                  (object contents) =>
     {
         lock (LockFactor)
         {
             Callback = () => JigsawPuzzleAsset.OverrideInfoData(JPFileMap.GetFileName(task), contents as byte[]);
         }
     },
                  (HttpResponseMessage message) =>
     {
         Debug.LogError(message.Content.ReadAsStringAsync().Result);
     });
 }
コード例 #5
0
 private void GetTaskMap()
 {
     Connector.Value.Get("GetFileMapJson", "Explorer",
                         (object obj) =>
     {
         FileMap             = obj as JPFileMap;
         string[] serverTask = FileMap.Task;
         FileMap.ClientTask  = new string[serverTask.Length];
         string[] clientTask = FileMap.ClientTask;
         HashSet <string> clientAssetFile = new HashSet <string>(JigsawPuzzleAsset.GetAssetList());
         for (int index = 0; index < serverTask.Length; index++)
         {
             string fileName = JPFileMap.GetFileName(serverTask[index]);
             if (clientAssetFile.Contains(fileName))
             {
                 clientTask[index] = "Exists";
             }
             else
             {
                 clientTask[index] = "Not Found";
             }
         }
     });
 }