137 lines
3.9 KiB
C#
137 lines
3.9 KiB
C#
using Newtonsoft.Json.Linq;
|
|
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class SearchCtrl : MonoBehaviour
|
|
{
|
|
[SerializeField] GameObject opsion;
|
|
|
|
[SerializeField] TMP_InputField name;
|
|
[SerializeField] TMP_Dropdown suitStyle;
|
|
[SerializeField] TMP_Dropdown suitType;
|
|
[SerializeField] TMP_Dropdown region;
|
|
[SerializeField] TMP_Dropdown animalTypes;
|
|
[SerializeField] Toggle[] colors;
|
|
[SerializeField] Sprite[] isOnSprite;
|
|
|
|
private SearchRequest request;
|
|
private List<Library> librarys;
|
|
|
|
private void Awake()
|
|
{
|
|
opsion.SetActive(false);
|
|
}
|
|
|
|
public void OpsionButton()
|
|
{
|
|
opsion.SetActive(!opsion.activeSelf);
|
|
ResetButton();
|
|
}
|
|
|
|
public void SearchButton()
|
|
{
|
|
Debug.Log("°Ë»ö ½ÃÀÛ");
|
|
request = new SearchRequest();
|
|
request.fursuitName = name.text;
|
|
if (suitStyle.value != 0)
|
|
request.suitStyle = GameManager.Instance.suitStyle[suitStyle.value - 1].code_id;
|
|
if (suitType.value != 0)
|
|
request.suitType = GameManager.Instance.suitType[suitType.value - 1].code_id;
|
|
if (region.value != 0)
|
|
request.suitRegion = GameManager.Instance.region[region.value - 1].code_id;
|
|
if (animalTypes.value != 0)
|
|
request.suitAnimalType = GameManager.Instance.animalTypes[animalTypes.value - 1].code_id;
|
|
NetworkManager.Instance.CreateRequest<SearchResponse>("library/select/suiters", request, (data) =>
|
|
{
|
|
librarys = data.data;
|
|
for(int n = 0; n < data.data.Count; n++)
|
|
{
|
|
Debug.Log($"name : {data.data[n].suit_name}");
|
|
}
|
|
});
|
|
}
|
|
|
|
public void NextSearch()
|
|
{
|
|
request.page++;
|
|
NetworkManager.Instance.CreateRequest<SearchResponse>("library/select/suiters", request, (data) =>
|
|
{
|
|
librarys.AddRange(data.data);
|
|
for (int n = 0; n < data.data.Count; n++)
|
|
{
|
|
Debug.Log($"name : {data.data[n].suit_name}");
|
|
}
|
|
});
|
|
}
|
|
|
|
public void GetImage(int velue)
|
|
{
|
|
NetworkManager.Instance.CreateImageRequest(librarys[velue].imageBase64.Substring(1), new object(), (data) =>
|
|
{
|
|
librarys[velue]._suit_image = Sprite.Create(data, new Rect(0, 0, data.width, data.height), new Vector2(0.5f, 0.5f));
|
|
}, null, BestHTTP.HTTPMethods.Get);
|
|
}
|
|
|
|
public void ResetButton()
|
|
{
|
|
suitStyle.value = 0;
|
|
suitType.value = 0;
|
|
region.value = 0;
|
|
animalTypes.value = 0;
|
|
for(int n = 0; n < colors.Length; n++)
|
|
{
|
|
colors[n].isOn = false;
|
|
colors[n].image.sprite = isOnSprite[0];
|
|
}
|
|
}
|
|
|
|
public void OnToggle(int velue)
|
|
{
|
|
colors[velue].image.sprite = isOnSprite[(colors[velue].isOn ? 1 : 0)];
|
|
}
|
|
}
|
|
|
|
public class SearchRequest
|
|
{
|
|
public int xid;
|
|
public string fursuitName = ""; /*¿À³Ê,½´Æ® À̸§*/
|
|
public string suitMaker; /*»ç¿ë¾ÈÇÔ*/
|
|
public string suitRegion = ""; /*Ȱµ¿ ±¹°¡*/
|
|
public string suitStyle = ""; /*½´Æ® ½ºÅ¸ÀÏ*/
|
|
public string suitAnimalType = ""; /*½´Æ® µ¿¹° Á¾*/
|
|
public string suitType = ""; /*½´Æ® ÇüÅÂ*/
|
|
public List<string> colorList = new List<string>(); /*½´Æ® »ö»ó*/
|
|
public int page = 1;
|
|
public int size = 5;
|
|
public int offset = 0;
|
|
}
|
|
public class SearchResponse
|
|
{
|
|
public List<Library> data;
|
|
public bool hasMore;
|
|
}
|
|
public class ImageResponse
|
|
{
|
|
public byte[] imageBytes;
|
|
}
|
|
|
|
public class Library
|
|
{
|
|
public string imageBase64;
|
|
public string suit_name;
|
|
public string owner_id;
|
|
public string owner_name;
|
|
public string production_date;
|
|
public string suit_image;//»ç¿ë¾ÈÇÔ
|
|
public Sprite _suit_image;
|
|
public string maker;
|
|
public string region;
|
|
public string animal_type;
|
|
public string suit_style;
|
|
public string suit_type;
|
|
public List<string> suit_color;
|
|
} |