public async void uploadMap(string mapData, int one_star_step, int two_star_step, int three_star_step, int index, GameObject curPanel, string level_name) { HttpClient client = new HttpClient(); Debug.Log(maker_id); var fileAddress = Path.Combine(Application.streamingAssetsPath, "Screenshots/Screenshot.png"); FileInfo fInfo0 = new FileInfo(fileAddress); if (fInfo0.Exists) { var content = new MultipartFormDataContent(); content.Add(new ByteArrayContent(File.ReadAllBytes(fileAddress)), "screenshot", "Screenshot.png"); //var sc = new StringContent("eeeee"); HttpResponseMessage response = await client.PostAsync( backendUrl + "level?type=0&try_num=0&pass_num=0&thumb_num=0" + "&one_star_step=" + one_star_step.ToString() + "&two_star_step=" + two_star_step.ToString() + "&three_star_step=" + three_star_step.ToString() + "&id_of_maker=" + maker_id + "&map_data=" + mapData + "&level_name=" + level_name, content); string responseString = await response.Content.ReadAsStringAsync(); // Debug.Log(responseString); LevelData ld = JsonConvert.DeserializeObject <LevelData>(responseString); LocalSlot ls = new LocalSlot(); ls.UpdateSlotMap(index, ld); curPanel.GetComponentInChildren <Text>().text = level_name; } else { Debug.Log("No"); return; } }
public void getCurrentUserMap() { LocalSlot ls = new LocalSlot(); LevelData[] ldArr = ls.GetAllSlotMap(); int ldArrLen = ldArr.Length; Debug.Log(ldArrLen); for (int i = 0; i < ldArrLen; i++) { int index = i; GameObject new_slotPanelCard = Instantiate(slotPanelCard, transform.position, Quaternion.identity); if (ldArr[i].levelId == -1) { new_slotPanelCard.GetComponentInChildren <Text>().text = ldArr[index].LevelName; new_slotPanelCard.GetComponentsInChildren <Button>()[1].onClick.AddListener(delegate() { OnClickRelease(ldArr[index], index); }); new_slotPanelCard.GetComponentsInChildren <Button>()[0].onClick.AddListener(delegate() { OnClickSlotPanelToMapDesign(ldArr[index], index); }); } else { new_slotPanelCard.GetComponentInChildren <Text>().text = ldArr[index].LevelName; Button cur = new_slotPanelCard.GetComponentsInChildren <Button>()[1]; cur.onClick.AddListener(delegate() { OnClickRelease(ldArr[index], index); }); cur.GetComponentInChildren <Text>().text = "Published"; cur.interactable = false; new_slotPanelCard.GetComponentsInChildren <Button>()[0].enabled = false; } new_slotPanelCard.GetComponentsInChildren <Button>()[2].onClick.AddListener(delegate() { OnClickDelete(ldArr[index], index); }); new_slotPanelCard.transform.SetParent(mySlotPanelTransform); new_slotPanelCard.SetActive(true); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") @Override public T acquire() public override T Acquire() { // Try and get it from the thread local LocalSlot <T> localSlot = _puddle.get(); T obj = localSlot.LocalSlotObject; if (obj != default(T)) { localSlot.Set(default(T)); return(obj); } // Try the reference queue, containing objects from dead threads LocalSlotReference <T> slotReference = (LocalSlotReference <T>)_objectsFromDeadThreads.poll(); if (slotReference != null && slotReference.LocalSlotReferenceObject != default(T)) { _slotReferences.remove(slotReference); // remove from old threads return(slotReference.LocalSlotReferenceObject); } // Fall back to the delegate pool return(@delegate.Acquire()); }
/// <summary> /// Dispose of all objects in this pool, releasing them back to the delegate pool /// </summary> //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") @Override public void close() public override void Close() { foreach (LocalSlotReference <T> slotReference in _slotReferences) { LocalSlot <T> slot = slotReference.get(); if (slot != null) { T obj = slot.LocalSlotObject; if (obj != default(T)) { slot.Set(default(T)); @delegate.Release(obj); } } } for (LocalSlotReference <T> reference; (reference = (LocalSlotReference <T>)_objectsFromDeadThreads.poll()) != null;) { T obj = reference.localSlotReferenceObject; if (obj != default(T)) { @delegate.Release(obj); } } }
//public int level_id; public async void deleteMap(int level_id, int index) { if (level_id != -1) { HttpClient client = new HttpClient(); await client.PostAsync(backendUrl + "level?type=2&level_id=" + level_id.ToString(), null); } LocalSlot ls = new LocalSlot(); ls.DeleteSlotMap(index - deleted_item_size); deleted_item_size += 1; }
public override void Release(T obj) { // Return it locally if possible LocalSlot <T> localSlot = _puddle.get(); if (localSlot.LocalSlotObject == default(T)) { localSlot.Set(obj); } else // Fall back to the delegate pool { @delegate.Release(obj); } }
public void OnClickAddNew() { gameController.gameplay_enetrance = 2; LocalSlot ls = new LocalSlot(); LevelData ld = new LevelData("", maker_id, 0, 0, 0, ""); gameController.cur_slot_index = -1; gameController.gameplay_enetrance = 2; gameController.target_map_json = ""; gameController.cur_one_star_step = -1; gameController.cur_two_star_step = -1; gameController.cur_three_star_step = -1; // NameMap.gameObject.SetActive(true); NameMap.GetComponentsInChildren <Button>()[0].onClick.AddListener(() => { OnClickNameMapConfirm(); }); NameMap.GetComponentsInChildren <Button>()[1].onClick.AddListener(() => { OnClickNameMapCancel(); }); }
/*Texture2D CaptureScreenshot2(Rect rect) * { * // 先创建一个的空纹理,大小可根据实现需要来设置 * Texture2D screenShot = new Texture2D((int)rect.width, (int)rect.height, TextureFormat.RGB24, false); * * // 读取屏幕像素信息并存储为纹理数据, * screenShot.ReadPixels(rect, 0, 0); * screenShot.Apply(); * * // 然后将这些纹理数据,成一个png图片文件 * byte[] bytes = screenShot.EncodeToPNG(); * string filename = Application.dataPath + "/Screenshot.png"; * System.IO.File.WriteAllBytes(filename, bytes); * Debug.Log(string.Format("截屏了一张图片: {0}", filename)); * * // 最后,我返回这个Texture2d对象,这样我们直接,所这个截图图示在游戏中,当然这个根据自己的需求的。 * return screenShot; * }*/ void OnClickSave() { StartCoroutine(CaptureScreenshot2(new Rect(Screen.width * 0.2f, Screen.height * 0f, Screen.width * 0.715f, Screen.height * 1f), screenshot => { if (one_star.text == "" || two_star.text == "" || three_star.text == "") { Debug.Log("Must have value of star values"); alert_text.text = "Please enter # steps to get each score!"; return; } int one_star_step = int.Parse(one_star.text); int two_star_step = int.Parse(two_star.text); int three_star_step = int.Parse(three_star.text); gameController.cur_one_star_step = one_star_step; gameController.cur_two_star_step = two_star_step; gameController.cur_three_star_step = three_star_step; string mapData = generateTestMapData(); LevelData ld = new LevelData(mapData, gameController.cur_maker_id, one_star_step, two_star_step, three_star_step, gameController.cur_level_name); LocalSlot ls = new LocalSlot(); if (gameController.cur_slot_index == -1) { ls.AddSlotMap(ld); } else { ls.UpdateSlotMap(gameController.cur_slot_index, ld); } Analytics.CustomEvent("design_finish", new Dictionary <string, object> { { "session_id", AnalyticsSessionInfo.sessionId }, { "user_id", AnalyticsSessionInfo.userId }, { "time_elapsed", Time.realtimeSinceStartup - AnalyticsHelper.time_startCreatingLevel } }); SceneManager.LoadScene("Community"); })); }