Browse Source

login manager fix

remotes/checkIfPRContentChanged-1717160137614929600/fix
AlexAT 2 years ago
parent
commit
f9b3a611c1
  1. 2
      Assets/GameAssets/Anim/TestCharacter.controller.meta
  2. 102
      Assets/GameAssets/Fonts/Jura/Jura-Medium.asset
  3. 212
      Assets/GameAssets/Prefabs/UI/LoadingScreen.prefab
  4. 7
      Assets/GameAssets/Prefabs/UI/LoadingScreen.prefab.meta
  5. 1061
      Assets/GameAssets/Scenes/Gameplay.unity
  6. 1046
      Assets/GameAssets/Scenes/Start.unity
  7. 3
      Assets/GameAssets/Scripts/GameManager.cs
  8. 21
      Assets/GameAssets/Scripts/Location/SceneLoader.cs
  9. 132
      Assets/GameAssets/Scripts/LoginManager.cs
  10. 8
      Assets/GameAssets/Scripts/Player.cs
  11. 1
      Assets/GameAssets/Scripts/UI/RS_InputField.cs
  12. 2
      Assets/GameAssets/Scripts/UI/RS_LabeledComponent.cs
  13. 0
      Assets/GameAssets/Scripts/Web/Models.meta
  14. 18
      Assets/GameAssets/Scripts/Web/Models/RegResult.cs
  15. 11
      Assets/GameAssets/Scripts/Web/Models/RegResult.cs.meta
  16. 21
      Assets/GameAssets/Scripts/Web/Models/User.cs
  17. 11
      Assets/GameAssets/Scripts/Web/Models/User.cs.meta
  18. 8
      Assets/GameAssets/Scripts/Web/WebRequest.cs

2
Assets/GameAssets/Anim/TestCharacter.controller.meta

@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: b169857d3894dc04b81f0173aa4dee61 guid: 1579d3e4692f73349897ccd46cf27aae
NativeFormatImporter: NativeFormatImporter:
externalObjects: {} externalObjects: {}
mainObjectFileID: 9100000 mainObjectFileID: 9100000

102
Assets/GameAssets/Fonts/Jura/Jura-Medium.asset

File diff suppressed because one or more lines are too long

212
Assets/GameAssets/Prefabs/UI/LoadingScreen.prefab

@ -0,0 +1,212 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &2985286132066478389
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 6184811926727128935}
- component: {fileID: 31077611765946517}
- component: {fileID: 3029901881213228508}
m_Layer: 5
m_Name: Text
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &6184811926727128935
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2985286132066478389}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 7231018850323323725}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 1, y: 0}
m_AnchorMax: {x: 1, y: 0}
m_AnchoredPosition: {x: -100, y: 30}
m_SizeDelta: {x: 500, y: 100}
m_Pivot: {x: 1, y: 0}
--- !u!222 &31077611765946517
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2985286132066478389}
m_CullTransparentMesh: 1
--- !u!114 &3029901881213228508
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2985286132066478389}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_text: Loading...
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: ee64b008deea801468d91e3c4c5a76e7, type: 2}
m_sharedMaterial: {fileID: -6143038999562868555, guid: ee64b008deea801468d91e3c4c5a76e7, type: 2}
m_fontSharedMaterials: []
m_fontMaterial: {fileID: 0}
m_fontMaterials: []
m_fontColor32:
serializedVersion: 2
rgba: 4294967295
m_fontColor: {r: 1, g: 1, b: 1, a: 1}
m_enableVertexGradient: 0
m_colorMode: 3
m_fontColorGradient:
topLeft: {r: 1, g: 1, b: 1, a: 1}
topRight: {r: 1, g: 1, b: 1, a: 1}
bottomLeft: {r: 1, g: 1, b: 1, a: 1}
bottomRight: {r: 1, g: 1, b: 1, a: 1}
m_fontColorGradientPreset: {fileID: 0}
m_spriteAsset: {fileID: 0}
m_tintAllSprites: 0
m_StyleSheet: {fileID: 0}
m_TextStyleHashCode: -1183493901
m_overrideHtmlColors: 0
m_faceColor:
serializedVersion: 2
rgba: 4294967295
m_fontSize: 100
m_fontSizeBase: 100
m_fontWeight: 400
m_enableAutoSizing: 0
m_fontSizeMin: 18
m_fontSizeMax: 72
m_fontStyle: 0
m_HorizontalAlignment: 4
m_VerticalAlignment: 512
m_textAlignment: 65535
m_characterSpacing: 0
m_wordSpacing: 0
m_lineSpacing: 0
m_lineSpacingMax: 0
m_paragraphSpacing: 0
m_charWidthMaxAdj: 0
m_enableWordWrapping: 1
m_wordWrappingRatios: 0.4
m_overflowMode: 0
m_linkedTextComponent: {fileID: 0}
parentLinkedComponent: {fileID: 0}
m_enableKerning: 1
m_enableExtraPadding: 0
checkPaddingRequired: 0
m_isRichText: 1
m_parseCtrlCharacters: 1
m_isOrthographic: 1
m_isCullingEnabled: 0
m_horizontalMapping: 0
m_verticalMapping: 0
m_uvLineOffset: 0
m_geometrySortingOrder: 0
m_IsTextObjectScaleStatic: 0
m_VertexBufferAutoSizeReduction: 0
m_useMaxVisibleDescender: 1
m_pageToDisplay: 1
m_margin: {x: 0, y: 0, z: 0, w: 0}
m_isUsingLegacyAnimationComponent: 0
m_isVolumetricText: 0
m_hasFontAssetChanged: 0
m_baseMaterial: {fileID: 0}
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
--- !u!1 &4296427251052565046
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 7231018850323323725}
- component: {fileID: 8447035205784126256}
- component: {fileID: 4927493037732406717}
m_Layer: 5
m_Name: LoadingScreen
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &7231018850323323725
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4296427251052565046}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 6184811926727128935}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &8447035205784126256
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4296427251052565046}
m_CullTransparentMesh: 1
--- !u!114 &4927493037732406717
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4296427251052565046}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0, g: 0, b: 0, a: 0.78431374}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 0}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1

7
Assets/GameAssets/Prefabs/UI/LoadingScreen.prefab.meta

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: baa43742aacd4e148a2fa3ce1cd1d9ed
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

1061
Assets/GameAssets/Scenes/Gameplay.unity

File diff suppressed because it is too large

1046
Assets/GameAssets/Scenes/Start.unity

File diff suppressed because it is too large

3
Assets/GameAssets/Scripts/GameManager.cs

@ -1,3 +1,4 @@
using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using Unity.Netcode; using Unity.Netcode;
@ -60,6 +61,8 @@ public class GameManager : MonoBehaviour
InitializePlayers(); InitializePlayers();
loadingScreen.SetActive(false); loadingScreen.SetActive(false);
mainScreensManager.SetGameScreen(); mainScreensManager.SetGameScreen();
print("test");
LocalPlayer.SetPosition(new Vector3());
}); });
} }

21
Assets/GameAssets/Scripts/Location/SceneLoader.cs

@ -85,25 +85,4 @@ public class SceneLoader : MonoBehaviour
} }
} }
private void Update()
{
if(Input.GetKeyDown(KeyCode.Keypad1))
{
//SceneManager.UnloadScene("TestPrologue");
LoadScene("School");
}
if (Input.GetKeyDown(KeyCode.Keypad0))
{
//SceneManager.UnloadScene("TestSchool");
LoadScene("Prologue");
}
if (Input.GetKeyDown(KeyCode.Keypad2))
{
//SceneManager.UnloadScene("TestSchool");
LoadScene("TestRoom");
}
}
} }

132
Assets/GameAssets/Scripts/LoginManager.cs

@ -1,3 +1,4 @@
using Mono.Cecil.Cil;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Net; using System.Net;
@ -8,6 +9,8 @@ using UnityEngine.SceneManagement;
public class LoginManager : MonoBehaviour public class LoginManager : MonoBehaviour
{ {
[SerializeField] private GameObject loading;
[Header("References")] [Header("References")]
[SerializeField] private GameObject formMain; [SerializeField] private GameObject formMain;
[SerializeField] private GameObject formLogin; [SerializeField] private GameObject formLogin;
@ -27,32 +30,11 @@ public class LoginManager : MonoBehaviour
[SerializeField] private RS_InputField _regPassword2; [SerializeField] private RS_InputField _regPassword2;
[SerializeField] private RS_LabeledComponent _regError; [SerializeField] private RS_LabeledComponent _regError;
[Header("Code")]
[SerializeField] private GameObject _panelCode;
[SerializeField] private RS_InputField _regCode;
[SerializeField] private RS_LabeledComponent _regCodeError;
[System.Serializable]
class TempID
{
public int id;
}
private void Start()
{
//WebRequest.Get(this, "Test", (UnityWebRequest.Result status, string data) =>
//{
// Debug.Log(status.ToString());
// Debug.Log(data);
//});
//string fields = $@"{{ ""username"": ""432"",
// ""email"": ""432"",
// ""password"": ""432""}}";
//WebRequest.Post(this, "RegUser", fields, (UnityWebRequest.Result status, string data) =>
//{
// Debug.Log(status.ToString());
// Debug.Log(data);
//});
}
private void ClearFormLogin() private void ClearFormLogin()
{ {
@ -91,17 +73,105 @@ public class LoginManager : MonoBehaviour
formMain.SetActive(true); formMain.SetActive(true);
} }
public void SkipTest() private void ShowError(RS_LabeledComponent error, string text)
{ {
bool isFirst = true; error.gameObject.SetActive(true);
error.SetLabel(text);
}
if(isFirst) private void ShowRegError(string text) => ShowError(_regError, text);
private void ShowLoginError(string text) => ShowError(_loginError, text);
private void ShowLoading() => loading.SetActive(true);
private void HideLoading() => loading.SetActive(false);
public void Register()
{
User user = new User(
_regLogin.Text,
_regEmail.Text,
_regPassword.Text
);
if (user.IsAnyEmpty())
{ {
SceneManager.LoadScene("AccountInit"); ShowRegError("Fill all fields!");
return;
} }
else
if (_regPassword.Text != _regPassword2.Text)
{ {
SceneManager.LoadScene("Game"); ShowRegError("Passwords do not match!");
return;
} }
ShowLoading();
WebRequest.Post(this, "RegUser", JsonUtility.ToJson(user), (UnityWebRequest request, string data) =>
{
HideLoading();
if (request.result == UnityWebRequest.Result.Success)
{
_panelCode.SetActive(true);
}
else
{
ShowRegError(request.error);
}
});
}
public void CodeConfirm()
{
var code = new { code = _regCode.Text };
ShowLoading();
WebRequest.Post(this, "Code", JsonUtility.ToJson(code), (UnityWebRequest request, string data) =>
{
HideLoading();
if (request.result == UnityWebRequest.Result.Success)
{
_panelCode.SetActive(false);
FormLogin();
}
else
{
ShowError(_regCodeError, "Invalid Code");
}
});
}
public void Login()
{
var user = new
{
login = _loginName.Text,
password = _loginPassword.Text
};
ShowLoading();
WebRequest.Post(this, "Login", JsonUtility.ToJson(user), (UnityWebRequest request, string data) =>
{
HideLoading();
if (request.result == UnityWebRequest.Result.Success)
{
bool isFirst = true;
if (isFirst)
{
SceneManager.LoadScene("AccountInit");
}
else
{
SceneManager.LoadScene("Game");
}
}
else
{
ShowLoginError(request.error);
}
});
} }
} }

8
Assets/GameAssets/Scripts/Player.cs

@ -123,4 +123,12 @@ public class Player : NetworkBehaviour
EmojiPopup popup = Instantiate(GameManager.EmojiPopupData.Prefab, transform); EmojiPopup popup = Instantiate(GameManager.EmojiPopupData.Prefab, transform);
popup.Initialize(index); popup.Initialize(index);
} }
public void SetPosition(Vector3 position)
{
if (!IsOwner) return;
movement.MoveTo(position);
transform.position = position;
}
} }

1
Assets/GameAssets/Scripts/UI/RS_InputField.cs

@ -7,6 +7,7 @@ public class RS_InputField : RS_LabeledComponent
[SerializeField] private Animator animator; [SerializeField] private Animator animator;
public bool IsEmpty => input.text.Length == 0; public bool IsEmpty => input.text.Length == 0;
public string Text => input.text;
protected override void OnUpdateLabel() protected override void OnUpdateLabel()
{ {

2
Assets/GameAssets/Scripts/UI/RS_LabeledComponent.cs

@ -2,6 +2,7 @@ using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using TMPro; using TMPro;
using UnityEngine; using UnityEngine;
using UnityEngine.UI;
public class RS_LabeledComponent : MonoBehaviour public class RS_LabeledComponent : MonoBehaviour
{ {
@ -20,6 +21,7 @@ public class RS_LabeledComponent : MonoBehaviour
if (labelText != null) if (labelText != null)
{ {
labelText.text = label; labelText.text = label;
LayoutRebuilder.ForceRebuildLayoutImmediate(labelText.rectTransform);
} }
OnUpdateLabel(); OnUpdateLabel();
} }

0
Assets/GameAssets/Data/Models.meta → Assets/GameAssets/Scripts/Web/Models.meta

18
Assets/GameAssets/Scripts/Web/Models/RegResult.cs

@ -0,0 +1,18 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class RegResult : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}

11
Assets/GameAssets/Scripts/Web/Models/RegResult.cs.meta

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 74d7e2c12b74f1347a808ab107d9a69c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

21
Assets/GameAssets/Scripts/Web/Models/User.cs

@ -0,0 +1,21 @@
using System;
[Serializable]
public class User
{
public string login;
public string email;
public string password;
public User(string login, string email, string password)
{
this.login = login;
this.email = email;
this.password = password;
}
public bool IsAnyEmpty()
{
return login == "" || email == "" || password == "";
}
}

11
Assets/GameAssets/Scripts/Web/Models/User.cs.meta

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2d0520f3e9253a8478898d8252325ebc
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

8
Assets/GameAssets/Scripts/Web/WebRequest.cs

@ -3,7 +3,7 @@ using System.Collections;
using UnityEngine; using UnityEngine;
using UnityEngine.Networking; using UnityEngine.Networking;
public delegate void RequestDelegate(UnityWebRequest.Result status, string data); public delegate void RequestDelegate(UnityWebRequest request, string data);
public static class WebRequest public static class WebRequest
{ {
@ -31,7 +31,7 @@ public static class WebRequest
request.SetRequestHeader("Content-Type", "application/json"); request.SetRequestHeader("Content-Type", "application/json");
yield return request.SendWebRequest(); yield return request.SendWebRequest();
action(request.result, request.downloadHandler.text); action(request, request.downloadHandler.text);
} }
} }
@ -45,7 +45,7 @@ public static class WebRequest
yield return request.SendWebRequest(); yield return request.SendWebRequest();
action(request.result, request.downloadHandler.text); action(request, request.downloadHandler.text);
} }
private static IEnumerator PostFileRequest(string url, string filePath, RequestDelegate action) private static IEnumerator PostFileRequest(string url, string filePath, RequestDelegate action)
@ -57,7 +57,7 @@ public static class WebRequest
yield return request.SendWebRequest(); yield return request.SendWebRequest();
action(request.result, request.downloadHandler.text); action(request, request.downloadHandler.text);
} }
} }

Loading…
Cancel
Save