192 lines
6.2 KiB
C#
192 lines
6.2 KiB
C#
using BestHTTP;
|
||
using Newtonsoft.Json;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.Globalization;
|
||
using System.Security.Cryptography;
|
||
using TMPro;
|
||
using UnityEngine;
|
||
using UnityEngine.UI;
|
||
using static Common;
|
||
using static GameManager;
|
||
|
||
public class FursuitAddCtrl : SingletonMonoBehaviour<FursuitAddCtrl>
|
||
{
|
||
[SerializeField] GameObject[] stepMenus;
|
||
[SerializeField] TMP_Text xid;
|
||
[SerializeField] TMP_InputField owner;
|
||
[SerializeField] TMP_InputField introeuce;
|
||
[SerializeField] TMP_InputField characterName;
|
||
[SerializeField] TMP_InputField makerName;
|
||
[SerializeField] TMP_Dropdown animalType;
|
||
[SerializeField] TMP_Dropdown suitType;
|
||
[SerializeField] TMP_Dropdown suitStyle;
|
||
[SerializeField] TMP_Dropdown region;
|
||
[SerializeField] TMP_InputField productionDate;
|
||
[SerializeField] Toggle[] colors;
|
||
[SerializeField] Sprite[] isOnSprite;
|
||
|
||
[SerializeField] TMP_Text sXid;
|
||
[SerializeField] TMP_Text sOwner;
|
||
[SerializeField] TMP_Text sCharacterName;
|
||
[SerializeField] TMP_Text sMmakerName;
|
||
[SerializeField] TMP_Text sAnimalType;
|
||
[SerializeField] TMP_Text sSuitType;
|
||
[SerializeField] TMP_Text sSuitStyle;
|
||
[SerializeField] TMP_Text sRegion;
|
||
[SerializeField] TMP_Text sProductionDate;
|
||
[SerializeField] GameObject[] sColors;
|
||
|
||
[SerializeField] GameObject infoUI;
|
||
[SerializeField] GameObject successUI;
|
||
[SerializeField] ScreenMove screenMove;
|
||
private void OnEnable()
|
||
{
|
||
UIReset();
|
||
xid.text = GameManager.Instance.xid;
|
||
sXid.text = GameManager.Instance.xid;
|
||
owner.text = GameManager.Instance.xname;
|
||
sOwner.text = GameManager.Instance.xname;
|
||
}
|
||
|
||
private void UIReset()
|
||
{
|
||
stepMenus[0].SetActive(false);
|
||
stepMenus[1].SetActive(false);
|
||
infoUI.SetActive(true);
|
||
successUI.SetActive(false);
|
||
xid.text = string.Empty;
|
||
owner.text = string.Empty;
|
||
introeuce.text = string.Empty;
|
||
characterName.text = string.Empty;
|
||
makerName.text = string.Empty;
|
||
animalType.value = 0;
|
||
suitType.value = 0;
|
||
suitStyle.value = 0;
|
||
region.value = 0;
|
||
productionDate.text = DateTime.Now.ToString("yyyy-MM-dd");
|
||
for (int n = 0; n < colors.Length; n++)
|
||
{
|
||
colors[n].isOn = false;
|
||
colors[n].image.sprite = isOnSprite[0];
|
||
}
|
||
}
|
||
|
||
private bool DateTimeCheck(string dateString, out DateTime date)
|
||
{
|
||
return DateTime.TryParseExact(dateString, "yyyy-MM-dd", CultureInfo.InvariantCulture, DateTimeStyles.None, out date);
|
||
}
|
||
|
||
public void SuccessButton()
|
||
{
|
||
if (xid.text == string.Empty)
|
||
{
|
||
Debug.Log("<22>α<EFBFBD><CEB1><EFBFBD> <20>ȵ<EFBFBD>");
|
||
return;
|
||
}
|
||
if (owner.text == string.Empty)
|
||
{
|
||
Debug.Log("<22><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>");
|
||
return;
|
||
}
|
||
|
||
if (characterName.text == string.Empty)
|
||
{
|
||
Debug.Log("<22>ɸ<EFBFBD><C9B8><EFBFBD> <20≯<EFBFBD> <20><><EFBFBD><EFBFBD>");
|
||
return;
|
||
}
|
||
if (animalType.value == 0)
|
||
{
|
||
Debug.Log("<22><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>");
|
||
return;
|
||
}
|
||
if (suitType.value == 0)
|
||
{
|
||
Debug.Log("<22><>Ʈ Ÿ<><C5B8> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>");
|
||
return;
|
||
}
|
||
if (suitStyle.value == 0)
|
||
{
|
||
Debug.Log("<22><>Ʈ<EFBFBD><C6AE>Ÿ<EFBFBD><C5B8> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>");
|
||
return;
|
||
}
|
||
if (region.value == 0)
|
||
{
|
||
Debug.Log("<22><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>");
|
||
return;
|
||
}
|
||
DateTime date;
|
||
if (!DateTimeCheck(productionDate.text, out date))
|
||
{
|
||
Debug.Log("<22><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>߸<EFBFBD><DFB8><EFBFBD>");
|
||
return;
|
||
}
|
||
sXid.text = xid.text;
|
||
sOwner.text = owner.text;
|
||
sCharacterName.text = characterName.text;
|
||
sMmakerName.text = makerName.text;
|
||
sAnimalType.text = GameManager.Instance.animalTypes[animalType.value - 1].code_nm;
|
||
sSuitType.text = GameManager.Instance.suitType[suitType.value - 1].code_nm;
|
||
sSuitStyle.text = GameManager.Instance.suitStyle[suitStyle.value - 1].code_nm;
|
||
sRegion.text = GameManager.Instance.region[region.value - 1].code_nm;
|
||
sProductionDate.text = productionDate.text;
|
||
for(int n = 0; n < colors.Length; n++)
|
||
{
|
||
sColors[n].SetActive(colors[n].isOn);
|
||
}
|
||
|
||
infoUI.SetActive(false);
|
||
successUI.SetActive(true);
|
||
}
|
||
public void OnToggle(int velue)
|
||
{
|
||
colors[velue].image.sprite = isOnSprite[(colors[velue].isOn ? 1 : 0)];
|
||
}
|
||
|
||
public void FursuitAdd()
|
||
{
|
||
RegSuitInfo regSuitInfo = new RegSuitInfo();
|
||
regSuitInfo.ownerName = owner.text;
|
||
regSuitInfo.charName = characterName.text;
|
||
regSuitInfo.suitAnimalType = GameManager.Instance.animalTypes[animalType.value - 1].code_id;
|
||
regSuitInfo.suitStyle = GameManager.Instance.suitStyle[suitStyle.value - 1].code_id;
|
||
regSuitInfo.suitType = GameManager.Instance.suitType[suitType.value - 1].code_id;
|
||
regSuitInfo.suitRegion = GameManager.Instance.region[region.value - 1].code_id;
|
||
regSuitInfo.suitMaker = makerName.text;
|
||
regSuitInfo.colorList = new List<string>();
|
||
for (int n = 0; n < colors.Length; n++)
|
||
{
|
||
if (colors[n].isOn)
|
||
{
|
||
eColor color = eColor.<EFBFBD><EFBFBD>ũ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> + n;
|
||
regSuitInfo.colorList.Add(((int)color).ToString());
|
||
}
|
||
}
|
||
regSuitInfo.id = xid.text;
|
||
|
||
Debug.Log(JsonConvert.SerializeObject(regSuitInfo));
|
||
//HTTPRequest httpFursuitAdd = NetworkManager.Instance.CreateRequest<object>("register/regFursuiterInfo", new object(), (data) =>
|
||
//{
|
||
// GameManager.Instance.infoPageUI.Set(InfoMessage.FursuitAdd, () => { screenMove.SearchView(); });
|
||
//}, null, HTTPMethods.Post);
|
||
//httpFursuitAdd.Send();
|
||
|
||
GameManager.Instance.infoPageUI.Set(InfoMessage.FursuitAdd, () => { screenMove.SearchView(); });
|
||
}
|
||
|
||
public class RegSuitInfo
|
||
{
|
||
public string ownerName;
|
||
public string charName;
|
||
public string suitAnimalType;
|
||
public string suitStyle;
|
||
public string suitType;
|
||
public string suitRegion;
|
||
public string suitMaker;
|
||
public List<string> colorList;
|
||
//public MultipartFile suitImg;
|
||
|
||
public string id;
|
||
}
|
||
}
|