Skip to content

Commit

Permalink
feat:[#117] UI뽑기기능- 뽑기에 성공, 실패 시 뜨는 모달을 만들었습니다.
Browse files Browse the repository at this point in the history
  • Loading branch information
Valentino1994 committed Nov 16, 2021
1 parent 3171b2e commit 7ea2202
Show file tree
Hide file tree
Showing 149 changed files with 4,636 additions and 7,568 deletions.
1,740 changes: 859 additions & 881 deletions unity/NextPlace/Assembly-CSharp-Editor.csproj

Large diffs are not rendered by default.

2,315 changes: 1,135 additions & 1,180 deletions unity/NextPlace/Assembly-CSharp.csproj

Large diffs are not rendered by default.

1,743 changes: 1,282 additions & 461 deletions unity/NextPlace/Assets/01. Scenes/Login.unity

Large diffs are not rendered by default.

19 changes: 10 additions & 9 deletions unity/NextPlace/Assets/02. Scripts/Data/DataManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ IEnumerator Get() {
url = url + "/spot?lat=" + lat + "&lng=" + lng;

using (UnityWebRequest www = UnityWebRequest.Get(url)) {
www.SetRequestHeader("Authorization", "Bearer12345");
yield return www.SendWebRequest();

if (www.error == null) {
Expand All @@ -72,7 +71,6 @@ IEnumerator GetSpotObject() {
url = url + "/spot?" + "lat=" + lat + "&lng=" + lng;

using (UnityWebRequest www = UnityWebRequest.Get(url)) {
www.SetRequestHeader("Authorization", "Bearer12345");
yield return www.SendWebRequest();

if (www.error == null) {
Expand Down Expand Up @@ -101,7 +99,6 @@ IEnumerator Get() {
url = url + "/pladex";

using (UnityWebRequest www = UnityWebRequest.Get(url)) {
www.SetRequestHeader("Authorization", "Bearer12345");
yield return www.SendWebRequest();

if (www.error == null) {
Expand Down Expand Up @@ -129,7 +126,6 @@ IEnumerator Get() {
url = url + "/plamon";

using (UnityWebRequest www = UnityWebRequest.Get(url)) {
www.SetRequestHeader("Authorization", "Bearer12345");
yield return www.SendWebRequest();

if (www.error == null) {
Expand Down Expand Up @@ -171,6 +167,7 @@ public void GoData(MyplamonDataJson MyPlamons) {
MypageUI.instance.MyPlamons = MyPlamons;
}

public Myplamon myPlamon = new Myplamon();
// POST CharacterGatcha
public void PostCharacterGatcha() {
StartCoroutine(Post());
Expand All @@ -182,14 +179,20 @@ IEnumerator Post() {
List<IMultipartFormSection> formData = new List<IMultipartFormSection>();

using (UnityWebRequest www = UnityWebRequest.Post(url, formData)) {
www.SetRequestHeader("Authorization", "Bearer12345");
yield return www.SendWebRequest();

if (www.error == null) {
string text = www.downloadHandler.text;
Debug.Log(text);
Myplamon data = JsonUtility.FromJson<Myplamon>(text);
myPlamon = data;
// 모달창 띄우고 user 정보를 갱신
GetUserInfo();
GameManager.instance.ModalOn("SuccessModal");
GatchaModalUI.instance.Initialize(data);
Debug.Log("뽑기 성공!");
} else {
// 모달창 띄우기
GameManager.instance.ModalOff("FailedModal");
Debug.Log("error");
}
}
Expand All @@ -210,7 +213,6 @@ IEnumerator Get() {
url = url + "/plaction";

using (UnityWebRequest www = UnityWebRequest.Get(url)) {
www.SetRequestHeader("Authorization", "Bearer12345");
yield return www.SendWebRequest();

if (www.error == null) {
Expand Down Expand Up @@ -238,7 +240,6 @@ IEnumerator Get() {
url = url + "/plaction/count";

using (UnityWebRequest www = UnityWebRequest.Get(url)) {
www.SetRequestHeader("Authorization", "Bearer12345");
yield return www.SendWebRequest();

if (www.error == null) {
Expand Down Expand Up @@ -268,6 +269,7 @@ IEnumerator Post() {
string text = www.downloadHandler.text;
Debug.Log(text);
Debug.Log("게스트 로그인 성공!");
GetUserInfo();
GameManager.instance.ChangeGameState(1);
} else {
Debug.Log("error");
Expand All @@ -284,7 +286,6 @@ IEnumerator Get() {
string url = URLManager.PUBLIC_URL;
url = url + "/user/me";
using (UnityWebRequest www = UnityWebRequest.Get(url)) {
www.SetRequestHeader("Authorization", "Bearer12345");
yield return www.SendWebRequest();
if (www.error == null) {
string text = www.downloadHandler.text;
Expand Down
29 changes: 26 additions & 3 deletions unity/NextPlace/Assets/02. Scripts/GameManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,6 @@ public void ChangeMyUid(string uid) {
if (uid == "null") {
myUid = "G-12345";
DataManager.instance.GetAllCharacters();
//DataManager.instance.GetAllPlactions();
//DataManager.instance.GetAllPlactionsCounts();
//Debug.Log(myUid);
} else {
myUid = uid;
}
Expand All @@ -122,4 +119,30 @@ public void CloseSpotUI() {
public void GetSpot() {
DataManager.instance.GetSpots(0.0f, 0.0f);
}

public GameObject successModal;
public GameObject failedModal;

public void ModalOn(string modalName)
{
if (modalName == "SuccessModal")
{
successModal.SetActive(true);
} else if (modalName == "FailedModal")
{
failedModal.SetActive(true);
}
}

public void ModalOff(string modalName)
{
if (modalName == "SuccessModal")
{
successModal.SetActive(false);
}
else if (modalName == "FailedModal")
{
failedModal.SetActive(false);
}
}
}
44 changes: 44 additions & 0 deletions unity/NextPlace/Assets/02. Scripts/UI/GatchaModalUI.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;

public class GatchaModalUI : MonoBehaviour
{
private static GatchaModalUI _instance = null;
public static GatchaModalUI instance
{
get
{
if (_instance == null)
{
var obj = GameObject.FindObjectOfType<GatchaModalUI>();
if (obj != null)
{
_instance = obj;
}
else
{
_instance = new GameObject("GatchaModalUI").AddComponent<GatchaModalUI>();
}
}
return _instance;
}
}
public Image mainImage;
public TextMeshProUGUI characterName;
public TextMeshProUGUI rank;

void OnDisable()
{
// 모달 끌 때 갓챠 UI의 골드를 갱신해준다.
GatchaUI.instance.Initialize(DataManager.instance.userInfo);
}

public void Initialize(Myplamon info)
{
mainImage.sprite = Resources.Load<Sprite>("Character/Main/" + info.pladex.id.ToString()) as Sprite;
characterName.text = info.pladex.name;
rank.text = "Rank - " + info.pladex.rank;
}
}
11 changes: 11 additions & 0 deletions unity/NextPlace/Assets/02. Scripts/UI/GatchaModalUI.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 41 additions & 0 deletions unity/NextPlace/Assets/02. Scripts/UI/GatchaUI.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;

public class GatchaUI : MonoBehaviour
{
private static GatchaUI _instance = null;
public static GatchaUI instance
{
get
{
if (_instance == null)
{
var obj = GameObject.FindObjectOfType<GatchaUI>();
if (obj != null)
{
_instance = obj;
}
else
{
_instance = new GameObject("GatchaUI").AddComponent<GatchaUI>();
}
}
return _instance;
}
}

public TextMeshProUGUI goldText;

void OnEnable()
{
Initialize(DataManager.instance.userInfo);
}

public void Initialize(UserInfoDataJson info)
{
goldText.text = info.gold.ToString();
}
}
11 changes: 11 additions & 0 deletions unity/NextPlace/Assets/02. Scripts/UI/GatchaUI.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
132 changes: 132 additions & 0 deletions unity/NextPlace/Assets/04. Images/Buttons/GatchaBtn.png.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 7ea2202

Please sign in to comment.