217 lines
7.2 KiB
C#
217 lines
7.2 KiB
C#
using BestHTTP;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.Globalization;
|
||
using TMPro;
|
||
using UnityEngine;
|
||
using UnityEngine.UI;
|
||
|
||
public class FursuitAddCtrl : SingletonMonoBehaviour<FursuitAddCtrl>
|
||
{
|
||
[SerializeField] Image setImage;
|
||
[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 byte[] image;
|
||
|
||
private void OnEnable()
|
||
{
|
||
WebGl.Instance.isOn = true;
|
||
image = null;
|
||
setImage.gameObject.SetActive(false);
|
||
UIReset();
|
||
xid.text = GameManager.Instance.xid;
|
||
sXid.text = GameManager.Instance.xid;
|
||
owner.text = GameManager.Instance.xname;
|
||
sOwner.text = GameManager.Instance.xname;
|
||
}
|
||
private void OnDisable()
|
||
{
|
||
WebGl.Instance.isOn = false;
|
||
}
|
||
public void SetImage(byte[] image)
|
||
{
|
||
this.image = image;
|
||
Texture2D texture = new Texture2D(2, 2);
|
||
if (texture.LoadImage(image))
|
||
{
|
||
setImage.sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f));
|
||
setImage.gameObject.SetActive(true);
|
||
}
|
||
else
|
||
{
|
||
Debug.LogError("<22>̹<EFBFBD><CCB9><EFBFBD> <20>ε<EFBFBD> <20><><EFBFBD><EFBFBD>!");
|
||
}
|
||
}
|
||
|
||
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)
|
||
{
|
||
GameManager.Instance.infoPageUI.SetError(InfoMessage.NotLogin);
|
||
return;
|
||
}
|
||
if (owner.text == string.Empty)
|
||
{
|
||
GameManager.Instance.infoPageUI.SetError(InfoMessage.NotOwner);
|
||
return;
|
||
}
|
||
|
||
if (characterName.text == string.Empty)
|
||
{
|
||
GameManager.Instance.infoPageUI.SetError(InfoMessage.NotName);
|
||
return;
|
||
}
|
||
if (animalType.value == 0)
|
||
{
|
||
GameManager.Instance.infoPageUI.SetError(InfoMessage.NotAnimalType);
|
||
return;
|
||
}
|
||
if (suitType.value == 0)
|
||
{
|
||
GameManager.Instance.infoPageUI.SetError(InfoMessage.NotSuitType);
|
||
return;
|
||
}
|
||
if (suitStyle.value == 0)
|
||
{
|
||
GameManager.Instance.infoPageUI.SetError(InfoMessage.NotSuitStyle);
|
||
return;
|
||
}
|
||
if (region.value == 0)
|
||
{
|
||
GameManager.Instance.infoPageUI.SetError(InfoMessage.NotRegion);
|
||
return;
|
||
}
|
||
DateTime date;
|
||
if (!DateTimeCheck(productionDate.text, out date))
|
||
{
|
||
GameManager.Instance.infoPageUI.SetError(InfoMessage.NotProductionDate);
|
||
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);
|
||
}
|
||
if (image == null)
|
||
{
|
||
GameManager.Instance.infoPageUI.SetError(InfoMessage.NotImageSet);
|
||
return;
|
||
}
|
||
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>();
|
||
regSuitInfo.suitImg = image;
|
||
regSuitInfo.userInfo = introeuce.text;
|
||
regSuitInfo.productionDate = productionDate.text;
|
||
for (int n = 0; n < colors.Length; n++)
|
||
{
|
||
if (colors[n].isOn)
|
||
{
|
||
GameManager.eColor color = GameManager.eColor.<EFBFBD><EFBFBD>ũ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> + n;
|
||
regSuitInfo.colorList.Add(((int)color).ToString());
|
||
}
|
||
}
|
||
|
||
HTTPRequest httpFursuitAdd = NetworkManager.Instance.CreateRequest<object>("register/regFursuiterInfo", regSuitInfo, (data) =>
|
||
{
|
||
GameManager.Instance.infoPageUI.Set(InfoMessage.FursuitAdd, () => { screenMove.SearchView(); });
|
||
}, null, HTTPMethods.Post);
|
||
httpFursuitAdd.Send();
|
||
}
|
||
|
||
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 byte[] suitImg;
|
||
|
||
public string userInfo;
|
||
public string productionDate;
|
||
}
|
||
}
|