Started creating a leaderboard

This commit is contained in:
Anthony Berg 2020-10-05 23:27:16 +01:00
parent 1e0fb19fe0
commit c1d5de61a8
10 changed files with 1236 additions and 111 deletions

View File

@ -3,7 +3,6 @@
<component name="ContentModelUserStore">
<attachedFolders />
<explicitIncludes>
<Path>Assets</Path>
<Path>Library/PackageCache/com.unity.collab-proxy@1.3.9</Path>
<Path>Library/PackageCache/com.unity.ext.nunit@1.0.0</Path>
<Path>Library/PackageCache/com.unity.ide.rider@1.2.1</Path>

View File

@ -4498,6 +4498,8 @@ MonoBehaviour:
username: {fileID: 1444966875}
password: {fileID: 1616246420}
login: {fileID: 570354252}
errors: {fileID: 1922298507}
errorsText: {fileID: 1922298509}
--- !u!114 &1549879027
MonoBehaviour:
m_ObjectHideFlags: 0
@ -5890,6 +5892,7 @@ RectTransform:
- {fileID: 570354255}
- {fileID: 876748453}
- {fileID: 1171125062}
- {fileID: 1922298508}
m_Father: {fileID: 1549879024}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
@ -5898,6 +5901,140 @@ RectTransform:
m_AnchoredPosition: {x: 0, y: 0.25}
m_SizeDelta: {x: 0, y: -0.5}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &1922298507
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1922298508}
- component: {fileID: 1922298510}
- component: {fileID: 1922298509}
m_Layer: 5
m_Name: Error Text
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
--- !u!224 &1922298508
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1922298507}
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_Children: []
m_Father: {fileID: 1922023088}
m_RootOrder: 7
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 153.38}
m_SizeDelta: {x: 200, y: 50}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1922298509
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1922298507}
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: 'Error:'
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 2e498d1c8094910479dc3e1b768306a4, type: 2}
m_sharedMaterial: {fileID: 2180264, guid: 2e498d1c8094910479dc3e1b768306a4, type: 2}
m_fontSharedMaterials: []
m_fontMaterial: {fileID: 0}
m_fontMaterials: []
m_fontColor32:
serializedVersion: 2
rgba: 4278190335
m_fontColor: {r: 1, g: 0, b: 0, 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: 36
m_fontSizeBase: 36
m_fontWeight: 400
m_enableAutoSizing: 0
m_fontSizeMin: 18
m_fontSizeMax: 72
m_fontStyle: 0
m_HorizontalAlignment: 1
m_VerticalAlignment: 256
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: 1
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!222 &1922298510
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1922298507}
m_CullTransparentMesh: 0
--- !u!1 &1922521208
GameObject:
m_ObjectHideFlags: 0

View File

@ -21,6 +21,8 @@ public class Login : MonoBehaviour
public TMP_InputField username; //This is for the username text input.
public TMP_InputField password; //This is for the password text input.
public Button login; //This is the button used to log in.
public GameObject errors;
public TextMeshProUGUI errorsText;
private bool CheckIsEmpty() //This checks if the strings are empty.
{
@ -85,8 +87,17 @@ public class Login : MonoBehaviour
else
{
string status = www.downloadHandler.text; //This downloads the data from the server.
LoginInformation information = JsonConvert.DeserializeObject<LoginInformation>(status); //This deserializes the JSON string to a class.
Debug.Log(status);
var settings = new JsonSerializerSettings
{
NullValueHandling = NullValueHandling.Ignore
};
LoginInformation information = JsonConvert.DeserializeObject<LoginInformation>(status, settings); //This deserializes the JSON string to a class.
if (information.errors != null)
{
errors.SetActive(true);
errorsText.text = information.errors;
}
if (information.success) //If the user has successfully logged in.
{

View File

@ -1,8 +1,10 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Newtonsoft.Json;
using UnityEditor;
using UnityEngine.Networking;
public class Property
@ -778,6 +780,31 @@ public class Player
public void Pay(float fee) //This function makes the user pay.
{
money -= Convert.ToInt32(fee); //This deducts the money from the user's balance.
if (fee > 0)
{
StartCoroutine(UpdateTable);
}
}
IEnumerable UpdateTable()
{
List<IMultipartFormSection> formData = new List<IMultipartFormSection>();
//POST Data
formData.Add(new MultipartFormDataSection("id", UserManager.userID.ToString())); //For the username.
formData.Add(new MultipartFormDataSection("money", "200")); //For the email.
UnityWebRequest www = UnityWebRequest.Post(Domain.subDomain("includes/updatespent.inc.php"), formData); //This initiates the post request.
yield return www.SendWebRequest(); //This sends the post request.
if (www.isNetworkError || www.isHttpError) //This checks for an error with the server.
{
Debug.Log(www.error); //This prints the error.
}
else
{
Debug.Log(www.downloadHandler.text); //This sends the error code or if it worked on the server side.
}
}
public bool Mortgage(int currentProperty) //This is used for mortgaging a property.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -9,7 +9,7 @@ Material:
m_PrefabAsset: {fileID: 0}
m_Name: LiberationSans SDF Material
m_Shader: {fileID: 4800000, guid: fe393ace9b354375a9cb14cdbbc28be4, type: 3}
m_ShaderKeywords: OUTLINE_ON
m_ShaderKeywords:
m_LightmapFlags: 1
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
@ -30,7 +30,7 @@ Material:
- _MaskSoftnessX: 0
- _MaskSoftnessY: 0
- _OutlineSoftness: 0
- _OutlineWidth: 0.074
- _OutlineWidth: 0.152
- _PerspectiveFilter: 0.875
- _ScaleRatioA: 0.9
- _ScaleRatioB: 1